Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
Created April 9, 2015 12:48
Show Gist options
  • Save mankyKitty/36a89af57e1cac3ccdfa to your computer and use it in GitHub Desktop.
Save mankyKitty/36a89af57e1cac3ccdfa to your computer and use it in GitHub Desktop.
Yeahhhhh, I have no idea what I'm doing here.. Haskell Functor type class in UrWeb ? .
datatype notlist a = NotNil | NotCons of (a * notlist a)
signature NOTFUNCTOR = sig
class notfunctor :: (Type -> Type) -> Type
val fmap : f :: (Type -> Type) -> a ::: Type -> b ::: Type -> (a -> b) -> f a -> f b
val mkNF : f ::: (Type -> Type) -> (a ::: Type -> b ::: Type -> (a -> b) -> f a -> f b) -> notfunctor (f)
val notfunctor_notlist : notfunctor notlist
end
structure NotListFunctor : NOTFUNCTOR = struct
class notfunctor
fun fmap [_] [a] [b] (f : a -> b) (xs : notlist a) : notlist b =
let
fun f' ys = case ys of
NotNil => NotNil
| NotCons (hd,tl) => NotCons (f hd, f' tl)
in
f' xs
end
fun mkNF [_] g : notfunctor (notlist) = g
val notfunctor_notlist = mkNF (fmap)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment