Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type _ tree =
- | Node : 'a tree * 'a tree -> 'a tree
- | Leaf : [ `good ] tree
- | Taint : [< `good | `bad ] tree -> [ `bad ] tree
- let taint : [< `good | `bad ] tree -> [ `bad ] tree =
- fun tr -> match tr with
- | Taint tr -> Taint tr
- | _ -> Taint tr
- let rec untaint : [< `good | `bad ] tree -> [ `good ] tree =
- function
- | Taint _ -> failwith "Cannot untaint this tree"
- | Leaf -> Leaf
- (* ^^^^
- Error: This pattern matches values of type [ `good ] tree
- but a pattern was expected which matches values of type [ `bad ] tree
- *)
- | Node (l, r) -> Node (untaint l, untaint r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement