Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Haskell
Cabal
Commits
b31dce66
Commit
b31dce66
authored
10 years ago
by
ttuegel
Browse files
Options
Downloads
Patches
Plain Diff
D.Compat.Binary: catch all ErrorCall in decodeOrFailIO
parent
3c0e6480
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cabal/Distribution/Compat/Binary.hs
+7
-12
7 additions, 12 deletions
Cabal/Distribution/Compat/Binary.hs
with
7 additions
and
12 deletions
Cabal/Distribution/Compat/Binary.hs
+
7
−
12
View file @
b31dce66
...
...
@@ -14,26 +14,21 @@ module Distribution.Compat.Binary
#
endif
)
where
import
Control.Exception
(
ErrorCall
(
..
),
catch
,
evaluate
)
import
Data.ByteString.Lazy
(
ByteString
)
#
if
__GLASGOW_HASKELL__
<
706
import
Prelude
hiding
(
catch
)
#
endif
#
if
__GLASGOW_HASKELL__
>=
708
||
MIN_VERSION_binary
(
0
,
7
,
0
)
import
Data.Binary
decodeOrFailIO
::
Binary
a
=>
ByteString
->
IO
(
Either
String
a
)
decodeOrFailIO
bs
=
return
$
case
decodeOrFail
bs
of
Left
(
_
,
_
,
msg
)
->
Left
msg
Right
(
_
,
_
,
a
)
->
Right
a
#
else
import
Control.Exception
(
ErrorCall
(
..
),
catch
,
evaluate
)
import
Data.Binary.Get
import
Data.Binary.Put
#
if
__GLASGOW_HASKELL__
<
706
import
Prelude
hiding
(
catch
)
#
endif
import
Distribution.Compat.Binary.Class
import
Distribution.Compat.Binary.Generic
()
...
...
@@ -49,9 +44,9 @@ encode :: Binary a => a -> ByteString
encode
=
runPut
.
put
{-# INLINE encode #-}
#
endif
decodeOrFailIO
::
Binary
a
=>
ByteString
->
IO
(
Either
String
a
)
decodeOrFailIO
bs
=
catch
(
evaluate
(
decode
bs
)
>>=
return
.
Right
)
$
\
(
ErrorCall
str
)
->
return
$
Left
str
#
endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment