haskell - Why can't I get overloaded strings? -
this code have in file temp.hs
:
{-# language overloadedstrings #-} module temp import data.string string1 = "darth vader" string2 = "obi-wan kenobi"
the problem want overloaded strings. understand, overloaded strings polymorphic, belonging typeclass isstring
. when load above file in ghc ,
:t string1
,
i should
string1 :: data.string.isstring => a
but is:
string1 :: string
help!
this answer in based on user2407038's comment.
turns out adding {-# language nomonomorphismrestriciton #-}
code solves problem. wouldn't recommend it. read monomorphism restriction.
but turns out, don't have it. ghc monomorphism thing , sets type of string1
string
, because thought didn't want else. overloadedstrings
extension still in effect! you'll notice if
string1 = "darth vader"::bytestring
ghc more happy make string1
variable bytestring
.
one more thing noticed in haskell's monomorphism restriction wiki page, is:
the restriction turned on default in compiled modules, , turned off default @ ghci prompt (since ghc 7.8.1).
Comments
Post a Comment