Skip to content
Snippets Groups Projects
Commit 7fbaaee9 authored by John van Groningen's avatar John van Groningen
Browse files

adjust generic class constraints for kind not * in generic examples for new compiler

parent 4ee34be5
No related branches found
No related tags found
No related merge requests found
......@@ -13,13 +13,13 @@ gMap{|FIELD|} f (FIELD x) = FIELD (f x)
gMap{|OBJECT|} f (OBJECT x) = OBJECT (f x)
// class gMap* t where gMap* :: t -> t
// class gMap*->* t where gMap* :: (a -> b) (t a) -> (t b)
// class gMap*->*->* t where gMap*->*->* :: (a1 -> b1) (a2 -> b2) (t a1 a2) -> (t b1 b2)
// class gMap*->* (t a) (t b) where gMap* :: (a -> b) (t a) -> (t b)
// class gMap*->*->* (t a1 a2) (t b1 b2) where gMap*->*->* :: (a1 -> b1) (a2 -> b2) (t a1 a2) -> (t b1 b2)
fmap :: (.a -> .b) .(f .a) -> .(f .b) | gMap{|*->*|} f
fmap :: (.a -> .b) .(f .a) -> .(f .b) | gMap{|*->*|} (f a) (f b)
fmap f xs = gMap{|*->*|} f xs
bfmap :: (.a1 -> .b1) (.a2 -> .b2) .(f .a1 .a2) -> .(f .b1 .b2) | gMap{|*->*->*|} f
bfmap :: (.a1 -> .b1) (.a2 -> .b2) .(f .a1 .a2) -> .(f .b1 .b2) | gMap{|*->*->*|} (f a1 a2) (f b1 b2)
bfmap f1 f2 xs = gMap{|*->*->*|} f1 f2 xs
:: Tree a b = Tip a | Bin b (Tree a b) (Tree a b)
......
......@@ -2,7 +2,6 @@ module mapSt
import StdGeneric, StdEnv
// mapStList :: (a -> st -> (b, st)) [a] st -> ([b], st)
generic gMapRSt a b :: .a .st -> (.b, .st)
......@@ -35,17 +34,16 @@ gMapLSt{|CONS|} f (CONS x) st = let (x1, st1) = f x st in (CONS x1, st1)
gMapLSt{|FIELD|} f (FIELD x) st = let (x1, st1) = f x st in (FIELD x1, st1)
gMapLSt{|OBJECT|} f (OBJECT x) st = let (x1, st1) = f x st in (OBJECT x1, st1)
//fmapLSt :: ((a -> st -> (b, st)) -> (t a) -> st -> (t b, st)) | gMapLSt{|*->*|} t & bimap{|*|} st
fmapLSt :: u:((.a -> .(.st -> (.b,.st))) -> v:(w:(t .a) -> x:(.st -> (w:(t .b),.st)))) | gMapLSt{|*->*|} t & bimap{|*|} st, [v <= u,x <= v,x <= w]
fmapLSt :: u:((.a -> .(.st -> (.b,.st))) -> v:(w:(t .a) -> x:(.st -> (w:(t .b),.st)))) | gMapLSt{|*->*|} (t a) (t b), [v <= u,x <= v,x <= w]
fmapLSt = gMapLSt{|*->*|}
fmapRSt :: u:((.a -> .(.st -> (.b,.st))) -> v:(w:(t .a) -> x:(.st -> (w:(t .b),.st)))) | gMapRSt{|*->*|} t & bimap{|*|} st, [v <= u,x <= v,x <= w]
fmapRSt :: u:((.a -> .(.st -> (.b,.st))) -> v:(w:(t .a) -> x:(.st -> (w:(t .b),.st)))) | gMapRSt{|*->*|} (t a) (t b), [v <= u,x <= v,x <= w]
fmapRSt = gMapRSt{|*->*|}
bfmapLSt :: u:((.a1 -> .(.st -> (.b1,.st))) -> v:((.a2 -> .(.st -> (.b2,.st))) -> w:(x:(t .a1 .a2) -> y:(.st -> (x:(t .b1 .b2), .st))))) | gMapLSt{|*->*->*|} t & bimap{|*|} st, [v <= u,w <= v,y <= w,y <= x]
bfmapLSt :: u:((.a1 -> .(.st -> (.b1,.st))) -> v:((.a2 -> .(.st -> (.b2,.st))) -> w:(x:(t .a1 .a2) -> y:(.st -> (x:(t .b1 .b2), .st))))) | gMapLSt{|*->*->*|} (t a1 a2) (t b1 b2), [v <= u,w <= v,y <= w,y <= x]
bfmapLSt = gMapLSt{|*->*->*|}
bfmapRSt :: u:((.a1 -> .(.st -> (.b1,.st))) -> v:((.a2 -> .(.st -> (.b2,.st))) -> w:(x:(t .a1 .a2) -> y:(.st -> (x:(t .b1 .b2), .st))))) | gMapRSt{|*->*->*|} t & bimap{|*|} st, [v <= u,w <= v,y <= w,y <= x]
bfmapRSt :: u:((.a1 -> .(.st -> (.b1,.st))) -> v:((.a2 -> .(.st -> (.b2,.st))) -> w:(x:(t .a1 .a2) -> y:(.st -> (x:(t .b1 .b2), .st))))) | gMapRSt{|*->*->*|} (t a1 a2) (t b1 b2), [v <= u,w <= v,y <= w,y <= x]
bfmapRSt = gMapRSt{|*->*->*|}
:: Tree a b = Tip a | Bin b (Tree a b) (Tree a b)
......
......@@ -33,10 +33,10 @@ gReduceLSt{|OBJECT|} f (OBJECT x) st = f x st
reduceEITHER fl fr (LEFT x) st = fl x st
reduceEITHER fl fr (RIGHT x) st = fr x st
fldr :: (.a -> .(.b -> .b)) .b .(t .a) -> .b | gReduceRSt{|*->*|} t & bimap{|*|} b
fldr :: (.a -> .(.b -> .b)) .b .(t .a) -> .b | gReduceRSt{|*->*|} (t a)
fldr op e xs = gReduceRSt{|*->*|} op xs e
fldl :: (.b -> .(.a -> .b)) .b .(t .a) -> .b | gReduceLSt{|*->*|} t & bimap{|*|} b
fldl :: (.b -> .(.a -> .b)) .b .(t .a) -> .b | gReduceLSt{|*->*|} (t a)
fldl op e xs = gReduceLSt{|*->*|} (flip op) xs e
:: Tree a b = Tip a | Bin b (Tree a b) (Tree a b)
......
......@@ -25,10 +25,10 @@ gZip{|OBJECT|} f (OBJECT x) (OBJECT y) = OBJECT (f x y)
derive gZip [], Tree, Rose, Fork, Sequ
fzip :: u:((.a -> .(.b -> .c)) -> v:(w:(d .a) -> x:(w:(d .b) -> w:(d .c)))) | gZip{|*->*|} d, [v <= u,x <= v,x <= w]
fzip :: u:((.a -> .(.b -> .c)) -> v:(w:(d .a) -> x:(w:(d .b) -> w:(d .c)))) | gZip{|*->*|} (d a) (d b) (d c), [v <= u,x <= v,x <= w]
fzip = gZip{|*->*|}
bfzip :: u:((.a -> .(.b -> .c)) -> v:((.d -> .(.e -> .f)) -> w:(x:(g .a .d) -> y:(x:(g .b .e) -> x:(g .c .f))))) | gZip{|*->*->*|} g, [v <= u,w <= v,y <= w,y <= x]
bfzip :: u:((.a -> .(.b -> .c)) -> v:((.d -> .(.e -> .f)) -> w:(x:(g .a .d) -> y:(x:(g .b .e) -> x:(g .c .f))))) | gZip{|*->*->*|} (g a d) (g b e) (g c f), [v <= u,w <= v,y <= w,y <= x]
bfzip = gZip{|*->*->*|}
Start =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment