You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code (from An Outsider's Guide to Statically Typed Functional Programming, @marick) produces a type mismatch error in 0.19:
moduleSumTypes.WholeStorySolutionexposing (..)
type Silly a b
=AsA a
|AsB b
|AlsoAsA a
|AsIntInt|AsFloatStringFloatString|AsBoth a b
|AsIntBInt b
|AsMaybe(Maybe b)|AsMaybeInt(MaybeInt)|DeeplySilly(Silly a a)(SillyInt b)|NoArgbVals:Sillyab->MaybebbVals silly =case silly of AsB b ->Just b
AsBoth _ b ->Just b
AsIntB _ b ->Just b
AsMaybe(Just b)->Just b -- could just be AsMaybe maybe -> maybeDeeplySilly _ nested -> bVals nested {- <--- Problem here -}
_ ->Nothing
Error:
Detected errors in 1 module.-- TYPE MISMATCH --------------------------------------------- src/SumTypes/WholeStorySolution.elmThe 1st argument to `bVals` is not what I expect:171| bVals nested
^^^^^^^^^^This`nested` value is a:SillyInt b
But`bVals` needs the 1st argument to be:Silly a b
[…]
Additional possibly interesting info:
> bVals
<function>:SillyInt a ->Maybe a -- The inferred type (without annotation)>AsFloatString4.5"hi"|> bVals
Nothing:Maybe b -- …Why is this not an error, it doesn't conform to the inferred type?
It seems like Silly a b should allow Silly Int b. Is this intended behavior?
The text was updated successfully, but these errors were encountered:
The following code (from An Outsider's Guide to Statically Typed Functional Programming, @marick) produces a type mismatch error in 0.19:
Error:
Additional possibly interesting info:
It seems like
Silly a b
should allowSilly Int b
. Is this intended behavior?The text was updated successfully, but these errors were encountered: