Re: [Haskell-cafe] Problem with Python AST

2008-02-26 Thread Thomas Schilling
On 22 feb 2008, at 17.31, Roel van Dijk wrote: Otherwise I need pattern matching at the type level to bind the reqLoop and reqFun type variables (is such a thing even possible?): Yep. You use type-classes. For some examples see [1]. [1] ..

Re: [Haskell-cafe] Problem with Python AST

2008-02-22 Thread Roel van Dijk
On Fri, Feb 22, 2008 at 2:42 PM, Daniel Gorín [EMAIL PROTECTED] wrote: On Feb 21, 2008, at 7:55 PM, Roel van Dijk wrote: Your solutions allows a bit more but fails with the equivalent of def foo(): for i in range(10): if i == 6: return None The loop context

Re: [Haskell-cafe] Problem with Python AST

2008-02-21 Thread Roel van Dijk
Your solutions allows a bit more but fails with the equivalent of def foo(): for i in range(10): if i == 6: return None The loop context 'overwrites' the function context which makes the return statement illegal. I think I need a type level list.

[Haskell-cafe] Problem with Python AST

2008-02-20 Thread Roel van Dijk
Hello everyone, I am trying to create an AST for Python. My approach is to create a data type for each syntactic construct. But I am stuck trying to statically enforce some constraints over my statements. A very short example to illustrate my problem: newtype Ident = Id String data BinOp = Add

Re: [Haskell-cafe] Problem with Python AST

2008-02-20 Thread Daniel Gorín
Hi Something like this would do? if_ = Compound $ If [(IntLit 6, Suite [] [Break])] Nothing while_ = Compound $ While (IntLit 6) (Suite [] [if_]) Nothing f = Program [while_] -- this one fails -- f2 = Program [if_] newtype Ident = Id String data BinOp = Add | Sub data Exp =