module SubHask.Compatibility.Base
()
where
import Data.Typeable
import qualified Prelude as Base
import qualified Control.Applicative as Base
import qualified Control.Monad as Base
import Language.Haskell.TH
import Control.Arrow
import Control.Monad.Identity (Identity(..))
import Control.Monad.Reader (Reader,ReaderT)
import Control.Monad.State.Strict (State,StateT)
import Control.Monad.Trans
import Control.Monad.ST (ST)
import GHC.Conc.Sync
import GHC.GHCi
import Text.ParserCombinators.ReadP
import Text.ParserCombinators.ReadPrec
import Control.Monad.Random
import SubHask.Algebra
import SubHask.Category
import SubHask.Monad
import SubHask.Internal.Prelude
import SubHask.TemplateHaskell.Base
import SubHask.TemplateHaskell.Deriving
instance Functor Hask NoIO where fmap = Base.liftM
dummy1 = undefined :: Identity a
dummy2 = undefined :: StateT s m a
dummy3 = undefined :: ReaderT s m a
forAllInScope ''Base.Functor mkPreludeFunctor
forAllInScope ''Base.Monad mkPreludeMonad
mkMutable [t| forall a. IO a |]
instance Semigroup a => Semigroup (IO a) where
(+) = liftM2 (+)
instance Monoid a => Monoid (IO a) where
zero = return zero
type instance Logic TypeRep = Bool
instance Eq_ TypeRep where
(==) = (Base.==)
instance POrd_ TypeRep where
inf x y = case Base.compare x y of
LT -> x
_ -> y
instance Lattice_ TypeRep where
sup x y = case Base.compare x y of
GT -> x
_ -> y
instance Ord_ TypeRep where compare = Base.compare
mkMutable [t| forall a b. Either a b |]
instance (Semigroup b) => Semigroup (Either a b) where
(Left a) + _ = Left a
_ + (Left a) = Left a
(Right b1)+(Right b2) = Right $ b1+b2
instance (Monoid b) => Monoid (Either a b) where
zero = Right zero
instance Base.Functor Maybe' where
fmap = fmap
instance Base.Applicative Maybe'
instance Base.Monad Maybe' where
return = Just'
Nothing' >>= f = Nothing'
(Just' a) >>= f = f a
instance Functor Hask Maybe' where
fmap f Nothing' = Nothing'
fmap f (Just' a) = Just' $ f a
instance Then Maybe' where
Nothing' >> _ = Nothing'
_ >> a = a
instance Monad Hask Maybe' where
return_ = Just'
join Nothing' = Nothing'
join (Just' Nothing') = Nothing'
join (Just' (Just' a)) = Just' a