2018-04-08 08:14:08 +02:00
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
|
2018-04-11 06:01:48 +02:00
|
|
|
module Nix.Context where
|
2018-04-08 08:14:08 +02:00
|
|
|
|
2019-03-17 22:47:38 +01:00
|
|
|
import Nix.Options
|
|
|
|
import Nix.Scope
|
|
|
|
import Nix.Frames
|
|
|
|
import Nix.Utils
|
|
|
|
import Nix.Expr.Types.Annotated ( SrcSpan
|
|
|
|
, nullSpan
|
|
|
|
)
|
2018-04-08 08:14:08 +02:00
|
|
|
|
2019-03-16 19:41:48 +01:00
|
|
|
data Context m t = Context
|
|
|
|
{ scopes :: Scopes m t
|
2018-04-25 22:00:41 +02:00
|
|
|
, source :: SrcSpan
|
2018-04-18 02:25:59 +02:00
|
|
|
, frames :: Frames
|
|
|
|
, options :: Options
|
2018-04-08 08:14:08 +02:00
|
|
|
}
|
|
|
|
|
2019-03-16 19:41:48 +01:00
|
|
|
instance Has (Context m t) (Scopes m t) where
|
2019-03-17 22:47:38 +01:00
|
|
|
hasLens f (Context x y z w) = (\x' -> Context x' y z w) <$> f x
|
2018-04-25 22:00:41 +02:00
|
|
|
|
2019-03-16 19:41:48 +01:00
|
|
|
instance Has (Context m t) SrcSpan where
|
2019-03-17 22:47:38 +01:00
|
|
|
hasLens f (Context x y z w) = (\y' -> Context x y' z w) <$> f y
|
2018-04-08 08:14:08 +02:00
|
|
|
|
2019-03-16 19:41:48 +01:00
|
|
|
instance Has (Context m t) Frames where
|
2019-03-17 22:47:38 +01:00
|
|
|
hasLens f (Context x y z w) = (\z' -> Context x y z' w) <$> f z
|
2018-04-11 20:53:30 +02:00
|
|
|
|
2019-03-16 19:41:48 +01:00
|
|
|
instance Has (Context m t) Options where
|
2019-03-17 22:47:38 +01:00
|
|
|
hasLens f (Context x y z w) = (\w' -> Context x y z w') <$> f w
|
2018-04-18 02:25:59 +02:00
|
|
|
|
2019-03-16 19:41:48 +01:00
|
|
|
newContext :: Options -> Context m t
|
2018-04-25 22:00:41 +02:00
|
|
|
newContext = Context emptyScopes nullSpan []
|