{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE InstanceSigs #-} module Nix.Cited.Basic where import Prelude hiding ( force ) import Control.Comonad ( Comonad ) import Control.Comonad.Env ( ComonadEnv ) import Control.Monad.Catch hiding ( catchJust ) import Nix.Cited import Nix.Eval as Eval import Nix.Exec import Nix.Expr import Nix.Frames import Nix.Options import Nix.Thunk import Nix.Utils import Nix.Value newtype Cited t f m a = Cited { Cited t f m a -> NCited m (NValue t f m) a getCited :: NCited m (NValue t f m) a } deriving ( (forall x. Cited t f m a -> Rep (Cited t f m a) x) -> (forall x. Rep (Cited t f m a) x -> Cited t f m a) -> Generic (Cited t f m a) forall x. Rep (Cited t f m a) x -> Cited t f m a forall x. Cited t f m a -> Rep (Cited t f m a) x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a forall t (f :: * -> *) (m :: * -> *) a x. Rep (Cited t f m a) x -> Cited t f m a forall t (f :: * -> *) (m :: * -> *) a x. Cited t f m a -> Rep (Cited t f m a) x $cto :: forall t (f :: * -> *) (m :: * -> *) a x. Rep (Cited t f m a) x -> Cited t f m a $cfrom :: forall t (f :: * -> *) (m :: * -> *) a x. Cited t f m a -> Rep (Cited t f m a) x Generic , Typeable , a -> Cited t f m b -> Cited t f m a (a -> b) -> Cited t f m a -> Cited t f m b (forall a b. (a -> b) -> Cited t f m a -> Cited t f m b) -> (forall a b. a -> Cited t f m b -> Cited t f m a) -> Functor (Cited t f m) forall a b. a -> Cited t f m b -> Cited t f m a forall a b. (a -> b) -> Cited t f m a -> Cited t f m b forall t (f :: * -> *) (m :: * -> *) a b. a -> Cited t f m b -> Cited t f m a forall t (f :: * -> *) (m :: * -> *) a b. (a -> b) -> Cited t f m a -> Cited t f m b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> Cited t f m b -> Cited t f m a $c<$ :: forall t (f :: * -> *) (m :: * -> *) a b. a -> Cited t f m b -> Cited t f m a fmap :: (a -> b) -> Cited t f m a -> Cited t f m b $cfmap :: forall t (f :: * -> *) (m :: * -> *) a b. (a -> b) -> Cited t f m a -> Cited t f m b Functor , Functor (Cited t f m) a -> Cited t f m a Functor (Cited t f m) -> (forall a. a -> Cited t f m a) -> (forall a b. Cited t f m (a -> b) -> Cited t f m a -> Cited t f m b) -> (forall a b c. (a -> b -> c) -> Cited t f m a -> Cited t f m b -> Cited t f m c) -> (forall a b. Cited t f m a -> Cited t f m b -> Cited t f m b) -> (forall a b. Cited t f m a -> Cited t f m b -> Cited t f m a) -> Applicative (Cited t f m) Cited t f m a -> Cited t f m b -> Cited t f m b Cited t f m a -> Cited t f m b -> Cited t f m a Cited t f m (a -> b) -> Cited t f m a -> Cited t f m b (a -> b -> c) -> Cited t f m a -> Cited t f m b -> Cited t f m c forall a. a -> Cited t f m a forall a b. Cited t f m a -> Cited t f m b -> Cited t f m a forall a b. Cited t f m a -> Cited t f m b -> Cited t f m b forall a b. Cited t f m (a -> b) -> Cited t f m a -> Cited t f m b forall a b c. (a -> b -> c) -> Cited t f m a -> Cited t f m b -> Cited t f m c forall t (f :: * -> *) (m :: * -> *). Functor (Cited t f m) forall t (f :: * -> *) (m :: * -> *) a. a -> Cited t f m a forall t (f :: * -> *) (m :: * -> *) a b. Cited t f m a -> Cited t f m b -> Cited t f m a forall t (f :: * -> *) (m :: * -> *) a b. Cited t f m a -> Cited t f m b -> Cited t f m b forall t (f :: * -> *) (m :: * -> *) a b. Cited t f m (a -> b) -> Cited t f m a -> Cited t f m b forall t (f :: * -> *) (m :: * -> *) a b c. (a -> b -> c) -> Cited t f m a -> Cited t f m b -> Cited t f m c forall (f :: * -> *). Functor f -> (forall a. a -> f a) -> (forall a b. f (a -> b) -> f a -> f b) -> (forall a b c. (a -> b -> c) -> f a -> f b -> f c) -> (forall a b. f a -> f b -> f b) -> (forall a b. f a -> f b -> f a) -> Applicative f <* :: Cited t f m a -> Cited t f m b -> Cited t f m a $c<* :: forall t (f :: * -> *) (m :: * -> *) a b. Cited t f m a -> Cited t f m b -> Cited t f m a *> :: Cited t f m a -> Cited t f m b -> Cited t f m b $c*> :: forall t (f :: * -> *) (m :: * -> *) a b. Cited t f m a -> Cited t f m b -> Cited t f m b liftA2 :: (a -> b -> c) -> Cited t f m a -> Cited t f m b -> Cited t f m c $cliftA2 :: forall t (f :: * -> *) (m :: * -> *) a b c. (a -> b -> c) -> Cited t f m a -> Cited t f m b -> Cited t f m c <*> :: Cited t f m (a -> b) -> Cited t f m a -> Cited t f m b $c<*> :: forall t (f :: * -> *) (m :: * -> *) a b. Cited t f m (a -> b) -> Cited t f m a -> Cited t f m b pure :: a -> Cited t f m a $cpure :: forall t (f :: * -> *) (m :: * -> *) a. a -> Cited t f m a $cp1Applicative :: forall t (f :: * -> *) (m :: * -> *). Functor (Cited t f m) Applicative , a -> Cited t f m a -> Bool Cited t f m m -> m Cited t f m a -> [a] Cited t f m a -> Bool Cited t f m a -> Int Cited t f m a -> a Cited t f m a -> a Cited t f m a -> a Cited t f m a -> a (a -> m) -> Cited t f m a -> m (a -> m) -> Cited t f m a -> m (a -> b -> b) -> b -> Cited t f m a -> b (a -> b -> b) -> b -> Cited t f m a -> b (b -> a -> b) -> b -> Cited t f m a -> b (b -> a -> b) -> b -> Cited t f m a -> b (a -> a -> a) -> Cited t f m a -> a (a -> a -> a) -> Cited t f m a -> a (forall m. Monoid m => Cited t f m m -> m) -> (forall m a. Monoid m => (a -> m) -> Cited t f m a -> m) -> (forall m a. Monoid m => (a -> m) -> Cited t f m a -> m) -> (forall a b. (a -> b -> b) -> b -> Cited t f m a -> b) -> (forall a b. (a -> b -> b) -> b -> Cited t f m a -> b) -> (forall b a. (b -> a -> b) -> b -> Cited t f m a -> b) -> (forall b a. (b -> a -> b) -> b -> Cited t f m a -> b) -> (forall a. (a -> a -> a) -> Cited t f m a -> a) -> (forall a. (a -> a -> a) -> Cited t f m a -> a) -> (forall a. Cited t f m a -> [a]) -> (forall a. Cited t f m a -> Bool) -> (forall a. Cited t f m a -> Int) -> (forall a. Eq a => a -> Cited t f m a -> Bool) -> (forall a. Ord a => Cited t f m a -> a) -> (forall a. Ord a => Cited t f m a -> a) -> (forall a. Num a => Cited t f m a -> a) -> (forall a. Num a => Cited t f m a -> a) -> Foldable (Cited t f m) forall a. Eq a => a -> Cited t f m a -> Bool forall a. Num a => Cited t f m a -> a forall a. Ord a => Cited t f m a -> a forall m. Monoid m => Cited t f m m -> m forall a. Cited t f m a -> Bool forall a. Cited t f m a -> Int forall a. Cited t f m a -> [a] forall a. (a -> a -> a) -> Cited t f m a -> a forall m a. Monoid m => (a -> m) -> Cited t f m a -> m forall b a. (b -> a -> b) -> b -> Cited t f m a -> b forall a b. (a -> b -> b) -> b -> Cited t f m a -> b forall t (f :: * -> *) (m :: * -> *) a. Eq a => a -> Cited t f m a -> Bool forall t (f :: * -> *) (m :: * -> *) a. Num a => Cited t f m a -> a forall t (f :: * -> *) (m :: * -> *) a. Ord a => Cited t f m a -> a forall t (f :: * -> *) (m :: * -> *) m. Monoid m => Cited t f m m -> m forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> Bool forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> Int forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> [a] forall t (f :: * -> *) (m :: * -> *) a. (a -> a -> a) -> Cited t f m a -> a forall t (f :: * -> *) (m :: * -> *) m a. Monoid m => (a -> m) -> Cited t f m a -> m forall t (f :: * -> *) (m :: * -> *) b a. (b -> a -> b) -> b -> Cited t f m a -> b forall t (f :: * -> *) (m :: * -> *) a b. (a -> b -> b) -> b -> Cited t f m 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 :: Cited t f m a -> a $cproduct :: forall t (f :: * -> *) (m :: * -> *) a. Num a => Cited t f m a -> a sum :: Cited t f m a -> a $csum :: forall t (f :: * -> *) (m :: * -> *) a. Num a => Cited t f m a -> a minimum :: Cited t f m a -> a $cminimum :: forall t (f :: * -> *) (m :: * -> *) a. Ord a => Cited t f m a -> a maximum :: Cited t f m a -> a $cmaximum :: forall t (f :: * -> *) (m :: * -> *) a. Ord a => Cited t f m a -> a elem :: a -> Cited t f m a -> Bool $celem :: forall t (f :: * -> *) (m :: * -> *) a. Eq a => a -> Cited t f m a -> Bool length :: Cited t f m a -> Int $clength :: forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> Int null :: Cited t f m a -> Bool $cnull :: forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> Bool toList :: Cited t f m a -> [a] $ctoList :: forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> [a] foldl1 :: (a -> a -> a) -> Cited t f m a -> a $cfoldl1 :: forall t (f :: * -> *) (m :: * -> *) a. (a -> a -> a) -> Cited t f m a -> a foldr1 :: (a -> a -> a) -> Cited t f m a -> a $cfoldr1 :: forall t (f :: * -> *) (m :: * -> *) a. (a -> a -> a) -> Cited t f m a -> a foldl' :: (b -> a -> b) -> b -> Cited t f m a -> b $cfoldl' :: forall t (f :: * -> *) (m :: * -> *) b a. (b -> a -> b) -> b -> Cited t f m a -> b foldl :: (b -> a -> b) -> b -> Cited t f m a -> b $cfoldl :: forall t (f :: * -> *) (m :: * -> *) b a. (b -> a -> b) -> b -> Cited t f m a -> b foldr' :: (a -> b -> b) -> b -> Cited t f m a -> b $cfoldr' :: forall t (f :: * -> *) (m :: * -> *) a b. (a -> b -> b) -> b -> Cited t f m a -> b foldr :: (a -> b -> b) -> b -> Cited t f m a -> b $cfoldr :: forall t (f :: * -> *) (m :: * -> *) a b. (a -> b -> b) -> b -> Cited t f m a -> b foldMap' :: (a -> m) -> Cited t f m a -> m $cfoldMap' :: forall t (f :: * -> *) (m :: * -> *) m a. Monoid m => (a -> m) -> Cited t f m a -> m foldMap :: (a -> m) -> Cited t f m a -> m $cfoldMap :: forall t (f :: * -> *) (m :: * -> *) m a. Monoid m => (a -> m) -> Cited t f m a -> m fold :: Cited t f m m -> m $cfold :: forall t (f :: * -> *) (m :: * -> *) m. Monoid m => Cited t f m m -> m Foldable , Functor (Cited t f m) Foldable (Cited t f m) Functor (Cited t f m) -> Foldable (Cited t f m) -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Cited t f m a -> f (Cited t f m b)) -> (forall (f :: * -> *) a. Applicative f => Cited t f m (f a) -> f (Cited t f m a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> Cited t f m a -> m (Cited t f m b)) -> (forall (m :: * -> *) a. Monad m => Cited t f m (m a) -> m (Cited t f m a)) -> Traversable (Cited t f m) (a -> f b) -> Cited t f m a -> f (Cited t f m b) forall t (f :: * -> *) (m :: * -> *). Functor (Cited t f m) forall t (f :: * -> *) (m :: * -> *). Foldable (Cited t f m) forall t (f :: * -> *) (m :: * -> *) (m :: * -> *) a. Monad m => Cited t f m (m a) -> m (Cited t f m a) forall t (f :: * -> *) (m :: * -> *) (f :: * -> *) a. Applicative f => Cited t f m (f a) -> f (Cited t f m a) forall t (f :: * -> *) (m :: * -> *) (m :: * -> *) a b. Monad m => (a -> m b) -> Cited t f m a -> m (Cited t f m b) forall t (f :: * -> *) (m :: * -> *) (f :: * -> *) a b. Applicative f => (a -> f b) -> Cited t f m a -> f (Cited t f m 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 => Cited t f m (m a) -> m (Cited t f m a) forall (f :: * -> *) a. Applicative f => Cited t f m (f a) -> f (Cited t f m a) forall (m :: * -> *) a b. Monad m => (a -> m b) -> Cited t f m a -> m (Cited t f m b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Cited t f m a -> f (Cited t f m b) sequence :: Cited t f m (m a) -> m (Cited t f m a) $csequence :: forall t (f :: * -> *) (m :: * -> *) (m :: * -> *) a. Monad m => Cited t f m (m a) -> m (Cited t f m a) mapM :: (a -> m b) -> Cited t f m a -> m (Cited t f m b) $cmapM :: forall t (f :: * -> *) (m :: * -> *) (m :: * -> *) a b. Monad m => (a -> m b) -> Cited t f m a -> m (Cited t f m b) sequenceA :: Cited t f m (f a) -> f (Cited t f m a) $csequenceA :: forall t (f :: * -> *) (m :: * -> *) (f :: * -> *) a. Applicative f => Cited t f m (f a) -> f (Cited t f m a) traverse :: (a -> f b) -> Cited t f m a -> f (Cited t f m b) $ctraverse :: forall t (f :: * -> *) (m :: * -> *) (f :: * -> *) a b. Applicative f => (a -> f b) -> Cited t f m a -> f (Cited t f m b) $cp2Traversable :: forall t (f :: * -> *) (m :: * -> *). Foldable (Cited t f m) $cp1Traversable :: forall t (f :: * -> *) (m :: * -> *). Functor (Cited t f m) Traversable , Functor (Cited t f m) Functor (Cited t f m) -> (forall a. Cited t f m a -> a) -> (forall a. Cited t f m a -> Cited t f m (Cited t f m a)) -> (forall a b. (Cited t f m a -> b) -> Cited t f m a -> Cited t f m b) -> Comonad (Cited t f m) Cited t f m a -> a Cited t f m a -> Cited t f m (Cited t f m a) (Cited t f m a -> b) -> Cited t f m a -> Cited t f m b forall a. Cited t f m a -> a forall a. Cited t f m a -> Cited t f m (Cited t f m a) forall a b. (Cited t f m a -> b) -> Cited t f m a -> Cited t f m b forall t (f :: * -> *) (m :: * -> *). Functor (Cited t f m) forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> a forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> Cited t f m (Cited t f m a) forall t (f :: * -> *) (m :: * -> *) a b. (Cited t f m a -> b) -> Cited t f m a -> Cited t f m b forall (w :: * -> *). Functor w -> (forall a. w a -> a) -> (forall a. w a -> w (w a)) -> (forall a b. (w a -> b) -> w a -> w b) -> Comonad w extend :: (Cited t f m a -> b) -> Cited t f m a -> Cited t f m b $cextend :: forall t (f :: * -> *) (m :: * -> *) a b. (Cited t f m a -> b) -> Cited t f m a -> Cited t f m b duplicate :: Cited t f m a -> Cited t f m (Cited t f m a) $cduplicate :: forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> Cited t f m (Cited t f m a) extract :: Cited t f m a -> a $cextract :: forall t (f :: * -> *) (m :: * -> *) a. Cited t f m a -> a $cp1Comonad :: forall t (f :: * -> *) (m :: * -> *). Functor (Cited t f m) Comonad , ComonadEnv [Provenance m (NValue t f m)] ) instance HasCitations1 m (NValue t f m) (Cited t f m) where citations1 :: Cited t f m a -> [Provenance m (NValue t f m)] citations1 (Cited NCited m (NValue t f m) a c) = NCited m (NValue t f m) a -> [Provenance m (NValue t f m)] forall (m :: * -> *) v a. HasCitations m v a => a -> [Provenance m v] citations NCited m (NValue t f m) a c addProvenance1 :: Provenance m (NValue t f m) -> Cited t f m a -> Cited t f m a addProvenance1 Provenance m (NValue t f m) x (Cited NCited m (NValue t f m) a c) = NCited m (NValue t f m) a -> Cited t f m a forall t (f :: * -> *) (m :: * -> *) a. NCited m (NValue t f m) a -> Cited t f m a Cited (NCited m (NValue t f m) a -> Cited t f m a) -> NCited m (NValue t f m) a -> Cited t f m a forall a b. (a -> b) -> a -> b $ Provenance m (NValue t f m) -> NCited m (NValue t f m) a -> NCited m (NValue t f m) a forall (m :: * -> *) v a. HasCitations m v a => Provenance m v -> a -> a addProvenance Provenance m (NValue t f m) x NCited m (NValue t f m) a c instance ( Has e Options , Framed e m , MonadThunk t m v , Typeable m , Typeable f , Typeable u , MonadCatch m ) => MonadThunk (Cited u f m t) m v where thunk :: m v -> m (Cited u f m t) thunk :: m v -> m (Cited u f m t) thunk m v mv = do Options opts :: Options <- (e -> Options) -> m Options forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a asks (FoldLike Options e e Options Options -> e -> Options forall a s t b. FoldLike a s t a b -> s -> a view FoldLike Options e e Options Options forall a b. Has a b => Lens' a b hasLens) m (Cited u f m t) -> m (Cited u f m t) -> Bool -> m (Cited u f m t) forall a. a -> a -> Bool -> a bool (NCited m (NValue u f m) t -> Cited u f m t forall t (f :: * -> *) (m :: * -> *) a. NCited m (NValue t f m) a -> Cited t f m a Cited (NCited m (NValue u f m) t -> Cited u f m t) -> (t -> NCited m (NValue u f m) t) -> t -> Cited u f m t forall b c a. (b -> c) -> (a -> b) -> a -> c . [Provenance m (NValue u f m)] -> t -> NCited m (NValue u f m) t forall (m :: * -> *) v a. [Provenance m v] -> a -> NCited m v a NCited [Provenance m (NValue u f m)] forall a. Monoid a => a mempty (t -> Cited u f m t) -> m t -> m (Cited u f m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> m v -> m t forall t (m :: * -> *) a. MonadThunk t m a => m a -> m t thunk m v mv) (do Frames frames :: Frames <- (e -> Frames) -> m Frames forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a asks (FoldLike Frames e e Frames Frames -> e -> Frames forall a s t b. FoldLike a s t a b -> s -> a view FoldLike Frames e e Frames Frames forall a b. Has a b => Lens' a b hasLens) -- Gather the current evaluation context at the time of thunk -- creation, and record it along with the thunk. let go :: SomeException -> [Provenance m v] go (SomeException -> Maybe (EvalFrame m v) forall e. Exception e => SomeException -> Maybe e fromException -> Just (EvaluatingExpr Scopes m v scope (AnnE SrcSpan s NExprF (Fix (Compose (Ann SrcSpan) NExprF)) e))) = let e' :: Compose (Ann SrcSpan) NExprF (Maybe a) e' = Ann SrcSpan (NExprF (Maybe a)) -> Compose (Ann SrcSpan) NExprF (Maybe a) forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1). f (g a) -> Compose f g a Compose (SrcSpan -> NExprF (Maybe a) -> Ann SrcSpan (NExprF (Maybe a)) forall ann a. ann -> a -> Ann ann a Ann SrcSpan s (Maybe a forall a. Maybe a Nothing Maybe a -> NExprF (Fix (Compose (Ann SrcSpan) NExprF)) -> NExprF (Maybe a) forall (f :: * -> *) a b. Functor f => a -> f b -> f a <$ NExprF (Fix (Compose (Ann SrcSpan) NExprF)) e)) in [Scopes m v -> NExprLocF (Maybe v) -> Provenance m v forall (m :: * -> *) v. Scopes m v -> NExprLocF (Maybe v) -> Provenance m v Provenance Scopes m v scope NExprLocF (Maybe v) forall a. Compose (Ann SrcSpan) NExprF (Maybe a) e'] go SomeException _ = [Provenance m v] forall a. Monoid a => a mempty ps :: [Provenance m (NValue u f m)] ps = (NixFrame -> [Provenance m (NValue u f m)]) -> Frames -> [Provenance m (NValue u f m)] forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b] concatMap (SomeException -> [Provenance m (NValue u f m)] forall (m :: * -> *) v. (Typeable m, Typeable v) => SomeException -> [Provenance m v] go (SomeException -> [Provenance m (NValue u f m)]) -> (NixFrame -> SomeException) -> NixFrame -> [Provenance m (NValue u f m)] forall b c a. (b -> c) -> (a -> b) -> a -> c . NixFrame -> SomeException frame) Frames frames NCited m (NValue u f m) t -> Cited u f m t forall t (f :: * -> *) (m :: * -> *) a. NCited m (NValue t f m) a -> Cited t f m a Cited (NCited m (NValue u f m) t -> Cited u f m t) -> (t -> NCited m (NValue u f m) t) -> t -> Cited u f m t forall b c a. (b -> c) -> (a -> b) -> a -> c . [Provenance m (NValue u f m)] -> t -> NCited m (NValue u f m) t forall (m :: * -> *) v a. [Provenance m v] -> a -> NCited m v a NCited [Provenance m (NValue u f m)] ps (t -> Cited u f m t) -> m t -> m (Cited u f m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> m v -> m t forall t (m :: * -> *) a. MonadThunk t m a => m a -> m t thunk m v mv ) (Options -> Bool thunks Options opts) thunkId :: Cited u f m t -> ThunkId m thunkId :: Cited u f m t -> ThunkId m thunkId (Cited (NCited [Provenance m (NValue u f m)] _ t t)) = t -> ThunkId m forall t (m :: * -> *) a. MonadThunk t m a => t -> ThunkId m thunkId @_ @m t t queryM :: m v -> Cited u f m t -> m v queryM :: m v -> Cited u f m t -> m v queryM m v m (Cited (NCited [Provenance m (NValue u f m)] _ t t)) = m v -> t -> m v forall t (m :: * -> *) a. MonadThunk t m a => m a -> t -> m a queryM m v m t t -- | The ThunkLoop exception is thrown as an exception with MonadThrow, -- which does not capture the current stack frame information to provide -- it in a NixException, so we catch and re-throw it here using -- 'throwError' from Frames.hs. force :: Cited u f m t -> m v force :: Cited u f m t -> m v force (Cited (NCited [Provenance m (NValue u f m)] ps t t)) = [Provenance m (NValue u f m)] -> m v -> m v forall (m :: * -> *) v e a. (MonadCatch m, Typeable m, Typeable v, Has e Frames, MonadReader e m) => [Provenance m v] -> m a -> m a handleDisplayProvenance [Provenance m (NValue u f m)] ps (m v -> m v) -> m v -> m v forall a b. (a -> b) -> a -> b $ t -> m v forall t (m :: * -> *) a. MonadThunk t m a => t -> m a force t t forceEff :: Cited u f m t -> m v forceEff :: Cited u f m t -> m v forceEff (Cited (NCited [Provenance m (NValue u f m)] ps t t)) = [Provenance m (NValue u f m)] -> m v -> m v forall (m :: * -> *) v e a. (MonadCatch m, Typeable m, Typeable v, Has e Frames, MonadReader e m) => [Provenance m v] -> m a -> m a handleDisplayProvenance [Provenance m (NValue u f m)] ps (m v -> m v) -> m v -> m v forall a b. (a -> b) -> a -> b $ t -> m v forall t (m :: * -> *) a. MonadThunk t m a => t -> m a forceEff t t further :: Cited u f m t -> m (Cited u f m t) further :: Cited u f m t -> m (Cited u f m t) further (Cited (NCited [Provenance m (NValue u f m)] ps t t)) = NCited m (NValue u f m) t -> Cited u f m t forall t (f :: * -> *) (m :: * -> *) a. NCited m (NValue t f m) a -> Cited t f m a Cited (NCited m (NValue u f m) t -> Cited u f m t) -> (t -> NCited m (NValue u f m) t) -> t -> Cited u f m t forall b c a. (b -> c) -> (a -> b) -> a -> c . [Provenance m (NValue u f m)] -> t -> NCited m (NValue u f m) t forall (m :: * -> *) v a. [Provenance m v] -> a -> NCited m v a NCited [Provenance m (NValue u f m)] ps (t -> Cited u f m t) -> m t -> m (Cited u f m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> t -> m t forall t (m :: * -> *) a. MonadThunk t m a => t -> m t further t t -- * Kleisli functor HOFs -- Please, do not use MonadThunkF for MonadThunk, later uses more straight-forward specialized line of functions. instance ( Has e Options , Framed e m , MonadThunkF t m v , Typeable m , Typeable f , Typeable u , MonadCatch m ) => MonadThunkF (Cited u f m t) m v where queryMF :: (v -> m r) -> m r -> Cited u f m t -> m r queryMF :: (v -> m r) -> m r -> Cited u f m t -> m r queryMF v -> m r k m r m (Cited (NCited [Provenance m (NValue u f m)] _ t t)) = (v -> m r) -> m r -> t -> m r forall t (m :: * -> *) a r. MonadThunkF t m a => (a -> m r) -> m r -> t -> m r queryMF v -> m r k m r m t t forceF :: (v -> m r) -> Cited u f m t -> m r forceF :: (v -> m r) -> Cited u f m t -> m r forceF v -> m r k (Cited (NCited [Provenance m (NValue u f m)] ps t t)) = [Provenance m (NValue u f m)] -> m r -> m r forall (m :: * -> *) v e a. (MonadCatch m, Typeable m, Typeable v, Has e Frames, MonadReader e m) => [Provenance m v] -> m a -> m a handleDisplayProvenance [Provenance m (NValue u f m)] ps (m r -> m r) -> m r -> m r forall a b. (a -> b) -> a -> b $ (v -> m r) -> t -> m r forall t (m :: * -> *) a r. MonadThunkF t m a => (a -> m r) -> t -> m r forceF v -> m r k t t forceEffF :: (v -> m r) -> Cited u f m t -> m r forceEffF :: (v -> m r) -> Cited u f m t -> m r forceEffF v -> m r k (Cited (NCited [Provenance m (NValue u f m)] ps t t)) = [Provenance m (NValue u f m)] -> m r -> m r forall (m :: * -> *) v e a. (MonadCatch m, Typeable m, Typeable v, Has e Frames, MonadReader e m) => [Provenance m v] -> m a -> m a handleDisplayProvenance [Provenance m (NValue u f m)] ps (m r -> m r) -> m r -> m r forall a b. (a -> b) -> a -> b $ (v -> m r) -> t -> m r forall t (m :: * -> *) a r. MonadThunkF t m a => (a -> m r) -> t -> m r forceEffF v -> m r k t t furtherF :: (m v -> m v) -> Cited u f m t -> m (Cited u f m t) furtherF :: (m v -> m v) -> Cited u f m t -> m (Cited u f m t) furtherF m v -> m v k (Cited (NCited [Provenance m (NValue u f m)] ps t t)) = NCited m (NValue u f m) t -> Cited u f m t forall t (f :: * -> *) (m :: * -> *) a. NCited m (NValue t f m) a -> Cited t f m a Cited (NCited m (NValue u f m) t -> Cited u f m t) -> (t -> NCited m (NValue u f m) t) -> t -> Cited u f m t forall b c a. (b -> c) -> (a -> b) -> a -> c . [Provenance m (NValue u f m)] -> t -> NCited m (NValue u f m) t forall (m :: * -> *) v a. [Provenance m v] -> a -> NCited m v a NCited [Provenance m (NValue u f m)] ps (t -> Cited u f m t) -> m t -> m (Cited u f m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (m v -> m v) -> t -> m t forall t (m :: * -> *) a. MonadThunkF t m a => (m a -> m a) -> t -> m t furtherF m v -> m v k t t -- ** Utils handleDisplayProvenance :: (MonadCatch m , Typeable m , Typeable v , Has e Frames , MonadReader e m ) => [Provenance m v] -> m a -> m a handleDisplayProvenance :: [Provenance m v] -> m a -> m a handleDisplayProvenance [Provenance m v] ps m a f = m a -> (ThunkLoop -> m a) -> m a forall (m :: * -> *) e a. (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a catch ([Provenance m v] -> m a -> m a forall (m :: * -> *) e v a. (MonadThrow m, MonadReader e m, Has e Frames, Typeable m, Typeable v) => [Provenance m v] -> m a -> m a displayProvenance [Provenance m v] ps m a f) (forall s e (m :: * -> *) a. (Framed e m, Exception s, MonadThrow m) => s -> m a forall e (m :: * -> *) a. (Framed e m, Exception ThunkLoop, MonadThrow m) => ThunkLoop -> m a throwError @ThunkLoop) displayProvenance :: (MonadThrow m , MonadReader e m , Has e Frames , Typeable m , Typeable v ) => [Provenance m v] -> m a -> m a displayProvenance :: [Provenance m v] -> m a -> m a displayProvenance = (m a -> m a) -> ([Provenance m v] -> m a -> m a) -> [Provenance m v] -> m a -> m a forall (t :: * -> *) b a. Foldable t => b -> (t a -> b) -> t a -> b list m a -> m a forall a. a -> a id (\ (Provenance Scopes m v scope e :: NExprLocF (Maybe v) e@(Compose (Ann SrcSpan s NExprF (Maybe v) _)) : [Provenance m v] _) -> NixLevel -> EvalFrame m v -> m a -> m a forall s e (m :: * -> *) a. (Framed e m, Exception s) => NixLevel -> s -> m a -> m a withFrame NixLevel Info (Scopes m v -> Fix (Compose (Ann SrcSpan) NExprF) -> EvalFrame m v forall (m :: * -> *) v. Scopes m v -> Fix (Compose (Ann SrcSpan) NExprF) -> EvalFrame m v ForcingExpr Scopes m v scope (SrcSpan -> NExprLocF (Maybe v) -> Fix (Compose (Ann SrcSpan) NExprF) forall r. SrcSpan -> NExprLocF r -> Fix (Compose (Ann SrcSpan) NExprF) wrapExprLoc SrcSpan s NExprLocF (Maybe v) e)) )