Usually you want to avoid restrictions on synonyms of your type, if really necessary. Take the Data.Set API from containers , for example.
Many operations in Data.Set require that the elements of a set be Ord instances, because Set implemented internally as a binary tree. member or insert both require Ord
member :: Ord a => a -> Set a -> Bool insert :: Ord a => a -> Set a -> Set a
However, the definition of Set does not mention Ord at all.
This is because some Set operations do not require an Ord instance, such as size or null .
size :: Set a -> Int null :: Set a -> Bool
If a class type constraint was part of the Set definition, these functions would have to include the constraint, although this was not necessary.
So, there may be limitations in type synonyms using RankNTypes , but this is usually not recommended. Itβs better to write a constraint for the functions they need.
source share