[Haskell-cafe] Functional Parsers in GHCI
Ivan Lazar Miljenovic
ivan.miljenovic at gmail.com
Sun May 23 03:08:09 EDT 2010
Amiruddin Nagri <amir.nagri at gmail.com> writes:
> Hi All,
>
> I am a newbie to Haskell, and have been using Programming in Haskell along
> with Eric Meijer videos covering the book syllabus. I am currently on
> Chapter 8 Functional Parsers, and trying to implement few of the examples
> given in the book.
>
> Following is the example :
>
> item = \inp -> case inp of
> [] -> []
> (x:xs) -> [(x,xs)]
>
> p = do x <- item
> y <- item
> z <- item
> return (x,y,z)
>
> =========
>
> When I compile it using GHCI, I get the following error :
>
> [1 of 1] Compiling Main ( parser.hs, interpreted )
>
> parser.hs:5:8:
> No instance for (Monad ((->) [t]))
> arising from a do statement at parser.hs:5:8-16
Try importing Control.Monad.Instances and see if that gets it to work.
> Possible fix: add an instance declaration for (Monad ((->) [t]))
> In a stmt of a 'do' expression: x <- item
> In the expression:
> do x <- item
> y <- item
> z <- item
> return (x, y, z)
> In the definition of `p':
> p = do x <- item
> y <- item
> z <- item
> ....
> Failed, modules loaded: none.
>
> =========
>
> I tried googling for samples, above error message etc. But not getting to
> solution. Can anyone guide me as to what am I doing wrong and how can I fix
> this.
>
> Regards,
> Amiruddin Nagri,
> India
>
> GTalk : amir.nagri at gmail.com
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
More information about the Haskell-Cafe
mailing list