[Haskell-cafe] Function composition in run-time?
dokondr at gmail.com
Wed Aug 24 15:16:57 CEST 2011
On Wed, Aug 24, 2011 at 4:52 PM, Arseniy Alekseyev <
arseniy.alekseyev at gmail.com> wrote:
> If your functions have the same type, then you can easily collect them
> in a data structure, say list, and fold that.
> For example:
> function :: String -> (String -> String)
> function "f1" = f1
> function "f2" = f2
> function "f3" = f3
> runAUserSpecifiedComposition :: String -> F
> runAUserSpecifiedComposition = foldl (.) id . map function . words
> runAUserSpecifiedComposition "f1 f2 f3" should be equal to (f1 . f2 . f3)
This is a nice one, looks already like tiny DSL )
I think I've got the main idea - enumerate in my program all function
compositions in some data structure for Haskell to compile, and the
associate these with parameter values in external file.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe