src/Tools/Haskell/Properties.hs
changeset 69381 4c9b4e2c5460
parent 69380 87644f76c997
child 69382 d70767e508d7
equal deleted inserted replaced
69380:87644f76c997 69381:4c9b4e2c5460
     1 {- generated by Isabelle -}
       
     2 
       
     3 {-  Title:      Tools/Haskell/Properties.hs
       
     4     Author:     Makarius
       
     5     LICENSE:    BSD 3-clause (Isabelle)
       
     6 
       
     7 Property lists.
       
     8 
       
     9 See also "$ISABELLE_HOME/src/Pure/General/properties.ML".
       
    10 -}
       
    11 
       
    12 module Isabelle.Properties (Entry, T, defined, get, put, remove)
       
    13 where
       
    14 
       
    15 import qualified Data.List as List
       
    16 
       
    17 
       
    18 type Entry = (String, String)
       
    19 type T = [Entry]
       
    20 
       
    21 defined :: T -> String -> Bool
       
    22 defined props name = any (\(a, _) -> a == name) props
       
    23 
       
    24 get :: T -> String -> Maybe String
       
    25 get props name = List.lookup name props
       
    26 
       
    27 put :: Entry -> T -> T
       
    28 put entry props = entry : remove (fst entry) props
       
    29 
       
    30 remove :: String -> T -> T
       
    31 remove name props =
       
    32   if defined props name then filter (\(a, _) -> a /= name) props
       
    33   else props