Thursday, November 25, 2010

Type Synonyms Generalized

Type functions are the new trend. Ωmega has them with the following syntax:
tfun :: Nat ~> Nat
{tfun Z} = S Z
Haskell (that is GHC) has them in the flavor of type families.

It has just occurred to me that they can be considered as a syntactic relaxation of type synonyms! Look:
tfun :: Nat ~> Nat
type tfun Z = S Z
type tfun (S n) = Z
When conventional type synonyms are used they must be fully applied. This should be the case here too. I am not sure whether type families or Ωmega-style type functions can be partially applied, though.

Anyway, a bit more to write at the definition site but less curlies to type at the call site; it may well be worth it.

No comments: