[Haskell-beginners] (no subject)

Jamie F Olson jamie.f.olson at gmail.com
Thu Mar 28 23:26:28 CET 2013


David McBride <toad3k <at> gmail.com> writes:

> 
> data JSValue = ... | JSObject (JSObject JSValue) | ...
> 
> The first JSValue is a type.  The first JSObject is a constructor.
> The second JSObject is a type and so is the second JSValue.  Put them
> together it is a single type "JSObject JSValue".  So that JObject
> constructor takes a single type of (JSObject JSValue).
> 
> newtype JSObject e = JSONObject [(String, e)]
> 
> The first JSObject is again a type.  The e will be replaced with a
> type.  JSONObject is a constructor again.  ...

Thank you very much for the clarification!

This is what I couldn't wrap my head around.  JSObject as a data constructor 
creates objects of type JSValue, not JSObject, which are instead created by 
JSONObject.  Frankly, it's the Text.JSON api that's confusing more than the 
language.  The language feature is more or less like classes vs constructors in 
OOP (except for types not actually existing in Haskell)

The other weird thing is that the types don't exist as objects that can be 
referenced.




More information about the Beginners mailing list