File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1
1
module Lib.SearchResults exposing
2
2
( Matches
3
3
, SearchResults (..)
4
+ , append
4
5
, cycleNext
5
6
, cyclePrev
6
7
, empty
@@ -17,6 +18,7 @@ module Lib.SearchResults exposing
17
18
, mapToList
18
19
, matchesToList
19
20
, next
21
+ , prepend
20
22
, prev
21
23
, toList
22
24
, toMaybe
@@ -128,6 +130,32 @@ toList results =
128
130
matchesToList matches
129
131
130
132
133
+ append : SearchResults a -> List a -> SearchResults a
134
+ append results new =
135
+ case results of
136
+ Empty ->
137
+ fromList new
138
+
139
+ SearchResults old ->
140
+ old
141
+ |> matchesToList
142
+ |> ( \ old_ -> old_ ++ new)
143
+ |> fromList
144
+
145
+
146
+ prepend : SearchResults a -> List a -> SearchResults a
147
+ prepend results new =
148
+ case results of
149
+ Empty ->
150
+ fromList new
151
+
152
+ SearchResults old ->
153
+ old
154
+ |> matchesToList
155
+ |> ( \ old_ -> new ++ old_)
156
+ |> fromList
157
+
158
+
131
159
next : SearchResults a -> SearchResults a
132
160
next =
133
161
map nextMatch
You can’t perform that action at this time.
0 commit comments