In Poly ML, how would you write a function that returned "true" if x was of type 'a, and false if it wasn't?
Asked
Active
Viewed 75 times
1 Answers
1
I might have misunderstood your question, but it sounds like you have missed the whole point of a statically typed language.
That means you can't call a function with arguments of other types, than what it is declared to. Anything else will be rejected by the interpretor/compiler.
One function that will do what you want is:
> fun foo _ = true
val foo = fn : 'a -> bool

Community
- 1
- 1

Jesper.Reenberg
- 5,944
- 23
- 31