[Haskell-cafe] Is there a type class for boring types?

David Feuer david.feuer at gmail.com
Tue Feb 2 17:41:34 UTC 2016


Or, alternatively, some common class that lets me express that a type is
boring (i.e., inhabited by precisely one fully-defined value)? lens has
Settable, whose law ensures the type involved has a boring representation
(in the sense of representable functor), but is there a more fundamental
way?

class Boring x where
  inhabitant :: x
instance Boring () where
  inhabitant = ()
instance Boring (Proxy a) where
  inhabitant = Proxy
instance Boring y => Boring (x -> y) where
  inhabitant = const inhabitant
instance (Boring x, Boring y) => Boring (x, y) where
  inhabitant = (inhabitant, inhabitant)
instance Boring x => Boring (Const x y) where
  inhabitant = Const inhabitant
instance Boring x => Boring (Identity x) where
  inhabitant = Identity inhabitant
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160202/68082828/attachment.html>


More information about the Haskell-Cafe mailing list