Why isn't this Overlapping?

Simon Peyton Jones simonpj at microsoft.com
Tue Apr 18 10:31:30 UTC 2017


Moreover, as discussed in the user manual section<http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#overlapping-instances>, GHC doesn’t complain about overlapping instances at the instance decl, but rather where the instances are used. That’s why there is no overlap complaint here

Simon


From: Glasgow-haskell-users [mailto:glasgow-haskell-users-bounces at haskell.org] On Behalf Of Iavor Diatchki
Sent: 18 April 2017 01:50
To: anthony_clayden at clear.net.nz
Cc: GHC Users Mailing List <glasgow-haskell-users at haskell.org>
Subject: Re: Why isn't this Overlapping?

Hello,

these two instances really should be rejected as they violate the FD of the class: we can derive `TypeEq a a True` using the first instance and `TypeEq a a False` using the second one.  Unfortunately, the check that we are using to validate FDs when `UndecidableInstances` is on, is not quite correct (relevant tickets are #9210 and #10675 where there are similar examples).

-Iavor



On Sun, Apr 16, 2017 at 12:13 AM, Anthony Clayden <anthony_clayden at clear.net.nz<mailto:anthony_clayden at clear.net.nz>> wrote:
--ghc 7.10 or 8.0.1

{-# LANGUAGE DataKinds, KindSignatures, GADTs,
                          MultiParamTypeClasses,
FunctionalDependencies, FlexibleInstances,
                          UndecidableInstances,
NoOverlappingInstances   #-}

class TypeEq a a' (b :: Bool) | a a' -> b

instance (b ~ True) => TypeEq a a b
instance (b ~ False) => TypeEq a a' b

Those two instance heads are nearly identical, surely they
overlap?
And for a type-level type equality test, they must be
unifiable.
But GHC doesn't complain.

If I take off the FunDep, then GHC complains.

AFAICT none of those extensions imply Overlaps,
but to be sure I've put NoOverlapping.


AntC
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users at haskell.org<mailto:Glasgow-haskell-users at haskell.org>
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fglasgow-haskell-users&data=02%7C01%7Csimonpj%40microsoft.com%7Cc6be4bcfd23946f5f4fc08d485f4f93a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636280734593515972&sdata=Us2Ovast3dKEpNkfEDbejyBHGmGKh2ElAi6%2FqQY8iFE%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20170418/f8eb40d9/attachment-0001.html>


More information about the Glasgow-haskell-users mailing list