Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Data/Aeson.hs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ decodeStrict = decodeStrictWith jsonEOF fromJSON
--
-- This function parses immediately, but defers conversion. See
-- 'json' for details.
--
-- Throws an 'Exception' when the file is missing.
decodeFileStrict :: (FromJSON a) => FilePath -> IO (Maybe a)
decodeFileStrict = fmap decodeStrict . B.readFile

Expand Down Expand Up @@ -257,6 +259,8 @@ decodeStrict' = decodeStrictWith jsonEOF' fromJSON
--
-- This function parses and performs conversion immediately. See
-- 'json'' for details.
--
-- Throws an 'Exception' when the file is missing.
decodeFileStrict' :: (FromJSON a) => FilePath -> IO (Maybe a)
decodeFileStrict' = fmap decodeStrict' . B.readFile

Expand All @@ -276,6 +280,8 @@ eitherDecodeStrict =
{-# INLINE eitherDecodeStrict #-}

-- | Like 'decodeFileStrict' but returns an error message when decoding fails.
--
-- Throws an 'Exception' when the file is missing.
eitherDecodeFileStrict :: (FromJSON a) => FilePath -> IO (Either String a)
eitherDecodeFileStrict =
fmap eitherDecodeStrict . B.readFile
Expand All @@ -293,6 +299,8 @@ eitherDecodeStrict' =
{-# INLINE eitherDecodeStrict' #-}

-- | Like 'decodeFileStrict'' but returns an error message when decoding fails.
--
-- Throws an 'Exception' when the file is missing.
eitherDecodeFileStrict' :: (FromJSON a) => FilePath -> IO (Either String a)
eitherDecodeFileStrict' =
fmap eitherDecodeStrict' . B.readFile
Expand Down