src/Tools/Haskell/Library.hs
changeset 69234 2dec32c7313f
parent 69227 71b48b749836
child 69240 16ca270090b6
equal deleted inserted replaced
69233:560263485988 69234:2dec32c7313f
     6 
     6 
     7 Basic library of Isabelle idioms.
     7 Basic library of Isabelle idioms.
     8 -}
     8 -}
     9 
     9 
    10 module Isabelle.Library
    10 module Isabelle.Library
    11   ((|>), (|->), (#>), (#->), fold, fold_rev, single, quote, trim_line)
    11   ((|>), (|->), (#>), (#->), the_default, fold, fold_rev, single, quote, trim_line)
    12 where
    12 where
       
    13 
       
    14 import Data.Maybe
       
    15 
    13 
    16 
    14 {- functions -}
    17 {- functions -}
    15 
    18 
    16 (|>) :: a -> (a -> b) -> b
    19 (|>) :: a -> (a -> b) -> b
    17 x |> f = f x
    20 x |> f = f x
    22 (#>) :: (a -> b) -> (b -> c) -> a -> c
    25 (#>) :: (a -> b) -> (b -> c) -> a -> c
    23 (f #> g) x = x |> f |> g
    26 (f #> g) x = x |> f |> g
    24 
    27 
    25 (#->) :: (a -> (c, b)) -> (c -> b -> d) -> a -> d
    28 (#->) :: (a -> (c, b)) -> (c -> b -> d) -> a -> d
    26 (f #-> g) x  = x |> f |-> g
    29 (f #-> g) x  = x |> f |-> g
       
    30 
       
    31 
       
    32 {- options -}
       
    33 
       
    34 the_default :: a -> Maybe a -> a
       
    35 the_default x Nothing = x
       
    36 the_default _ (Just y) = y
    27 
    37 
    28 
    38 
    29 {- lists -}
    39 {- lists -}
    30 
    40 
    31 fold :: (a -> b -> b) -> [a] -> b -> b
    41 fold :: (a -> b -> b) -> [a] -> b -> b