@@ -6,6 +6,7 @@
66{-# LANGUAGE DataKinds #-}
77{-# LANGUAGE PolyKinds #-}
88{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9+{-# LANGUAGE MagicHash #-}
910
1011-- | See "Control.Monad.Trans.Except".
1112
@@ -24,6 +25,7 @@ module Control.Monad.Trans.Ether.Except
2425 , catch
2526 ) where
2627
28+import GHC.Prim (Proxy#)
2729import Data.Functor.Identity (Identity(..))
2830import qualified Control.Monad.Trans.Except as Trans
2931import Control.Monad.Trans.Ether.Tagged
@@ -38,7 +40,7 @@ import Control.Monad.Trans.Ether.Tagged
3840type Except tag e = ExceptT tag e Identity
3941
4042-- | Runs an 'Except' and returns either an exception or a normal value.
41−runExcept :: proxy tag -> Except tag e a -> Either e a
43+runExcept :: Proxy# tag -> Except tag e a -> Either e a
4244runExcept _ = Trans.runExcept . unpack
4345
4446-- | The exception monad transformer.
@@ -48,22 +50,22 @@ runExcept _ = Trans.runExcept . unpack
4850type ExceptT tag e = TaggedTrans tag (Trans.ExceptT e)
4951
5052-- | Constructor for computations in the exception monad transformer.
51−exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a
53+exceptT :: Proxy# tag -> m (Either e a) -> ExceptT tag e m a
5254exceptT _ = pack . Trans.ExceptT
5355
5456-- | Constructor for computations in the exception monad
5557-- (the inverse of 'runExcept').
56−except :: Monad m => proxy tag -> Either e a -> ExceptT tag e m a
58+except :: Monad m => Proxy# tag -> Either e a -> ExceptT tag e m a
5759except t = exceptT t . return
5860
5961-- | Runs an 'ExceptT' and returns either an exception or a normal value.
60−runExceptT :: proxy tag -> ExceptT tag e m a -> m (Either e a)
62+runExceptT :: Proxy# tag -> ExceptT tag e m a -> m (Either e a)
6163runExceptT _ = Trans.runExceptT . unpack
6264
6365-- | Is used within a monadic computation to begin exception processing.
64−throw :: Monad m => proxy tag -> e -> ExceptT tag e m a
66+throw :: Monad m => Proxy# tag -> e -> ExceptT tag e m a
6567throw _ = pack . Trans.throwE
6668
6769-- | A handler function to handle previous exceptions and return to normal execution.
68−catch :: Monad m => proxy tag -> ExceptT tag e m a -> (e -> ExceptT tag e m a) -> ExceptT tag e m a
70+catch :: Monad m => Proxy# tag -> ExceptT tag e m a -> (e -> ExceptT tag e m a) -> ExceptT tag e m a
6971catch _ m h = pack $ Trans.catchE (unpack m) (unpack . h)