fork download
  1. data ZipList a = ZL [a] a [a] deriving (Eq, Show)
  2.  
  3. test :: ZipList Int
  4. test = ZL [3,2,1] 4 [5,6,7]
  5.  
  6. -- Create a new empty list and make e the default item that is
  7. newZipList :: a -> ZipList a
  8. newZipList x = ZL [] x []
  9.  
  10. -- Returns true if only one item present
  11. -- i.e. the left and right lists are empty
  12. isSingleton :: ZipList a -> Bool
  13. isSingleton (ZL [] _ []) = True
  14. isSingleton _ = False
  15.  
  16. -- Move the current item one place forwards in the list
  17. after :: ZipList a -> ZipList a
  18. after (ZL ls x []) = ZL ls x [] -- Can't go any further right
  19. after (ZL ls x (r:rs)) = ZL (x:ls) r rs
  20.  
  21. -- Move the current item one place backwards in the list
  22. before :: ZipList a -> ZipList a
  23. before (ZL [] x rs) = ZL [] x rs -- Can't go any further left
  24. before (ZL (l:ls) x rs) = ZL ls l (x:rs)
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:1: error: unknown type name ‘data’
 data ZipList a = ZL [a] a [a] deriving (Eq, Show)
 ^~~~
prog.c:1:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘a’
 data ZipList a = ZL [a] a [a] deriving (Eq, Show)
              ^
prog.c:18:43: warning: missing terminating ' character
 after (ZL ls x [])     = ZL ls x [] -- Can't go any further right
                                           ^
prog.c:18:43: error: missing terminating ' character
 after (ZL ls x [])     = ZL ls x [] -- Can't go any further right
                                           ^~~~~~~~~~~~~~~~~~~~~~~
prog.c:23:44: warning: missing terminating ' character
 before (ZL [] x rs)     = ZL [] x rs -- Can't go any further left
                                            ^
prog.c:23:44: error: missing terminating ' character
 before (ZL [] x rs)     = ZL [] x rs -- Can't go any further left
                                            ^~~~~~~~~~~~~~~~~~~~~~
stdout
Standard output is empty