diff --git a/repl/REPL.hs b/repl/REPL.hs index 32a9a0a96..6e5772f5c 100644 --- a/repl/REPL.hs +++ b/repl/REPL.hs @@ -71,7 +71,7 @@ loop = do Just [] -> loop Just (":h":_) -> showHelp *> loop Just (":help":_) -> showHelp *> loop - Just ("\\l":_) -> refcard *> loop + Just ("\\l":_) -> liftIO (putStr refcard) *> loop Just (":ty":e) -> tyExprR (unwords e) *> loop Just [":q"] -> pure () Just [":quit"] -> pure () @@ -123,56 +123,9 @@ showHelp = liftIO $ putStr $ concat -- TODO: dump debug state ] -refcard :: Repl AlexPosn () -refcard = liftIO $ putStr $ concat - [ lOption "Λ" "scan" "√" "sqrt" - , lOption "⋉" "max" "⋊" "min" - , lOption "⍳" "iota" "⌊, ⌈" "floor, ceiling" - , lOption "e:" "exp" "⨳ {m,n}" "convolve" - , lOption "\\~" "successive application" "\\`n" "infix" - , lOption "_." "log" "'" "map" - , lOption "`" "zip" "`{i,j∘[k,l]}" "rank" - , lOption "𝒻" "range (real)" "𝜋" "pi" - , lOption "_" "negate" ":" "size" - , lOption "𝓉" "dimension" "{x⟜y;z}" "no inline" - , lOption "->n" "select" "**" "power" - , lOption "⊂" "scatter" "}." "last" - , lOption "⊲" "cons" "⊳" "snoc" - , lOption "^:" "iterate" "%." "matmul" - , lOption "⊗" "outer product" "⍉, |:" "transpose" - , lOption "{." "head" "}:" "typesafe init" - , lOption "⟨z,w⟩" "array literal" "?p,.e1,.e2" "conditional" - , lOption "/*" "fold all" "ℝ" "i->f conversion" - , lOption "⧺" "cat" "{:" "typesafe tail" - , lOption "⊖" "rotate" "sin." "sine" - , lOption "𝔯" "rand" ".." "(integer) range" - , lOption "/ₒ" "fold with seed" "Λₒ" "scan with seed" - , lOption "{x←y;z}" "let...in" "⊙" "cycle" - , lOption "˙" "at" "|" "rem" - , lOption "@." "index of" "/." "idiv" - , lOption "%:" "vector mul" "odd." "parity" - , lOption "⍋" "sort" "𝓕" "course-of-value recursion" - , lOption "~" "reverse" "¬,⊻,∧,∨" "logical" - , lOption "♭" "flatten" "♯" "add dimension" - , lOption "⩪" "indices of" "§, #." "filter" - , lOption "ug." "unfold" "(i × j)" "dimensions" - , lOption "gen." "generate" "}:?" "init" - , lOption "{:?" "tail" "∴" "compose" - , lOption "𝔸" "digit literal" "ᶥ" "vector indices" - , lOption "〃" "ditto" "𝐒,𝐊" "combinators" - , lOption "⑂" "fork" "𝞈,𝟘,𝟙,𝟚" "fancy types" - , lOption "℘" "partition" "" "" - ] - -lOption op0 desc0 op1 desc1 = - rightPad 14 op0 ++ rightPad 25 desc0 ++ rightPad 14 op1 ++ desc1 ++ "\n" - -rightPad :: Int -> String -> String -rightPad n str = take n $ str ++ repeat ' ' - helpOption :: String -> String -> String -> String helpOption cmd args desc = - rightPad 15 cmd ++ rightPad 14 args ++ desc ++ "\n" + padstr 15 cmd ++ padstr 14 args ++ desc ++ "\n" ubs :: String -> BSL.ByteString ubs = encodeUtf8 . TL.pack diff --git a/src/C/Trans.hs b/src/C/Trans.hs index 8270ca676..36ec39ac1 100644 --- a/src/C/Trans.hs +++ b/src/C/Trans.hs @@ -746,7 +746,7 @@ aeval (EApp _ f@(EApp _ (Builtin _ Map) op) e) t a | tX@(Arr sh _) <- eAnn e, (A contents <- rfill f (AD t (Just a) (Just tX) Nothing Nothing (Just$Tmp nR)) [AI (AD xR l (Just tX) Nothing Nothing Nothing)] pure (plE$nR=:ev tX (xR,l):vSz sh t a (Tmp nR) sz++contents) aeval (EApp (Arr oSh _) (EApp _ (Builtin _ Map) f) xs) t a - | (Arrow tD tC) <- eAnn f + | Arrow tD tC <- eAnn f , Arr xSh _ <- eAnn xs , Just xRnk <- staRnk xSh , Just (ta, rnk) <- tRnk tD @@ -774,7 +774,7 @@ aeval (EApp (Arr oSh _) (EApp _ (Builtin _ Map) f) xs) t a y <- nI; y0 <- nI; szX <- nI; szY <- nI td <- nI (plX, (lX, xR)) <- plA xs - (x0, wX0) <- arg tD (\_ -> AElem xR (KI xRnk) lX 0 dSz) + (x0, wX0) <- arg tD (const $ AElem xR (KI xRnk) lX 0 dSz) (x, wX) <- arg tD (\kϵ -> AElem xR (KI xRnk) lX (Tmp kϵ) dSz) (lY0, ss0) <- writeF f [ra x0] (IT y0) (lY, ss) <- writeF f [ra x] (IT y) diff --git a/src/P.hs b/src/P.hs index 106c28e13..291433804 100644 --- a/src/P.hs +++ b/src/P.hs @@ -15,6 +15,8 @@ module P ( Err (..), FErr (..) , opt , ir , cmm + , refcard + , padstr , eDumpC , eDumpIR , aarch64 @@ -235,3 +237,50 @@ tc fp = do tyParse :: BSL.ByteString -> Either (Err AlexPosn) (E (T ()), Int) tyParse = tyParseCtx alexInitUserState + +refcard :: String +refcard = concat + [ lOption "Λ" "scan" "√" "sqrt" + , lOption "⋉" "max" "⋊" "min" + , lOption "⍳" "iota" "⌊, ⌈" "floor, ceiling" + , lOption "e:" "exp" "⨳ {m,n}" "convolve" + , lOption "\\~" "successive application" "\\`n" "infix" + , lOption "_." "log" "'" "map" + , lOption "`" "zip" "`{i,j∘[k,l]}" "rank" + , lOption "𝒻" "range (real)" "𝜋" "pi" + , lOption "_" "negate" ":" "size" + , lOption "𝓉" "dimension" "{x⟜y;z}" "no inline" + , lOption "->n" "select" "**" "power" + , lOption "⊂" "scatter" "}." "last" + , lOption "⊲" "cons" "⊳" "snoc" + , lOption "^:" "iterate" "%." "matmul" + , lOption "⊗" "outer product" "⍉, |:" "transpose" + , lOption "{." "head" "}:" "typesafe init" + , lOption "⟨z,w⟩" "array literal" "?p,.e1,.e2" "conditional" + , lOption "/*" "fold all" "ℝ" "i->f conversion" + , lOption "⧺" "cat" "{:" "typesafe tail" + , lOption "⊖" "rotate" "sin." "sine" + , lOption "𝔯" "rand" ".." "(integer) range" + , lOption "/ₒ" "fold with seed" "Λₒ" "scan with seed" + , lOption "{x←y;z}" "let...in" "⊙" "cycle" + , lOption "˙" "at" "|" "rem" + , lOption "@." "index of" "/." "idiv" + , lOption "%:" "vector mul" "odd." "parity" + , lOption "⍋" "sort" "𝓕" "course-of-value recursion" + , lOption "~" "reverse" "¬,⊻,∧,∨" "logical" + , lOption "♭" "flatten" "♯" "add dimension" + , lOption "⩪" "indices of" "§, #." "filter" + , lOption "ug." "unfold" "(i × j)" "dimensions" + , lOption "gen." "generate" "}:?" "init" + , lOption "{:?" "tail" "∴" "compose" + , lOption "𝔸" "digit literal" "ᶥ" "vector indices" + , lOption "〃" "ditto" "𝐒,𝐊" "combinators" + , lOption "⑂" "fork" "𝞈,𝟘,𝟙,𝟚" "fancy types" + , lOption "℘" "partition" "" "" + ] + where + lOption op0 desc0 op1 desc1 = + padstr 14 op0 ++ padstr 25 desc0 ++ padstr 14 op1 ++ desc1 ++ "\n" + +padstr :: Int -> String -> String +padstr n str = take n $ str ++ repeat ' '