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.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index 64c1933..c90db5c 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -69,13 +69,21 @@ data Sidecar = Sidecar
69 , tags :: Maybe [String] 69 , tags :: Maybe [String]
70 } deriving (Generic, FromJSON, Show) 70 } deriving (Generic, FromJSON, Show)
71 71
72emptySidecar :: Sidecar
73emptySidecar = Sidecar
74 { title = Nothing
75 , date = Nothing
76 , description = Nothing
77 , tags = Nothing }
78
72 79
73readInputTree :: AnchoredFSNode -> IO InputTree 80readInputTree :: AnchoredFSNode -> IO InputTree
74readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root 81readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
75 where 82 where
76 mkInputNode :: FSNode -> IO (Maybe InputTree) 83 mkInputNode :: FSNode -> IO (Maybe InputTree)
77 mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename = 84 mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename =
78 decodeYamlFile (localPath $ anchor /> path) 85 (decodeYamlFile (localPath $ anchor /> path) :: IO (Maybe Sidecar))
86 >>= return . maybe emptySidecar id
79 >>= return . InputFile ((dropExtension filename):pathto) 87 >>= return . InputFile ((dropExtension filename):pathto)
80 >>= return . Just 88 >>= return . Just
81 mkInputNode File{} = return Nothing 89 mkInputNode File{} = return Nothing