What is () defined as? I see it in type signatures, I thought it was the unit type same as in Haskell but it seems instead Purescript uses Unit. So then what is ()?
Using spago repl was not helpful either:
> :t ()
Unexpected token ')' at line 1, column 2
> :i ()
Unrecognized directive. Type :? for help.
> :k ()
Error found:
at :1:2 - 1:3 (line 1, column 2 - line 1, column 3)
Type variable k is undefined.
while inferring the kind of k
while checking that type k
has kind Type
while inferring the kind of () @k
See https://github.com/purescript/documentation/blob/master/errors/UndefinedTypeVariable.md for more information,
or to contribute content related to this error.
()is of kindRow Type. As one commentor mentioned, it is in fact the empty row type. I think that the parser struggles with it, if it is encountered randomly without context (e.g. after:k) because it could also be the start of a pair of parenthesis. It could probably be considered a bug. If you give it context, it works. It just completely defeats the point of using:kin the first place.It can be used where row types are expected:
Record ()is the type of the empty record{}.