[Haskell-cafe] Constraint on data type

Albert Y. C. Lai trebla at vex.net
Tue Jan 21 22:29:00 UTC 2014


On 14-01-20 06:48 AM, Vlatko Basic wrote:
> I have another data definition
>
>      data ACT aur c = ACT { x :: aur, ... }
>
> but the type 'aur' should be restricted to (AD u r) only.
> (I would like to keep 'aur' as 1 parameter, not as

It is unnecessary to enforce your rule at the data declaration. It is 
sufficient and necessary to enforce it at relevant functions and values. 
For example:

transform :: (UA u, RA r) => ACT (AD u r) Int -> ACT (AD u r) Bool



More information about the Haskell-Cafe mailing list