Fix typos and clean up slightly
This commit is contained in:
parent
51317c0737
commit
38ba94f675
1 changed files with 4 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
module Mima.Vm.Storage
|
module Mima.Vm.Storage
|
||||||
(
|
(
|
||||||
-- * Methods for loading/storing Metadata
|
-- * Methods for loading/storing 'Metadata'
|
||||||
loadMetadata
|
loadMetadata
|
||||||
, saveMetadata
|
, saveMetadata
|
||||||
-- * Test methods
|
-- * Test methods
|
||||||
|
|
@ -14,12 +14,11 @@ import qualified Data.Text as T
|
||||||
import Mima.Run
|
import Mima.Run
|
||||||
import Mima.Vm.Metadata
|
import Mima.Vm.Metadata
|
||||||
|
|
||||||
-- | Loads 'Metadata' from a given file path
|
-- | Loads 'Metadata' from a given file path.
|
||||||
loadMetadata :: FilePath -> Run Metadata
|
loadMetadata :: FilePath -> Run Metadata
|
||||||
loadMetadata path = do
|
loadMetadata path = do
|
||||||
file <- readFileBS path
|
file <- readFileBS path
|
||||||
let decoded = eitherDecode (BSL.fromStrict file) :: Either String Metadata
|
case eitherDecode $ BSL.fromStrict file of
|
||||||
case decoded of
|
|
||||||
Left msg -> throw (T.pack msg)
|
Left msg -> throw (T.pack msg)
|
||||||
Right metadata -> pure metadata
|
Right metadata -> pure metadata
|
||||||
|
|
||||||
|
|
@ -27,7 +26,7 @@ loadMetadata path = do
|
||||||
saveMetadata :: FilePath -> Metadata -> Run ()
|
saveMetadata :: FilePath -> Metadata -> Run ()
|
||||||
saveMetadata path metadata = writeFileBS path (BSL.toStrict (encodePretty metadata))
|
saveMetadata path metadata = writeFileBS path (BSL.toStrict (encodePretty metadata))
|
||||||
|
|
||||||
-- | A garbage test method that resds the input file, parses it and writes the
|
-- | A garbage test method that reads the input file, parses it and writes the
|
||||||
-- prettified result back in the output file.
|
-- prettified result back in the output file.
|
||||||
--
|
--
|
||||||
-- Can be used with the example file:
|
-- Can be used with the example file:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue