Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. type _ tree =
  2. | Node : 'a tree * 'a tree -> 'a tree
  3. | Leaf : [ `good ] tree
  4. | Taint : [< `good | `bad ] tree -> [ `bad ] tree
  5.  
  6. let taint : [< `good | `bad ] tree -> [ `bad ] tree =
  7. fun tr -> match tr with
  8. | Taint tr -> Taint tr
  9. | _ -> Taint tr
  10.  
  11. let rec untaint (type t) (tr : t tree) : [ `good ] tree =
  12. match tr with
  13. | Taint _ -> failwith "Cannot untaint this tree"
  14. | Leaf -> Leaf
  15. | Node (l, r) -> Node (untaint l, untaint r)
  16. (* ^
  17. Error: This expression has type t tree
  18. but an expression was expected of type t tree
  19. The type constructor t would escape its scope
  20. *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement