on master help sign in
Merge pull request #927 from JanBessai/FunctionChains

Chain higher order Fun types

commitefb461a39d2455d51b6e2558dcc125c4093e5bfa authorEdwin Brady <edwin.brady@gmail.com> dateWed 5 Mar 2014, 13:39 (13 years ago) parentaf082b649de647
1 file changed+6
libs/base/Data/Fun.idr+6
libs/base/Data/Fun.idr+6
@@ -1,5 +1,7 @@
11module Data.Fun
22
3+%default total
4+
35--------------------------------------------------------------------------------
46-- Build an n-ary function type from a Vect of Types and a result type
57--------------------------------------------------------------------------------
@@ -7,6 +9,10 @@ Fun : Vect n Type -> Type -> Type
79Fun [] r = r
810Fun (t::ts) r = t -> Fun ts r
911
12+chain : {ts : Vect n Type} -> Fun [r] r' -> Fun ts r -> Fun ts r'
13+chain {ts = []} g r = g r
14+chain {ts = (_::_)} g f = \ x => chain g (f x)
15+
1016target : {ts : Vect n Type} -> Fun ts r -> Type
1117target {r} _ = r
1218