Artificial intelligent assistant

Haskell Snappy パッケージの decompress を利用した場合の例外処理について Snappy decompress decompress :: ByteString -> ByteString Decompress data in the Snappy format. If the input is not compressed or is corrupt, an exception will be thrown. `try` Left Right ghci> import Data.ByteString ghci> import Control.Exception ghci> import Codec.Compression.Snappy ghci> let bs = "test" :: ByteString ghci> decompress bs "*** Exception: user error (Codec.Compression.Snappy.decompress: corrupt input ) ghci> try (return $ decompress bs)::IO (Either SomeException ByteString) Right "*** Exception: user error (Codec.Compression.Snappy.decompress: corrupt input )

snappyHaskell


λ:2> import Control.Exception
λ:3> try (return undefined) :: IO (Either SomeException ())
Right *** Exception: Prelude.undefined


`return``try (return undefined)``undefined``Right undefined`GHCi`Right``Control.Exception.evaluate`


λ:4> try (evaluate undefined) :: IO (Either SomeException ())
Left Prelude.undefined


Real World Haskell19

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 89091131b1e593452902eba76264acdd