This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -385,13 +385,15 @@ toList (Two left k v right) = toList left <> Tuple k v : toList right
385385toList (Three left k1 v1 mid k2 v2 right) = toList left <> Tuple k1 v1 : toList mid <> Tuple k2 v2 : toList right
386386
387387-- | Convert a map to an unfoldable structure of key/value pairs
388- toUnfoldable :: forall f k v . (Ord k , Unfoldable f ) => Map k v -> f (Tuple k v )
389- toUnfoldable = unfoldr go
390- where
391- go :: Map k v -> Maybe (Tuple (Tuple k v ) (Map k v ))
392- go Leaf = Nothing
393- go (Two left k v right) = Just $ Tuple (Tuple k v) (left <> right)
394- go (Three left k1 v1 mid k2 v2 right) = Just $ Tuple (Tuple k1 v1) (insert k2 v2 (left <> mid <> right))
388+ toUnfoldable :: forall f k v . Unfoldable f => Map k v -> f (Tuple k v )
389+ toUnfoldable m = unfoldr go (m : Nil ) where
390+ go Nil = Nothing
391+ go (hd : tl) = case hd of
392+ Leaf -> go tl
393+ Two left k v right ->
394+ Just $ Tuple (Tuple k v) (left : right : tl)
395+ Three left k1 v1 mid k2 v2 right ->
396+ Just $ Tuple (Tuple k1 v1) (singleton k2 v2 : left : mid : right : tl)
395397
396398-- | Get a list of the keys contained in a map
397399keys :: forall k v . Map k v -> List k
You can’t perform that action at this time.
0 commit comments