diff options
Diffstat (limited to 'lib/Data/Packed/Internal')
-rw-r--r-- | lib/Data/Packed/Internal/Common.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Data/Packed/Internal/Common.hs b/lib/Data/Packed/Internal/Common.hs index bfa63f1..455b176 100644 --- a/lib/Data/Packed/Internal/Common.hs +++ b/lib/Data/Packed/Internal/Common.hs | |||
@@ -17,7 +17,7 @@ | |||
17 | module Data.Packed.Internal.Common( | 17 | module Data.Packed.Internal.Common( |
18 | Adapt, | 18 | Adapt, |
19 | app1, app2, app3, app4, | 19 | app1, app2, app3, app4, |
20 | (//), check, | 20 | (//), check, mbCatch, |
21 | splitEvery, common, compatdim, | 21 | splitEvery, common, compatdim, |
22 | fi, | 22 | fi, |
23 | table | 23 | table |
@@ -29,6 +29,7 @@ import Foreign.C.String(peekCString) | |||
29 | import Foreign.C.Types | 29 | import Foreign.C.Types |
30 | import Foreign.Storable.Complex() | 30 | import Foreign.Storable.Complex() |
31 | import Data.List(transpose,intersperse) | 31 | import Data.List(transpose,intersperse) |
32 | import Control.Exception as E | ||
32 | 33 | ||
33 | -- | @splitEvery 3 [1..9] == [[1,2,3],[4,5,6],[7,8,9]]@ | 34 | -- | @splitEvery 3 [1..9] == [[1,2,3],[4,5,6],[7,8,9]]@ |
34 | splitEvery :: Int -> [a] -> [[a]] | 35 | splitEvery :: Int -> [a] -> [[a]] |
@@ -151,3 +152,9 @@ check msg f = do | |||
151 | 152 | ||
152 | -- | description of GSL error codes | 153 | -- | description of GSL error codes |
153 | foreign import ccall "auxi.h gsl_strerror" gsl_strerror :: CInt -> IO (Ptr CChar) | 154 | foreign import ccall "auxi.h gsl_strerror" gsl_strerror :: CInt -> IO (Ptr CChar) |
155 | |||
156 | -- | Error capture and conversion to Maybe | ||
157 | mbCatch :: IO x -> IO (Maybe x) | ||
158 | mbCatch act = E.catch (Just `fmap` act) f | ||
159 | where f :: SomeException -> IO (Maybe x) | ||
160 | f _ = return Nothing | ||