/
Lenses.purs
54 lines (40 loc) · 2.13 KB
/
Lenses.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- | Misc. useful lenses.
module Playground.Lenses where
import Data.Function ((<<<))
import Data.Json.JsonMap (_JsonMap)
import Data.Lens (Lens')
import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Record (prop)
import Data.Map (Map)
import Data.Newtype (class Newtype)
import Data.Symbol (SProxy(..))
import Ledger.Index (UtxoIndex, _UtxoIndex)
import Ledger.Tx (TxOut, TxOutRef)
import Ledger.TxId (TxId)
import Ledger.Value (CurrencySymbol, TokenName, _CurrencySymbol, _TokenName)
_currencySymbol :: Lens' CurrencySymbol String
_currencySymbol = _CurrencySymbol <<< prop (SProxy :: SProxy "unCurrencySymbol")
_tokenName :: Lens' TokenName String
_tokenName = _TokenName <<< prop (SProxy :: SProxy "unTokenName")
_amount :: forall r a. Lens' { amount :: a | r } a
_amount = prop (SProxy :: SProxy "amount")
_recipient :: forall r a. Lens' { recipient :: a | r } a
_recipient = prop (SProxy :: SProxy "recipient")
_endpointDescription :: forall r a. Lens' { endpointDescription :: a | r } a
_endpointDescription = prop (SProxy :: SProxy "endpointDescription")
_getEndpointDescription :: forall s r a. Newtype s { getEndpointDescription :: a | r } => Lens' s a
_getEndpointDescription = _Newtype <<< prop (SProxy :: SProxy "getEndpointDescription")
_endpointValue :: forall s r a. Newtype s { unEndpointValue :: a | r } => Lens' s a
_endpointValue = _Newtype <<< prop (SProxy :: SProxy "unEndpointValue")
_schema :: forall r a. Lens' { schema :: a | r } a
_schema = prop (SProxy :: SProxy "schema")
_txConfirmed :: forall s r a. Newtype s { unTxConfirmed :: a | r } => Lens' s a
_txConfirmed = _Newtype <<< prop (SProxy :: SProxy "unTxConfirmed")
_txId :: Lens' TxId String
_txId = _Newtype <<< prop (SProxy :: SProxy "getTxId")
_utxoIndexEntries :: Lens' UtxoIndex (Map TxOutRef TxOut)
_utxoIndexEntries = _UtxoIndex <<< prop (SProxy :: SProxy "getIndex") <<< _JsonMap
_aeDescription :: forall s r a. Newtype s { aeDescription :: a | r } => Lens' s a
_aeDescription = _Newtype <<< prop (SProxy :: SProxy "aeDescription")
_aeMetadata :: forall s r a. Newtype s { aeMetadata :: a | r } => Lens' s a
_aeMetadata = _Newtype <<< prop (SProxy :: SProxy "aeMetadata")