Re: [Haskell-cafe] Re: Can this be done?

2009-02-14 Thread wren ng thornton

Chung-chieh Shan wrote:

wren ng thornton wrote:
 It's ugly, but one option is to just reify your continuations as an ADT, 
 where there are constructors for each function and fields for each 
 variable that needs closing over. Serializing that ADT should be simple 
 (unless some of those functions are higher-order in which case you run 
 into the same problem of how to serialize the function arguments). In 
 GHC's STG machine this representation shouldn't have much overhead, 
 though it does require the developer to do the compiler's job.


FWIW, this idea is called defunctionalization (due to Reynolds),
and it works for higher-order functions as well (because you can
defunctionalize those function arguments in the same way).


Oh certainly. Depending on how the HOFs are used, however, that can lead 
to a very large grammar. The basic ADT approach works best when there 
are a small selection of actions to take or pass around (aka few states 
in the state machine).


For a more general solution you'll want to use something like HOAS or 
Template Haskell's AST, with explicit representations for general 
function application, let binding, and case expressions. That way the 
building blocks are small enough to keep the evaluator simple to maintain.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Can this be done?

2009-02-12 Thread Cristiano Paris
On Wed, Feb 11, 2009 at 6:41 PM, Achim Schneider bars...@web.de wrote:
 ...
 I got curious and made two pages point to each other, resulting in as
 many stale continuations as your left mouse button would permit. While
 the model certainly is cool, I'm not aware of any implementation that
 even comes close to having production-safe (that is, non-abusable)
 semantics.

Stale continuations are an issue (think of anonymous accesses), even
if my personal feeling is that it may be mitigated using continuations
wisely (i.e. only when they're actually relevant).

Cristiano
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Can this be done?

2009-02-12 Thread Derek Elkins
On Thu, 2009-02-12 at 19:55 -0500, Chung-chieh Shan wrote:
 wren ng thornton w...@freegeek.org wrote in article 
 4993bbee.9070...@freegeek.org in gmane.comp.lang.haskell.cafe:
  It's ugly, but one option is to just reify your continuations as an ADT, 
  where there are constructors for each function and fields for each 
  variable that needs closing over. Serializing that ADT should be simple 
  (unless some of those functions are higher-order in which case you run 
  into the same problem of how to serialize the function arguments). In 
  GHC's STG machine this representation shouldn't have much overhead, 
  though it does require the developer to do the compiler's job.
 
 FWIW, this idea is called defunctionalization (due to Reynolds),
 and it works for higher-order functions as well (because you can
 defunctionalize those function arguments in the same way).
 
 People in many fields put a lot of effort into turning their programs
 into state machines...
 
This paper by Ezra Cooper and Phil Wadler is an interesting recent
development in the theory of defunctionalization and very relevant to
this particular topic as well:
http://homepages.inf.ed.ac.uk/wadler/topics/links.html#located-lambda

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Can this be done?

2009-02-11 Thread Sebastian Sylvan
On Wed, Feb 11, 2009 at 5:41 PM, Achim Schneider bars...@web.de wrote:

 Evan Laforge qdun...@gmail.com wrote:

  On Wed, Feb 11, 2009 at 9:34 PM, Alistair Bayley
  alist...@abayley.org wrote:
   2009/2/11 Cristiano Paris cristiano.pa...@gmail.com:
   I wonder whether this can be done in Haskell (see muleherd's
   comment):
  
  
 http://www.reddit.com/r/programming/comments/7wi7s/how_continuationbased_web_frameworks_work/
  
   WASH did/does something similar. You can certainly write
   applications in a similar, workflow-ish style (rather than like a
   state machine).
 
  To hijack the subject, what happened to WASH?  The paper seemed like
  it was full of interesting ideas, but the implementation seems to have
  failed to capture many hearts.  Now it seems like a stagnant project.
  What were the fatal flaws?
 
 I got curious and made two pages point to each other, resulting in as
 many stale continuations as your left mouse button would permit. While
 the model certainly is cool, I'm not aware of any implementation that
 even comes close to having production-safe (that is, non-abusable)
 semantics.


Shouldn't the following WASH function help?

once :: (Read a, Show a) = CGI a - CGI a


-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe