Skip to content

Instantly share code, notes, and snippets.

@patrl
Created February 4, 2020 21:18
Show Gist options
  • Save patrl/2dd02b1d2bda4a017cc278568baa507a to your computer and use it in GitHub Desktop.
Save patrl/2dd02b1d2bda4a017cc278568baa507a to your computer and use it in GitHub Desktop.
newtype ContBool a = ContBool { (>-) :: (a -> Bool) -> Bool }
instance Functor ContBool where
fmap f m = ContBool $ \k ->
m >-
\a ->
k $ f a
instance Applicative ContBool where
pure a = ContBool $ \k -> k a
m <*> n = ContBool $ \k ->
m >-
\f ->
n >-
\x -> k $ f x
class (Monad' f) where
return' :: a -> f a
join' :: f (f a) -> f a
instance Monad' ContBool where
return' = pure
join' m' = ContBool $ \k ->
m' >-
\m -> m >- k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment