[Haskell-cafe] Annotations in abstract syntax tree

j.romildo at gmail.com j.romildo at gmail.com
Fri Apr 27 13:39:23 CEST 2012

On Thu, Apr 26, 2012 at 10:21:36AM +0200, José Pedro Magalhães wrote:
> Hi Romildo,
> If I understand correctly, you now want to add annotations to
> mutually-recursive datatypes. The annotations package supports that.
> Section 8 of our paper [1] gives an example of how to do that, and also
> Chapter 6 of Martijn's MSc thesis [2].
> Let me know if these references do not answer your question.

I am reading Martijn's MSc thesis and trying some code he presents. In
secton 5.1 he presents catamorphisms over fixed points.

The code I am trying is attached.

When evaluating the expression

    cata exprEval (runExpr (1+2*3))

I am getting the following error:

    No instance for (Functor ExprF)
      arising from a use of `cata'
    Possible fix: add an instance declaration for (Functor ExprF)
    In the expression: cata exprEval (runExpr (1 + 2 * 3))
    In an equation for `it': it = cata exprEval (runExpr (1 + 2 * 3))

How should an instance of (Functor ExprF) be defined? It is not shown in
the thesis.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Annot.hs
Type: text/x-haskell
Size: 479 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120427/9ad0ed24/attachment.hs>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Expr.hs
Type: text/x-haskell
Size: 1409 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120427/9ad0ed24/attachment-0001.hs>

More information about the Haskell-Cafe mailing list