[GHC] #14084: Strange behavior of GHC by writing the types in GHCi

GHC ghc-devs at haskell.org
Thu Aug 3 17:22:10 UTC 2017


#14084: Strange behavior of GHC by writing the types in GHCi
-------------------------------------+-------------------------------------
        Reporter:  vanto             |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.0.2
      Resolution:  invalid           |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by hsyl20):

 @vanto

 > It can with numbers but it can not with characters.

 It seems like you don't understand the type of numeric literals in
 Haskell. Please read
 https://www.haskell.org/onlinereport/basic.html#sect6.4.1

 Then this will make sense:
 {{{#!hs
 > :t (:)
 (:) :: a -> [a] -> [a]
 > :t 1
 1 :: Num t => t
 > :t (1:)
 (1:) :: Num a => [a] -> [a]
 > :t (1:2)
 (1:2) :: (Num [a], Num a) => [a]
 }}}

 > The ML and Miranda compilers, for example, do not manage to evaluate
 this kind of poorly written list, as well as with numbers or characters.

 Probably because they aren't compilers for the same language. AFAIK ML
 compilers don't allow `1` to be used as a Float literal, we have to use
 `1.` instead. Different trade offs...

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14084#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list