Skip to content

Instantly share code, notes, and snippets.

@ClaireNeveu
Last active July 24, 2016 23:04
Show Gist options
  • Save ClaireNeveu/f10439c97a2a7c537db6d65f4bdcc2da to your computer and use it in GitHub Desktop.
Save ClaireNeveu/f10439c97a2a7c537db6d65f4bdcc2da to your computer and use it in GitHub Desktop.
Defining Categories with Structural Types
type 'a monad = { bind : 'b. ('a -> 'b monad) -> 'b monad }
type 'a option = { getOrElse : 'a -> 'a }
let none = { getOrElse = (fun b -> b); bind = fun f -> none};;
let some a = { getOrElse = (fun b -> a); bind = fun f -> f a};;
@ClaireNeveu
Copy link
Author

I think I'll need to build a language with Equirecursive types in order to try this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment