History

Some tiny updates

Most importantly: Case operators should not be inlined indiscriminately, because that might duplicate work (e.g. via a variable pattern for the scrutinee, where the variable is used more than once)

Edwin Brady committed 6 years ago

Commit b0d640f1 parent 25843793 files · +6 −4Browse files

Unified · Split

3 files
  1. src/Compiler/Scheme/Common.idr +4 −1
  2. src/TTImp/Elab/Case.idr +0 −1
  3. src/Text/Parser/Core.idr +2 −2
src/Compiler/Scheme/Common.idr+4−1
@@ -237,7 +237,10 @@ schConstant : (String -> String) -> Constant -> String · 236 unmodified lines
237schConstant _ (I x) = show x237schConstant _ (I x) = show x
238schConstant _ (BI x) = show x238schConstant _ (BI x) = show x
239schConstant schString (Str x) = schString x239schConstant schString (Str x) = schString x
240schConstant _ (Ch x) = "#\\" ++ cast x240schConstant _ (Ch x)
241 = if (the Int (cast x) >= 32 && the Int (cast x) < 127)
242 then "#\\" ++ cast x
243 else "(integer->char " ++ show (the Int (cast x)) ++ ")"
241schConstant _ (Db x) = show x244schConstant _ (Db x) = show x
242schConstant _ WorldVal = "#f"245schConstant _ WorldVal = "#f"
243schConstant _ IntType = "#t"246schConstant _ IntType = "#t"
src/TTImp/Elab/Case.idr+0−1
@@ -202,7 +202,6 @@ caseBlock {vars} rigc elabinfo fc nest env scr scrtm scrty caseRig alts expected · 201 unmodified lines
202 = maybe (App fc applyEnv scrtm)202 = maybe (App fc applyEnv scrtm)
203 (const applyEnv)203 (const applyEnv)
204 splitOn204 splitOn
205 setFlag fc casen Inline
206 205
207 let alts' = map (updateClause casen splitOn nest env) alts206 let alts' = map (updateClause casen splitOn nest env) alts
208 log 2 $ "Generated alts: " ++ show alts'207 log 2 $ "Generated alts: " ++ show alts'
src/Text/Parser/Core.idr+2−2
@@ -31,7 +31,7 @@ data Grammar : (tok : Type) -> (consumes : Bool) -> Type -> Type where · 30 unmodified lines
31 Grammar tok c1 a -> (a -> Grammar tok c2 b) ->31 Grammar tok c1 a -> (a -> Grammar tok c2 b) ->
32 Grammar tok (c1 || c2) b32 Grammar tok (c1 || c2) b
33 Alt : {c1, c2 : Bool} ->33 Alt : {c1, c2 : Bool} ->
34 Grammar tok c1 ty -> Grammar tok c2 ty ->34 Grammar tok c1 ty -> Lazy (Grammar tok c2 ty) ->
35 Grammar tok (c1 && c2) ty35 Grammar tok (c1 && c2) ty
36 36
37||| Sequence two grammars. If either consumes some input, the sequence is37||| Sequence two grammars. If either consumes some input, the sequence is
@@ -69,7 +69,7 @@ join {c1 = True} p = SeqEat p id · 31 unmodified lines
69export69export
70(<|>) : {c1,c2 : Bool} -> 70(<|>) : {c1,c2 : Bool} ->
71 Grammar tok c1 ty ->71 Grammar tok c1 ty ->
72 Grammar tok c2 ty ->72 Lazy (Grammar tok c2 ty) ->
73 Grammar tok (c1 && c2) ty73 Grammar tok (c1 && c2) ty
74(<|>) = Alt74(<|>) = Alt
75 75

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t