1
1
module Statebox.Core.Lenses where
2
2
3
3
import Prelude
4
- import Data.Lens (Prism' , prism' , Lens' , lens )
4
+ import Data.Lens (Prism' , Iso' , Lens' , lens , prism' , re , _Newtype )
5
+ import Data.Lens.Iso.Newtype (_Newtype )
5
6
import Data.Maybe (Maybe (..))
6
7
import Data.NonEmpty (singleton , head )
7
8
import Statebox.Core.Transaction (TxSum (..), WiringTx , FiringTx , isExecutionTx )
8
- import Statebox.Core.Types (Firing , GluedTransitionIdRaw )
9
+ import Statebox.Core.Types (Firing , GluedTransitionId (..), GluedTransitionIdRaw )
9
10
10
11
-- ------------------------------------------------------------------------------
11
12
@@ -26,5 +27,11 @@ _executionTx = prism' FiringTxInj $ case _ of FiringTxInj x | isExecutionTx x ->
26
27
_firing :: Lens' FiringTx Firing
27
28
_firing = lens (_.firing) (_ { firing = _ })
28
29
29
- _firingPath :: Lens' Firing GluedTransitionIdRaw
30
- _firingPath = lens (_.path >>> head) (\r x -> r { path = singleton x })
30
+ _firingPath :: Lens' Firing GluedTransitionId
31
+ _firingPath = _firingPathRaw <<< re _GluedTransitionId
32
+
33
+ _firingPathRaw :: Lens' Firing GluedTransitionIdRaw
34
+ _firingPathRaw = lens (_.path >>> head) (\r x -> r { path = singleton x })
35
+
36
+ _GluedTransitionId :: Iso' GluedTransitionId GluedTransitionIdRaw
37
+ _GluedTransitionId = _Newtype
0 commit comments