File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Breaking changes:
99- Renamed ` scanrLazy ` to ` scanlLazy ` and fixed parameter ordering (#161 )
1010- Renamed ` group' ` to ` groupAll ` (#182 )
1111- Changed ` Alt ZipList ` to satisfy distributivity (#150 )
12+ - Updated the ` Show ` instances for (non empty) lazy lists (#181 )
1213
1314New features:
1415- Added ` nubEq ` /` nubByEq ` (#179 )
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ newtype List a = List (Lazy (Step a))
3434-- | `Cons` constructor).
3535data Step a = Nil | Cons a (List a )
3636
37+ instance showStep :: Show a => Show (Step a ) where
38+ show Nil = " Nil"
39+ show (Cons x xs) = " (" <> show x <> " : " <> show xs <> " )"
40+
3741-- | Unwrap a lazy linked list
3842step :: forall a . List a -> Step a
3943step = force <<< unwrap
@@ -59,10 +63,12 @@ infixr 6 cons as :
5963derive instance newtypeList :: Newtype (List a ) _
6064
6165instance showList :: Show a => Show (List a ) where
62- show xs = " fromStrict (" <> go (step xs) <> " )"
63- where
64- go Nil = " Nil"
65- go (Cons x xs') = " (Cons " <> show x <> " " <> go (step xs') <> " )"
66+ show xs = " (fromFoldable ["
67+ <> case step xs of
68+ Nil -> " "
69+ Cons x xs' ->
70+ show x <> foldl (\shown x' -> shown <> " ," <> show x') " " xs'
71+ <> " ])"
6672
6773instance eqList :: Eq a => Eq (List a ) where
6874 eq = eq1
You can’t perform that action at this time.
0 commit comments