Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Data/List/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ instance ordList :: Ord a => Ord (List a) where
other -> other

instance semigroupList :: Semigroup (List a) where
append Nil ys = ys
append (x : xs) ys = x : (xs <> ys)
append xs ys = foldr (:) ys xs

instance monoidList :: Monoid (List a) where
mempty = Nil
Expand Down
7 changes: 7 additions & 0 deletions test/Test/Data/List.purs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ testList = do
let xs = fromFoldable (range 1 100000)
assert $ traverse Just xs == Just xs

log "append should concatenate two lists"
assert $ (l [1, 2]) <> (l [3, 4]) == (l [1, 2, 3, 4])

log "append should be stack-safe"
void $ pure $ xs <> xs


step :: Int -> Maybe (Tuple Int Int)
step 6 = Nothing
step n = Just (Tuple n (n + 1))
Expand Down