on e4e1d25 help sign in
streamly/src/Streamly/Internal/BaseCompat.hs
42 lines 913 B history raw
1-- |
2-- Module : Streamly.Internal.BaseCompat
3-- License : BSD3
4-- Maintainer : streamly@composewell.com
5-- Stability : experimental
6-- Portability : GHC
7--
8-- Compatibility functions for "base" package.
9--
10module Streamly.Internal.BaseCompat
11 (
12 (#.)
13 , errorWithoutStackTrace
14 , fromLeft
15 , fromRight
16 )
17where
19import Data.Coerce (Coercible, coerce)
20#if MIN_VERSION_base(4,10,0)
21import Data.Either (fromRight, fromLeft)
22#endif
24{-# INLINE (#.) #-}
25(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c)
26(#.) _f = coerce
28#if !(MIN_VERSION_base(4,9,0))
29{-# NOINLINE errorWithoutStackTrace #-}
30errorWithoutStackTrace :: String -> a
31errorWithoutStackTrace = error
32#endif
34#if !(MIN_VERSION_base(4,10,0))
35fromLeft :: a -> Either a b -> a
36fromLeft _ (Left a) = a
37fromLeft a _ = a
39fromRight :: b -> Either a b -> b
40fromRight _ (Right b) = b
41fromRight b _ = b
42#endif