[Haskell-cafe] Avoiding undecidables
Daniel Fischer
daniel.is.fischer at web.de
Sat Dec 5 16:43:03 EST 2009
Am Samstag 05 Dezember 2009 21:51:26 schrieb Michael Snoyman:
> On Sat, Dec 5, 2009 at 10:33 PM, José Iborra <pepeiborra at gmail.com> wrote:
> > Since you have already decided MPTCs are ok, in my opinion undecidable
> > instances are fine here.
> > But I realize this is not the usual stance, so I might be wrong.
> >
As far as I understand, all UndecidableInstances does is tell the compiler "Maybe instance
checking won't terminate, try anyway", so they're dangerous *only during compilation*,
once things compile, everything's dandy.
> Sounds reasonable to me. I'm waiting for the boogey man to jump out
> though
>
> and explain why undecidables here will get me gored to death by a raptor
> [1].
They won't. They might suck you into a black hole, but raptors are very specialised.
> >
> > instance Convert Integer Double where convert = Just . fromIntegral
> > instance TotalConvert Double -- that's all
instance TotalConvert Integer Double
> >
> Interestng approach. The current approach is *almost* the same, just
> leaves
>
> off the default definition. I'd be wary of putting in a definition like
> that; although it saves a line of typing, it let's a partial function get
> in which could cause trouble for unsuspecting users. But it is a
> possibility.
But only if they declare misbehaved instances of TotalConvert. Whenever a reasonable
instance TotalConvert x y exists, the Convert instance should satisfy the demands of the
default definition.
>
> > Cheers,
> > pepe
>
> [1] http://xkcd.com/292/
More information about the Haskell-Cafe
mailing list