[GHC] #13097: Num a => Num (Down a)

#13097: Num a => Num (Down a) -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: | Version: 8.0.1 libraries/base | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Let's us write {{{#!hs
deriving instance Num a => Num (Down a)
(<) 10 20 True
(<) @(Down _) 10 20 False }}}
With #12363 {{{#!hs
10 < @(Down _) 20 False }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Comment (by 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! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: @@ -26,1 +26,0 @@ - @@ -31,0 +30,8 @@ + + with #12363 + #12465 + + + {{{#!hs + >>> 10 < @Down{} 20 + False + }}} 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 }}}
with #12363 + #12465 {{{#!hs
10 < @Down{} 20 False }}}
-- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: @@ -19,2 +19,2 @@ - `MonadFix`, ... I don't know that they would ever get but it wouldn't be - much trouble copying `Identity`, `Dual` instances. + `MonadFix`, ... I don't know that they would see use but we can use + `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 see use but we can use `Identity`, `Dual` instances. ---- With #12363 {{{#!hs
10 < @(Down _) 20 False }}}
with #12363 + #12465 {{{#!hs
10 < @Down{} 20 False }}}
-- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): These instances feel extremely straightforward and uncontroversial to me. Mind whipping up a Phabricator Diff to add them? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13097: Num a => Num (Down a) -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) 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): Phab:D3500 Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamse): * differential: => Phab:D3500 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13097: Num a => Num (Down a)
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
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): Phab:D3500
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#13097: Num a => Num (Down a) -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: 8.4.1 Component: libraries/base | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3500 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13097#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC