Created
April 9, 2015 12:48
-
-
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 ? .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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