News for hackers. Stuff that matters.
Re:Clojure vs. The Static Typing World by platz on Friday October 27, 2017 @11:03AM (#15569035)
> The "can Haskell..." stuff has a similar smell to it. The answer is always "yes, Haskell (and everyone else) have hash maps and HOFs."

+1 !

If necessary you don't need to use and ADT+pattern matching on JSON. You just work with the hashmap directly.

Re:Clojure vs. The Static Typing World by keymone on Friday October 27, 2017 @12:29PM (#15569899)
What is the type signature for json hashmap in Haskell and how using it is different from using a dynamically typed language?
Re:Clojure vs. The Static Typing World by chowells on Friday October 27, 2017 @12:42PM (#15570006)
The easiest way to use JSON as dynamically typed data in Haskell is with the lens[1] and lens-aeson[2] packages. The type signatures those use are astounding, and not trivial to understand.

But the code that results is very simple while remaining strongly typed.

It ends up being not that different in style from something like hpricot in ruby.

[1] https://hackage.haskell.org/package/lens

[2] https://hackage.haskell.org/package/lens-aeson

Re:Clojure vs. The Static Typing World by platz on Friday October 27, 2017 @12:45PM (#15570037)
A json object has the type signature:

    type Object = HashMap Text Value
which is A JSON "object" (key/value map).

The keys of the hashmap are Text and the leaves are "Value" which contain more JSON

here are different well-formed json values that both resolve to the same type, A.Object (either you get a parse error String for not-well-formed json, or an A.Object)

    >>> A.eitherDecode "{ \"name\": \"Joe\", \"age\": 12 }" :: Either String A.Object

    Right (fromList [("age",Number 12.0),("name",String "Joe")])

    >>> A.eitherDecode "{ \"name\": \"Joe\", \"age\": {\"foo\": \"12\"} }" :: Either String A.Object

    Right (fromList [("age",Object (fromList [("foo",String "12")])),("name",String "Joe")])
Then you can access values in the HashMap by key just like a hashmap in any other language.

Or, as noted by chowells, you can use lens-aeson which can be thought of as a DSL to perform queries in a dynamic fashion:

retrieve value of "foo" in "age"

    >>> s = "{ \"name\": \"Joe\", \"age\": {\"foo\": \"12\"} }" :: String
    >>> s ^? key "age" . key "foo"
    Just (String "12")
Re:Clojure vs. The Static Typing World by tome on Saturday October 28, 2017 @07:34AM (#15574797)
> how using it is different from using a dynamically typed language

It's not different for that type. The point of using a statically typed language is you can give static types to other entities in your program!