packages feed

phino 0.0.0.29 → 0.0.0.30

raw patch · 3 files changed

+15/−1 lines, 3 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Parser: parseAttributeThrows :: String -> IO Attribute

Files

phino.cabal view
@@ -1,7 +1,7 @@ cabal-version:      3.0  name:               phino-version:            0.0.0.29+version:            0.0.0.30 license:            MIT synopsis:           Command-Line Manipulator of 𝜑-Calculus Expressions description:        Please see the README on GitHub at <https://github.com/objectionary/phino#readme>
src/Functions.hs view
@@ -17,6 +17,7 @@ import Matcher import Misc import Numeric (showHex)+import Parser (parseAttributeThrows) import Pretty import Random (randomString) import Regexp@@ -118,4 +119,9 @@   bds <- buildBindingThrows (BiMeta meta) subst   pure (TeExpression (DataNumber (numToBts (fromIntegral (length bds))))) buildTermFromFunction "size" _ _ _ = throwIO (userError "Function size() requires exactly 1 meta binding")+buildTermFromFunction "tau" [ArgExpression expr] subst prog = do+  TeBytes bts <- buildTermFromFunction "dataize" [ArgExpression expr] subst prog+  attr <- parseAttributeThrows (btsToUnescapedStr bts)+  pure (TeAttribute attr)+buildTermFromFunction "tau" _ _ _ = throwIO (userError "Function tau() requires exactly 1 argument as expression") buildTermFromFunction func _ _ _ = throwIO (userError (printf "Function %s() is not supported or does not exist" func))
src/Parser.hs view
@@ -11,6 +11,7 @@     parseExpression,     parseExpressionThrows,     parseAttribute,+    parseAttributeThrows,     parseBinding,     parseBytes,   )@@ -37,11 +38,13 @@ data ParserException   = CouldNotParseProgram {message :: String}   | CouldNotParseExpression {message :: String}+  | CouldNotParseAttribute {message :: String}   deriving (Exception)  instance Show ParserException where   show CouldNotParseProgram {..} = printf "Couldn't parse given phi program, cause: %s" message   show CouldNotParseExpression {..} = printf "Couldn't parse given phi program, cause: %s" message+  show CouldNotParseAttribute {..} = printf "Couldn't parse given attribute, cause: %s" message  -- White space consumer whiteSpace :: Parser ()@@ -437,6 +440,11 @@  parseAttribute :: String -> Either String Attribute parseAttribute = parse' "attribute" fullAttribute++parseAttributeThrows :: String -> IO Attribute+parseAttributeThrows attr = case parseAttribute attr of+  Right attr' -> pure attr'+  Left err -> throwIO (CouldNotParseAttribute err)  parseExpression :: String -> Either String Expression parseExpression = parse' "expression" expression