Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-15 Thread Jacques Carette
(sorry for the slow reply on this topic...) Robert Atkey and Oleg presented some very interesting code in response to your query. But some of you might (and should!) be asking why on earth did Jacques use unsafePerformIO?, especially when neither Robert nor Oleg did. Simply put: I answered

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-15 Thread Günther Schmidt
Hi Jacques, thank you again for your post, better late than never :)! Let me first apologize to you, I did not immediately recognize you as one of the authors of the Finally Tagless paper. After 2 years now of using haskell at a mere layman's level and nevertheless writing better and more

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-07 Thread Robert Atkey
On Mon, 2009-10-05 at 19:22 -0400, David Menendez wrote: The two obvious options are call-by-name and call-by-value. I wonder how easily one can provide both, like in Algol. Fairly easy, you can either do a language that has an explicit monad (a bit like Haskell with only the IO monad), or

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-07 Thread Robert Atkey
On Mon, 2009-10-05 at 22:42 +0100, Robert Atkey wrote: There is a difference in the syntax between CBN and CBV that is not always obvious from the usual paper presentations. There is a split between pieces of syntax that are values and those that are computations. Values do not have

[Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-05 Thread Günther Schmidt
Hi all, I'm playing around with finally tagless. Here is the class for my Syntax: class HOAS repr where lam :: (repr a - repr b) - repr (a - b) app :: repr (a - b) - repr a - repr b fix :: (repr a - repr a) - repr a let_ :: repr a - (repr a - repr b) - repr b int :: Int -

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-05 Thread Jacques Carette
It's possible, but it's not nice. You need to be able to get out of the monad to make the types match, i.e. lam f = I (return $ \x - let y = I (return x) in unsafePerformIO $ unI (f y)) The use of IO 'forces' lam to transform its effectful input into an even

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-05 Thread Günther Schmidt
Hello Jacques, thanks, that is disappointing in some way, guess I still have a lot to learn. Günther Am 05.10.2009, 18:06 Uhr, schrieb Jacques Carette care...@mcmaster.ca: It's possible, but it's not nice. You need to be able to get out of the monad to make the types match, i.e.

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-05 Thread Jacques Carette
BTW, here is a more symmetric version of the same code: lam f = I . return $ unsafePerformIO . unI . f . I . return which has a very clear pattern of lam f = embed $ extract . f. embed where 'embed' is often called return. Implementations of lam in tagless final style tend to follow the

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-05 Thread Robert Atkey
Hi Günther, The underlying problem with the implementation of 'lam' is that you have to pick an evaluation order for the side effects you want in the semantics of your embedded language. The two obvious options are call-by-name and call-by-value. The tricky point is that the types of the

Re: [Haskell-cafe] Finally tagless - stuck with implementation of lam

2009-10-05 Thread David Menendez
2009/10/5 Robert Atkey bob.at...@ed.ac.uk: Hi Günther, The underlying problem with the implementation of 'lam' is that you have to pick an evaluation order for the side effects you want in the semantics of your embedded language. The two obvious options are call-by-name and call-by-value. I