[Haskell] I'm a beginner --- struggling with the SimpleJSON example from Real World Haskell
Patrick LeBoutillier
patrick.leboutillier at gmail.com
Tue Dec 14 22:37:28 CET 2010
Hi,
Make sure the line
data JValue ...
is not indented. I should start at the first column.
Patrick
On Tue, Dec 14, 2010 at 4:28 PM, dhjdhj <dhjdhj at gmail.com> wrote:
>
>
>
> I'm sure this question has been asked many times but I have not been able to
> find it anywhere.
>
>
> I have written the code below into Lekseh directly from the RWH book.
> However, I always get the error
>
> parse error on input 'getString' and the line number refers to the type
> declaration for getString.
>
> I have no idea what's wrong and would appreciate any suggestions to get past
> this.
>
> Thanks in advance
>
> David
> ----------------------------
>
>
>
> module SimpleJSON (
>
> JValue(..),
> getString,
> getInt,
> getDouble,
> getBool,
> getObject,
> getArray,
> isNull
> )
>
> where
>
>
>
> data JValue = JString String
> | JNumber Double
> | JBool Bool
> | JNull
> | JObject [ (String, JValue) ]
> | JArray [JValue]
>
> deriving (Eq, Ord, Show)
>
>
> getString :: JValue -> Maybe String
> getString (JString s) = Just s
> getString _ = Nothing
>
> getInt (JNumber n) = Just (truncate n)
> getInt _ = Nothing
>
> getDouble (JNumber n) = Just n
> getDouble _ = Nothing
>
> getBool (JBool b) = Just b
> getBool _ = Nothing
>
> getObject (JObject o) = Just o
> getObject _ = Nothing
>
> getArray (JArray a) = Just a
> getArray _ = Nothing
>
> isNull v = v == JNull
>
>
>
> --
> View this message in context: http://haskell.1045720.n5.nabble.com/I-m-a-beginner-struggling-with-the-SimpleJSON-example-from-Real-World-Haskell-tp3305331p3305331.html
> Sent from the Haskell - Haskell mailing list archive at Nabble.com.
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada
More information about the Haskell
mailing list