Skip to content

Instantly share code, notes, and snippets.

@zbskii
Created August 6, 2014 21:36
Show Gist options
  • Save zbskii/d54a7a43aba176d88456 to your computer and use it in GitHub Desktop.
Save zbskii/d54a7a43aba176d88456 to your computer and use it in GitHub Desktop.
instance Applicative Haxl where
pure = return
Haxl f <*> Haxl a = Haxl $ do
r <- f
case r of
Done f' -> do
ra <- a
case ra of
Done a' -> return (Done (f' a'))
Blocked a' -> return (Blocked (f' <$> a'))
Blocked f' -> do
ra <- a
case ra of
Done a' -> return (Blocked (f' <*> return a'))
Blocked a' -> return (Blocked (f' <*> a'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment