Skip to content

Instantly share code, notes, and snippets.

@paulp
Created August 23, 2018 06:42
Show Gist options
  • Save paulp/29c8b46f445552e1b5183a8a7693d16c to your computer and use it in GitHub Desktop.
Save paulp/29c8b46f445552e1b5183a8a7693d16c to your computer and use it in GitHub Desktop.

Revisions

  1. paulp created this gist Aug 23, 2018.
    4 changes: 4 additions & 0 deletions monad.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    instance Monad f => Monad (OptionalT f) where
    f =<< x = OptionalT $ runOptionalT x >>= \case
    Empty -> return Empty
    Full a -> runOptionalT $ f a