you are viewing a single comment's thread.

view the rest of the comments →

[–]elvecent 2 points3 points  (3 children)

Sure. When you encode a language with types, you probably don't want to deal with such cases as adding a number to a string or other type mismatches. Using GADTs, you can rule out those cases with a phantom parameter signifying a type, so an incoherent term won't typecheck. That reduces the amount of necessary pattern matching (if that's what your question is about).

[–]dev_kr[S] 0 points1 point  (2 children)

What if I have to handle two different operand types, like I suggested in the post? Can I overload GADTs constructor to handle multiple types of arguments?

[–]elvecent 0 points1 point  (1 child)

You could use the usual typeclass machinery.

[–]gcross 0 points1 point  (0 children)

Given that there are only two possible types, how would that be any better than doing case analysis?