Copyright | (c) Joseph Morag 2021-2022 |
---|---|
License | BSD3 |
Maintainer | Joseph Morag <jm@josephmorag.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module exports orphan instances for
, Ixed
BValue
, Plated
BValue
, Ixed
BDictMap
, Plated
BDictMap
, Traversable
BDictMap
, FunctorWithIndex
BDictMap
, and FoldableWithIndex
BDictMap
.TraversbaleWithIndex
BDictMap
Prisms
class AsBValue t where Source #
Things that can be treated as a BValue
. Instances are provided for strict
and lazy ByteString
as well as BValue
s themselves.
_BValue :: Prism' t BValue Source #
_BInteger :: Prism' t BInteger Source #
>>>
("i3e" :: ByteString) ^? _BInteger
Just 3
_BString :: Prism' t BString Source #
>>>
("0:" :: ByteString) ^? _BString
Just ""
>>>
("4:spam" :: ByteString) ^? _BString
Just "spam"
_BList :: Prism' t BList Source #
>>>
("le" :: ByteString) ^? _BList
Just []
>>>
("l4:spam4:eggse" :: ByteString) ^? _BList == Just [BString "spam", BString "eggs"]
True
_BDict :: Prism' t BDict Source #
>>>
("de" :: ByteString) ^? _BDict
Just Nil
>>>
("d3:cow3:moo4:spam4:eggse" :: ByteString) ^? _BDict == Just (Cons "cow" (BString "moo") (Cons "spam" (BString "eggs") Nil))
True
BDicts and BLists
members :: AsBValue t => IndexedTraversal' BKey t BValue Source #
>>>
("d3:cow3:moo4:spam4:eggse" :: ByteString) ^@.. members
[("cow",BString "moo"),("spam",BString "eggs")]
key :: AsBValue t => BKey -> Traversal' t BValue Source #
>>>
("d3:cow3:moo4:spam4:eggse" :: ByteString) ^? key "cow"
Just (BString "moo")
nth :: AsBValue t => Int -> Traversal' t BValue Source #
>>>
("li0ei1ee" :: ByteString) ^? nth 0
Just (BInteger 0)
values :: AsBValue t => IndexedTraversal' Int t BValue Source #
>>>
("ll1:ae3:cow3:moo4:spam4:eggse" :: ByteString) ^.. values
[BList [BString "a"],BString "cow",BString "moo",BString "spam",BString "eggs"]