[GHC] #8026: DatatypeContexts should be fixed, not deprecated
GHC
ghc-devs at haskell.org
Mon Sep 22 13:04:13 UTC 2014
#8026: DatatypeContexts should be fixed, not deprecated
-------------------------------------+-------------------------------------
Reporter: gidyn | Owner:
Type: feature | Status: closed
request | Milestone:
Priority: normal | Version: 7.6.3
Component: Compiler | Keywords:
Resolution: wontfix | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by yokto):
I like the idea of fixing this too. The main Idea would be to hide
Contexts from sight. As an example of how this could be useful consider
Num were a newtype instead of a type class
{{{
newtype (Prelude.Num n) => Num n = Num n
newtype Int = Num Prelude.Int
(+) :: Num n -> Num n -> Num n
}}}
This would mean you could actually make instances
{{{
instance SomeClass (Num n)
}}}
that don't conflict with all other instances
{{{
instance (Num n) => SomeClass n
instance SomeClass Char
}}}
crash
and even if you enable ugly extensions like UndecidableInstances this can
not fix your problems if you want to use type families or functional
dependencies.
you can not make an instance
{{{
class SomeClass a b | a -> b
instance (Num n) => SomeClass n b
}}}
without immediately blocking all other possible Instances.
Maybe these DatatypeContexts based containers are a bit less flexible than
common classes in that they don't mix, but if you know they don't have to
mix it makes instances a lot easier and safer.
of course you can always add the context explicitly but it would be nice
if ghc infer them. As gidyn said I don't think this would change the type
system overly much. You would just get contexts that don't need not be
explicitly stated. Every time you do context checks you can easily derive
them from the type.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8026#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list