[Haskell-cafe] instance for (Show ([(String, Int)] -> Int))
Aaron Gray
aaronngray.lists at gmail.com
Sat Dec 25 00:32:38 CET 2010
On 24 December 2010 22:07, Daniel Fischer
<daniel.is.fischer at googlemail.com>wrote:
> On Friday 24 December 2010 22:47:55, Aaron Gray wrote:
> > On 24 December 2010 18:24, Henning Thielemann
> > <lemming at henning-thielemann.de
> >
> > > wrote:
> > >
> > >
> > > On Fri, 24 Dec 2010, Aaron Gray wrote:
> > >
> > > The compiler is requesting an instance declaration for Show :-
> > >
> > >> expr-eval.hs:334:23:
> > >> No instance for (Show ([(String, Int)] -> Int))
> > >> arising from a use of `print' at expr-eval.hs:334:23-27
> > >> Possible fix:
> > >> add an instance declaration for (Show ([(String, Int)] ->
> > >> Int)) In the first argument of `(.)', namely `print'
> > >> In the second argument of `(>>=)', namely `print . calc .
> > >> lexer' In the expression: getContents >>= print . calc . lexer
> > >
> > > ... maybe 'calc' needs a further argument?
> >
> > I have attached what I have typed in so far.
>
> Well,
>
> *ExprEval> :t calc
> calc :: [Token] -> [(String, Int)] -> Int
>
> calc needs an environment (a dictionary of let-bound names), which you have
> to provide.
>
> main = print . flip calc [] . lexer
>
> works fine.
>
Okay great, works this end too, but what does the 'flip' do ???
Now to get it to work as a REPL and to read from file :)
Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101224/bd42f31a/attachment.htm>
More information about the Haskell-Cafe
mailing list