Skip to content
Merged
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
20 changes: 16 additions & 4 deletions src/Data/Aeson.hs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ encodeFile fp = L.writeFile fp . encode
-- This function parses immediately, but defers conversion. See
-- 'json' for details.
--
-- Throws an 'Exception' when the file is missing.
-- Throws an exception when the file cannot be accessed
-- (e.g., it is missing or permissions are invalid).
-- This function uses 'Data.ByteString.readFile' without handling
-- any of its exceptions.
decodeFileStrict :: (FromJSON a) => FilePath -> IO (Maybe a)
decodeFileStrict = fmap decodeStrict . B.readFile

Expand Down Expand Up @@ -228,15 +231,21 @@ decodeStrict' = decodeStrict
-- If this fails due to incomplete or invalid input, 'Nothing' is
-- returned.
--
-- Throws an 'Exception' when the file is missing.
-- Throws an exception when the file cannot be accessed
-- (e.g., it is missing or permissions are invalid).
-- This function uses 'Data.ByteString.readFile' without handling
-- any of its exceptions.
--
-- Since @2.2.0.0@ an alias for 'decodeFileStrict'.
decodeFileStrict' :: (FromJSON a) => FilePath -> IO (Maybe a)
decodeFileStrict' = decodeFileStrict

-- | Like 'decodeFileStrict' but returns an error message when decoding fails.
--
-- Throws an 'Exception' when the file is missing.
-- Throws an exception when the file cannot be accessed
-- (e.g., it is missing or permissions are invalid).
-- This function uses 'Data.ByteString.readFile' without handling
-- any of its exceptions.
eitherDecodeFileStrict :: (FromJSON a) => FilePath -> IO (Either String a)
eitherDecodeFileStrict =
fmap eitherDecodeStrict . B.readFile
Expand All @@ -258,7 +267,10 @@ eitherDecodeStrict' = eitherDecodeStrict

-- | Like 'decodeFileStrict'' but returns an error message when decoding fails.
--
-- Throws an 'Exception' when the file is missing.
-- Throws an exception when the file cannot be accessed
-- (e.g., it is missing or permissions are invalid).
-- This function uses 'Data.ByteString.readFile' without handling
-- any of its exceptions.
--
-- Since @2.2.0.0@ an alias for 'eitherDecodeFileStrict'.
eitherDecodeFileStrict' :: (FromJSON a) => FilePath -> IO (Either String a)
Expand Down