<p>Here is simplified version got from cardano-cli Parsers that works.</p>
<pre><code>module BuildTxOut
where

import Cardano.Api
import Cardano.CLI.Types
import Cardano.CLI.Shelley.Parsers

import qualified Text.Parsec as Parsec

import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec


parseTxOutAnyEra2 :: Parsec.Parser (TxOutDatumAnyEra -&gt; TxOutAnyEra)
parseTxOutAnyEra2 = do
    addr &lt;- parseAddressAny
    Parsec.spaces
    -- Accept the old style of separating the address and value in a
    -- transaction output:
    Parsec.option () (Parsec.char '+' &gt;&gt; Parsec.spaces)
    val &lt;- parseValue
    return (TxOutAnyEra addr val)

pTxOut ::  Parsec.Parser TxOutAnyEra
pTxOut = parseTxOutAnyEra2 &lt;*&gt; pTxOutDatum


-- INFO: can be modified to accept all functionality
-- see original implementation

pTxOutDatum ::  Parsec.Parser TxOutDatumAnyEra
pTxOutDatum = pure TxOutDatumByNone

getTxOut :: String -&gt; Either Parsec.ParseError TxOutAnyEra
getTxOut s = Parsec.parse pTxOut &quot;Wrong&quot; s
</code></pre>

CC BY-SA 4.0
2022-03-16T09:00:56.130Z
2022-03-16T09:00:56.130Z
ViktorYasterbov
<p>Example:</p>
<pre><code>testTxOut :: IO ()
testTxOut = do
  let
    testInput = &quot;addr_test1vqwvs32x3wg5ea2l5tr7t93hpta8arwxllr4ey96dhl5d7sytaf9n + 1000000 lovelace&quot;
  case (OutBuilder.getTxOutFrom testInput) of
     Left err -&gt; putStrLn $ show err
     Right tx -&gt; putStrLn $ &quot;passed&quot; -- HOW TO SHOW IT HERE
</code></pre>
<p>almost from the Cardano.CLI.Shelley.Parsers because it does not export one</p>
<pre><code>module BuildTxOut
  (getTxOutFrom)
where

import Cardano.Api
import Cardano.CLI.Types
import Cardano.CLI.Shelley.Parsers

import qualified Text.Parsec as Parsec

import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec


parseTxOutAnyEra2 :: Parsec.Parser (TxOutDatumAnyEra -&gt; TxOutAnyEra)
parseTxOutAnyEra2 = do
    addr &lt;- parseAddressAny
    Parsec.spaces
    -- Accept the old style of separating the address and value in a
    -- transaction output:
    Parsec.option () (Parsec.char '+' &gt;&gt; Parsec.spaces)
    val &lt;- parseValue
    return (TxOutAnyEra addr val)

getTxOutFrom :: String -&gt; Either Parsec.ParseError (TxOutDatumAnyEra -&gt; TxOutAnyEra )
getTxOutFrom s = Parsec.parse parseTxOutAnyEra2 &quot;Wrong&quot; s
</code></pre>

<cardano-cli><cardano-node>
How to apply show to TxOutAnyEra datatype from cardano-cli sources?
# How to apply show to TxOutAnyEra datatype from cardano-cli sources?

(Asked by: username_0 on 2022-03-15)

Example:
testTxOut :: IO ()
testTxOut = do
  let
    testInput = "addr_test1vqwvs32x3wg5ea2l5tr7t93hpta8arwxllr4ey96dhl5d7sytaf9n + 1000000 lovelace"
  case (OutBuilder.getTxOutFrom testInput) of
     Left err -> putStrLn $ show err
     Right tx -> putStrLn $ "passed" -- HOW TO SHOW IT HERE

almost from the Cardano.CLI.Shelley.Parsers because it does not export one
module BuildTxOut
  (getTxOutFrom)
where

import Cardano.Api
import Cardano.CLI.Types
import Cardano.CLI.Shelley.Parsers

import qualified Text.Parsec as Parsec

import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec


parseTxOutAnyEra2 :: Parsec.Parser (TxOutDatumAnyEra -> TxOutAnyEra)
parseTxOutAnyEra2 = do
    addr <- parseAddressAny
    Parsec.spaces
    -- Accept the old style of separating the address and value in a
    -- transaction output:
    Parsec.option () (Parsec.char '+' >> Parsec.spaces)
    val <- parseValue
    return (TxOutAnyEra addr val)

getTxOutFrom :: String -> Either Parsec.ParseError (TxOutDatumAnyEra -> TxOutAnyEra )
getTxOutFrom s = Parsec.parse parseTxOutAnyEra2 "Wrong" s

**Tags:** cardano-cli, cardano-node

---

## 1 answers

### Answer by username_0 on 2022-03-16. Score: 1

Here is simplified version got from cardano-cli Parsers that works.
module BuildTxOut
where

import Cardano.Api
import Cardano.CLI.Types
import Cardano.CLI.Shelley.Parsers

import qualified Text.Parsec as Parsec

import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec


parseTxOutAnyEra2 :: Parsec.Parser (TxOutDatumAnyEra -> TxOutAnyEra)
parseTxOutAnyEra2 = do
    addr <- parseAddressAny
    Parsec.spaces
    -- Accept the old style of separating the address and value in a
    -- transaction output:
    Parsec.option () (Parsec.char '+' >> Parsec.spaces)
    val <- parseValue
    return (TxOutAnyEra addr val)

pTxOut ::  Parsec.Parser TxOutAnyEra
pTxOut = parseTxOutAnyEra2 <*> pTxOutDatum


-- INFO: can be modified to accept all functionality
-- see original implementation

pTxOutDatum ::  Parsec.Parser TxOutDatumAnyEra
pTxOutDatum = pure TxOutDatumByNone

getTxOut :: String -> Either Parsec.ParseError TxOutAnyEra
getTxOut s = Parsec.parse pTxOut "Wrong" s


---

