<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I feel like I must be missing something, but what's wrong with</div><div class=""><br class=""></div><div class=""><div class=""></div></div><blockquote type="cite" class=""><div class=""><div class="">class Semigroup1 f where</div><div class=""> op :: f a -> f a -> f a</div><div class=""><br class=""></div><div class=""> default op :: Monoid (f a) => f a -> f a -> f a</div><div class=""> op = (<>)</div></div></blockquote><div class=""><br class=""></div><div class="">? Does that do what you like?</div><div class=""><br class=""></div><div class="">Richard</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 1, 2016, at 11:15 PM, David Feuer <<a href="mailto:david.feuer@gmail.com" class="">david.feuer@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><p dir="ltr" class="">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</p><p dir="ltr" class="">class Semigroup1 f where<br class="">
op :: f a -> f a -> f a</p><p dir="ltr" class="">then we could, hypothetically, give a default definition for (<>):</p><p dir="ltr" class=""> default (<>) :: Semigroup1 f => f a -> f a -> f a<br class="">
(<>) = op</p><p dir="ltr" class="">But we can't give a default definition</p><p dir="ltr" class=""> op = (<>)</p><p dir="ltr" class="">because there's no way to write its signature. However, for any F with</p><p dir="ltr" class="">instance Semigroup (F a) where ...</p><p dir="ltr" class="">the definition op = (<>) is perfectly fine.</p><p dir="ltr" class="">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?</p>
_______________________________________________<br class="">ghc-devs mailing list<br class=""><a href="mailto:ghc-devs@haskell.org" class="">ghc-devs@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br class=""></div></blockquote></div><br class=""></body></html>