
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
solutions.
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
enough?
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,
but...
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"
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe