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] ..
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
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.
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
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 =