[GHC] #14076: cons operator for list give weird output

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Keywords: cons(:) | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- on typing the following command in ghci\\ :t 1:2\\ I get the output\\ (Num [a], Num a) => [a]\\ While running the same on char like follows, gives me an error:\\ :t 'a':'b' -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: invalid | Keywords: cons(:) Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: This looks like correct behavior to me. Recall that numbers in Haskell are overloaded, meaning that the type of a number `1` is `Num a => a`. Your initial expression conses one number onto another -- thus both the element and the list type must be in the `Num` type class. Please reopen if you see a flaw here somewhere, and thanks for posting! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: | Keywords: cons(:) Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by vanto): * status: closed => new * resolution: invalid => Comment: Reply to [[span(style=color: #FF0000, goldfire )]]:\\ you have to write {{{:t 'a':'b':[]}}}\\ reply {{{'a':'b':[] :: [Char]}}}\\\\ otherwise {{{:t 1:2:[]}}}\\ reply {{{1:2:[] :: Num a => [a]}}}\\\\ That's right, it sounds weird. I'm reopening this ticket so you can think a little better about the problem, goldfire.\\ Thanks. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: | Keywords: cons(:) 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 Iceland_jack): This is expected, someone could define a `Num` instance for lists in a separate module {{{#!hs instance Num a => Num [a] where fromInteger :: Integer -> [a] fromInteger i = [fromInteger] (+) :: [a] -> [a] -> [a] (+) = liftA2 (+) -- .. }}} at which point your expression reduces to `[1,2]` {{{
:t 1 : 2 1 : 2 :: Num a => [a] 1 : 2 [1,2] }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

I'm reopening this ticket so you can think a little better about the
#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: invalid | Keywords: cons(:) Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => closed * resolution: => invalid Comment: problem, goldfire. There is, in general, no need to tell goldfire to think better. He already thinks frighteningly goo. Please, vanto, give the developers of GHC the benefit of doubt that they know what they are talking about, and what the appropriate status of a bug is (unless you are very sure that they made a mistake, which is of course possible. In that case point out their mistake in a friendly manner, and let them change the status back if they are indeed wrong). Anyways, GHC is doing everything right here (and it’s not GHC’s fault if Haskell can be a bit confusing sometimes). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: | Keywords: cons(:) Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by vanto): * status: closed => new * resolution: invalid => Comment: Reply to [[span(style=color: #FF0000, nomeata )]]:\\ '''Well, sorry about that. I apologize for the hassle I gave to some of you'''. But this sentence is just a simple discussion and not a criticism of a GHC developer. And I'm very surprised at your behavior. Goldfire can think better just like me I can also think better and you and everyone can also think better!.\\ '''Where is the wrong in this sentence?'''.\\ I know you work a lot and even you do a good job. But if I want to draw the attention of someone of you I reopen the ticket for a discussion, not to bother you.\\ Here AshHash is right to point this difference. Maybe the error message needs to be improved?\\ '''If you don't want to think better, leave the Committee! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: invalid | Keywords: cons(:) Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dibblego): * status: new => closed * resolution: => invalid Comment: Replying to [comment:5 vanto]: Hi vanto, we thought about this a lot and this is the correct behaviour of GHC. If you'd like to discuss why it is correct behaviour, I invite you to IRC where we can think better together. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14076: cons operator for list give weird output -------------------------------------+------------------------------------- Reporter: AshHash | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: invalid | Keywords: cons(:) 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 nomeata):
I reopen the ticket for a discussion
There is no reason to reopen a ticket, just to have a discussion. The ticket is closed as invalid right now, and we are still having a discussion here. If the discussion comes to a conclusion that there is something to be done, then someone will change the status of the ticket accordingly.
Maybe the error message needs to be improved?
Which error message? He was observing {{{ :t 1:2 (Num [a], Num a) => [a] }}} which (rightly) does not produce any error message. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14076#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC