[Haskell-cafe] Monadic bind with associated types + PHOAS?

2008-11-18 Thread Ryan Ingram
This is an idea that has been bouncing around in my head for a while, having to do with embedded languages. A few of the talks at CUFP this year mentioned using Haskell to embed a DSL that gets compiled into the output of the program; the hydraulic engine talk embedded the code for the real-time s

[Haskell-cafe] Monadic bind with associated types + PHOAS?

2008-11-18 Thread oleg
Ryan Ingram wrote: > One thing that often comes up is a desire to do a pass on the > resultant code to optimize it, but it's pretty difficult with the > standard monadic formulation because of embedded functions. You can't > do introspection on functions in Haskell; they aren't elements of Eq > o

Re: [Haskell-cafe] Monadic bind with associated types + PHOAS?

2008-11-19 Thread Wouter Swierstra
Hi Ryan, On 19 Nov 2008, at 04:39, Ryan Ingram wrote: In HOAS, a lambda expression in the target language is represented by a function in the source language: data ExpE t where ApE :: ExpE (a -> b) -> ExpE a -> ExpE b LamE :: (ExpE a -> ExpE b) -> ExpE (a -> b) But without a way to ins

Re: [Haskell-cafe] Monadic bind with associated types + PHOAS?

2008-11-19 Thread Ryan Ingram
On Wed, Nov 19, 2008 at 1:04 AM, Wouter Swierstra <[EMAIL PROTECTED]> wrote: > I'm not convinced yet. The problem is that there's no best way to handle > binding. HOAS is great for some things (you don't have to write > substitution), but annoying for others (optimisations or showing code). PHOAS