make YAML module less misleading

This commit is contained in:
rhiannon morris 2022-03-30 03:15:13 +02:00
parent 3e433df2fe
commit aa9f411f50

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.Event as YAML (untagged)
import Data.YAML
import Data.YAML.Event (untagged)
import Data.Text (Text)
import qualified Data.Text as Text
import Misc
@ -32,13 +32,13 @@ list = Sequence () untagged . map toYAML
-- | read a chunk from the beginning of the file between a
-- @---@ 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
ln <- BS.hGetLine h
if (ln /= "---") then
fail $ file <> ": no header"
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
-- lines read, excluding the terminator