3 ms·
It will do some wrangling of literals for you, as long as it can unambiguously decide on an exact type during type-checking. If no other info is given, it will
by mrkeen 2y ago
It will do some wrangling of literals for you, as long as it can unambiguously decide on an exact type during type-checking.
If no other info is given, it will treat `3 + 3` as Integer + Integer (and emit a compiler warning because it guessed the type).
With `(3 :: Int64) + 3`, the right 3 will resolve to Int64. Same if you swap their positions.
`(3 :: Int64) + (3 :: Int32)` is a compile error.
"Text literals" can become a String, a Text, or a ByteString if you're not explicit about it.
> implicit cast operator
Wouldn't that make it explicit?
- magicalhippo 2y ago> Wouldn't that make it explicit? No, the casting is still done implicitly. That is I can make the following compile fine in Delphi if I add an implicit cast operator to either Foo or Bar: Foo x := Foo.Create(); Bar y := x; If neither of them have a suitable implicit cast operator defined, it will of course fail to compile. Just an example, nothing unique about Delphi. You can see an example of the operator definition here[1]. [1]: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Operator_Overloading_(Delphi) https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Oper...
- itishappy 2y ago> "Text literals" can become a String, a Text, or a ByteString if you're not explicit about it. Not without explicitly enabling `OverloadedStrings`! https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/overloaded_strings.html https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/over...