Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any standard implementation of the "trivial constraint", or "object class"?

I want just

class Trivial t instance Trivial t 

This is of course useless in Haskell 98 since you can just omit the constraint; but with ConstraintKinds we can have explicitly required arguments of kind * -> Constraint. Ideally, I would like to just define this as an "anonymous type-level function" \type a -> (), but that's evidently not possible.

What should I do, use something predefined or just define that class locally right where I need it (as nobody will need to access it because the instance is universal, that seems quite ok as well)?

like image 355
leftaroundabout Avatar asked Feb 06 '14 14:02

leftaroundabout


1 Answers

As this appears to be quite popular, I finally pushed such a trivial-constraint class to a Hackage package.

import Data.Constraint.Trivial  id' :: Unconstrained t => t -> t id' = id 
like image 181
leftaroundabout Avatar answered Sep 23 '22 04:09

leftaroundabout