doc-src/Codegen/Thy/examples/Example.hs
changeset 37428 b3d94253e7f2
parent 34156 3a7937841585
child 37610 1b09880d9734
equal deleted inserted replaced
37427:e482f206821e 37428:b3d94253e7f2
     1 {-# OPTIONS_GHC -fglasgow-exts #-}
     1 {-# OPTIONS_GHC -fglasgow-exts #-}
     2 
     2 
     3 module Example where {
     3 module Example where {
     4 
       
     5 foldla :: forall a b. (a -> b -> a) -> a -> [b] -> a;
       
     6 foldla f a [] = a;
       
     7 foldla f a (x : xs) = foldla f (f a x) xs;
       
     8 
       
     9 rev :: forall a. [a] -> [a];
       
    10 rev xs = foldla (\ xsa x -> x : xsa) [] xs;
       
    11 
     4 
    12 list_case :: forall a b. a -> (b -> [b] -> a) -> [b] -> a;
     5 list_case :: forall a b. a -> (b -> [b] -> a) -> [b] -> a;
    13 list_case f1 f2 (a : list) = f2 a list;
     6 list_case f1 f2 (a : list) = f2 a list;
    14 list_case f1 f2 [] = f1;
     7 list_case f1 f2 [] = f1;
    15 
     8