I want to accomplish something like this, but I can't quite get the syntax down.
type _ s = Var : 'a -> 'a s
type _ t =
| AA :('a -> 'a s) -> 'c t
| AB : ('a -> 'b s) -> 'c t
let apply_to x = function
| AA g -> g x
| AB g -> g x
I want to accomplish something like this, but I can't quite get the syntax down.
type _ s = Var : 'a -> 'a s
type _ t =
| AA :('a -> 'a s) -> 'c t
| AB : ('a -> 'b s) -> 'c t
let apply_to x = function
| AA g -> g x
| AB g -> g x
Well, a type like 'a -> 'a s
makes sense. You can see how the parameter is going to work. A type like ('a -> 'a s) -> 'c t
doesn't make sense (to me). I don't see where the 'c
type is supposed to come from. The same goes for 'a -> 'b s
. I don't see where the 'b
is supposed to come from. Types like this are usually associated with code that doesn't actually return at all (undefined code, code that raises an exception, etc.).
It's (very) possible there's a subtlety of GADTs that I don't understand, but maybe this will help at least a little.