[Haskell-cafe] Type arithmetic with ATs/TFs

Robert Greayer robgreayer at gmail.com
Fri Feb 12 15:32:10 EST 2010


On Fri, Feb 12, 2010 at 2:11 PM, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
> OK, well in that case, I'm utterly puzzled as to why both forms exist in the
> first place. If TFs don't allow you to do anything that can't be done with
> ATs, why have them?
>
> My head hurts...
>

I think the question is the reverse -- why do ATs exist when you can
do everything with the more general Type Families?  This is the answer
from the GHC documentation:

"Type families appear in two flavours: (1) they can be defined on the
toplevel or (2) they can appear inside type classes (in which case
they are known as associated type synonyms). The former is the more
general variant, as it lacks the requirement for the type-indices to
coincide with the class parameters. However, the latter can lead to
more clearly structured code and compiler warnings if some type
instances were - possibly accidentally - omitted."

http://www.haskell.org/haskellwiki/GHC/Indexed_types#Detailed_definition_of_type_synonym_families


More information about the Haskell-Cafe mailing list