{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} module Nix.Context where import Nix.Options import Nix.Scope import Nix.Frames import Nix.Utils import Nix.Expr.Types.Annotated ( SrcSpan , nullSpan ) data Context m t = Context { Context m t -> Scopes m t scopes :: Scopes m t , Context m t -> SrcSpan source :: SrcSpan , Context m t -> Frames frames :: Frames , Context m t -> Options options :: Options } instance Has (Context m t) (Scopes m t) where hasLens :: LensLike' f (Context m t) (Scopes m t) hasLens f :: Scopes m t -> f (Scopes m t) f (Context x :: Scopes m t x y :: SrcSpan y z :: Frames z w :: Options w) = (\x' :: Scopes m t x' -> Scopes m t -> SrcSpan -> Frames -> Options -> Context m t forall (m :: * -> *) t. Scopes m t -> SrcSpan -> Frames -> Options -> Context m t Context Scopes m t x' SrcSpan y Frames z Options w) (Scopes m t -> Context m t) -> f (Scopes m t) -> f (Context m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Scopes m t -> f (Scopes m t) f Scopes m t x instance Has (Context m t) SrcSpan where hasLens :: LensLike' f (Context m t) SrcSpan hasLens f :: SrcSpan -> f SrcSpan f (Context x :: Scopes m t x y :: SrcSpan y z :: Frames z w :: Options w) = (\y' :: SrcSpan y' -> Scopes m t -> SrcSpan -> Frames -> Options -> Context m t forall (m :: * -> *) t. Scopes m t -> SrcSpan -> Frames -> Options -> Context m t Context Scopes m t x SrcSpan y' Frames z Options w) (SrcSpan -> Context m t) -> f SrcSpan -> f (Context m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> SrcSpan -> f SrcSpan f SrcSpan y instance Has (Context m t) Frames where hasLens :: LensLike' f (Context m t) Frames hasLens f :: Frames -> f Frames f (Context x :: Scopes m t x y :: SrcSpan y z :: Frames z w :: Options w) = (\z' :: Frames z' -> Scopes m t -> SrcSpan -> Frames -> Options -> Context m t forall (m :: * -> *) t. Scopes m t -> SrcSpan -> Frames -> Options -> Context m t Context Scopes m t x SrcSpan y Frames z' Options w) (Frames -> Context m t) -> f Frames -> f (Context m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Frames -> f Frames f Frames z instance Has (Context m t) Options where hasLens :: LensLike' f (Context m t) Options hasLens f :: Options -> f Options f (Context x :: Scopes m t x y :: SrcSpan y z :: Frames z w :: Options w) = (\w' :: Options w' -> Scopes m t -> SrcSpan -> Frames -> Options -> Context m t forall (m :: * -> *) t. Scopes m t -> SrcSpan -> Frames -> Options -> Context m t Context Scopes m t x SrcSpan y Frames z Options w') (Options -> Context m t) -> f Options -> f (Context m t) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Options -> f Options f Options w newContext :: Options -> Context m t newContext :: Options -> Context m t newContext = Scopes m t -> SrcSpan -> Frames -> Options -> Context m t forall (m :: * -> *) t. Scopes m t -> SrcSpan -> Frames -> Options -> Context m t Context Scopes m t forall (m :: * -> *) a. Scopes m a emptyScopes SrcSpan nullSpan []