Created
January 4, 2020 03:08
-
-
Save tydeu/415d3401e618eb7c2f1fbb43b3dee7c4 to your computer and use it in GitHub Desktop.
This file contains 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 RankNTypes #-} | |
module Cont where | |
import Data.Coerce | |
import Data.Function | |
import Control.Applicative | |
import Control.Monad | |
newtype Cont a = Cont { runCont :: forall r. (a -> r) -> r } | |
cont :: a -> Cont a | |
cont a = Cont ($ a) | |
instance Functor Cont where | |
fmap = liftM | |
instance Applicative Cont where | |
pure = cont | |
liftA2 = liftM2 | |
(*>) = (>>) | |
(<*) = flip (>>) | |
instance Monad Cont where | |
(>>=) = runCont |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment