data ZipList a = ZL [a] a [a] deriving (Eq, Show) test :: ZipList Int test = ZL [3,2,1] 4 [5,6,7] -- Create a new empty list and make e the default item that is newZipList :: a -> ZipList a newZipList x = ZL [] x [] -- Returns true if only one item present -- i.e. the left and right lists are empty isSingleton :: ZipList a -> Bool isSingleton (ZL [] _ []) = True isSingleton _ = False -- Move the current item one place forwards in the list after :: ZipList a -> ZipList a after (ZL ls x []) = ZL ls x [] -- Can't go any further right after (ZL ls x (r:rs)) = ZL (x:ls) r rs -- Move the current item one place backwards in the list before :: ZipList a -> ZipList a before (ZL [] x rs) = ZL [] x rs -- Can't go any further left before (ZL (l:ls) x rs) = ZL ls l (x:rs)