(.module: [lux #* [data [text ("text/." Equivalence)]]]) (type: #export (PList a) (List [Text a])) (def: #export (get key properties) (All [a] (-> Text (PList a) (Maybe a))) (case properties #.Nil #.None (#.Cons [k' v'] properties') (if (text/= key k') (#.Some v') (get key properties')))) (def: #export (contains? key properties) (All [a] (-> Text (PList a) Bit)) (case (get key properties) (#.Some _) #1 #.None #0)) (def: #export (put key val properties) (All [a] (-> Text a (PList a) (PList a))) (case properties #.Nil (list [key val]) (#.Cons [k' v'] properties') (if (text/= key k') (#.Cons [key val] properties') (#.Cons [k' v'] (put key val properties'))))) (def: #export (update key f properties) (All [a] (-> Text (-> a a) (PList a) (PList a))) (case properties #.Nil #.Nil (#.Cons [k' v'] properties') (if (text/= key k') (#.Cons [k' (f v')] properties') (#.Cons [k' v'] (update key f properties'))))) (def: #export (remove key properties) (All [a] (-> Text (PList a) (PList a))) (case properties #.Nil properties (#.Cons [k' v'] properties') (if (text/= key k') properties' (#.Cons [k' v'] (remove key properties')))))