Commit 6f4fe0c0 authored by John's avatar John

add binumap

parent a40eddd7
...@@ -64,6 +64,11 @@ derive bimap RECORD ...@@ -64,6 +64,11 @@ derive bimap RECORD
derive bimap FIELD derive bimap FIELD
derive bimap (->) derive bimap (->)
generic binumap a b | binumap b a :: a -> b
derive binumap c
derive binumap (->)
// HACK: dictionaries for all generics. // HACK: dictionaries for all generics.
// It works since all generic classes have only one method and do not inherit // It works since all generic classes have only one method and do not inherit
// from other classes // from other classes
......
...@@ -21,6 +21,12 @@ bimap{|OBJECT|} fx _ (OBJECT x) = OBJECT (fx x) ...@@ -21,6 +21,12 @@ bimap{|OBJECT|} fx _ (OBJECT x) = OBJECT (fx x)
bimap{|(->)|} _ ba fr _ f = comp3 fr f ba bimap{|(->)|} _ ba fr _ f = comp3 fr f ba
generic binumap a b | binumap b a :: a ->b
binumap{|c|} x = x
binumap{|(->)|} _ ba fr _ f = comp3 fr f ba
comp3 :: !(.a -> .b) u:(.c -> .a) !(.d -> .c) -> u:(.d -> .b) comp3 :: !(.a -> .b) u:(.c -> .a) !(.d -> .c) -> u:(.d -> .b)
comp3 f g h comp3 f g h
| is_id f | is_id f
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment