Skip to content

Commit 9ac0bd3

Browse files
jamesmckinnaandreasabel
authored andcommitted
Improve Data.List.Base (fix #2359; deprecate use of with #2123) (#2366)
* refactor towards `if_then_else_` * layout * `let` into `where`
1 parent d06c432 commit 9ac0bd3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Data/List/Base.agda

+7-6
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,10 @@ linesBy {A = A} P? = go nothing where
421421

422422
go : Maybe (List A) List A List (List A)
423423
go acc [] = maybe′ ([_] ∘′ reverse) [] acc
424-
go acc (c ∷ cs) with does (P? c)
425-
... | true = reverse (Maybe.fromMaybe [] acc) ∷ go nothing cs
426-
... | false = go (just (c ∷ Maybe.fromMaybe [] acc)) cs
424+
go acc (c ∷ cs) = if does (P? c)
425+
then reverse acc′ ∷ go nothing cs
426+
else go (just (c ∷ acc′)) cs
427+
where acc′ = Maybe.fromMaybe [] acc
427428

428429
linesByᵇ : (A Bool) List A List (List A)
429430
linesByᵇ p = linesBy (T? ∘ p)
@@ -441,9 +442,9 @@ wordsBy {A = A} P? = go [] where
441442

442443
go : List A List A List (List A)
443444
go acc [] = cons acc []
444-
go acc (c ∷ cs) with does (P? c)
445-
... | true = cons acc (go [] cs)
446-
... | false = go (c ∷ acc) cs
445+
go acc (c ∷ cs) = if does (P? c)
446+
then cons acc (go [] cs)
447+
else go (c ∷ acc) cs
447448

448449
wordsByᵇ : (A Bool) List A List (List A)
449450
wordsByᵇ p = wordsBy (T? ∘ p)

0 commit comments

Comments
 (0)