comparison variant.urs @ 6:799f43bce62b

Import some code from iwl
author Adam Chlipala <adam@chlipala.net>
date Tue, 14 Dec 2010 10:33:24 -0500
parents
children 296807a9fd50
comparison
equal deleted inserted replaced
5:943410267fad 6:799f43bce62b
1 (** Derived functions dealing with polymorphic variants *)
2
3 val read : r ::: {Unit} -> t ::: Type -> folder r -> $(mapU t r) -> variant (mapU {} r) -> t
4 val write : r ::: {Unit} -> t ::: Type -> folder r -> $(mapU t r) -> variant (mapU {} r) -> t -> $(mapU t r)
5
6 val search : r ::: {Unit} -> t ::: Type -> (variant (mapU {} r) -> option t) -> folder r -> option t
7 val find : r ::: {Unit} -> (variant (mapU {} r) -> bool) -> folder r -> option (variant (mapU {} r))
8
9 val test : nm :: Name -> t ::: Type -> ts ::: {Type} -> [[nm] ~ ts] => folder ([nm = t] ++ ts)
10 -> variant ([nm = t] ++ ts) -> option t
11 val testLess : nm :: Name -> t ::: Type -> ts ::: {Type} -> [[nm] ~ ts] => folder ts -> variant ([nm = t] ++ ts) -> option t
12
13 val testEq : K --> f :: (K -> Type) -> nm :: Name -> t ::: K -> ts ::: {K} -> r ::: {K} -> [[nm] ~ ts] =>
14 Eq.eq r ([nm = t] ++ ts)
15 -> folder r
16 -> variant (map f r) -> option (f t)
17
18 val eq : r ::: {Unit} -> folder r -> variant (mapU {} r) -> variant (mapU {} r) -> bool
19
20 val makeEq : K --> f :: (K -> Type) -> nm :: Name -> t ::: K -> ts ::: {K} -> r ::: {K} -> [[nm] ~ ts] =>
21 Eq.eq r ([nm = t] ++ ts)
22 -> f t
23 -> variant (map f r)
24
25 val fold : r ::: {Unit} -> t ::: Type -> folder r -> (variant (mapU {} r) -> t -> t) -> t -> t
26
27 val destrR : K --> f :: (K -> Type) -> fr :: (K -> Type) -> t ::: Type
28 -> (p :: K -> f p -> fr p -> t)
29 -> r ::: {K} -> folder r -> variant (map f r) -> $(map fr r) -> t
30
31 val destr2R : K --> f1 :: (K -> Type) -> f2 :: (K -> Type) -> fr :: (K -> Type) -> t ::: Type
32 -> (p :: K -> f1 p -> f2 p -> fr p -> t)
33 -> r ::: {K} -> folder r -> variant (map f1 r) -> variant (map f2 r) -> $(map fr r) -> option t