Constraint on data type

Hi Cafe, I have these typeclasses defined: class UA a where ... class RA a where ... and this data definition data (UA u, RA r) => AD u r = AD { ... } 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 data ACT u r c = ACT { x :: AD u r, ... } ) How can such constraint be defined? Best regards, vlatko

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
participants (2)
-
Albert Y. C. Lai
-
Vlatko Basic