module CfnFlip.Aeson
  ( eitherDecodeFileStrictThrow
  , module Data.Aeson
  ) where

import CfnFlip.Prelude

import Data.Aeson

eitherDecodeFileStrictThrow :: (MonadIO m, FromJSON a) => FilePath -> m a
eitherDecodeFileStrictThrow :: FilePath -> m a
eitherDecodeFileStrictThrow FilePath
path = do
  Either FilePath a
result <- IO (Either FilePath a) -> m (Either FilePath a)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Either FilePath a) -> m (Either FilePath a))
-> IO (Either FilePath a) -> m (Either FilePath a)
forall a b. (a -> b) -> a -> b
$ FilePath -> IO (Either FilePath a)
forall a. FromJSON a => FilePath -> IO (Either FilePath a)
eitherDecodeFileStrict FilePath
path
  (FilePath -> m a) -> (a -> m a) -> Either FilePath a -> m a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either FilePath -> m a
forall (m :: * -> *) a.
(MonadIO m, HasCallStack) =>
FilePath -> m a
throwString a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Either FilePath a
result