Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 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 : [< `good | `bad ] tree -> [ `good ] tree =
  12. function
  13. | Taint _ -> failwith "Cannot untaint this tree"
  14. | Leaf -> Leaf
  15. (* ^^^^
  16. Error: This pattern matches values of type [ `good ] tree
  17. but a pattern was expected which matches values of type [ `bad ] tree
  18. *)
  19. | Node (l, r) -> Node (untaint l, untaint r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement