Unprincipled defaults
David Feuer
david.feuer at gmail.com
Fri Sep 2 03:15:48 UTC 2016
On occasion, it can be useful to have default definitions that don't
typecheck even with DefaultSignatures. It would be nice to be able to use
them anyway. For example, if we have
class Semigroup1 f where
op :: f a -> f a -> f a
then we could, hypothetically, give a default definition for (<>):
default (<>) :: Semigroup1 f => f a -> f a -> f a
(<>) = op
But we can't give a default definition
op = (<>)
because there's no way to write its signature. However, for any F with
instance Semigroup (F a) where ...
the definition op = (<>) is perfectly fine.
Would it be possible to offer a completely wild defaulting mechanism
allowing *any expression* as a default, and only checking its type and
compiling it when it's actually used?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160901/e7ccc75a/attachment.html>
More information about the ghc-devs
mailing list