phino 0.0.169 → 0.0.170
raw patch · 14 files changed
+277/−110 lines, 14 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ CLI.Types: [_dropTests] :: OptsSodg -> Bool
+ Forks: Fabric :: Function -> Attribute -> Attribute -> Attribute -> Fabric
+ Forks: [_fallback] :: Fabric -> Function
+ Forks: [_leftward] :: Fabric -> Attribute
+ Forks: [_rightward] :: Fabric -> Attribute
+ Forks: [_weighing] :: Fabric -> Attribute
+ Forks: data Fabric
+ Forks: fabric :: Function -> Fabric
+ Forks: instance GHC.Classes.Eq Forks.Fabric
+ Forks: instance GHC.Show.Show Forks.Fabric
+ Sodg: untested :: Expression -> Expression
- CLI.Types: OptsSodg :: LogLevel -> Int -> IOFormat -> Maybe FilePath -> OptsSodg
+ CLI.Types: OptsSodg :: LogLevel -> Int -> IOFormat -> Bool -> Maybe FilePath -> OptsSodg
- Forks: forked :: Function -> Either Int Bytes -> (Expression, Expression) -> (Expression, Expression) -> Either Refusal Expression
+ Forks: forked :: Fabric -> Either Int Bytes -> (Expression, Expression) -> (Expression, Expression) -> Either Refusal Expression
- Lambdas: Joining :: Either Meta Expression -> Expression -> Expression -> Maybe Function -> Ending
+ Lambdas: Joining :: Either Meta Expression -> Expression -> Expression -> Maybe Fabric -> Ending
Files
- README.md +89/−82
- phino.cabal +1/−1
- src/CLI/Parsers.hs +1/−0
- src/CLI/Runners.hs +2/−2
- src/CLI/Types.hs +1/−0
- src/Evaluate.hs +3/−3
- src/Forks.hs +23/−13
- src/Lambdas.hs +27/−5
- src/Sodg.hs +20/−0
- test-resources/evaluate-packs/fires-again-a-fabricated-formation-whose-parts-the-otherwise-names.yaml +60/−0
- test/CLISpec.hs +12/−0
- test/ForksSpec.hs +7/−2
- test/LambdasSpec.hs +22/−2
- test/SodgSpec.hs +9/−0
README.md view
@@ -34,7 +34,7 @@ ```bash cabal update-cabal install --overwrite-policy=always phino-0.0.168+cabal install --overwrite-policy=always phino-0.0.169 phino --version ``` @@ -59,7 +59,7 @@ for the runner and puts it on the `PATH`: ```yaml-- uses: objectionary/phino@0.0.168+- uses: objectionary/phino@0.0.169 with: version-file: phino-version.txt - run: phino --version@@ -173,6 +173,10 @@ meta. It may hold `otherwise`, a λ name that joins two formations of different shapes one attribute at a time, and the file must answer that name too.+ It may be a mapping instead, holding that name under `λ` and the names of+ the condition and the two sides in the formation it makes under `on`,+ `left` and `right`, such as `c🌵`; each ends with `🌵`, and a missing one+ is `on🌵`, `left🌵` or `right🌵`. * `terminators` lists λ names that only raise, as in `[L_throw]`. A term holding one of them, or an application of one, passes every line as it is, and `join` takes it for a side that raises, as it takes `⊥`.@@ -536,6 +540,9 @@ P c0 x c1 ``` +With `--drop-tests`, it skips the unit tests of every object, the attributes+named `p🌵…` and `n🌵…`, with all the cells they hold.+ ## Compile By default, `phino` reads its rules from YAML and interprets them at every@@ -749,119 +756,119 @@ === parse/phi === warmup: 3 iterations batches: 10 x 1- total: 2413980.968 μs- avg: 241398.097 μs- min: 215225.227 μs- max: 284695.902 μs- std dev: 25724.434 μs+ total: 1817079.413 μs+ avg: 181707.941 μs+ min: 164807.231 μs+ max: 205518.423 μs+ std dev: 17870.767 μs === parse/xmir === warmup: 3 iterations batches: 10 x 1- total: 10044170.261 μs- avg: 1004417.026 μs- min: 928746.607 μs- max: 1079348.074 μs- std dev: 50756.236 μs+ total: 7860141.670 μs+ avg: 786014.167 μs+ min: 739622.130 μs+ max: 892586.550 μs+ std dev: 51459.020 μs === rewrite/normalize === warmup: 3 iterations batches: 10 x 1- total: 20.328 μs- avg: 2.033 μs- min: 1.723 μs- max: 2.685 μs- std dev: 0.289 μs+ total: 11.371 μs+ avg: 1.137 μs+ min: 1.053 μs+ max: 1.537 μs+ std dev: 0.136 μs === print/sweet/multiline === warmup: 3 iterations batches: 10 x 1- total: 1911999.027 μs- avg: 191199.903 μs- min: 185908.584 μs- max: 202990.068 μs- std dev: 4905.518 μs+ total: 1476341.035 μs+ avg: 147634.104 μs+ min: 143163.468 μs+ max: 159257.458 μs+ std dev: 4796.363 μs === print/sweet/flat === warmup: 3 iterations batches: 10 x 1- total: 1145909.419 μs- avg: 114590.942 μs- min: 92613.667 μs- max: 139357.482 μs- std dev: 15308.656 μs+ total: 780800.712 μs+ avg: 78080.071 μs+ min: 65787.616 μs+ max: 96222.881 μs+ std dev: 9333.636 μs === print/salty/multiline === warmup: 3 iterations batches: 10 x 1- total: 7468225.700 μs- avg: 746822.570 μs- min: 735697.009 μs- max: 774034.524 μs- std dev: 10278.722 μs+ total: 5808590.269 μs+ avg: 580859.027 μs+ min: 546062.759 μs+ max: 625821.280 μs+ std dev: 24899.656 μs === morph/symbolic/demo/e1 === warmup: 3 iterations- batches: 10 x 9- total: 13798.063 μs- avg: 153.312 μs- min: 149.894 μs- max: 163.169 μs- std dev: 3.598 μs+ batches: 10 x 13+ total: 15407.077 μs+ avg: 118.516 μs+ min: 110.364 μs+ max: 124.315 μs+ std dev: 4.525 μs === morph/symbolic/demo/e2 === warmup: 3 iterations- batches: 10 x 116- total: 177830.095 μs- avg: 153.302 μs- min: 152.510 μs- max: 155.166 μs- std dev: 0.755 μs+ batches: 10 x 148+ total: 196118.294 μs+ avg: 132.512 μs+ min: 110.295 μs+ max: 187.052 μs+ std dev: 21.211 μs === morph/symbolic/demo/e3 === warmup: 3 iterations- batches: 10 x 109- total: 172419.898 μs- avg: 158.183 μs- min: 156.401 μs- max: 160.218 μs- std dev: 1.203 μs+ batches: 10 x 148+ total: 171831.495 μs+ avg: 116.102 μs+ min: 111.857 μs+ max: 122.684 μs+ std dev: 3.360 μs === morph/symbolic/demo/e4 === warmup: 3 iterations- batches: 10 x 114- total: 179087.429 μs- avg: 157.094 μs- min: 155.294 μs- max: 159.724 μs- std dev: 1.170 μs+ batches: 10 x 151+ total: 176286.007 μs+ avg: 116.746 μs+ min: 110.924 μs+ max: 121.950 μs+ std dev: 3.950 μs === morph/symbolic/demo/e5 === warmup: 3 iterations- batches: 10 x 96- total: 169758.902 μs- avg: 176.832 μs- min: 175.759 μs- max: 177.918 μs- std dev: 0.603 μs+ batches: 10 x 116+ total: 166326.077 μs+ avg: 143.385 μs+ min: 124.257 μs+ max: 170.471 μs+ std dev: 14.090 μs === morph/symbolic/native/e5 === warmup: 3 iterations- batches: 10 x 5- total: 54422.069 μs- avg: 1088.441 μs- min: 1031.613 μs- max: 1174.642 μs- std dev: 53.929 μs+ batches: 10 x 1+ total: 126809.762 μs+ avg: 12680.976 μs+ min: 12033.615 μs+ max: 13380.528 μs+ std dev: 385.658 μs === morph/symbolic/accum/0 === warmup: 3 iterations- batches: 10 x 68- total: 87262.677 μs- avg: 128.327 μs- min: 126.014 μs- max: 130.276 μs- std dev: 1.292 μs+ batches: 10 x 78+ total: 75701.566 μs+ avg: 97.053 μs+ min: 93.905 μs+ max: 106.537 μs+ std dev: 3.774 μs === morph/symbolic/accum/400 === warmup: 3 iterations- batches: 10 x 48- total: 70884.786 μs- avg: 147.677 μs- min: 144.986 μs- max: 152.842 μs- std dev: 1.934 μs+ batches: 10 x 63+ total: 68593.670 μs+ avg: 108.879 μs+ min: 106.440 μs+ max: 115.421 μs+ std dev: 2.429 μs ``` The results were calculated in [this GHA job][benchmark-gha]-on 2026-11-19 at 15:32,+on 2026-11-25 at 12:54, on Linux with 4 CPUs. <!-- benchmark_end -->@@ -904,4 +911,4 @@ [jna]: https://github.com/java-native-access/jna [jna-native]: https://github.com/java-native-access/jna/blob/master/src/com/sun/jna/Native.java [jeo]: https://github.com/objectionary/jeo-maven-plugin-[benchmark-gha]: https://github.com/objectionary/phino/actions/runs/44555174198+[benchmark-gha]: https://github.com/objectionary/phino/actions/runs/45615140704
phino.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: phino-version: 0.0.169+version: 0.0.170 license: MIT synopsis: Command-Line Manipulator of 𝜑-Calculus Expressions description: Please see the README on GitHub at <https://github.com/objectionary/phino#readme>
src/CLI/Parsers.hs view
@@ -654,6 +654,7 @@ <$> optLogLevel <*> optLogLines <*> optInputFormat+ <*> switch (long "drop-tests" <> help "Drop the unit tests of every object, the attributes named p🌵…, n🌵…, +… or -…, with all they hold") <*> argInputFile )
src/CLI/Runners.hs view
@@ -44,7 +44,7 @@ import Rule (RuleContext (..), matchExpressionWithRule) import Sides (sides) import Slots (anonymous)-import Sodg (printCommands, sodg)+import Sodg (printCommands, sodg, untested) import System.Directory (canonicalizePath, doesFileExist, getModificationTime) import System.Exit (exitSuccess) import System.FilePath (takeDirectory, (</>))@@ -444,7 +444,7 @@ runSodg OptsSodg{..} = do input <- readInput _inputFile expr <- parseInput input _inputFormat POLYFORM- graph <- sodg expr+ graph <- sodg (if _dropTests then untested expr else expr) putStr (printCommands graph) runCompile :: OptsCompile -> IO ()
src/CLI/Types.hs view
@@ -284,6 +284,7 @@ { _logLevel :: LogLevel , _logLines :: Int , _inputFormat :: IOFormat+ , _dropTests :: Bool , _inputFile :: Maybe FilePath }
src/Evaluate.hs view
@@ -23,7 +23,7 @@ import qualified Data.Text as T import Deps (Evaluation (..), Judgment (Evaluation, Morphing), State (..), dontSaveEval, dontSaveStep, resited) import Engine (Engine (..))-import Forks (Refusal (Unnamed, Unripe), Side (Lefthand, Righthand), bared, forked, joined)+import Forks (Fabric, Refusal (Unnamed, Unripe), Side (Lefthand, Righthand), bared, forked, joined) import Lambdas (Ending (..), Lambda (..), Line (..), Meta (..), cast, emptyLambdas, matched, minted, rewritten, stayed, symbolized, thrown) import Matcher (MetaValue (..), Subst, combine, substEmpty, substSingle, substSlot) import Morph (Answer (..), Budget (..), Firing (..), Kept (..), Kindred, ReduceContext (..), ReduceException (..), Steps (..), adopted, argued, awaited, called, charged, coined, counted, deeper, ended, expired, fired, isLambda, kindle, kindred, lambda, minting, morphing, normalized, noted, opening, placed, recalled, remember, remembered, remembering, repeats, retained, settled, starved, unparked, voided)@@ -408,7 +408,7 @@ (normal, state'') <- settled built univ state' =<< opening Morphing ctx{_saveEval = ctx._saveEval . resited ctx._site built} ctx._saveEval (EvAnswer ctx._nesting normal) pure (Answer built normal, state'')- merged :: ReduceContext -> [T.Text] -> Subst -> [(T.Text, Either Int Bytes)] -> Either Meta Expression -> Expression -> Expression -> Maybe Function -> State -> IO (Answer, State)+ merged :: ReduceContext -> [T.Text] -> Subst -> [(T.Text, Either Int Bytes)] -> Either Meta Expression -> Expression -> Expression -> Maybe Fabric -> State -> IO (Answer, State) merged ctx terminators bound operands on left right fallback state' = do condition <- weighed operands on (one, state'') <- reached ctx bound left state'@@ -432,7 +432,7 @@ Left path -> do leftName <- Sides.named ctx._sides one rightName <- Sides.named ctx._sides two- case maybe (Left Unnamed) (\name -> forked name condition (leftName, one) (rightName, two)) fallback of+ case maybe (Left Unnamed) (\names -> forked names condition (leftName, one) (rightName, two)) fallback of Right term -> do ctx._saveEval (EvFabricated ctx._nesting (left, one) (right, two) [(leftName, one), (rightName, two)] term) pure (Joined term, state''')
src/Forks.hs view
@@ -4,7 +4,7 @@ -- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com -- SPDX-License-Identifier: MIT -module Forks (Refusal (..), Side (..), bared, forked, joined) where+module Forks (Fabric (..), Refusal (..), Side (..), bared, fabric, forked, joined) where import AST (Argument (..), Attribute (AtDelta, AtLabel, AtLambda, AtRho), Binding (..), Bytes, Expression (ExApplication, ExDispatch, ExFormation, ExPhiAgain, ExPhiMeet, ExTermination, ExXi), Function (FnSymbol), attributeFromBinding, symbols) import Control.Monad.Trans.State.Strict (State, runState, state)@@ -15,11 +15,18 @@ import Data.Maybe (fromMaybe, listToMaybe, mapMaybe) import Data.Set (Set) import qualified Data.Set as Set-import Data.Text (Text) import qualified Data.Text as T type Joining = (Int, Maybe Int, Map (Int, Int) Int, [(Int, (Int, Int))]) +data Fabric = Fabric+ { _fallback :: Function+ , _weighing :: Attribute+ , _leftward :: Attribute+ , _rightward :: Attribute+ }+ deriving (Eq, Show)+ data Side = Lefthand | Righthand deriving (Eq, Show) @@ -117,8 +124,11 @@ taken ExTermination = False taken side = not (bare side) -forked :: Function -> Either Int Bytes -> (Expression, Expression) -> (Expression, Expression) -> Either Refusal Expression-forked func condition (leftName, left) (rightName, right) = do+fabric :: Function -> Fabric+fabric func = Fabric func (AtLabel "on🌵") (AtLabel "left🌵") (AtLabel "right🌵")++forked :: Fabric -> Either Int Bytes -> (Expression, Expression) -> (Expression, Expression) -> Either Refusal Expression+forked (Fabric func onward lefty righty) condition (leftName, left) (rightName, right) = do one <- inlined <$> formed Lefthand left two <- inlined <$> formed Righthand right maybe (Right (fabricated one two)) Left (listToMaybe (unripe Lefthand one two ++ unripe Righthand two one))@@ -127,7 +137,7 @@ formed side (ExFormation bds) = maybe (Right bds) (Left . Holding side) (listToMaybe [attr | Just attr <- map attributeFromBinding bds, attr == AtDelta || attr == AtLambda]) formed side _ = Left (Unformed side) fabricated :: [Binding] -> [Binding] -> Expression- fabricated one two = ExFormation (map BiVoid voids ++ [copy "left🌵" leftName one, copy "right🌵" rightName two] ++ map branch (filter (`Set.notMember` vacated) (distinct (attributes one ++ attributes two))))+ fabricated one two = ExFormation (map BiVoid voids ++ [copy lefty leftName one, copy righty rightName two] ++ map branch (filter (`Set.notMember` vacated) (distinct (attributes one ++ attributes two)))) where voids :: [Attribute] voids = distinct (vacant one ++ vacant two)@@ -138,17 +148,17 @@ heldTwo :: Map Attribute [Attribute] heldTwo = held two branch :: Attribute -> Binding- branch attr = BiTau attr (ExFormation ([BiVoid AtRho, BiLambda func] ++ map BiVoid (inner attr) ++ [weighing, ask "left🌵" leftward heldOne attr, ask "right🌵" rightward heldTwo attr]))+ branch attr = BiTau attr (ExFormation ([BiVoid AtRho, BiLambda func] ++ map BiVoid (inner attr) ++ [weighing, ask lefty leftward heldOne attr, ask righty rightward heldTwo attr])) weighing :: Binding- weighing = BiTau (AtLabel "on🌵") (ExFormation [either (BiLambda . FnSymbol) BiDelta condition])+ weighing = BiTau onward (ExFormation [either (BiLambda . FnSymbol) BiDelta condition]) leftward :: Expression- leftward = ExDispatch (ExDispatch ExXi AtRho) (AtLabel "left🌵")+ leftward = ExDispatch (ExDispatch ExXi AtRho) lefty rightward :: Expression- rightward = ExDispatch (ExDispatch ExXi AtRho) (AtLabel "right🌵")+ rightward = ExDispatch (ExDispatch ExXi AtRho) righty inner :: Attribute -> [Attribute] inner attr = nub (concat (mapMaybe (Map.lookup attr) [heldOne, heldTwo]))- ask :: Text -> Expression -> Map Attribute [Attribute] -> Attribute -> Binding- ask name side holding attr = BiTau (AtLabel name) (applied (ExDispatch side attr) (fromMaybe (inner attr) (Map.lookup attr holding)))+ ask :: Attribute -> Expression -> Map Attribute [Attribute] -> Attribute -> Binding+ ask name side holding attr = BiTau name (applied (ExDispatch side attr) (fromMaybe (inner attr) (Map.lookup attr holding))) inlined :: [Binding] -> [Binding] inlined bds = map goBinding bds where@@ -174,8 +184,8 @@ own :: Attribute -> Bool own (AtLabel label) = not ("🌵" `T.isSuffixOf` label) own attr = attr `notElem` [AtRho, AtLambda, AtDelta]- copy :: Text -> Expression -> [Binding] -> Binding- copy name side bds = BiTau (AtLabel name) (applied side (vacant bds))+ copy :: Attribute -> Expression -> [Binding] -> Binding+ copy name side bds = BiTau name (applied side (vacant bds)) applied :: Expression -> [Attribute] -> Expression applied = foldl (\term attr -> ExApplication term (ArTau attr (ExDispatch ExXi attr))) held :: [Binding] -> Map Attribute [Attribute]
src/Lambdas.hs view
@@ -32,13 +32,13 @@ import Control.Exception (Exception, throwIO) import Control.Monad ((<$!>)) import Control.Monad.Trans.State.Strict (State, runState, state)-import Data.Aeson (FromJSON (parseJSON), Key, Object, withObject, (.!=), (.:?))+import Data.Aeson (FromJSON (parseJSON), Key, Object, Value (Object, String), withObject, (.!=), (.:?)) import qualified Data.Aeson.Key as Key import qualified Data.Aeson.KeyMap as KeyMap import Data.Aeson.Types (JSONPathElement (Key), (<?>)) import Data.Char (isDigit) import Data.Either (partitionEithers)-import Data.List (find, sortOn)+import Data.List (find, nub, sortOn) import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe (fromMaybe, listToMaybe)@@ -46,6 +46,7 @@ import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) import qualified Data.Yaml as Yaml+import Forks (Fabric (Fabric), fabric) import Language (Language, language, shared) import Logger (logDebug) import Matcher (substEmpty)@@ -77,7 +78,7 @@ data Ending = Answering Expression- | Joining (Either Meta Expression) Expression Expression (Maybe Function)+ | Joining (Either Meta Expression) Expression Expression (Maybe Fabric) data Lambda = Lambda { _key :: Text@@ -159,8 +160,29 @@ side name term = case metas term of [] -> pure term meta : _ -> fail (printf "The side '%s' of the 'join' block of λ function '%s' reads the meta '%s' inside a term, while a side is a path from '$' or a meta alone" name key (T.unpack meta))- fallback :: Text -> Yaml.Parser Function- fallback spelling = case parseBinding (printf "λ ⤍ %s" (T.unpack spelling)) of+ fallback :: Value -> Yaml.Parser Fabric+ fallback (String spelling) = fabric <$> function spelling+ fallback (Object names) = do+ case filter (`notElem` ["λ", "on", "left", "right"]) (map Key.toText (KeyMap.keys names)) of+ [] -> pure ()+ name : _ -> fail (printf "The key '%s' of the 'otherwise' of the 'join' block of λ function '%s' is none of its keys: λ, on, left, right" (T.unpack name) key)+ func <- names .:? "λ" >>= maybe (fail (printf "The 'otherwise' of the 'join' block of λ function '%s' has no 'λ' key" key)) function+ onward <- label "on" "on🌵"+ lefty <- label "left" "left🌵"+ righty <- label "right" "right🌵"+ if length (nub [onward, lefty, righty]) < 3+ then fail (printf "The 'otherwise' of the 'join' block of λ function '%s' gives one name to two of 'on', 'left' and 'right', while each of them names an attribute of its own" key)+ else pure (Fabric func onward lefty righty)+ where+ label :: Key -> Text -> Yaml.Parser Attribute+ label name spelling = names .:? name >>= maybe (pure (AtLabel spelling)) (attribute name)+ attribute :: Key -> Text -> Yaml.Parser Attribute+ attribute name spelling = case parseExpression (printf "ξ.%s" (T.unpack spelling)) of+ Right (ExDispatch ExXi attr@(AtLabel text)) | "🌵" `T.isSuffixOf` text -> pure attr+ _ -> fail (printf "The '%s' of the 'otherwise' of the 'join' block of λ function '%s' is '%s', while it must name an attribute ending with '🌵', such as 'on🌵'" (Key.toString name) key (T.unpack spelling))+ fallback _ = fail (printf "The 'otherwise' of the 'join' block of λ function '%s' is neither a λ name nor a mapping with the keys λ, on, left, right" key)+ function :: Text -> Yaml.Parser Function+ function spelling = case parseBinding (printf "λ ⤍ %s" (T.unpack spelling)) of Right (BiLambda func@(Function _)) -> pure func _ -> fail (printf "The 'otherwise' of the 'join' block of λ function '%s' is '%s', while it must name a λ function, such as 'L_join'" key (T.unpack spelling)) reductions :: Text -> (Text -> Yaml.Parser Meta) -> (Meta -> Meta -> Line) -> Object -> Key -> Yaml.Parser [Either (Meta, Expression) Line]
src/Sodg.hs view
@@ -12,6 +12,7 @@ , commands , sodg , printCommands+ , untested , vertex ) where@@ -109,6 +110,25 @@ Function name -> Right name FnSymbol idx -> Right ("𝜎" <> T.pack (show idx)) other -> patterned place (ExFormation [BiLambda other])++untested :: Expression -> Expression+untested = \case+ ExFormation bds -> ExFormation (map inner (filter kept bds))+ ExDispatch base attr -> ExDispatch (untested base) attr+ ExApplication proto (ArTau attr value) -> ExApplication (untested proto) (ArTau attr (untested value))+ other -> other+ where+ kept :: Binding -> Bool+ kept = \case+ BiTau (AtLabel label) _ -> not (test label)+ BiVoid (AtLabel label) -> not (test label)+ _ -> True+ test :: Text -> Bool+ test label = any (`T.isPrefixOf` label) ["p🌵", "n🌵", "+", "-"]+ inner :: Binding -> Binding+ inner = \case+ BiTau attr value -> BiTau attr (untested value)+ other -> other sodg :: Expression -> IO [Command] sodg = either throwIO pure . commands
+ test-resources/evaluate-packs/fires-again-a-fabricated-formation-whose-parts-the-otherwise-names.yaml view
@@ -0,0 +1,60 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+---+# yamllint disable rule:line-length+# The two sides of 'L_fork' differ in shape, so the firing fabricates a+# formation, naming its parts as the 'otherwise' of the block says: the+# condition under 'c🌵' and the sides under 'a🌵' and 'b🌵', the very names+# 'L_fork' reads (#2483). The program asks that formation for 'φ', a copy of+# 'L_fork' itself, and asks it for 'φ' too, which fires it again and finds there the condition and both+# sides, two copies of 'hx' that differ in a symbol alone, so its join mints+# a fresh symbol for them.+symbolic: |+ - λ: L_fork+ dataize:+ 𝛿1: $.c🌵+ join:+ on: 𝛿1+ left: $.a🌵+ right: $.b🌵+ otherwise:+ λ: L_fork+ on: c🌵+ left: a🌵+ right: b🌵+location: 'Q.y'+input: '⟦ hx(ke) ↦ ⟦ φ ↦ ke ⟧, y ↦ ⟦ c🌵 ↦ ⟦ λ ⤍ 𝜎1 ⟧, a🌵 ↦ ⟦ φ ↦ Φ.hx( ke ↦ ⟦ λ ⤍ 𝜎2 ⟧ ), ob ↦ Φ.hx ⟧, b🌵 ↦ ⟦ φ ↦ Φ.hx( ke ↦ ⟦ λ ⤍ 𝜎3 ⟧ ) ⟧, λ ⤍ L_fork ⟧.φ.φ ⟧'+result: '𝜎4:λ'+protocol: |+ 𝕄(Φ.y):+ 𝔼(L_fork):+ 𝔻(ξ.c🌵):+ 𝛿·1·1 ≔ 𝔻(𝜎1:λ)+ 𝛿1·1 ≔ 𝛿·1·1 # 𝔻(ξ.c🌵)+ 𝕄(ξ.a🌵):+ morphed 𝑛·1·1 ≔ ⟦ φ ↦ Φ.hx( ke ↦ 𝜎2:λ ), ob ↦ Φ.hx ⟧+ 𝕄(ξ.b🌵):+ morphed 𝑛·1·2 ≔ Φ.hx( ke ↦ 𝜎3:λ ):φ+ fabricated 𝑛·1·3 ≔ 𝑛·1·1 and 𝑛·1·2 # ⟦ a🌵 ↦ 𝑛·1·1, b🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_fork, c🌵 ↦ 𝜎1:λ, a🌵 ↦ ρ.a🌵.φ, b🌵 ↦ ρ.b🌵.φ ⟧, ob ↦ ⟦ λ ⤍ L_fork, c🌵 ↦ 𝜎1:λ, a🌵 ↦ ρ.a🌵.ob, b🌵 ↦ ρ.b🌵.ob ⟧ ⟧+ evaluated 𝑛·1·4 ≔ 𝑛·1·3 # ⟦ c🌵 ↦ 𝜎1:λ, a🌵 ↦ 𝑛·1·1, b🌵 ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 ≔ ⟦ λ ⤍ L_fork, c🌵 ↦ 𝜎1:λ, a🌵 ↦ ρ.a🌵.φ, b🌵 ↦ ρ.b🌵.φ ⟧ # 𝑛·1·4.φ+ 𝔼(L_fork):+ 𝔻(ξ.c🌵):+ 𝛿·2·1 ≔ 𝔻(𝜎1:λ)+ 𝛿1·2 ≔ 𝛿·2·1 # 𝔻(ξ.c🌵)+ 𝕄(ξ.a🌵):+ remembered 𝑛·2·1 ≡ Φ.hx # ⟦ ke ↦ ∅, φ ↦ ke ⟧+ 𝑛·2·2 ≔ Φ.hx( ke ↦ 𝜎2:λ )+ 𝑛·2·3 ≔ ⟦ ke ↦ 𝜎2:λ, φ ↦ ke ⟧+ remembered 𝑛·2·3 ≡ 𝑛·2·1( ke ↦ 𝜎2:λ )+ morphed 𝑛·2·4 ≔ 𝑛·2·3+ 𝕄(ξ.b🌵):+ 𝑛·2·5 ≔ Φ.hx( ke ↦ 𝜎3:λ )+ 𝑛·2·6 ≔ ⟦ ke ↦ 𝜎3:λ, φ ↦ ke ⟧+ remembered 𝑛·2·6 ≡ 𝑛·2·1( ke ↦ 𝜎3:λ )+ morphed 𝑛·2·7 ≔ 𝑛·2·6+ joined 𝜎4 ≔ 𝛿1·2 ? 𝜎2 : 𝜎3+ 𝑛·2·8 ≔ ⟦ ke ↦ 𝜎4:λ, φ ↦ ke ⟧+ evaluated 𝑛·2·9 ≔ 𝑛·2·8 # ⟦ λ ⤍ L_fork, c🌵 ↦ 𝜎1:λ, a🌵 ↦ ρ.a🌵.φ, b🌵 ↦ ρ.b🌵.φ ⟧+ normalized 𝑛·0·2 ≔ 𝜎4:λ # 𝑛·2·9.φ+ morphed 𝑛·0·3 ≔ 𝑛·0·2
test/CLISpec.hs view
@@ -4935,6 +4935,18 @@ withStdin "⟦ a ↦ ⊥ ⟧" $ testCLISucceeded ["sodg"] ["F c0 a\nT c1\nP c0 a c1\n"] + it "drops the tests with --drop-tests" $+ withStdin "⟦ a ↦ ⟦ x ↦ ∅, p🌵works ↦ ⟦ φ ↦ ξ.ρ.x ⟧, n🌵fails ↦ Φ.b ⟧ ⟧" $+ testCLISucceeded ["sodg", "--drop-tests"] ["F c0 a\nF c1 x\nP c0 a c1\n"]++ it "drops the tests of XMIR with --drop-tests" $+ withStdin "<object><o name=\"app\"><o name=\"x\" base=\"Φ.number\"/><o name=\"+works\"><o name=\"φ\" base=\"Φ.true\"/></o></o></object>" $+ testCLISucceeded ["sodg", "--input=xmir", "--drop-tests"] ["F c0 app\nF c1 x\nD c2 c0 number\nP c1 x c2\nP c0 app c1\n"]++ it "keeps the tests without --drop-tests" $+ withStdin "⟦ p🌵works ↦ Φ.b ⟧" $+ testCLISucceeded ["sodg"] ["F c0 p🌵works\nD c1 c0 b\nP c0 p🌵works c1\n"]+ it "rejects an option of other commands" $ withStdin "⟦⟧" $ testCLIFailed ["sodg", "--sweet"] ["Invalid option"]
test/ForksSpec.hs view
@@ -7,7 +7,7 @@ import AST import Data.Text (Text)-import Forks (Refusal (..), Side (..), forked, joined)+import Forks (Fabric (..), Refusal (..), Side (..), fabric, forked, joined) import Parser (parseExpressionThrows) import Test.Hspec (Spec, describe, it, shouldBe) @@ -89,7 +89,7 @@ describe "forked" $ do let fork :: Text -> Either Int Bytes -> String -> String -> IO (Either Refusal Expression)- fork func condition left right = forked (Function func) condition <$> fmap twice (parseExpressionThrows left) <*> fmap twice (parseExpressionThrows right)+ fork func condition left right = forked (fabric (Function func)) condition <$> fmap twice (parseExpressionThrows left) <*> fmap twice (parseExpressionThrows right) twice :: Expression -> (Expression, Expression) twice side = (side, side) it "asks the copies of both sides for an attribute the λ it is given picks between" $ do@@ -110,6 +110,11 @@ it "keeps one void for an attribute both sides leave void" $ do expected <- parseExpressionThrows "⟦ dk ↦ ∅, left🌵 ↦ ⟦ dk ↦ ∅, φ ↦ Φ.ic ⟧( dk ↦ ξ.dk ), right🌵 ↦ ⟦ φ ↦ Φ.yo, dk ↦ ∅ ⟧( dk ↦ ξ.dk ), φ ↦ ⟦ ρ ↦ ∅, λ ⤍ L_vb, on🌵 ↦ ⟦ Δ ⤍ 3E- ⟧, left🌵 ↦ ξ.ρ.left🌵.φ, right🌵 ↦ ξ.ρ.right🌵.φ ⟧ ⟧" fork "L_vb" (Right (BtOne "3E")) "⟦ dk ↦ ∅, φ ↦ Φ.ic ⟧" "⟦ φ ↦ Φ.yo, dk ↦ ∅ ⟧" >>= (`shouldBe` Right expected)+ it "names its parts by the names it is given" $ do+ expected <- parseExpressionThrows "⟦ ab🌵 ↦ ⟦ ke ↦ Φ.qo, ty ↦ Φ.wa ⟧, cd🌵 ↦ ⟦ ke ↦ Φ.ri ⟧, ke ↦ ⟦ ρ ↦ ∅, λ ⤍ L_xu, ef🌵 ↦ ⟦ λ ⤍ 𝜎5 ⟧, ab🌵 ↦ ξ.ρ.ab🌵.ke, cd🌵 ↦ ξ.ρ.cd🌵.ke ⟧, ty ↦ ⟦ ρ ↦ ∅, λ ⤍ L_xu, ef🌵 ↦ ⟦ λ ⤍ 𝜎5 ⟧, ab🌵 ↦ ξ.ρ.ab🌵.ty, cd🌵 ↦ ξ.ρ.cd🌵.ty ⟧ ⟧"+ left <- parseExpressionThrows "⟦ ke ↦ Φ.qo, ty ↦ Φ.wa ⟧"+ right <- parseExpressionThrows "⟦ ke ↦ Φ.ri ⟧"+ forked (Fabric (Function "L_xu") (AtLabel "ef🌵") (AtLabel "ab🌵") (AtLabel "cd🌵")) (Left 5) (left, left) (right, right) `shouldBe` Right expected it "tells that the left side leaves void an attribute the right side binds" $ fork "L_oh" (Right (BtOne "52")) "⟦ ws ↦ ∅ ⟧" "⟦ ws ↦ Φ.ug ⟧" >>= (`shouldBe` Left (Unripe Lefthand (AtLabel "ws"))) it "tells that the right side leaves void an attribute the left side binds" $
test/LambdasSpec.hs view
@@ -12,6 +12,7 @@ import Data.List (isInfixOf) import Data.Text qualified as T import Fixtures (withLambdasOf)+import Forks (Fabric (..), fabric) import Functions (buildTerm) import Lambdas (Ending (..), Lambda (..), Lambdas, Line (..), Meta (..), cast, emptyLambdas, matched, minted, readLambdas, rewritten, stayed, symbolized, taken, thrown) import Parser (parseExpressionThrows)@@ -99,7 +100,7 @@ Just (Joining _ left right _) -> Just (left, right) _ -> Nothing -fallback :: Lambdas -> T.Text -> Maybe Function+fallback :: Lambdas -> T.Text -> Maybe Fabric fallback known func = case _ending <$> matched known func of Just (Joining _ _ _ name) -> name _ -> Nothing@@ -244,8 +245,20 @@ it "reads the λ function the 'otherwise' of a 'join' block names" $ do known <- lambdasOf (joint <> " otherwise: L_join\n")- fallback known "L_fork" `shouldBe` Just (Function "L_join")+ fallback known "L_fork" `shouldBe` Just (fabric (Function "L_join")) + it "reads the names of the parts of a fabricated formation the 'otherwise' of a 'join' block gives" $ do+ known <- lambdasOf (joint <> " otherwise:\n λ: L_join\n on: c🌵\n left: a🌵\n right: b🌵\n")+ fallback known "L_fork" `shouldBe` Just (Fabric (Function "L_join") (AtLabel "c🌵") (AtLabel "a🌵") (AtLabel "b🌵"))++ it "keeps the default name of a part of a fabricated formation the 'otherwise' of a 'join' block does not give" $ do+ known <- lambdasOf (joint <> " otherwise:\n λ: L_join\n left: a🌵\n")+ fallback known "L_fork" `shouldBe` Just (Fabric (Function "L_join") (AtLabel "on🌵") (AtLabel "a🌵") (AtLabel "right🌵"))++ it "reads an 'otherwise' holding only a λ as one keeping every default name" $ do+ known <- lambdasOf (joint <> " otherwise:\n λ: L_join\n")+ fallback known "L_fork" `shouldBe` Just (fabric (Function "L_join"))+ it "reads a 'join' block with no 'otherwise' as one fabricating nothing" $ do known <- lambdasOf joint fallback known "L_fork" `shouldBe` Nothing@@ -493,6 +506,13 @@ , ("a 'join' block with a key it does not read", joint <> " middle: $.m\n", "The key 'middle' of the 'join' block of λ function 'L_fork' is none of its keys: on, left, right, otherwise") , ("a 'join' block whose 'otherwise' is no λ name", joint <> " otherwise: l_join\n", "The 'otherwise' of the 'join' block of λ function 'L_fork' is 'l_join', while it must name a λ function, such as 'L_join'") , ("a 'join' block whose 'otherwise' names a symbol", joint <> " otherwise: 𝜎3\n", "The 'otherwise' of the 'join' block of λ function 'L_fork' is '𝜎3', while it must name a λ function, such as 'L_join'")+ , ("an 'otherwise' naming a part by a name with no 🌵", joint <> " otherwise:\n λ: L_join\n on: c\n", "The 'on' of the 'otherwise' of the 'join' block of λ function 'L_fork' is 'c', while it must name an attribute ending with '🌵', such as 'on🌵'")+ , ("an 'otherwise' naming a part by what is no attribute", joint <> " otherwise:\n λ: L_join\n left: a🌵.b🌵\n", "The 'left' of the 'otherwise' of the 'join' block of λ function 'L_fork' is 'a🌵.b🌵', while it must name an attribute ending with '🌵'")+ , ("an 'otherwise' giving one name to two parts", joint <> " otherwise:\n λ: L_join\n left: on🌵\n", "The 'otherwise' of the 'join' block of λ function 'L_fork' gives one name to two of 'on', 'left' and 'right'")+ , ("an 'otherwise' with no 'λ' key", joint <> " otherwise:\n on: c🌵\n", "The 'otherwise' of the 'join' block of λ function 'L_fork' has no 'λ' key")+ , ("an 'otherwise' with a key it does not read", joint <> " otherwise:\n λ: L_join\n middle: m🌵\n", "The key 'middle' of the 'otherwise' of the 'join' block of λ function 'L_fork' is none of its keys: λ, on, left, right")+ , ("an 'otherwise' whose 'λ' is no λ name", joint <> " otherwise:\n λ: l_join\n", "The 'otherwise' of the 'join' block of λ function 'L_fork' is 'l_join', while it must name a λ function")+ , ("an 'otherwise' which is a list", joint <> " otherwise: [L_join]\n", "The 'otherwise' of the 'join' block of λ function 'L_fork' is neither a λ name nor a mapping with the keys λ, on, left, right") , ("a 'join' block which is no mapping", "- λ: L_fork\n dataize:\n 𝛿1: $.c\n join: [𝛿1, $.a, $.b]\n", "join: parsing") , ("a side of a 'join' block naming a meta nothing binds", "- λ: L_fork\n dataize:\n 𝛿1: $.c\n join:\n on: 𝛿1\n left: 𝑛1\n right: $.b\n", "The side 'left' of the 'join' block of λ function 'L_fork' reads the meta 'n1' that none of 'morph', 'undress', 'evaluate', 'stay', 'rewrite', 'symbolize', 'cast' and 'defer' binds") , ("a side of a 'join' block reading a meta inside a term", "- λ: L_fork\n dataize:\n 𝛿1: $.c\n morph:\n 𝑛1: $.a\n join:\n on: 𝛿1\n left: 𝑛1.x\n right: $.b\n", "The side 'left' of the 'join' block of λ function 'L_fork' reads the meta 'n1' inside a term, while a side is a path from '$' or a meta alone")
test/SodgSpec.hs view
@@ -53,6 +53,15 @@ _ -> expectationFailure "The pack holds neither a single 'output' nor a single 'fails'" ) + describe "untested" $ do+ it "drops the tests of every object, however deep" $ do+ expr <- parseExpressionThrows "⟦ a ↦ Φ.f( x ↦ ⟦ y ↦ ⟦ n🌵no ↦ ∅, z ↦ Φ.u ⟧ ⟧ ).g, p🌵it ↦ ⟦ q ↦ Φ.v ⟧ ⟧"+ expected <- parseExpressionThrows "⟦ a ↦ Φ.f( x ↦ ⟦ y ↦ ⟦ z ↦ Φ.u ⟧ ⟧ ).g ⟧"+ untested expr `shouldBe` expected+ it "drops the tests the XMIR reader names with a sign" $+ untested (ExFormation [BiTau (AtLabel "+ok") ExRoot, BiTau (AtLabel "x") ExRoot, BiVoid (AtLabel "-bad")])+ `shouldBe` ExFormation [BiTau (AtLabel "x") ExRoot]+ describe "sodg keeps its four promises on any program" $ do prop "every F, D, A and T makes a fresh name and a command uses only names made above it" $ \(Grown grown) -> let expr = scrubbed False grown