diff options
author | pacien | 2020-01-05 16:24:02 +0100 |
---|---|---|
committer | pacien | 2020-01-05 16:24:02 +0100 |
commit | 9dd271504160b624284dbc438cdc867b6ca0d0e7 (patch) | |
tree | 8701aa1897e664aab1f80a7952dbdc5c0c27624c /compiler/src/Input.hs | |
parent | abdf82bbfde843a87bd00746f52dafdd28f3f60b (diff) | |
download | ldgallery-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.hs | 9 |
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 | ||
33 | import GHC.Generics (Generic) | 33 | import GHC.Generics (Generic) |
34 | import Control.Exception (Exception, throwIO) | 34 | import Control.Exception (Exception, AssertionFailed(..), throw, throwIO) |
35 | import Control.Monad.IO.Class (MonadIO, liftIO) | 35 | import Control.Monad.IO.Class (MonadIO, liftIO) |
36 | import Data.Function ((&)) | 36 | import Data.Function ((&)) |
37 | import Data.Maybe (mapMaybe, catMaybes) | 37 | import Data.Maybe (catMaybes) |
38 | import Data.Bool (bool) | 38 | import Data.Bool (bool) |
39 | import Data.List (find) | 39 | import Data.List (find) |
40 | import Data.Yaml (ParseException, decodeFileEither) | 40 | import Data.Yaml (ParseException, decodeFileEither) |
@@ -90,6 +90,8 @@ readSidecarFile filepath = | |||
90 | 90 | ||
91 | 91 | ||
92 | readInputTree :: AnchoredFSNode -> IO InputTree | 92 | readInputTree :: AnchoredFSNode -> IO InputTree |
93 | readInputTree (AnchoredFSNode _ File{}) = | ||
94 | throw $ AssertionFailed "Input directory is a file" | ||
93 | readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root | 95 | readInputTree (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) |