sw17ch / data-clist

A purely functional ring data structure for Haskell.
Other
8 stars 9 forks source link

Weird Foldable.toList behaviour #24

Open noinia opened 2 years ago

noinia commented 2 years ago

The current Foldable instance leads to somewhat weird behaviour in which the elements are produced in a weird order, as evidenced by the following example:

>>> import qualified Data.Foldable as F
>>> import qualified Data.CircularList as C
>>> mapM_ print $ fmap (\cl -> (cl, F.toList cl, C.toList cl)) $ C.allRotations $ C.fromList [0,8,5,4,1]
(fromList [0,8,5,4,1],[0,8,5,1,4],[0,8,5,4,1])
(fromList [8,5,4,1,0],[8,5,0,1,4],[8,5,4,1,0])
(fromList [5,4,1,0,8],[5,8,0,1,4],[5,4,1,0,8])
(fromList [1,0,8,5,4],[1,0,8,5,4],[1,0,8,5,4])
(fromList [4,1,0,8,5],[4,1,0,8,5],[4,1,0,8,5])

I would probably expect Foldable's toList to behave the same way as C.toList