module Slick.Utils
( getDirectoryPaths
, convert
) where
import Data.Aeson as A
import Development.Shake
import Development.Shake.FilePath
getDirectoryPaths :: [FilePath]
-> [FilePath]
-> Action [FilePath]
getDirectoryPaths extensions dirs =
concat <$> mapM getPaths dirs
where
getPaths :: FilePath -> Action [FilePath]
getPaths dir =
fmap (dir </>) <$>
getDirectoryFiles dir extensions
convert :: (FromJSON a, ToJSON a, FromJSON b) => a -> Action b
convert a = case fromJSON (toJSON a) of
A.Success r -> pure r
A.Error err -> fail $ "json conversion error:" ++ err