If I define
data Thing = Shoe
| Ship
| SealingWax
| Cabbage
| King
and then in a later cell in an IHaskell Notebook enter
thing :: Thing
thing = 4
I get an error ("No instance for (Num Thing) arising from the literal ‘4’") as expected. But if I first complete a valid binding with
thing :: Thing
thing = King
and then later, in a separate cell make the same (invalid) assignment with
thing = 4
I get no error, and t: thing
yields thing :: (Num a) => a
.
More perplexingly, if I put
thing = Cabbage
:t thing
thing = 5
:t thing
in a single cell I get no errors and
thing :: Thing
thing :: (Num a) => a
but a single cell without the :t
lines
thing = Cabbage
thing = 5
gives an error:
Multiple declarations of ‘thing’
Declared at: :1:1
:2:1
Why can I change the type of a variable in separate IHaskell Notebook cells?