File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
src/Codec/CBOR/Cuddle/Huddle Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ library
5151 Codec.CBOR.Cuddle.CDDL.Resolve
5252 Codec.CBOR.Cuddle.Huddle
5353 Codec.CBOR.Cuddle.Huddle.HuddleM
54+ Codec.CBOR.Cuddle.Huddle.Optics
5455 Codec.CBOR.Cuddle.Parser
5556 Codec.CBOR.Cuddle.Pretty
5657
Original file line number Diff line number Diff line change 1+ -- | Optics for mutating Huddle rules
2+ module Coded.CBOR.Cuddle.Huddle.Optics (commentL , nameL ) where
3+
4+ import Codec.CBOR.Cuddle.Huddle
5+ import Data.Generics.Product (HasField' (field' ))
6+ import Data.Text qualified as T
7+ import Optics.Core
8+
9+ mcommentL ::
10+ (HasField' " description" a (Maybe T. Text )) =>
11+ Lens a a (Maybe T. Text ) (Maybe T. Text )
12+ mcommentL = field' @ " description"
13+
14+ -- | Traversal to the comment field of a description. Using this we can for
15+ -- example set the comment with 'a & commentL .~ "This is a comment"'
16+ commentL ::
17+ (HasField' " description" a (Maybe T. Text )) =>
18+ AffineTraversal a a T. Text T. Text
19+ commentL = mcommentL % _Just
20+
21+ -- | Lens to the name of a rule (or other named entity). Using this we can
22+ -- for example append to the name with 'a & nameL %~ (<> "_1")'
23+ nameL :: Lens (Named a ) (Named a ) T. Text T. Text
24+ nameL = field' @ " name"
You can’t perform that action at this time.
0 commit comments