Re: [GHC] #12047: Users Guide: GeneralizedNewtypeDeriving derives “instance Num Int => Num Dollars”
GHC
ghc-devs at haskell.org
Wed May 25 21:11:11 UTC 2016
#12047: Users Guide: GeneralizedNewtypeDeriving derives “instance Num Int => Num
Dollars”
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: task | Status: new
Priority: normal | Milestone:
Component: Documentation | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Documentation | Unknown/Multiple
bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):
* component: Compiler => Documentation
Comment:
That section isn't saying that `newtype Dollars = Dollars Int deriving
Num` literally derives an instance of the form `instance Num Int => Num
Dollars`, but rather it generates an `instance Num Dollars` by starting
with `Num Int` as the context, then simplifying as much as possible. In
that example, since a `Num Int` instance exists, we can discharge that
constraint and be left with `()`, giving us the `instance Num Dollars`
that you actually get when you compile with `-ddump-deriv`.
I agree that the wording in that section is a bit vague (it uses the
phrase "Notationally" without going into much detail about what it really
entails) and could stand to be clarified.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12047#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list