Reputation: 128
Error came up when writing this:
definition x = x
definition :: Int -> Int
Upvotes: 2
Views: 81
Reputation: 477190
You here first defined a function definition x = x
. In the second line, you then have an expression definition :: Int -> Int
. But a function is not an instance of Show
, and thus the interpreter can not print the function.
It looks however like your second line is the signature you want to add to the function. You can use :{
and :}
to write multi-line statements, like:
Prelude> :{
Prelude| definition :: Int -> Int
Prelude| definition x = x
Prelude| :}
Upvotes: 6
Reputation: 116174
You are entering your code in GHCi, line by line.
The first line defines your function.
The second line asks it to be printed, which can not be done.
Don't write your code line by line in GHCi. Write it in a file, and then load it in GHCi.
Upvotes: 6