make YAML module less misleading

This commit is contained in:
rhiannon morris 2022-03-30 03:15:13 +02:00
parent 3e433df2fe
commit aa9f411f50
1 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
module YAML (module YAML) where module YAML (module YAML, module Data.YAML, untagged) where
import Data.YAML as YAML import Data.YAML
import Data.YAML.Event as YAML (untagged) import Data.YAML.Event (untagged)
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text import qualified Data.Text as Text
import Misc import Misc
@ -32,13 +32,13 @@ list = Sequence () untagged . map toYAML
-- | read a chunk from the beginning of the file between a -- | read a chunk from the beginning of the file between a
-- @---@ and a @...@. throw an exception if there isn't one -- @---@ and a @...@. throw an exception if there isn't one
readHeader :: FilePath -> IO (YAML.Node YAML.Pos) readHeader :: FilePath -> IO (Node Pos)
readHeader file = IO.withFile file IO.ReadMode \h -> do readHeader file = IO.withFile file IO.ReadMode \h -> do
ln <- BS.hGetLine h ln <- BS.hGetLine h
if (ln /= "---") then if (ln /= "---") then
fail $ file <> ": no header" fail $ file <> ": no header"
else else
unwrap file . YAML.decode1 =<< linesUntil "..." h unwrap file . decode1 =<< linesUntil "..." h
-- | read all the lines from a handle until the given terminator. return the -- | read all the lines from a handle until the given terminator. return the
-- lines read, excluding the terminator -- lines read, excluding the terminator