File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -365,7 +365,28 @@ instance ToExpr HSE.Exp where
365
365
toExpr (HSE. Case _ expr matches) =
366
366
AST. ECaseBlock $
367
367
AST. CaseBlock Nothing (toExpr expr) (map altToClause matches)
368
- toExpr expr@ HSE. Do {} = unsupportedExpr expr
368
+ toExpr (HSE. Do _ stmts) =
369
+ AST. EFunctionApplication $
370
+ AST. FunctionApplication
371
+ Nothing
372
+ (AST. EIdentifier Nothing " do'" )
373
+ (map handleStmt stmts)
374
+ where
375
+ handleStmt (HSE. Generator _ pat expr) =
376
+ AST. EFunctionApplication $
377
+ AST. FunctionApplication
378
+ Nothing
379
+ (AST. EIdentifier Nothing " <-" )
380
+ [toExpr pat, toExpr expr]
381
+ handleStmt (HSE. Qualifier _ expr) = toExpr expr
382
+ handleStmt (HSE. LetStmt _ binds) =
383
+ AST. EFunctionApplication $
384
+ AST. FunctionApplication
385
+ Nothing
386
+ (AST. EIdentifier Nothing " let" )
387
+ (map handleClause $ bindsToClauses binds)
388
+ handleClause (var, val) =
389
+ AST. EFunctionApplication $ AST. FunctionApplication Nothing var [val]
369
390
toExpr expr@ HSE. MDo {} = unsupportedExpr expr
370
391
toExpr (HSE. Tuple _ _ exps) =
371
392
AST. EFunctionApplication $
You can’t perform that action at this time.
0 commit comments