Hacker News new | ask | show | jobs
by Smaug123 1892 days ago
It doesn't have a type in Haskell, from a certain point of view. `3` is polymorphic.

Prelude> :t 3

3 :: Num p => p

1 comments

It does have a type. You just wrote it down!
Hence "from a certain point of view" - I would argue, in fact, that it's extremely similar to the sense in which 3 doesn't have a type in Go. Haskell's type system can express that sense, whereas Go's can't; but it's the same sense.

> It is an error if the constant value cannot be represented as a value of the respective type. An untyped constant has a default type which is the type to which the constant is implicitly converted in contexts where a typed value is required, for instance, in a short variable declaration such as i := 0 where there is no explicit type. The default type of an untyped constant is bool, rune, int, float64, complex128 or string respectively, depending on whether it is a boolean, rune, integer, floating-point, complex, or string constant.