| 29297 |      1 | {-# OPTIONS_GHC -fglasgow-exts #-}
 | 
|  |      2 | 
 | 
| 28421 |      3 | module Example where {
 | 
|  |      4 | 
 | 
|  |      5 | 
 | 
| 32360 |      6 | foldla :: forall a b. (a -> b -> a) -> a -> [b] -> a;
 | 
| 28421 |      7 | foldla f a [] = a;
 | 
|  |      8 | foldla f a (x : xs) = foldla f (f a x) xs;
 | 
|  |      9 | 
 | 
|  |     10 | rev :: forall a. [a] -> [a];
 | 
|  |     11 | rev xs = foldla (\ xsa x -> x : xsa) [] xs;
 | 
|  |     12 | 
 | 
| 32360 |     13 | list_case :: forall a b. a -> (b -> [b] -> a) -> [b] -> a;
 | 
| 28421 |     14 | list_case f1 f2 (a : list) = f2 a list;
 | 
|  |     15 | list_case f1 f2 [] = f1;
 | 
|  |     16 | 
 | 
| 29798 |     17 | data Queue a = AQueue [a] [a];
 | 
| 28421 |     18 | 
 | 
|  |     19 | empty :: forall a. Queue a;
 | 
| 29798 |     20 | empty = AQueue [] [];
 | 
| 28421 |     21 | 
 | 
|  |     22 | dequeue :: forall a. Queue a -> (Maybe a, Queue a);
 | 
| 29798 |     23 | dequeue (AQueue [] []) = (Nothing, AQueue [] []);
 | 
|  |     24 | dequeue (AQueue xs (y : ys)) = (Just y, AQueue xs ys);
 | 
|  |     25 | dequeue (AQueue (v : va) []) =
 | 
| 31848 |     26 |   let {
 | 
| 28421 |     27 |     (y : ys) = rev (v : va);
 | 
| 31848 |     28 |   } in (Just y, AQueue [] ys);
 | 
| 28421 |     29 | 
 | 
|  |     30 | enqueue :: forall a. a -> Queue a -> Queue a;
 | 
| 29798 |     31 | enqueue x (AQueue xs ys) = AQueue (x : xs) ys;
 | 
| 28421 |     32 | 
 | 
|  |     33 | }
 |