문제

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