Re:Effective Programs: 10 Years of Clojure
by wellpast on Tuesday October 31, 2017 @05:42PM
(#15596850)
How would it infer:
isOld(parseJson(json))
When parseJson may or may not produce an entity with the "age" property?
Re:Effective Programs: 10 Years of Clojure
by Bogdanp on Wednesday November 01, 2017 @06:24AM
(#15599971)
Sorry, I wasn't clear. My point was that you don't have to declare the type of `thing` up front in that example. It would be able to infer that it's a record with an `age` field from the function's definition.
In your example, `parseJson` would have to return a record with an age field, otherwise the compiler would complain. Personally, I think that represents a reasonable tradeoff in ease of use for safety.
Elm (and Purescript) should be able to fully infer the type of that function w/o forcing you to declare which fields you want to use up-front.