On Thursday, February 16, 2017 at 2:50:10 PM UTC, Martin Cerny wrote:
>
> I would say not type checking your example is correct behavior. Since all 
> occurrences of a type parameter have to resolve to the same type, the value 
> of test is not defined if b resolves to anything other than String. And 
> thus the compiler expects you to say it is a string. To be more specific, 
> if your code would compile, the following would also compile, which is bad:
>
> intToString: Int -> String
> intToString a = 
>   "Value:" ++ (toString a)
>
> err: Int->Int
> err =
>   test (Specific intToString)
>
> showError:Int
> showError =
>   err 5  --Now I am casting a string "Value:5" to int.
>  
>

I think you got the type of the 'err' function wrong? It would be Int -> 
String (as it applies test to a Val Int String). So err 5 would be 
"Value:5", a String as expected.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to