src/Tools/Haskell/Properties.hs
author wenzelm
Mon, 12 Nov 2018 15:14:12 +0100
changeset 69289 bf6937af7fe8
parent 69280 e1d01b351724
permissions -rw-r--r--
clarified signature;

{- generated by Isabelle -}

{-  Title:      Tools/Haskell/Properties.hs
    Author:     Makarius
    LICENSE:    BSD 3-clause (Isabelle)

Property lists.

See also "$ISABELLE_HOME/src/Pure/General/properties.ML".
-}

module Isabelle.Properties (Entry, T, defined, get, put, remove)
where

import qualified Data.List as List


type Entry = (String, String)
type T = [Entry]

defined :: T -> String -> Bool
defined props name = any (\(a, _) -> a == name) props

get :: T -> String -> Maybe String
get props name = List.lookup name props

put :: Entry -> T -> T
put entry props = entry : remove (fst entry) props

remove :: String -> T -> T
remove name props =
  if defined props name then filter (\(a, _) -> a /= name) props
  else props