stringlistocaml

Uncertain of how to read OCaml function type signatures


Could someone explain to me the following type? Specifically the return type.

string list -> (string * string * string) list 

Solution

  • Expression Meaning
    -> indicates a function type from one type to another.
    string list is the type of a list of strings.
    string * string * string is the type of a tuple of three strings.
    (string * string * string) list is the type of a list of those tuples.

    Therefore string list -> ( string * string * string) list is the type of a function which maps from a list of strings to a list of tuples of three strings.