Do notation for arbitrary monads

From: Arthur Peters <amp4_at_pdx.edu>
Date: Tue, 06 Sep 2011 10:02:53 -0700

Hello there,

I am currently working on writing a compiler from FlatCurry to OCaml
(using an explicitly graph rewrite based evaluation engine). I am
writing this compiler in curry (because there is a fairly nice
FlatCurry lib). However I have run into a problem.

I want to use a custom monad (a specialized state monad probably) for
generating the OCaml code. And of course I want to use do notation
to code with this monad. However I am getting errors like:

"/home/amp/shared/school/
Thesis/curry/State.curry", line 26.9: Type
error in statement
v <- return 2

Term: return 2
Inferred type: State _58 Prelude.Int
Expected type: Prelude.IO _56
Types Prelude.IO _56 and State _58 Prelude.Int are incompatible

It seems that do notation only works with the IO monad. Is this the
case? Is there any way around it or is this just what we are stuck
with until curry gets type-classes? (which I know will be a long while
because there is other more useful work to do on the language.)

I'm pretty sure I could use IORefs to store the information I need in
the IO monad but that seems like an ugly hack so I wanted to ask
before I committed to that path.

I am using PAKCS.

-Arthur



_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mi Sep 07 2011 - 09:16:53 CEST

This archive was generated by hypermail 2.3.0 : Do Feb 01 2024 - 07:15:10 CET