RE: Implementing forward refs in monadic assembler and interprete r

2002-12-02 Thread Simon Peyton-Jones

| For the moment I've chosen to do the mdo desugaring manually instead
| of moving to the CVS ghc (or exclusively using Hugs.)  Will mdo be in
| the next release?  (That's 5.04.2, I think -- though I've recently
| been confused about GHC releases.)  The relevant revision to Lex.lhs
| is pretty recent and doesn't seem to be on ghc-5-04-branch.

mdo won't be in 5.04.2; these patch releases are meant to be bug fixes
only.

As I mentioned in an earlier message, we are undecided about when to
invest the effort to make another major release.   The more people that
yell, the sooner we will do it!  Main things in the next major release
are
mdo
Template Haskell
a fairly major fix to the newtype-deriving mechanism (it's 
a bit broken in 5.04)

Simon
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



RE: Implementing forward refs in monadic assembler and interprete r

2002-12-02 Thread Ashley Yakeley
At 2002-12-02 00:37, Simon Peyton-Jones wrote:

Main things in the next major release are
   mdo
   Template Haskell

Can mdo be done in TH? It would be nice if there were some kind of macro 
system for this sort of thing; I know there's also a syntax for Arrows 
that requires a preprocessor...

-- 
Ashley Yakeley, Seattle WA

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Implementing forward refs in monadic assembler and interprete r

2002-11-29 Thread Mike Gunter


Thank to all who replied.  After giving up on continuations (which
make everything but forward branches seductively easy), I settled on
something with the following interface:

 class MonadGoto lbl gm | gm - lbl where
   liftG   :: Monad m = m () - gm m ()
   label   :: Monad m = gm m lbl
   gotoIf  :: Monad m = m Bool - lbl - gm m ()

Note that, unlike a monad transformer, only ()-producing computations
can be embedded.  This limitation reflects the problem of def-use
across basic-block boundaries.  Of course, computations in the
embedded monad can be done there, then lifted, e.g.:

;top -label
;  ...
;  liftG (do v - m1
;...
;m2 v
;...)
;  brPositive r3 top
;  ...   


I've implemented MonadGoto as

 newtype GotoT m a = GotoT { unGotoT ::  WriterT [GotoLbldT m ()] LblSupply a }

 data GotoLbldT m a= Label  !Lbl
   | GotoIf (m Bool) !Lbl
   | Inner (m a)

 wrL   = GotoT . tell . (:[])
 instance MonadGoto Lbl GotoT where
   liftG   = wrL . Inner
   label   = GotoT $ lift fromSupply = \l - tell [Label l]  return l
   gotoIf p l  = wrL $ GotoIf p l

where GotoLbldT gets converted to 

 data GotoLbldRunT m a = ThenLabel  { before :: m (), next :: GotoLbldRunT m a, 
labelLbl :: !Lbl }
   | ThenGotoIf { before :: m (), next :: GotoLbldRunT m a
, gotoPred :: m Bool, gotoLbl :: !Lbl }
   | Tail (m a)

which can then be run

 type JumpArray m v= [(Lbl, m v)]
 runGM :: Monad m = JumpArray m v - GotoLbldRunT m v - (JumpArray 
m v, m v)

.  My Verilog has delayed branches (because that's the easy thing to
do.)  So, I implemented a DelayedGotoT which provides for delayed
branches by shuffling the GotoLbldTs and using a StateT to save the
result of the gotoPred evaluation.


Erkok, Levent [EMAIL PROTECTED] writes:

 You need a fairly recent version of Hugs to run this
 example, November 2002 release would do (try with -98). For ghc, you need
 the CVS version, or wait till the next release. As far as I know, no other
 implementation supports mdo, nor there are any plans for it.

For the moment I've chosen to do the mdo desugaring manually instead
of moving to the CVS ghc (or exclusively using Hugs.)  Will mdo be in
the next release?  (That's 5.04.2, I think -- though I've recently
been confused about GHC releases.)  The relevant revision to Lex.lhs
is pretty recent and doesn't seem to be on ghc-5-04-branch.

thanks,
mike
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe