The following fails to compile:
module Main where
import Text.JSON (JSObject, JSValue)
main = print "hello world"
getObject :: JSValue -> JSObject JSValue
getObject (JSObject x) = x
Giving the error:
Not in scope: data constructor `JSObject'
But removing the import list allows it compilation to success succeed (even though JSObject
was imported above)
module Main where
import Text.JSON
main = print "hello world"
getObject :: JSValue -> JSObject JSValue
getObject (JSObject x) = x
Why is GHC (7.4.2) ignoring my import of JSObject
?
If you write import Text.JSON (JSObject)
you only import type, not the constructors it has. To import constructurs do import Text.JSON (JSObject(..))
or instead of ..
specify comma-separated list of constructor names you wish to use, e.g. Text.JSON(JSObject(Cons1, Cons2))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With