{-# options_haddock hide #-}
{-# language NoImplicitPrelude #-}

module Polysemy.Conc.Prelude (
  module Data.Kind,
  module Polysemy.Conc.Prelude,
  module GHC.Err,
  module Polysemy,
  module Polysemy.AtomicState,
  module Relude,
) where

import Control.Exception (try)
import Data.Kind (Type)
import qualified Data.String.Interpolate as Interpolate
import GHC.Err (undefined)
import Language.Haskell.TH.Quote (QuasiQuoter)
import Polysemy (
  Effect,
  EffectRow,
  Embed,
  Final,
  InterpreterFor,
  Member,
  Members,
  Sem,
  WithTactics,
  embed,
  embedToFinal,
  interpret,
  interpretH,
  makeSem,
  pureT,
  raise,
  raiseUnder,
  raiseUnder2,
  raiseUnder3,
  reinterpret,
  runFinal,
  )
import Polysemy.AtomicState (AtomicState, atomicGet, atomicGets, atomicModify', atomicPut)
import Polysemy.Internal.Kind (Append)
import Relude hiding (
  Reader,
  State,
  Sum,
  Type,
  ask,
  asks,
  evalState,
  filterM,
  get,
  gets,
  hoistEither,
  modify,
  modify',
  put,
  readFile,
  runReader,
  runState,
  state,
  trace,
  traceShow,
  undefined,
  )

qt :: QuasiQuoter
qt :: QuasiQuoter
qt =
  QuasiQuoter
Interpolate.i
{-# inline qt #-}

unify :: Either a a -> a
unify :: Either a a -> a
unify =
  (a -> a) -> (a -> a) -> Either a a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
{-# inline unify #-}

tryAny ::
  Member (Embed IO) r =>
  IO a ->
  Sem r (Either Text a)
tryAny :: IO a -> Sem r (Either Text a)
tryAny =
  forall (r :: [(* -> *) -> * -> *]) a.
Member (Embed IO) r =>
IO a -> Sem r a
forall (m :: * -> *) (r :: [(* -> *) -> * -> *]) a.
Member (Embed m) r =>
m a -> Sem r a
embed @IO (IO (Either Text a) -> Sem r (Either Text a))
-> (IO a -> IO (Either Text a)) -> IO a -> Sem r (Either Text a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Either SomeException a -> Either Text a)
-> IO (Either SomeException a) -> IO (Either Text a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((SomeException -> Text) -> Either SomeException a -> Either Text a
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first SomeException -> Text
forall b a. (Show a, IsString b) => a -> b
show) (IO (Either SomeException a) -> IO (Either Text a))
-> (IO a -> IO (Either SomeException a))
-> IO a
-> IO (Either Text a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
Exception SomeException =>
IO a -> IO (Either SomeException a)
forall e a. Exception e => IO a -> IO (Either e a)
try @SomeException
{-# INLINE tryAny #-}

type a ++ b =
  Append a b

leftM ::
  Applicative m =>
  m b ->
  Either a b ->
  m b
leftM :: m b -> Either a b -> m b
leftM m b
f =
  (a -> m b) -> (b -> m b) -> Either a b -> m b
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (m b -> a -> m b
forall a b. a -> b -> a
const m b
f) b -> m b
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# inline leftM #-}