Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
Created April 30, 2015 11:44
Show Gist options
  • Save mankyKitty/b202c50f01e59287eb6e to your computer and use it in GitHub Desktop.
Save mankyKitty/b202c50f01e59287eb6e to your computer and use it in GitHub Desktop.
So that happened....
datatype notlist a = NotNil | NotCons of (a * notlist a)
structure Pointed : sig
class pointed :: (Type -> Type) -> Type
val point : a ::: Type -> f ::: (Type -> Type)
-> pointed f
-> a -> f a
val mkPointed : f ::: (Type -> Type)
-> {Point : a ::: Type -> a -> f a}
-> pointed f
end = struct
con pointed f = {Point : a ::: Type -> a -> f a}
fun point [a] [f] (witness : pointed f) = @@witness.Point [a]
fun mkPointed [f] witness = witness
end
structure Hunctor : sig
class hunctor :: (Type -> Type) -> Type
val fmap : a ::: Type -> b ::: Type -> f ::: (Type -> Type)
-> hunctor f
-> (a -> b)
-> f a
-> f b
val mkHunctor : f ::: (Type -> Type)
-> {Fmap : a ::: Type -> b ::: Type -> (a -> b) -> f a -> f b}
-> hunctor f
end = struct
con hunctor f = {Fmap : a ::: Type -> b ::: Type -> (a -> b) -> f a -> f b}
fun fmap [a] [b] [f] (witness : hunctor f) = @@witness.Fmap [a] [b]
fun mkHunctor [f] witness = witness
end
open Pointed
open Hunctor
val pointed_list : pointed list = mkPointed {Point = fn [a] x => Cons (x,Nil)}
val hunctor_list : hunctor list = mkHunctor {Fmap = fn [a] [b] => List.mp}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment