Copyright | (c) Joseph Morag 2021-2022 |
---|---|
License | BSD3 |
Maintainer | Joseph Morag <[email protected]> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Data.BEncode.Lens
Description
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.
Minimal complete definition
Methods
_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"]
Orphan instances
Traversable BDictMap Source # | |
Ixed BValue Source # | |
Plated BValue Source # | |
Methods plate :: Traversal' BValue BValue # | |
TraversableWithIndex BKey BDictMap Source # | |
FoldableWithIndex BKey BDictMap Source # | |
Methods ifoldMap :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m # ifoldMap' :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m # ifoldr :: (BKey -> a -> b -> b) -> b -> BDictMap a -> b # ifoldl :: (BKey -> b -> a -> b) -> b -> BDictMap a -> b # | |
FunctorWithIndex BKey BDictMap Source # | |
Ixed (BDictMap a) Source # | |
At (BDictMap a) Source # | |