avoid needing a build-dep on hxt for Data.AssocList
This commit is contained in:
parent
d0b51099a4
commit
207ac67aaa
6 changed files with 25 additions and 12 deletions
|
@ -61,3 +61,21 @@ unsetEnv var = do
|
|||
#else
|
||||
unsetEnv _ = return False
|
||||
#endif
|
||||
|
||||
{- Adds the environment variable to the input environment. If already
|
||||
- present in the list, removes the old value.
|
||||
-
|
||||
- This does not really belong here, but Data.AssocList is for some reason
|
||||
- buried inside hxt.
|
||||
-}
|
||||
addEntry :: Eq k => k -> v -> [(k, v)] -> [(k, v)]
|
||||
addEntry k v l = ( (k,v) : ) $! delEntry k l
|
||||
|
||||
addEntries :: Eq k => [(k, v)] -> [(k, v)] -> [(k, v)]
|
||||
addEntries = foldr (.) id . map (uncurry addEntry) . reverse
|
||||
|
||||
delEntry :: Eq k => k -> [(k, v)] -> [(k, v)]
|
||||
delEntry _ [] = []
|
||||
delEntry k (x@(k1,_) : rest)
|
||||
| k == k1 = rest
|
||||
| otherwise = ( x : ) $! delEntry k rest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue