Skip to content

Commit

Permalink
Simplify code using Parsec
Browse files Browse the repository at this point in the history
  • Loading branch information
cblp committed Apr 19, 2022
1 parent 8e049ac commit 94c2835
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Options.Applicative hiding (help, str)
import qualified Options.Applicative as Opt
import qualified Options.Applicative.Help as H
import Prettyprinter (line, pretty)
import Text.Parsec ((<?>))
import qualified Text.Parsec as Parsec
import qualified Text.Parsec.Error as Parsec
import qualified Text.Parsec.Language as Parsec
Expand Down Expand Up @@ -1974,7 +1975,7 @@ parseTxIn = TxIn <$> parseTxId <*> (Parsec.char '#' *> parseTxIx)

parseTxId :: Parsec.Parser TxId
parseTxId = do
str <- Parsec.many1 Parsec.hexDigit Parsec.<?> "transaction id (hexadecimal)"
str <- some Parsec.hexDigit <?> "transaction id (hexadecimal)"
case deserialiseFromRawBytesHex AsTxId (BSC.pack str) of
Right addr -> return addr
Left e -> fail $ "Incorrect transaction id format: " ++ displayError e
Expand Down Expand Up @@ -2787,7 +2788,7 @@ pExtraEntropy =
parseEntropyBytes :: Parsec.Parser ByteString
parseEntropyBytes = either fail return
. B16.decode . BSC.pack
=<< Parsec.many1 Parsec.hexDigit
=<< some Parsec.hexDigit

pUTxOCostPerWord :: Parser Lovelace
pUTxOCostPerWord =
Expand Down

0 comments on commit 94c2835

Please sign in to comment.