aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Input.hs
diff options
context:
space:
mode:
authorpacien2020-01-05 16:24:02 +0100
committerpacien2020-01-05 16:24:02 +0100
commit9dd271504160b624284dbc438cdc867b6ca0d0e7 (patch)
tree8701aa1897e664aab1f80a7952dbdc5c0c27624c /compiler/src/Input.hs
parentabdf82bbfde843a87bd00746f52dafdd28f3f60b (diff)
downloadldgallery-9dd271504160b624284dbc438cdc867b6ca0d0e7.tar.gz
compiler: enable warnings and fix them
GitHub: fixes #9
Diffstat (limited to 'compiler/src/Input.hs')
-rw-r--r--compiler/src/Input.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index 7e1b169..ab2bc3c 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -31,10 +31,10 @@ module Input
31 31
32 32
33import GHC.Generics (Generic) 33import GHC.Generics (Generic)
34import Control.Exception (Exception, throwIO) 34import Control.Exception (Exception, AssertionFailed(..), throw, throwIO)
35import Control.Monad.IO.Class (MonadIO, liftIO) 35import Control.Monad.IO.Class (MonadIO, liftIO)
36import Data.Function ((&)) 36import Data.Function ((&))
37import Data.Maybe (mapMaybe, catMaybes) 37import Data.Maybe (catMaybes)
38import Data.Bool (bool) 38import Data.Bool (bool)
39import Data.List (find) 39import Data.List (find)
40import Data.Yaml (ParseException, decodeFileEither) 40import Data.Yaml (ParseException, decodeFileEither)
@@ -90,6 +90,8 @@ readSidecarFile filepath =
90 90
91 91
92readInputTree :: AnchoredFSNode -> IO InputTree 92readInputTree :: AnchoredFSNode -> IO InputTree
93readInputTree (AnchoredFSNode _ File{}) =
94 throw $ AssertionFailed "Input directory is a file"
93readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root 95readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
94 where 96 where
95 mkInputNode :: FSNode -> IO (Maybe InputTree) 97 mkInputNode :: FSNode -> IO (Maybe InputTree)
@@ -101,7 +103,8 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
101 mkInputNode dir@Dir{} = mkDirNode dir >>= return . Just 103 mkInputNode dir@Dir{} = mkDirNode dir >>= return . Just
102 104
103 mkDirNode :: FSNode -> IO InputTree 105 mkDirNode :: FSNode -> IO InputTree
104 mkDirNode (Dir path items) = 106 mkDirNode File{} = throw $ AssertionFailed "Input directory is a file"
107 mkDirNode Dir{path, items} =
105 mapM mkInputNode items 108 mapM mkInputNode items
106 >>= return . catMaybes 109 >>= return . catMaybes
107 >>= return . InputDir path (findThumbnail items) 110 >>= return . InputDir path (findThumbnail items)