Skip to content

Instantly share code, notes, and snippets.

@clojj
Last active January 26, 2017 10:40
Show Gist options
  • Select an option

  • Save clojj/7daac2bd510e50275db249292cbc36f6 to your computer and use it in GitHub Desktop.

Select an option

Save clojj/7daac2bd510e50275db249292cbc36f6 to your computer and use it in GitHub Desktop.
compose list of Maybe functions
import Data.List
compose :: [Maybe (a -> a)] -> a -> a
compose fs v = foldl' compf id fs $ v
compf :: (a -> a) -> Maybe (a -> a) -> (a -> a)
compf f mg =
case mg of
Nothing -> f
Just g -> g . f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment