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 ~> Nattype tfun Z = S Ztype 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:
Post a Comment