haskellsyntaxtuplessml

What is the difference between ('a,'b) and ('a*'b)?


In Haskell we have a tuple type like (a, b, ...). I am trying to read some SML code and I already know that a value (a, b) type is a * b. But then I saw this:

type ('a,'b) reader = 'b -> ('a * 'b) option

and I understand ('a * 'b) option - in Haskell it's Maybe (a,b), but what is ('a,'b) reader ?! Why is not it ('a * 'b) reader? As I got the syntax of type level tuples is something * something.


Solution

  • When introducing a type variable for a type, the parentheses are not necessary. E.g.

    datatype 'a list = Nil | Cons of 'a * 'a list
    

    When introducing more than one type variable, we use parens and commas. E.g.

    datatype ('a, 'b) either = Left of 'a | Right of 'b;
    

    As noted in comments, this does not describe a tuple.