Srinivas
Srinivas

Reputation: 2100

lines function not working as expected

In Prelude, unlines work as expected. Below is the example

GHCi>unlines ["aa","bb","bb"]
"aa\nbb\nbb\n"

But why does lines not work. Even the type signature says that it can only take numbers.

GHCi>:t lines
lines :: Num t => [t]

So, if I try

GHCi>lines "aa\nbb\nbb\n"

why do I get an error? Is there a lines that I need to import?

Regards,

Upvotes: 0

Views: 90

Answers (1)

mathk
mathk

Reputation: 8143

Are you sure that you are not shadowing the lines function:

:t lines
lines :: String -> [String]

Make sure you have not define a lines variable. As @ChadGilbert mention you can use :i

Upvotes: 5

Related Questions