{-# LANGUAGE LambdaCase #-}

{-|
See "KDL" for more information.
-}
module KDL.Decoder.Monad (
  -- * Monad-specific definitions
  fail,

  -- * Re-exports from "KDL.Decoder.Arrow"
  module KDL.Decoder.Arrow,
) where

import Control.Arrow (arr, (>>>))
import Data.Text (Text)
import KDL.Decoder.Arrow hiding (
  fail,
 )
import KDL.Decoder.Arrow qualified as Arrow
import Prelude hiding (any, fail, null)

-- | Same as 'KDL.Decoder.Arrow.fail', except a more ergonomic signature
-- for use in do-notation.
fail :: forall a o. Text -> Decoder o a
fail :: forall a o. Text -> Decoder o a
fail Text
msg = (() -> Text) -> DecodeArrow o () Text
forall b c. (b -> c) -> DecodeArrow o b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (\() -> Text
msg) DecodeArrow o () Text -> DecodeArrow o Text a -> DecodeArrow o () a
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> DecodeArrow o Text a
forall b o. DecodeArrow o Text b
Arrow.fail