{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DeriveTraversable #-}
module HIE.Bios.Types where
import System.Exit
import qualified Colog.Core as L
import Control.Exception ( Exception )
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
#if MIN_VERSION_base(4,9,0)
import qualified Control.Monad.Fail as Fail
#endif
import Data.Text.Prettyprint.Doc
data BIOSVerbosity = Silent | Verbose
data Cradle a = Cradle {
Cradle a -> FilePath
cradleRootDir :: FilePath
, Cradle a -> CradleAction a
cradleOptsProg :: CradleAction a
} deriving (Int -> Cradle a -> ShowS
[Cradle a] -> ShowS
Cradle a -> FilePath
(Int -> Cradle a -> ShowS)
-> (Cradle a -> FilePath)
-> ([Cradle a] -> ShowS)
-> Show (Cradle a)
forall a. Show a => Int -> Cradle a -> ShowS
forall a. Show a => [Cradle a] -> ShowS
forall a. Show a => Cradle a -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Cradle a] -> ShowS
$cshowList :: forall a. Show a => [Cradle a] -> ShowS
show :: Cradle a -> FilePath
$cshow :: forall a. Show a => Cradle a -> FilePath
showsPrec :: Int -> Cradle a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Cradle a -> ShowS
Show, a -> Cradle b -> Cradle a
(a -> b) -> Cradle a -> Cradle b
(forall a b. (a -> b) -> Cradle a -> Cradle b)
-> (forall a b. a -> Cradle b -> Cradle a) -> Functor Cradle
forall a b. a -> Cradle b -> Cradle a
forall a b. (a -> b) -> Cradle a -> Cradle b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Cradle b -> Cradle a
$c<$ :: forall a b. a -> Cradle b -> Cradle a
fmap :: (a -> b) -> Cradle a -> Cradle b
$cfmap :: forall a b. (a -> b) -> Cradle a -> Cradle b
Functor)
data ActionName a
= Stack
| Cabal
| Bios
| Default
| Multi
| Direct
| None
| Other a
deriving (Int -> ActionName a -> ShowS
[ActionName a] -> ShowS
ActionName a -> FilePath
(Int -> ActionName a -> ShowS)
-> (ActionName a -> FilePath)
-> ([ActionName a] -> ShowS)
-> Show (ActionName a)
forall a. Show a => Int -> ActionName a -> ShowS
forall a. Show a => [ActionName a] -> ShowS
forall a. Show a => ActionName a -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [ActionName a] -> ShowS
$cshowList :: forall a. Show a => [ActionName a] -> ShowS
show :: ActionName a -> FilePath
$cshow :: forall a. Show a => ActionName a -> FilePath
showsPrec :: Int -> ActionName a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> ActionName a -> ShowS
Show, ActionName a -> ActionName a -> Bool
(ActionName a -> ActionName a -> Bool)
-> (ActionName a -> ActionName a -> Bool) -> Eq (ActionName a)
forall a. Eq a => ActionName a -> ActionName a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionName a -> ActionName a -> Bool
$c/= :: forall a. Eq a => ActionName a -> ActionName a -> Bool
== :: ActionName a -> ActionName a -> Bool
$c== :: forall a. Eq a => ActionName a -> ActionName a -> Bool
Eq, Eq (ActionName a)
Eq (ActionName a)
-> (ActionName a -> ActionName a -> Ordering)
-> (ActionName a -> ActionName a -> Bool)
-> (ActionName a -> ActionName a -> Bool)
-> (ActionName a -> ActionName a -> Bool)
-> (ActionName a -> ActionName a -> Bool)
-> (ActionName a -> ActionName a -> ActionName a)
-> (ActionName a -> ActionName a -> ActionName a)
-> Ord (ActionName a)
ActionName a -> ActionName a -> Bool
ActionName a -> ActionName a -> Ordering
ActionName a -> ActionName a -> ActionName a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (ActionName a)
forall a. Ord a => ActionName a -> ActionName a -> Bool
forall a. Ord a => ActionName a -> ActionName a -> Ordering
forall a. Ord a => ActionName a -> ActionName a -> ActionName a
min :: ActionName a -> ActionName a -> ActionName a
$cmin :: forall a. Ord a => ActionName a -> ActionName a -> ActionName a
max :: ActionName a -> ActionName a -> ActionName a
$cmax :: forall a. Ord a => ActionName a -> ActionName a -> ActionName a
>= :: ActionName a -> ActionName a -> Bool
$c>= :: forall a. Ord a => ActionName a -> ActionName a -> Bool
> :: ActionName a -> ActionName a -> Bool
$c> :: forall a. Ord a => ActionName a -> ActionName a -> Bool
<= :: ActionName a -> ActionName a -> Bool
$c<= :: forall a. Ord a => ActionName a -> ActionName a -> Bool
< :: ActionName a -> ActionName a -> Bool
$c< :: forall a. Ord a => ActionName a -> ActionName a -> Bool
compare :: ActionName a -> ActionName a -> Ordering
$ccompare :: forall a. Ord a => ActionName a -> ActionName a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (ActionName a)
Ord, a -> ActionName b -> ActionName a
(a -> b) -> ActionName a -> ActionName b
(forall a b. (a -> b) -> ActionName a -> ActionName b)
-> (forall a b. a -> ActionName b -> ActionName a)
-> Functor ActionName
forall a b. a -> ActionName b -> ActionName a
forall a b. (a -> b) -> ActionName a -> ActionName b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> ActionName b -> ActionName a
$c<$ :: forall a b. a -> ActionName b -> ActionName a
fmap :: (a -> b) -> ActionName a -> ActionName b
$cfmap :: forall a b. (a -> b) -> ActionName a -> ActionName b
Functor)
data Log =
LogAny String
| LogProcessOutput String
deriving Int -> Log -> ShowS
[Log] -> ShowS
Log -> FilePath
(Int -> Log -> ShowS)
-> (Log -> FilePath) -> ([Log] -> ShowS) -> Show Log
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Log] -> ShowS
$cshowList :: [Log] -> ShowS
show :: Log -> FilePath
$cshow :: Log -> FilePath
showsPrec :: Int -> Log -> ShowS
$cshowsPrec :: Int -> Log -> ShowS
Show
instance Pretty Log where
pretty :: Log -> Doc ann
pretty (LogAny FilePath
s) = FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
s
pretty (LogProcessOutput FilePath
s) = FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
s
data CradleAction a = CradleAction {
CradleAction a -> ActionName a
actionName :: ActionName a
, CradleAction a
-> LogAction IO (WithSeverity Log)
-> FilePath
-> IO (CradleLoadResult ComponentOptions)
runCradle :: L.LogAction IO (L.WithSeverity Log) -> FilePath -> IO (CradleLoadResult ComponentOptions)
, CradleAction a -> [FilePath] -> IO (CradleLoadResult FilePath)
runGhcCmd :: [String] -> IO (CradleLoadResult String)
}
deriving (a -> CradleAction b -> CradleAction a
(a -> b) -> CradleAction a -> CradleAction b
(forall a b. (a -> b) -> CradleAction a -> CradleAction b)
-> (forall a b. a -> CradleAction b -> CradleAction a)
-> Functor CradleAction
forall a b. a -> CradleAction b -> CradleAction a
forall a b. (a -> b) -> CradleAction a -> CradleAction b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> CradleAction b -> CradleAction a
$c<$ :: forall a b. a -> CradleAction b -> CradleAction a
fmap :: (a -> b) -> CradleAction a -> CradleAction b
$cfmap :: forall a b. (a -> b) -> CradleAction a -> CradleAction b
Functor)
instance Show a => Show (CradleAction a) where
show :: CradleAction a -> FilePath
show CradleAction { actionName :: forall a. CradleAction a -> ActionName a
actionName = ActionName a
name } = FilePath
"CradleAction: " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ ActionName a -> FilePath
forall a. Show a => a -> FilePath
show ActionName a
name
data CradleLoadResult r
= CradleSuccess r
| CradleFail CradleError
| CradleNone
deriving (a -> CradleLoadResult b -> CradleLoadResult a
(a -> b) -> CradleLoadResult a -> CradleLoadResult b
(forall a b. (a -> b) -> CradleLoadResult a -> CradleLoadResult b)
-> (forall a b. a -> CradleLoadResult b -> CradleLoadResult a)
-> Functor CradleLoadResult
forall a b. a -> CradleLoadResult b -> CradleLoadResult a
forall a b. (a -> b) -> CradleLoadResult a -> CradleLoadResult b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> CradleLoadResult b -> CradleLoadResult a
$c<$ :: forall a b. a -> CradleLoadResult b -> CradleLoadResult a
fmap :: (a -> b) -> CradleLoadResult a -> CradleLoadResult b
$cfmap :: forall a b. (a -> b) -> CradleLoadResult a -> CradleLoadResult b
Functor, CradleLoadResult a -> Bool
(a -> m) -> CradleLoadResult a -> m
(a -> b -> b) -> b -> CradleLoadResult a -> b
(forall m. Monoid m => CradleLoadResult m -> m)
-> (forall m a. Monoid m => (a -> m) -> CradleLoadResult a -> m)
-> (forall m a. Monoid m => (a -> m) -> CradleLoadResult a -> m)
-> (forall a b. (a -> b -> b) -> b -> CradleLoadResult a -> b)
-> (forall a b. (a -> b -> b) -> b -> CradleLoadResult a -> b)
-> (forall b a. (b -> a -> b) -> b -> CradleLoadResult a -> b)
-> (forall b a. (b -> a -> b) -> b -> CradleLoadResult a -> b)
-> (forall a. (a -> a -> a) -> CradleLoadResult a -> a)
-> (forall a. (a -> a -> a) -> CradleLoadResult a -> a)
-> (forall a. CradleLoadResult a -> [a])
-> (forall a. CradleLoadResult a -> Bool)
-> (forall a. CradleLoadResult a -> Int)
-> (forall a. Eq a => a -> CradleLoadResult a -> Bool)
-> (forall a. Ord a => CradleLoadResult a -> a)
-> (forall a. Ord a => CradleLoadResult a -> a)
-> (forall a. Num a => CradleLoadResult a -> a)
-> (forall a. Num a => CradleLoadResult a -> a)
-> Foldable CradleLoadResult
forall a. Eq a => a -> CradleLoadResult a -> Bool
forall a. Num a => CradleLoadResult a -> a
forall a. Ord a => CradleLoadResult a -> a
forall m. Monoid m => CradleLoadResult m -> m
forall a. CradleLoadResult a -> Bool
forall a. CradleLoadResult a -> Int
forall a. CradleLoadResult a -> [a]
forall a. (a -> a -> a) -> CradleLoadResult a -> a
forall m a. Monoid m => (a -> m) -> CradleLoadResult a -> m
forall b a. (b -> a -> b) -> b -> CradleLoadResult a -> b
forall a b. (a -> b -> b) -> b -> CradleLoadResult a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: CradleLoadResult a -> a
$cproduct :: forall a. Num a => CradleLoadResult a -> a
sum :: CradleLoadResult a -> a
$csum :: forall a. Num a => CradleLoadResult a -> a
minimum :: CradleLoadResult a -> a
$cminimum :: forall a. Ord a => CradleLoadResult a -> a
maximum :: CradleLoadResult a -> a
$cmaximum :: forall a. Ord a => CradleLoadResult a -> a
elem :: a -> CradleLoadResult a -> Bool
$celem :: forall a. Eq a => a -> CradleLoadResult a -> Bool
length :: CradleLoadResult a -> Int
$clength :: forall a. CradleLoadResult a -> Int
null :: CradleLoadResult a -> Bool
$cnull :: forall a. CradleLoadResult a -> Bool
toList :: CradleLoadResult a -> [a]
$ctoList :: forall a. CradleLoadResult a -> [a]
foldl1 :: (a -> a -> a) -> CradleLoadResult a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> CradleLoadResult a -> a
foldr1 :: (a -> a -> a) -> CradleLoadResult a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> CradleLoadResult a -> a
foldl' :: (b -> a -> b) -> b -> CradleLoadResult a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> CradleLoadResult a -> b
foldl :: (b -> a -> b) -> b -> CradleLoadResult a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> CradleLoadResult a -> b
foldr' :: (a -> b -> b) -> b -> CradleLoadResult a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> CradleLoadResult a -> b
foldr :: (a -> b -> b) -> b -> CradleLoadResult a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> CradleLoadResult a -> b
foldMap' :: (a -> m) -> CradleLoadResult a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> CradleLoadResult a -> m
foldMap :: (a -> m) -> CradleLoadResult a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> CradleLoadResult a -> m
fold :: CradleLoadResult m -> m
$cfold :: forall m. Monoid m => CradleLoadResult m -> m
Foldable, Functor CradleLoadResult
Foldable CradleLoadResult
Functor CradleLoadResult
-> Foldable CradleLoadResult
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CradleLoadResult a -> f (CradleLoadResult b))
-> (forall (f :: * -> *) a.
Applicative f =>
CradleLoadResult (f a) -> f (CradleLoadResult a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CradleLoadResult a -> m (CradleLoadResult b))
-> (forall (m :: * -> *) a.
Monad m =>
CradleLoadResult (m a) -> m (CradleLoadResult a))
-> Traversable CradleLoadResult
(a -> f b) -> CradleLoadResult a -> f (CradleLoadResult b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
CradleLoadResult (m a) -> m (CradleLoadResult a)
forall (f :: * -> *) a.
Applicative f =>
CradleLoadResult (f a) -> f (CradleLoadResult a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CradleLoadResult a -> m (CradleLoadResult b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CradleLoadResult a -> f (CradleLoadResult b)
sequence :: CradleLoadResult (m a) -> m (CradleLoadResult a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
CradleLoadResult (m a) -> m (CradleLoadResult a)
mapM :: (a -> m b) -> CradleLoadResult a -> m (CradleLoadResult b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CradleLoadResult a -> m (CradleLoadResult b)
sequenceA :: CradleLoadResult (f a) -> f (CradleLoadResult a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
CradleLoadResult (f a) -> f (CradleLoadResult a)
traverse :: (a -> f b) -> CradleLoadResult a -> f (CradleLoadResult b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CradleLoadResult a -> f (CradleLoadResult b)
$cp2Traversable :: Foldable CradleLoadResult
$cp1Traversable :: Functor CradleLoadResult
Traversable, Int -> CradleLoadResult r -> ShowS
[CradleLoadResult r] -> ShowS
CradleLoadResult r -> FilePath
(Int -> CradleLoadResult r -> ShowS)
-> (CradleLoadResult r -> FilePath)
-> ([CradleLoadResult r] -> ShowS)
-> Show (CradleLoadResult r)
forall r. Show r => Int -> CradleLoadResult r -> ShowS
forall r. Show r => [CradleLoadResult r] -> ShowS
forall r. Show r => CradleLoadResult r -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [CradleLoadResult r] -> ShowS
$cshowList :: forall r. Show r => [CradleLoadResult r] -> ShowS
show :: CradleLoadResult r -> FilePath
$cshow :: forall r. Show r => CradleLoadResult r -> FilePath
showsPrec :: Int -> CradleLoadResult r -> ShowS
$cshowsPrec :: forall r. Show r => Int -> CradleLoadResult r -> ShowS
Show, CradleLoadResult r -> CradleLoadResult r -> Bool
(CradleLoadResult r -> CradleLoadResult r -> Bool)
-> (CradleLoadResult r -> CradleLoadResult r -> Bool)
-> Eq (CradleLoadResult r)
forall r. Eq r => CradleLoadResult r -> CradleLoadResult r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CradleLoadResult r -> CradleLoadResult r -> Bool
$c/= :: forall r. Eq r => CradleLoadResult r -> CradleLoadResult r -> Bool
== :: CradleLoadResult r -> CradleLoadResult r -> Bool
$c== :: forall r. Eq r => CradleLoadResult r -> CradleLoadResult r -> Bool
Eq)
cradleLoadResult :: c -> (CradleError -> c) -> (r -> c) -> CradleLoadResult r -> c
cradleLoadResult :: c -> (CradleError -> c) -> (r -> c) -> CradleLoadResult r -> c
cradleLoadResult c
c CradleError -> c
_ r -> c
_ CradleLoadResult r
CradleNone = c
c
cradleLoadResult c
_ CradleError -> c
f r -> c
_ (CradleFail CradleError
e) = CradleError -> c
f CradleError
e
cradleLoadResult c
_ CradleError -> c
_ r -> c
f (CradleSuccess r
r) = r -> c
f r
r
instance Applicative CradleLoadResult where
pure :: a -> CradleLoadResult a
pure = a -> CradleLoadResult a
forall a. a -> CradleLoadResult a
CradleSuccess
CradleSuccess a -> b
a <*> :: CradleLoadResult (a -> b)
-> CradleLoadResult a -> CradleLoadResult b
<*> CradleSuccess a
b = b -> CradleLoadResult b
forall a. a -> CradleLoadResult a
CradleSuccess (a -> b
a a
b)
CradleFail CradleError
err <*> CradleLoadResult a
_ = CradleError -> CradleLoadResult b
forall r. CradleError -> CradleLoadResult r
CradleFail CradleError
err
CradleLoadResult (a -> b)
_ <*> CradleFail CradleError
err = CradleError -> CradleLoadResult b
forall r. CradleError -> CradleLoadResult r
CradleFail CradleError
err
CradleLoadResult (a -> b)
_ <*> CradleLoadResult a
_ = CradleLoadResult b
forall r. CradleLoadResult r
CradleNone
instance Monad CradleLoadResult where
return :: a -> CradleLoadResult a
return = a -> CradleLoadResult a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
CradleSuccess a
r >>= :: CradleLoadResult a
-> (a -> CradleLoadResult b) -> CradleLoadResult b
>>= a -> CradleLoadResult b
k = a -> CradleLoadResult b
k a
r
CradleFail CradleError
err >>= a -> CradleLoadResult b
_ = CradleError -> CradleLoadResult b
forall r. CradleError -> CradleLoadResult r
CradleFail CradleError
err
CradleLoadResult a
CradleNone >>= a -> CradleLoadResult b
_ = CradleLoadResult b
forall r. CradleLoadResult r
CradleNone
newtype CradleLoadResultT m a = CradleLoadResultT { CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT :: m (CradleLoadResult a) }
instance Functor f => Functor (CradleLoadResultT f) where
{-# INLINE fmap #-}
fmap :: (a -> b) -> CradleLoadResultT f a -> CradleLoadResultT f b
fmap a -> b
f = f (CradleLoadResult b) -> CradleLoadResultT f b
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (f (CradleLoadResult b) -> CradleLoadResultT f b)
-> (CradleLoadResultT f a -> f (CradleLoadResult b))
-> CradleLoadResultT f a
-> CradleLoadResultT f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((CradleLoadResult a -> CradleLoadResult b)
-> f (CradleLoadResult a) -> f (CradleLoadResult b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((CradleLoadResult a -> CradleLoadResult b)
-> f (CradleLoadResult a) -> f (CradleLoadResult b))
-> ((a -> b) -> CradleLoadResult a -> CradleLoadResult b)
-> (a -> b)
-> f (CradleLoadResult a)
-> f (CradleLoadResult b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> CradleLoadResult a -> CradleLoadResult b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) a -> b
f (f (CradleLoadResult a) -> f (CradleLoadResult b))
-> (CradleLoadResultT f a -> f (CradleLoadResult a))
-> CradleLoadResultT f a
-> f (CradleLoadResult b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CradleLoadResultT f a -> f (CradleLoadResult a)
forall (m :: * -> *) a.
CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT
instance (Monad m, Applicative m) => Applicative (CradleLoadResultT m) where
{-# INLINE pure #-}
pure :: a -> CradleLoadResultT m a
pure = m (CradleLoadResult a) -> CradleLoadResultT m a
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult a) -> CradleLoadResultT m a)
-> (a -> m (CradleLoadResult a)) -> a -> CradleLoadResultT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CradleLoadResult a -> m (CradleLoadResult a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CradleLoadResult a -> m (CradleLoadResult a))
-> (a -> CradleLoadResult a) -> a -> m (CradleLoadResult a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> CradleLoadResult a
forall a. a -> CradleLoadResult a
CradleSuccess
{-# INLINE (<*>) #-}
CradleLoadResultT m (a -> b)
x <*> :: CradleLoadResultT m (a -> b)
-> CradleLoadResultT m a -> CradleLoadResultT m b
<*> CradleLoadResultT m a
f = m (CradleLoadResult b) -> CradleLoadResultT m b
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult b) -> CradleLoadResultT m b)
-> m (CradleLoadResult b) -> CradleLoadResultT m b
forall a b. (a -> b) -> a -> b
$ do
CradleLoadResult (a -> b)
a <- CradleLoadResultT m (a -> b) -> m (CradleLoadResult (a -> b))
forall (m :: * -> *) a.
CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT CradleLoadResultT m (a -> b)
x
case CradleLoadResult (a -> b)
a of
CradleSuccess a -> b
a' -> do
CradleLoadResult a
b <- CradleLoadResultT m a -> m (CradleLoadResult a)
forall (m :: * -> *) a.
CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT CradleLoadResultT m a
f
case CradleLoadResult a
b of
CradleSuccess a
b' -> CradleLoadResult b -> m (CradleLoadResult b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (b -> CradleLoadResult b
forall a. a -> CradleLoadResult a
CradleSuccess (a -> b
a' a
b'))
CradleFail CradleError
err -> CradleLoadResult b -> m (CradleLoadResult b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CradleLoadResult b -> m (CradleLoadResult b))
-> CradleLoadResult b -> m (CradleLoadResult b)
forall a b. (a -> b) -> a -> b
$ CradleError -> CradleLoadResult b
forall r. CradleError -> CradleLoadResult r
CradleFail CradleError
err
CradleLoadResult a
CradleNone -> CradleLoadResult b -> m (CradleLoadResult b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure CradleLoadResult b
forall r. CradleLoadResult r
CradleNone
CradleFail CradleError
err -> CradleLoadResult b -> m (CradleLoadResult b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CradleLoadResult b -> m (CradleLoadResult b))
-> CradleLoadResult b -> m (CradleLoadResult b)
forall a b. (a -> b) -> a -> b
$ CradleError -> CradleLoadResult b
forall r. CradleError -> CradleLoadResult r
CradleFail CradleError
err
CradleLoadResult (a -> b)
CradleNone -> CradleLoadResult b -> m (CradleLoadResult b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure CradleLoadResult b
forall r. CradleLoadResult r
CradleNone
instance Monad m => Monad (CradleLoadResultT m) where
{-# INLINE return #-}
return :: a -> CradleLoadResultT m a
return = m (CradleLoadResult a) -> CradleLoadResultT m a
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult a) -> CradleLoadResultT m a)
-> (a -> m (CradleLoadResult a)) -> a -> CradleLoadResultT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CradleLoadResult a -> m (CradleLoadResult a)
forall (m :: * -> *) a. Monad m => a -> m a
return (CradleLoadResult a -> m (CradleLoadResult a))
-> (a -> CradleLoadResult a) -> a -> m (CradleLoadResult a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> CradleLoadResult a
forall a. a -> CradleLoadResult a
CradleSuccess
{-# INLINE (>>=) #-}
CradleLoadResultT m a
x >>= :: CradleLoadResultT m a
-> (a -> CradleLoadResultT m b) -> CradleLoadResultT m b
>>= a -> CradleLoadResultT m b
f = m (CradleLoadResult b) -> CradleLoadResultT m b
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult b) -> CradleLoadResultT m b)
-> m (CradleLoadResult b) -> CradleLoadResultT m b
forall a b. (a -> b) -> a -> b
$ do
CradleLoadResult a
val <- CradleLoadResultT m a -> m (CradleLoadResult a)
forall (m :: * -> *) a.
CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT CradleLoadResultT m a
x
case CradleLoadResult a
val of
CradleSuccess a
r -> CradleLoadResultT m b -> m (CradleLoadResult b)
forall (m :: * -> *) a.
CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT (CradleLoadResultT m b -> m (CradleLoadResult b))
-> (a -> CradleLoadResultT m b) -> a -> m (CradleLoadResult b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> CradleLoadResultT m b
f (a -> m (CradleLoadResult b)) -> a -> m (CradleLoadResult b)
forall a b. (a -> b) -> a -> b
$ a
r
CradleFail CradleError
err -> CradleLoadResult b -> m (CradleLoadResult b)
forall (m :: * -> *) a. Monad m => a -> m a
return (CradleLoadResult b -> m (CradleLoadResult b))
-> CradleLoadResult b -> m (CradleLoadResult b)
forall a b. (a -> b) -> a -> b
$ CradleError -> CradleLoadResult b
forall r. CradleError -> CradleLoadResult r
CradleFail CradleError
err
CradleLoadResult a
CradleNone -> CradleLoadResult b -> m (CradleLoadResult b)
forall (m :: * -> *) a. Monad m => a -> m a
return (CradleLoadResult b -> m (CradleLoadResult b))
-> CradleLoadResult b -> m (CradleLoadResult b)
forall a b. (a -> b) -> a -> b
$ CradleLoadResult b
forall r. CradleLoadResult r
CradleNone
#if !(MIN_VERSION_base(4,13,0))
fail = CradleLoadResultT . fail
{-# INLINE fail #-}
#endif
#if MIN_VERSION_base(4,9,0)
instance Fail.MonadFail m => Fail.MonadFail (CradleLoadResultT m) where
fail :: FilePath -> CradleLoadResultT m a
fail = m (CradleLoadResult a) -> CradleLoadResultT m a
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult a) -> CradleLoadResultT m a)
-> (FilePath -> m (CradleLoadResult a))
-> FilePath
-> CradleLoadResultT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> m (CradleLoadResult a)
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
Fail.fail
{-# INLINE fail #-}
#endif
instance MonadTrans CradleLoadResultT where
lift :: m a -> CradleLoadResultT m a
lift = m (CradleLoadResult a) -> CradleLoadResultT m a
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult a) -> CradleLoadResultT m a)
-> (m a -> m (CradleLoadResult a)) -> m a -> CradleLoadResultT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> CradleLoadResult a) -> m a -> m (CradleLoadResult a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> CradleLoadResult a
forall a. a -> CradleLoadResult a
CradleSuccess
{-# INLINE lift #-}
instance (MonadIO m) => MonadIO (CradleLoadResultT m) where
liftIO :: IO a -> CradleLoadResultT m a
liftIO = m a -> CradleLoadResultT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> CradleLoadResultT m a)
-> (IO a -> m a) -> IO a -> CradleLoadResultT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
{-# INLINE liftIO #-}
modCradleError :: Monad m => CradleLoadResultT m a -> (CradleError -> m CradleError) -> CradleLoadResultT m a
modCradleError :: CradleLoadResultT m a
-> (CradleError -> m CradleError) -> CradleLoadResultT m a
modCradleError CradleLoadResultT m a
action CradleError -> m CradleError
f = m (CradleLoadResult a) -> CradleLoadResultT m a
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult a) -> CradleLoadResultT m a)
-> m (CradleLoadResult a) -> CradleLoadResultT m a
forall a b. (a -> b) -> a -> b
$ do
CradleLoadResult a
a <- CradleLoadResultT m a -> m (CradleLoadResult a)
forall (m :: * -> *) a.
CradleLoadResultT m a -> m (CradleLoadResult a)
runCradleResultT CradleLoadResultT m a
action
case CradleLoadResult a
a of
CradleFail CradleError
err -> CradleError -> CradleLoadResult a
forall r. CradleError -> CradleLoadResult r
CradleFail (CradleError -> CradleLoadResult a)
-> m CradleError -> m (CradleLoadResult a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CradleError -> m CradleError
f CradleError
err
CradleLoadResult a
_ -> CradleLoadResult a -> m (CradleLoadResult a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure CradleLoadResult a
a
throwCE :: Monad m => CradleError -> CradleLoadResultT m a
throwCE :: CradleError -> CradleLoadResultT m a
throwCE = m (CradleLoadResult a) -> CradleLoadResultT m a
forall (m :: * -> *) a.
m (CradleLoadResult a) -> CradleLoadResultT m a
CradleLoadResultT (m (CradleLoadResult a) -> CradleLoadResultT m a)
-> (CradleError -> m (CradleLoadResult a))
-> CradleError
-> CradleLoadResultT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CradleLoadResult a -> m (CradleLoadResult a)
forall (m :: * -> *) a. Monad m => a -> m a
return (CradleLoadResult a -> m (CradleLoadResult a))
-> (CradleError -> CradleLoadResult a)
-> CradleError
-> m (CradleLoadResult a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CradleError -> CradleLoadResult a
forall r. CradleError -> CradleLoadResult r
CradleFail
data CradleError = CradleError
{ CradleError -> [FilePath]
cradleErrorDependencies :: [FilePath]
, CradleError -> ExitCode
cradleErrorExitCode :: ExitCode
, CradleError -> [FilePath]
cradleErrorStderr :: [String]
}
deriving (Int -> CradleError -> ShowS
[CradleError] -> ShowS
CradleError -> FilePath
(Int -> CradleError -> ShowS)
-> (CradleError -> FilePath)
-> ([CradleError] -> ShowS)
-> Show CradleError
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [CradleError] -> ShowS
$cshowList :: [CradleError] -> ShowS
show :: CradleError -> FilePath
$cshow :: CradleError -> FilePath
showsPrec :: Int -> CradleError -> ShowS
$cshowsPrec :: Int -> CradleError -> ShowS
Show, CradleError -> CradleError -> Bool
(CradleError -> CradleError -> Bool)
-> (CradleError -> CradleError -> Bool) -> Eq CradleError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CradleError -> CradleError -> Bool
$c/= :: CradleError -> CradleError -> Bool
== :: CradleError -> CradleError -> Bool
$c== :: CradleError -> CradleError -> Bool
Eq)
instance Exception CradleError where
data ComponentOptions = ComponentOptions {
ComponentOptions -> [FilePath]
componentOptions :: [String]
, ComponentOptions -> FilePath
componentRoot :: FilePath
, ComponentOptions -> [FilePath]
componentDependencies :: [FilePath]
} deriving (ComponentOptions -> ComponentOptions -> Bool
(ComponentOptions -> ComponentOptions -> Bool)
-> (ComponentOptions -> ComponentOptions -> Bool)
-> Eq ComponentOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentOptions -> ComponentOptions -> Bool
$c/= :: ComponentOptions -> ComponentOptions -> Bool
== :: ComponentOptions -> ComponentOptions -> Bool
$c== :: ComponentOptions -> ComponentOptions -> Bool
Eq, Eq ComponentOptions
Eq ComponentOptions
-> (ComponentOptions -> ComponentOptions -> Ordering)
-> (ComponentOptions -> ComponentOptions -> Bool)
-> (ComponentOptions -> ComponentOptions -> Bool)
-> (ComponentOptions -> ComponentOptions -> Bool)
-> (ComponentOptions -> ComponentOptions -> Bool)
-> (ComponentOptions -> ComponentOptions -> ComponentOptions)
-> (ComponentOptions -> ComponentOptions -> ComponentOptions)
-> Ord ComponentOptions
ComponentOptions -> ComponentOptions -> Bool
ComponentOptions -> ComponentOptions -> Ordering
ComponentOptions -> ComponentOptions -> ComponentOptions
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ComponentOptions -> ComponentOptions -> ComponentOptions
$cmin :: ComponentOptions -> ComponentOptions -> ComponentOptions
max :: ComponentOptions -> ComponentOptions -> ComponentOptions
$cmax :: ComponentOptions -> ComponentOptions -> ComponentOptions
>= :: ComponentOptions -> ComponentOptions -> Bool
$c>= :: ComponentOptions -> ComponentOptions -> Bool
> :: ComponentOptions -> ComponentOptions -> Bool
$c> :: ComponentOptions -> ComponentOptions -> Bool
<= :: ComponentOptions -> ComponentOptions -> Bool
$c<= :: ComponentOptions -> ComponentOptions -> Bool
< :: ComponentOptions -> ComponentOptions -> Bool
$c< :: ComponentOptions -> ComponentOptions -> Bool
compare :: ComponentOptions -> ComponentOptions -> Ordering
$ccompare :: ComponentOptions -> ComponentOptions -> Ordering
$cp1Ord :: Eq ComponentOptions
Ord, Int -> ComponentOptions -> ShowS
[ComponentOptions] -> ShowS
ComponentOptions -> FilePath
(Int -> ComponentOptions -> ShowS)
-> (ComponentOptions -> FilePath)
-> ([ComponentOptions] -> ShowS)
-> Show ComponentOptions
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [ComponentOptions] -> ShowS
$cshowList :: [ComponentOptions] -> ShowS
show :: ComponentOptions -> FilePath
$cshow :: ComponentOptions -> FilePath
showsPrec :: Int -> ComponentOptions -> ShowS
$cshowsPrec :: Int -> ComponentOptions -> ShowS
Show)