-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support where expressions in Gibbon #209
Comments
Good first issue, indeed. Note, however, that in Haskell there are subtle differences between For example, this is not easy to encode with f x
| cond1 x = a
| cond2 x = g a
| otherwise = f (h x a)
where
a = w x But Gibbon doesn't seem to allow guards in function definitions. So, maybe the proposed desugaring into let's is viable. |
Currently, the parser seems to simply be throwing away the -- tmp.gibbon.hs
f x = y
where
y = x+1
gibbon_main = f 1 ❯ $g --run ./tmp.gibbon.hs -v4
! Responding to env Var: GIBBON_DEBUG=4
! We set DEBUG based on command-line verbose arg: 4
[compiler] pipeline starting, parsed program:
================================================================================
Prog {ddefs = [],
fundefs = [(f,
FunDef {funName = "f",
funArgs = [x],
funTy = ForAll [] (ArrowTy [MetaTv $0] (MetaTv $1)),
funBody = VarE "y",
funMeta = FunMeta {funRec = NotRec,
funInline = NoInline,
funCanTriggerGC = False}})],
mainExp = Just (AppE "f" [] [LitE 1], MetaTv $2)}
[compiler] Running pass, freshen
Pass output:
================================================================================
{meta: FunMeta {funRec = NotRec, funInline = NoInline, funCanTriggerGC = False}}
f :: forall. ($0 -> $1)
f x_3 =
y
gibbon_main :: $2
gibbon_main = (f [] 1)
[compiler] Running pass, typecheck
gibbon: L0.Typecheck:
Unbound variable y in Var "f"
CallStack (from HasCallStack):
error, called at src/Gibbon/L0/Typecheck.hs:83:18 in gibbon-0.3-inplace:Gibbon.L0.Typecheck |
The AST for
|
Making an issue from discussion with @ckoparkar in the onboarding session.
Gibbon doesn't support where expressions currently.
Neither does it have a Where expression in L0-L4.
To get around this we can parse where expressions in the HaskellFront end, then write a L0 -> L0 compiler pass to transform a where expression to its equivalent Let expression which is supported in the language.
This is a good compiler pass to write for anyone who wants to get familiar with Gibbon internals.
equivalent let expression.
The text was updated successfully, but these errors were encountered: