
#13097: Num a => Num (Down a) -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- @@ -1,1 +1,2 @@ - Let's us write + There are many missing instances for `Down`, I happened to need `Num (Down + _)`. It can be derived with GND: @@ -4,1 +5,2 @@ - >>> deriving instance Num a => Num (Down a) + newtype Down a = Down a deriving (Eq, Show, Read, Num) + }}} @@ -6,0 +8,3 @@ + which let's us write + + {{{#!hs @@ -12,0 +17,6 @@ + + We can of course add instances for `Functor`, `Applicative`, `Monad`, + `MonadFix`, ... I don't know that they would ever get but it wouldn't be + much trouble copying `Identity`, `Dual` instances. + + ---- New description: There are many missing instances for `Down`, I happened to need `Num (Down _)`. It can be derived with GND: {{{#!hs newtype Down a = Down a deriving (Eq, Show, Read, Num) }}} which let's us write {{{#!hs
(<) 10 20 True
(<) @(Down _) 10 20 False }}}
We can of course add instances for `Functor`, `Applicative`, `Monad`, `MonadFix`, ... I don't know that they would ever get but it wouldn't be much trouble copying `Identity`, `Dual` instances. ---- With #12363 {{{#!hs
10 < @(Down _) 20 False }}}
-- Comment (by Iceland_jack): Replying to [comment:1 mpickering]:
Is this a feature request to add a `Num` instance for `Down`? It would be very helpful if you explained this on the ticket!
Yes, along with other instances — changed description. What is the stance of ''base'', do we provide every instance that makes sense or limit it to instances we know have a use? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler