Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Higher-kinded endofunctors

Name: Anonymous 2015-04-02 22:10

Higher-kinded type classes is what makes Haskell stand out above other functional languages for me. Things like endofunctors just cannot exist in virtually any other language.

Name: Anonymous 2015-04-04 15:32

import Control.Monad.Cont -- mtl

data Void = Void !Void

absurd :: Void -> a
absurd (Void v) = absurd v

vacuous :: Functor f => f Void -> f a
vacuous = fmap absurd

data LabelT r m = LabelT (ContT r m Void)

label :: ContT r m (LabelT r m)
label = callCC $ \k ->
let
l = LabelT $ k l
in return l

goto :: LabelT r m -> ContT r m a
goto (LabelT l) = vacuous l

usesGoto :: (Monad m) => ContT r m r -> m r
usesGoto = flip runContT return

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List