module Nix.Context where
import Nix.Options ( Options )
import Nix.Scope ( Scopes )
import Nix.Frames ( Frames )
import Nix.Expr.Types.Annotated ( SrcSpan
, nullSpan
)
data Context m t = Context
{ forall (m :: * -> *) t. Context m t -> Scopes m t
scopes :: Scopes m t
, forall (m :: * -> *) t. Context m t -> SrcSpan
source :: SrcSpan
, forall (m :: * -> *) t. Context m t -> Frames
frames :: Frames
, forall (m :: * -> *) t. Context m t -> Options
options :: Options
}
instance Has (Context m t) (Scopes m t) where
hasLens :: Lens' (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 { scopes :: Scopes m t
scopes = 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
scopes Context m t
a)
instance Has (Context m t) SrcSpan where
hasLens :: Lens' (Context m t) SrcSpan
hasLens SrcSpan -> f SrcSpan
f Context m t
a = (\SrcSpan
x -> Context m t
a { source :: SrcSpan
source = 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
source Context m t
a)
instance Has (Context m t) Frames where
hasLens :: Lens' (Context m t) Frames
hasLens Frames -> f Frames
f Context m t
a = (\Frames
x -> Context m t
a { frames :: Frames
frames = 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
frames Context m t
a)
instance Has (Context m t) Options where
hasLens :: Lens' (Context m t) Options
hasLens Options -> f Options
f Context m t
a = (\Options
x -> Context m t
a { options :: Options
options = 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
options Context m t
a)
newContext :: Options -> Context m t
newContext :: forall (m :: * -> *) t. 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 a. Monoid a => a
mempty SrcSpan
nullSpan Frames
forall a. Monoid a => a
mempty