File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import Data.Array.NonEmpty as NEA
10
10
import Data.Identity (Identity )
11
11
import Data.Lens.Internal.Wander (wander )
12
12
import Data.Lens.Types (Traversal' )
13
+ import Data.List (List )
14
+ import Data.List as L
13
15
import Data.Map as M
14
16
import Data.Maybe (Maybe , maybe , fromMaybe )
15
17
import Data.Set as S
@@ -76,6 +78,14 @@ instance indexNonEmptyArray :: Index (NEA.NonEmptyArray a) Int a where
76
78
(pure xs)
77
79
(coalg >>> map \x -> fromMaybe xs (NEA .updateAt n x xs))
78
80
81
+ instance indexList :: Index (List a ) Int a where
82
+ ix n =
83
+ wander \coalg xs ->
84
+ xs L .!! n #
85
+ maybe
86
+ (pure xs)
87
+ (coalg >>> map \x -> fromMaybe xs (L .updateAt n x xs))
88
+
79
89
instance indexSet :: Ord a => Index (S.Set a ) a Unit where
80
90
ix x =
81
91
wander \coalg ->
You can’t perform that action at this time.
0 commit comments