質問

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

役に立ちましたか?

解決

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top