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:
9
9
- Renamed ` scanrLazy ` to ` scanlLazy ` and fixed parameter ordering (#161 )
10
10
- Renamed ` group' ` to ` groupAll ` (#182 )
11
11
- Changed ` Alt ZipList ` to satisfy distributivity (#150 )
12
+ - Updated the ` Show ` instances for (non empty) lazy lists (#181 )
12
13
13
14
New features:
14
15
- 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))
34
34
-- | `Cons` constructor).
35
35
data Step a = Nil | Cons a (List a )
36
36
37
+ instance showStep :: Show a => Show (Step a ) where
38
+ show Nil = " Nil"
39
+ show (Cons x xs) = " (" <> show x <> " : " <> show xs <> " )"
40
+
37
41
-- | Unwrap a lazy linked list
38
42
step :: forall a . List a -> Step a
39
43
step = force <<< unwrap
@@ -59,10 +63,12 @@ infixr 6 cons as :
59
63
derive instance newtypeList :: Newtype (List a ) _
60
64
61
65
instance 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
+ <> " ])"
66
72
67
73
instance eqList :: Eq a => Eq (List a ) where
68
74
eq = eq1
You can’t perform that action at this time.
0 commit comments