module Nix.Context where
import Nix.Prelude
import Nix.Options ( Options )
import Nix.Scope ( Scopes )
import Nix.Frames ( Frames )
import Nix.Expr.Types.Annotated ( SrcSpan
, nullSpan
)
data Context m t =
Context
{ Context m t -> Options
getOptions :: Options
, Context m t -> Scopes m t
getScopes :: Scopes m t
, Context m t -> SrcSpan
getSource :: SrcSpan
, Context m t -> Frames
getFrames :: Frames
}
instance Has (Context m t) (Scopes m t) where
hasLens :: LensLike' f (Context m t) (Scopes m t)
hasLens Scopes m t -> f (Scopes m t)
f Context m t
a = (\Scopes m t
x -> Context m t
a { getScopes :: Scopes m t
getScopes = Scopes m t
x }) (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 (Context m t -> Scopes m t
forall (m :: * -> *) t. Context m t -> Scopes m t
getScopes Context m t
a)
instance Has (Context m t) SrcSpan where
hasLens :: LensLike' f (Context m t) SrcSpan
hasLens SrcSpan -> f SrcSpan
f Context m t
a = (\SrcSpan
x -> Context m t
a { getSource :: SrcSpan
getSource = SrcSpan
x }) (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 (Context m t -> SrcSpan
forall (m :: * -> *) t. Context m t -> SrcSpan
getSource Context m t
a)
instance Has (Context m t) Frames where
hasLens :: LensLike' f (Context m t) Frames
hasLens Frames -> f Frames
f Context m t
a = (\Frames
x -> Context m t
a { getFrames :: Frames
getFrames = Frames
x }) (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 (Context m t -> Frames
forall (m :: * -> *) t. Context m t -> Frames
getFrames Context m t
a)
instance Has (Context m t) Options where
hasLens :: LensLike' f (Context m t) Options
hasLens Options -> f Options
f Context m t
a = (\Options
x -> Context m t
a { getOptions :: Options
getOptions = Options
x }) (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 (Context m t -> Options
forall (m :: * -> *) t. Context m t -> Options
getOptions Context m t
a)
newContext :: Options -> Context m t
newContext :: Options -> Context m t
newContext Options
o = Options -> Scopes m t -> SrcSpan -> Frames -> Context m t
forall (m :: * -> *) t.
Options -> Scopes m t -> SrcSpan -> Frames -> Context m t
Context Options
o Scopes m t
forall a. Monoid a => a
mempty SrcSpan
nullSpan Frames
forall a. Monoid a => a
mempty