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

insanemole . monkleyon at googlemail.com
Tue Feb 2 19:16:39 UTC 2016

I suspect there are a lot of classes that are almost right - and they might
even be better suited to a particular application than the more generic

The most striking for me is Monoid. 'inhabitant' looks like 'mempty', while
'mappend' would simply be (\_ _ -> inhabitant). What's more, almost all
instances you mention are already instances of Monoid, so less work for
you. Also note that there is no way to ensure that only "truly boring"
classes will be made instances of your class, so maybe relying on Monoid is

Another class that comes to mind is
class Unit m where unit :: m ()
which is one of the fundamental classes of the functor hierarchy. (Note
that pure x == fmap (const x) unit). Granted, it's of a different kind,
Just this weekend I have been working on a polykinded class:
class Reducible target r where reduce :: Proxy r -> target
which can be seen as a generalization of Boring, Unit, Typeable, and heaps
of other stuff. So there is probably no end to how fundamental you can be.
Am 02.02.2016 18:41 schrieb "David Feuer" <david.feuer at gmail.com>:

> 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
> ...
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160202/8b84ff8f/attachment.html>

More information about the Haskell-Cafe mailing list