Created
February 19, 2019 15:54
-
-
Save dmwit/44afc00dd3e58609084f43357db4003d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
import Data.Functor.Compose | |
import Control.Monad | |
joinEntry :: Maybe [Maybe [a]] -> Maybe [a] | |
joinEntry = fmap join . join . fmap sequenceA | |
instance Monad (Compose Maybe []) where | |
-- or use liberal applications of coerce to avoid the calls to Compose and getCompose | |
x >>= f = Compose . joinEntry . getCompose . fmap (getCompose . f) $ x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment