Skip to content

Commit

Permalink
ref for export
Browse files Browse the repository at this point in the history
  • Loading branch information
vmchale committed Feb 19, 2025
1 parent d43cc7b commit 1fef7b9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
51 changes: 2 additions & 49 deletions repl/REPL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/C/Trans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (\-> AElem xR (KI xRnk) lX (Tmp kϵ) dSz)
(lY0, ss0) <- writeF f [ra x0] (IT y0)
(lY, ss) <- writeF f [ra x] (IT y)
Expand Down
49 changes: 49 additions & 0 deletions src/P.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module P ( Err (..), FErr (..)
, opt
, ir
, cmm
, refcard
, padstr
, eDumpC
, eDumpIR
, aarch64
Expand Down Expand Up @@ -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 ' '

0 comments on commit 1fef7b9

Please sign in to comment.