aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Input.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Input.hs')
-rw-r--r--compiler/src/Input.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index 78622bf..fa36d59 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -20,7 +20,8 @@
20 20
21 21
22module Input 22module Input
23 ( Sidecar, title, date, description, tags 23 ( decodeYamlFile
24 , Sidecar, title, date, description, tags
24 , InputTree(..), readInputTree 25 , InputTree(..), readInputTree
25 ) where 26 ) where
26 27
@@ -42,12 +43,10 @@ import Utils
42data LoadException = LoadException String ParseException deriving Show 43data LoadException = LoadException String ParseException deriving Show
43instance Exception LoadException 44instance Exception LoadException
44 45
45decodeYamlFile :: (MonadIO m, FromJSON a) => Path -> m a 46decodeYamlFile :: (MonadIO m, FromJSON a) => FileName -> m a
46decodeYamlFile path = 47decodeYamlFile path =
47 liftIO $ Data.Yaml.decodeFileEither fpath 48 liftIO $ Data.Yaml.decodeFileEither path
48 >>= either (throwIO . LoadException fpath) return 49 >>= either (throwIO . LoadException path) return
49 where
50 fpath = localPath path
51 50
52 51
53-- | Tree representing the input from the input directory. 52-- | Tree representing the input from the input directory.
@@ -75,7 +74,7 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) =
75 where 74 where
76 mkInputNode :: FSNode -> IO (Maybe InputTree) 75 mkInputNode :: FSNode -> IO (Maybe InputTree)
77 mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename = 76 mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename =
78 decodeYamlFile (anchor /> path) 77 decodeYamlFile (localPath $ anchor /> path)
79 >>= return . InputFile ((dropExtension filename):pathto) 78 >>= return . InputFile ((dropExtension filename):pathto)
80 >>= return . Just 79 >>= return . Just
81 mkInputNode File{} = return Nothing 80 mkInputNode File{} = return Nothing