module YamlUnscrambler.Util.Yaml where import qualified Conduit import qualified Data.Yaml.Parser as YamlParser import qualified Text.Libyaml as Libyaml import YamlUnscrambler.Prelude parseByteStringToRawDoc :: ByteString -> Either Text YamlParser.RawDoc parseByteStringToRawDoc :: ByteString -> Either Text RawDoc parseByteStringToRawDoc ByteString input = forall (p :: * -> * -> *) a b c. Bifunctor p => (a -> b) -> p a c -> p b c first (forall a. Monoid a => a -> a -> a mappend Text "YAML AST parsing: " forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall a. Show a => a -> Text showAsText) forall a b. (a -> b) -> a -> b $ forall a. IO a -> a unsafePerformIO forall a b. (a -> b) -> a -> b $ forall e a. Exception e => IO a -> IO (Either e a) try @SomeException forall a b. (a -> b) -> a -> b $ forall (m :: * -> *) r. MonadUnliftIO m => ConduitT () Void (ResourceT m) r -> m r Conduit.runConduitRes forall a b. (a -> b) -> a -> b $ forall (m :: * -> *) a b c r. Monad m => ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r Conduit.fuse (forall (m :: * -> *) i. MonadResource m => ByteString -> ConduitM i Event m () Libyaml.decode ByteString input) (forall (m :: * -> *) o. MonadThrow m => ConduitM Event o m RawDoc YamlParser.sinkRawDoc)