How do I write a monad? It should be pretty simple to port a simple haskell monad over, but I'm running into an assert error. I think I'm not passing in the right type function. Here's the monad typeclass:
###################################################### typeclass Monad [M: TYPE->TYPE] { virtual fun bind[a,b]: M a * (a -> M b) -> M b; virtual fun ret[a]: a -> M a; } ###################################################### And here's my instance: ###################################################### #import <flx.flxh> instance Monad[opt] { fun bind[a,b] (o:opt[a], f:a -> opt[b]): opt[b] => match o with | None[a] => None[b] | Some ?x => f x endmatch ; fun ret[a] (x:a): opt[a] => Some x; } open[T] Monad[opt[T]]; ###################################################### This errors out with: EXCEPTION File "./lpsrc/flx_lookup.ipk", line 1702, characters 6-12: Assertion failed (and on a side note, this tiny little code block takes 60s to compile with dypgen (!). I didn't realize we had that much of a slowdown!) ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language