dimanche 5 août 2018

Design pattern for extracting features in a stack of analysis.

I would like to know if there is a design pattern in the context of functional programming using Scala.

I have a stack of procedures that operate on a set of some language functions. The i-th procedure of the stack performs an analysis Ai. The functions for which Ai succeeds are discarded, the functions for which it fails, are passed on to a deeper level of the stack. The whole analysis A of the stack succeeds if at the end there are no functions left.

My goal is to add a new behaviour to the stack, namely, when functions are discarded, they should be annotated with some syntactic construct (a measure).

Requirements

I would like to keep these two functionalities as decoupled as possible.

Question

So my question is, what is the right way to this in functional programming. Should I go through the original code and just set a flag to indicate the wanted behaviour? I'm looking for a more elegant solution that would extract this annotated functions operating from a different module. Is it possible?

Aucun commentaire:

Enregistrer un commentaire