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

constraint-kinds, haskell, typeclass

Solution

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

Problem

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)?

Original source