It used to be the case in that

:t 3

would give you

3 :: Num a => a


let x = 3
:t x

would give you

x :: Integer

because storing a value in variable forced the system to commit to a specific type.

Nowadays, though, the latter gives you

x :: Num a => a

What changed? I'm at a loss as to how to search the web for an answer to this one.

@freemo That got me a short answer

that includes a link to a much deeper rabbit hole than I care to explore.

@peterdrake I think it’s because of the “let polymorphism with type schemes”

@peterdrake Is x an Int or an Integer?

> let x = 3 :: Integer
x :: Integer

> let x = 3 :: Int
x :: Int

@maridonkers Yes, you can declare the type. The question was about what happens if you don't; the rules have (slightly) changed since 2013.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.