- expandStrings = mapM expandString
-
- -- Just for fun, keep this in the IO monad.
+ expandStrings :: [String] -> IO [String]
+ expandStrings = liftM concat . mapM expandSpecial
+
+ -- Permit substitutions for list-valued variables (but only when
+ -- they occur alone), e.g., package_deps["${deps}"] where env var
+ -- (say) 'deps' is "base,haskell98,network"
+ expandSpecial :: String -> IO [String]
+ expandSpecial str =
+ let expand f = liftM f $ expandString str
+ in case splitString str of
+ [Var _] -> expand (wordsBy (== ','))
+ _ -> expand (\x -> [x])
+