Skip to content

Instantly share code, notes, and snippets.

@startling
Created February 14, 2014 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save startling/8996300 to your computer and use it in GitHub Desktop.
Save startling/8996300 to your computer and use it in GitHub Desktop.
-- bound
import Bound
-- | Standalone type for 'let' bindings.
data Lets f v = Lets (f v) (Scope () f v)
instance Bound Lets where
Lets l b >>>= f = Lets (l >>= f) (b >>>= f)
-- | Abstract syntax trees with optional extra types involved.
data Abstract l v
= Free v -- ^ Free variables.
| With (l (Abstract l) v) -- ^ Other types.
| Apply (Abstract l v) (Abstract l v) -- ^ Function application.
instance Bound l => Monad (Abstract l) where
return = Free
Free v >>= f = f v
With l >>= f = With (l >>>= f)
Apply a b >>= f = Apply (a >>= f) (b >>= f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment