through the constructor or through
A Json.Decode.Decoder for Pairs encoded by encodePair
"""
{
\"left\": 1,
\"right\": 11
}
"""
|>Decode.decodeString
(Pair.decode Decode.int Decode.int)
Ok ( 1, 11 )
access the left value in a Pair.
openClosedCurlyBracePair=
( '{', '}' )
openCurly= leftIn openClosedCurlyBracePairaccess the right value in a Pair.
openClosedCurlyBracePair=
( '{', '}' )
closedCurly= rightIn openClosedCurlyBracePairmap the left value in a Pair
( 128522, "smile" )
|>mapLeft Char.fromCode
( '😊', "smile" )
This is handy when using maps or folds etc.
namedEmojiCodes=
PairDict.empty
|>PairDict.insert ( 127824, "pear" )
|>PairDict.insert ( 127795, "tree" )
namedEmojis=
namedEmojiCodes
|>PairDict.map (Pair.mapLeft Char.fromCode)
PairDict.fromList [ ( '🍐', "pear" ), ( '🌳', "tree" ) ]
map the right value in a Pair
( "smile", 128522 )
|>mapRight Char.fromCode
( "smile", '😊' )
This is handy when using maps or folds etc.
namedEmojiCodes=
PairDict.empty
|>PairDict.insert ( "pear", 127824 )
|>PairDict.insert ( "tree", 127795 )
namedEmojis=
namedEmojiCodes
|>PairDict.map (Pair.mapRight Char.fromCode)
PairDict.fromList [ ( "pear", '🍐' ), ( "tree", '🌳' ) ]
map the right value in a Pair
( "smile", 128522 )
|>mapRight Char.fromCode
( "smile", '😊' )
This is handy when using maps or folds etc.
namedEmojiCodes=
PairDict.empty
|>PairDict.insert ( "pear", 127824 )
|>PairDict.insert ( "tree", 127795 )
namedEmojis=
namedEmojiCodes
|>PairDict.map (Pair.map String.toUpper)
PairDict.fromList [ ( "PEAR", '🍐' ), ( "TREE", '🌳' ) ]
Convert a Pair to a Json.Encode.Value.
Encode.encode 1
(Pair.encode
Encode.int Encode.int
( 1, 11 )
)
"""
{
\"left\": 1,
\"right\": 11
}
"""
( left, right )as a value-pair.