hnix-0.16.0: Haskell implementation of the Nix language
Safe HaskellNone
LanguageHaskell2010

Nix.Value

Description

The core of the type system, Nix language values

Synopsis

NValueF: Base functor (F)

data NValueF p m r Source #

An NValueF p m r represents all the possible types of Nix values.

Is is the base functor to form the Free monad of nix expressions. The parameter r represents Nix values in their final form (NValue). The parameter p represents exactly the same type, but is kept separate or it would prevent NValueF from being a proper functor. It is intended to be hard-coded to the same final type as r. m is the monad in which evaluations will run.

An NValue' t f m a is a magic layer between NValueF and the Free monad construction.

It fixes the p parameter of NValueF to the final NValue type, making the definition of NValue' and NValue depend on each other in a recursive fashion.

It also introduces a f parameter for a custom functor that can be used to wrap each intermediate value in the reduced expression tree. This is where expression evaluations can store annotations and other useful information.

t is not really used here, but is needed to type the (NValue t f m) used to tie the knot of the p parameter in the inner NValueF.

a is will be an `NValue t f m` when NValue' functor is turned into a Free monad.

'NValue t f m' is the most reduced form of a NExpr after evaluation is completed. It is a layer cake of NValueF base values, wrapped in the f functor and into the Free recursive construction.

Concretely, an NValue t f m can either be a thunk, representing a value yet to be evaluated (Pure t), or a know value in WHNF (Free (NValue' t f m (NValue t f m))) = (Free (f (NValueF NValue m NValue)) That is, a base value type, wrapped into the generic f functor, and based on other NValue's, which can in turn be either thunks, or more already WHNF evaluated values.

As an example, the value `[1]` will be represented as

Free (f (NVListF [ (Free (f (NVConstantF (NInt 1)))) ]))

Should this 1 be a laziy and yet unevaluated value, it would be represented as

Free (f (NVListF [ (Pure t) ]))

Where the t is evaluator dependant, and should contain anough information to be evaluated to an NValue when needed. demand of force are used to turn a potential thunk into a `m (NValue t f m)`.

Of course, trees can be much bigger.

The number of layers and type aliases for similar things is huge, so this module provides ViewPatterns for each NValueF constructor.

For example, the pattern NVStr' ns matches a NValue' containing an NVStrF, and bind that NVStrF to ns, ignoring the f functor inside. Similarly, the pattern NVStr ns (without prime mark) will match the inner NVstrF value inside an NValue. Of course, the patterns are declined for all the NValueF constructors. The non primed version also has an NVThunk t pattern to account for the possibility of an NValue to no be fully evaluated yet, as opposed to an NValue'.

Constructors

NVConstantF NAtom 
NVStrF NixString

A string has a value and a context, which can be used to record what a string has been build from

NVPathF Path 
NVListF [r] 
NVSetF PositionSet (AttrSet r)

Quite frequently actions/processing happens with values (for example - forcing of values & recreation of the monad), but SourcePos does not change then.

NVClosureF (Params ()) (p -> m r)

A function is a closed set of parameters representing the "call signature", used at application time to check the type of arguments passed to the function. Since it supports default values which may depend on other values within the final argument set, this dependency is represented as a set of pending evaluations. The arguments are finally normalized into a set which is passed to the function.

Note that 'm r' is being used here because effectively a function and its set of default arguments is "never fully evaluated". This enforces in the type that it must be re-evaluated for each call.

NVBuiltinF VarName (p -> m r)

A builtin function is itself already in normal form. Also, it may or may not choose to evaluate its argument in the production of a result.

Instances

Instances details
Functor m => Functor (NValueF p m) Source # 
Instance details

Defined in Nix.Value

Methods

fmap :: (a -> b) -> NValueF p m a -> NValueF p m b #

(<$) :: a -> NValueF p m b -> NValueF p m a #

Foldable (NValueF p m) Source #

Folds what the value is known to contain at time of fold.

Instance details

Defined in Nix.Value

Methods

fold :: Monoid m0 => NValueF p m m0 -> m0 #

foldMap :: Monoid m0 => (a -> m0) -> NValueF p m a -> m0 #

foldMap' :: Monoid m0 => (a -> m0) -> NValueF p m a -> m0 #

foldr :: (a -> b -> b) -> b -> NValueF p m a -> b #

foldr' :: (a -> b -> b) -> b -> NValueF p m a -> b #

foldl :: (b -> a -> b) -> b -> NValueF p m a -> b #

foldl' :: (b -> a -> b) -> b -> NValueF p m a -> b #

foldr1 :: (a -> a -> a) -> NValueF p m a -> a #

foldl1 :: (a -> a -> a) -> NValueF p m a -> a #

toList :: NValueF p m a -> [a] #

null :: NValueF p m a -> Bool #

length :: NValueF p m a -> Int #

elem :: Eq a => a -> NValueF p m a -> Bool #

maximum :: Ord a => NValueF p m a -> a #

minimum :: Ord a => NValueF p m a -> a #

sum :: Num a => NValueF p m a -> a #

product :: Num a => NValueF p m a -> a #

Eq1 (NValueF p m) Source # 
Instance details

Defined in Nix.Value

Methods

liftEq :: (a -> b -> Bool) -> NValueF p m a -> NValueF p m b -> Bool #

Show r => Show (NValueF p m r) Source # 
Instance details

Defined in Nix.Value

Methods

showsPrec :: Int -> NValueF p m r -> ShowS #

show :: NValueF p m r -> String #

showList :: [NValueF p m r] -> ShowS #

Generic (NValueF p m r) Source # 
Instance details

Defined in Nix.Value

Associated Types

type Rep (NValueF p m r) :: Type -> Type #

Methods

from :: NValueF p m r -> Rep (NValueF p m r) x #

to :: Rep (NValueF p m r) x -> NValueF p m r #

type Rep (NValueF p m r) Source # 
Instance details

Defined in Nix.Value

type Rep (NValueF p m r) = D1 ('MetaData "NValueF" "Nix.Value" "hnix-0.16.0-8yNt853wvoc5yRPRKlu02G" 'False) ((C1 ('MetaCons "NVConstantF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NAtom)) :+: (C1 ('MetaCons "NVStrF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NixString)) :+: C1 ('MetaCons "NVPathF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Path)))) :+: ((C1 ('MetaCons "NVListF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [r])) :+: C1 ('MetaCons "NVSetF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PositionSet) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (AttrSet r)))) :+: (C1 ('MetaCons "NVClosureF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Params ())) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (p -> m r))) :+: C1 ('MetaCons "NVBuiltinF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 VarName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (p -> m r))))))

Eq1

Show

Foldable

Traversable

sequenceNValueF :: (Functor n, Monad m, Applicative n) => (forall x. n x -> m x) -> NValueF p m (n a) -> n (NValueF p m a) Source #

sequence

Monad

bindNValueF Source #

Arguments

:: (Monad m, Monad n) 
=> (forall x. n x -> m x)

Transform n into m.

-> (a -> n b)

A Kleisli arrow (see Kleisli & Kleisli catagory).

-> NValueF p m a

Unfixed (openly recursive) value of an embedded Nix language.

-> n (NValueF p m b)

An implementation of transform (f =<< x) for embedded Nix language values.

bind

MonadTrans

liftNValueF :: (MonadTrans u, Monad m) => NValueF p m a -> NValueF p (u m) a Source #

lift

MonadTransUnlift

unliftNValueF :: (MonadTrans u, Monad m) => (forall x. u m x -> m x) -> NValueF p (u m) a -> NValueF p m a Source #

unlift

Utils

hoistNValueF :: (forall x. m x -> n x) -> NValueF p m a -> NValueF p n a Source #

Back & forth hoisting in the monad stack

NValue': forming the (F(A))

newtype NValue' t f m a Source #

At the time of constructor, the expected arguments to closures are values that may contain thunks. The type of such thunks are fixed at that time.

Constructors

NValue' 

Fields

  • _nValue :: f (NValueF (NValue t f m) m a)

    Applying F-algebra Base functor data type (NValueF) to the F-algebra carrier (NValue), forming the \( F(A)-> A \)).

Instances

Instances details
Convertible e t f m => ToValue Bool m (NExprF (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Bool -> m (NExprF (NValue t f m)) Source #

Convertible e t f m => ToValue () m (NExprF (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: () -> m (NExprF (NValue t f m)) Source #

(Convertible e t f m, ToValue a m (Deeper (NValue' t f m (NValue t f m)))) => ToValue a m (Deeper (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: a -> m (Deeper (NValue t f m)) Source #

(Convertible e t f m, FromValue a m (NValue' t f m (NValue t f m))) => FromValue a m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: Deeper (NValue' t f m (NValue t f m)) -> m a Source #

fromValueMay :: Deeper (NValue' t f m (NValue t f m)) -> m (Maybe a) Source #

(Convertible e t f m, MonadValue (NValue t f m) m, FromValue a m (Deeper (NValue' t f m (NValue t f m)))) => FromValue a m (Deeper (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: Deeper (NValue t f m) -> m a Source #

fromValueMay :: Deeper (NValue t f m) -> m (Maybe a) Source #

(HasCitations1 m v f, HasCitations m v t) => HasCitations m v (NValue t f m) Source # 
Instance details

Defined in Nix.Cited

Methods

citations :: NValue t f m -> [Provenance m v] Source #

addProvenance :: Provenance m v -> NValue t f m -> NValue t f m Source #

(Convertible e t f m, ToValue a m (NValue' t f m (NValue t f m))) => ToValue a m (NValue t f m) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: a -> m (NValue t f m) Source #

(Convertible e t f m, MonadValue (NValue t f m) m, FromValue a m (NValue' t f m (NValue t f m))) => FromValue a m (NValue t f m) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue t f m -> m a Source #

fromValueMay :: NValue t f m -> m (Maybe a) Source #

HasCitations1 m v f => HasCitations m v (NValue' t f m a) Source # 
Instance details

Defined in Nix.Cited

Methods

citations :: NValue' t f m a -> [Provenance m v] Source #

addProvenance :: Provenance m v -> NValue' t f m a -> NValue' t f m a Source #

Convertible e t f m => ToValue Bool m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Bool -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue Float m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Float -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue Int m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Int -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue Integer m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Integer -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue () m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: () -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue ByteString m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: ByteString -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue Text m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Text -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue SourcePos m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: SourcePos -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue Path m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: Path -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue NixString m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: NixString -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue NixLikeContextValue m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: NixLikeContextValue -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue StorePath m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: StorePath -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => FromValue Bool m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m Bool Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe Bool) Source #

Convertible e t f m => FromValue Float m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m Float Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe Float) Source #

Convertible e t f m => FromValue Int m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m Int Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe Int) Source #

Convertible e t f m => FromValue Integer m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m Integer Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe Integer) Source #

Convertible e t f m => FromValue () m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m () Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe ()) Source #

Convertible e t f m => FromValue ByteString m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m ByteString Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe ByteString) Source #

Convertible e t f m => FromValue Text m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m Text Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe Text) Source #

(Convertible e t f m, MonadValue (NValue t f m) m) => FromValue Path m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m Path Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe Path) Source #

(Convertible e t f m, MonadValue (NValue t f m) m, MonadEffects t f m) => FromValue NixString m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m NixString Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe NixString) Source #

HasCitations m (StdValue m) (StdThunk m) Source # 
Instance details

Defined in Nix.Standard

HasCitations1 m (StdValue m) (StdCited m) Source # 
Instance details

Defined in Nix.Standard

HasCitations1 m (NValue t f m) (Cited t f m) Source # 
Instance details

Defined in Nix.Cited.Basic

Methods

citations1 :: Cited t f m a -> [Provenance m (NValue t f m)] Source #

addProvenance1 :: Provenance m (NValue t f m) -> Cited t f m a -> Cited t f m a Source #

MonadReader (Context m (StdValue m)) m => Scoped (StdValue m) m Source # 
Instance details

Defined in Nix.Standard

Methods

askScopes :: m (Scopes m (StdValue m)) Source #

clearScopes :: m r -> m r Source #

pushScopes :: Scopes m (StdValue m) -> m r -> m r Source #

lookupVar :: VarName -> m (Maybe (StdValue m)) Source #

(MonadAtomicRef m, MonadCatch m, Typeable m, MonadReader (Context m (StdValue m)) m, MonadThunkId m) => MonadValueF (StdValue m) m Source # 
Instance details

Defined in Nix.Standard

Methods

demandF :: (StdValue m -> m r) -> StdValue m -> m r Source #

informF :: (m (StdValue m) -> m (StdValue m)) -> StdValue m -> m (StdValue m) Source #

(MonadAtomicRef m, MonadCatch m, Typeable m, MonadReader (Context m (StdValue m)) m, MonadThunkId m) => MonadValue (StdValue m) m Source # 
Instance details

Defined in Nix.Standard

Methods

defer :: m (StdValue m) -> m (StdValue m) Source #

demand :: StdValue m -> m (StdValue m) Source #

inform :: StdValue m -> m (StdValue m) Source #

(Typeable m, MonadThunkId m, MonadAtomicRef m, MonadCatch m, MonadReader (Context m (StdValue m)) m) => MonadThunkF (StdThunk m) m (StdValue m) Source # 
Instance details

Defined in Nix.Standard

Methods

queryF :: (StdValue m -> m r) -> m r -> StdThunk m -> m r Source #

forceF :: (StdValue m -> m r) -> StdThunk m -> m r Source #

forceEffF :: (StdValue m -> m r) -> StdThunk m -> m r Source #

furtherF :: (m (StdValue m) -> m (StdValue m)) -> StdThunk m -> m (StdThunk m) Source #

(Typeable m, MonadThunkId m, MonadAtomicRef m, MonadCatch m, MonadReader (Context m (StdValue m)) m) => MonadThunk (StdThunk m) m (StdValue m) Source # 
Instance details

Defined in Nix.Standard

Methods

thunkId :: StdThunk m -> ThunkId m Source #

thunk :: m (StdValue m) -> m (StdThunk m) Source #

query :: m (StdValue m) -> StdThunk m -> m (StdValue m) Source #

force :: StdThunk m -> m (StdValue m) Source #

forceEff :: StdThunk m -> m (StdValue m) Source #

further :: StdThunk m -> m (StdThunk m) Source #

(Convertible e t f m, ToValue a m (NValue t f m)) => ToValue [a] m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: [a] -> m (Deeper (NValue' t f m (NValue t f m))) Source #

(Convertible e t f m, ToValue a m (NValue t f m)) => ToValue (AttrSet a) m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: AttrSet a -> m (Deeper (NValue' t f m (NValue t f m))) Source #

(Convertible e t f m, FromValue a m (NValue t f m)) => FromValue [a] m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: Deeper (NValue' t f m (NValue t f m)) -> m [a] Source #

fromValueMay :: Deeper (NValue' t f m (NValue t f m)) -> m (Maybe [a]) Source #

(Convertible e t f m, FromValue a m (NValue t f m)) => FromValue (AttrSet a) m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: Deeper (NValue' t f m (NValue t f m)) -> m (AttrSet a) Source #

fromValueMay :: Deeper (NValue' t f m (NValue t f m)) -> m (Maybe (AttrSet a)) Source #

Convertible e t f m => ToValue [NValue t f m] m (NValue' t f m (NValue t f m)) Source #

With ToValue, we can always act recursively

Instance details

Defined in Nix.Convert

Methods

toValue :: [NValue t f m] -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => ToValue (AttrSet (NValue t f m)) m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: AttrSet (NValue t f m) -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => FromValue [NValue t f m] m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m [NValue t f m] Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe [NValue t f m]) Source #

Convertible e t f m => FromValue (AttrSet (NValue t f m)) m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m (AttrSet (NValue t f m)) Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe (AttrSet (NValue t f m))) Source #

ComonadEnv [Provenance m (StdValue m)] (StdCited m) Source # 
Instance details

Defined in Nix.Standard

Methods

ask :: StdCited m a -> [Provenance m (StdValue m)] #

ComonadEnv [Provenance m (NValue t f m)] (Cited t f m) Source # 
Instance details

Defined in Nix.Cited.Basic

Methods

ask :: Cited t f m a -> [Provenance m (NValue t f m)] #

(Convertible e t f m, ToValue a m (NValue t f m)) => ToValue (AttrSet a, PositionSet) m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: (AttrSet a, PositionSet) -> m (Deeper (NValue' t f m (NValue t f m))) Source #

(Convertible e t f m, FromValue a m (NValue t f m)) => FromValue (AttrSet a, PositionSet) m (Deeper (NValue' t f m (NValue t f m))) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: Deeper (NValue' t f m (NValue t f m)) -> m (AttrSet a, PositionSet) Source #

fromValueMay :: Deeper (NValue' t f m (NValue t f m)) -> m (Maybe (AttrSet a, PositionSet)) Source #

Convertible e t f m => ToValue (AttrSet (NValue t f m), PositionSet) m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

toValue :: (AttrSet (NValue t f m), PositionSet) -> m (NValue' t f m (NValue t f m)) Source #

Convertible e t f m => FromValue (AttrSet (NValue t f m), PositionSet) m (NValue' t f m (NValue t f m)) Source # 
Instance details

Defined in Nix.Convert

Methods

fromValue :: NValue' t f m (NValue t f m) -> m (AttrSet (NValue t f m), PositionSet) Source #

fromValueMay :: NValue' t f m (NValue t f m) -> m (Maybe (AttrSet (NValue t f m), PositionSet)) Source #

Monad m => MonadReader (Context r (StdValue r)) (StandardTF r m) Source # 
Instance details

Defined in Nix.Standard

Methods

ask :: StandardTF r m (Context r (StdValue r)) #

local :: (Context r (StdValue r) -> Context r (StdValue r)) -> StandardTF r m a -> StandardTF r m a #

reader :: (Context r (StdValue r) -> a) -> StandardTF r m a #

(Functor f, Functor m) => Functor (NValue' t f m) Source # 
Instance details

Defined in Nix.Value

Methods

fmap :: (a -> b) -> NValue' t f m a -> NValue' t f m b #

(<$) :: a -> NValue' t f m b -> NValue' t f m a #

Foldable f => Foldable (NValue' t f m) Source # 
Instance details

Defined in Nix.Value

Methods

fold :: Monoid m0 => NValue' t f m m0 -> m0 #

foldMap :: Monoid m0 => (a -> m0) -> NValue' t f m a -> m0 #

foldMap' :: Monoid m0 => (a -> m0) -> NValue' t f m a -> m0 #

foldr :: (a -> b -> b) -> b -> NValue' t f m a -> b #

foldr' :: (a -> b -> b) -> b -> NValue' t f m a -> b #

foldl :: (b -> a -> b) -> b -> NValue' t f m a -> b #

foldl' :: (b -> a -> b) -> b -> NValue' t f m a -> b #

foldr1 :: (a -> a -> a) -> NValue' t f m a -> a #

foldl1 :: (a -> a -> a) -> NValue' t f m a -> a #

toList :: NValue' t f m a -> [a] #

null :: NValue' t f m a -> Bool #

length :: NValue' t f m a -> Int #

elem :: Eq a => a -> NValue' t f m a -> Bool #

maximum :: Ord a => NValue' t f m a -> a #

minimum :: Ord a => NValue' t f m a -> a #

sum :: Num a => NValue' t f m a -> a #

product :: Num a => NValue' t f m a -> a #

(Eq t, Eq1 f, Eq1 m) => Eq1 (NValue' t f m) Source # 
Instance details

Defined in Nix.Value

Methods

liftEq :: (a -> b -> Bool) -> NValue' t f m a -> NValue' t f m b -> Bool #

Comonad f => Show1 (NValue' t f m) Source # 
Instance details

Defined in Nix.Value

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NValue' t f m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NValue' t f m a] -> ShowS #

MonadNix e t f m => MonadEval (NValue t f m) m Source # 
Instance details

Defined in Nix.Exec

Methods

freeVariable :: VarName -> m (NValue t f m) Source #

synHole :: VarName -> m (NValue t f m) Source #

attrMissing :: NonEmpty VarName -> Maybe (NValue t f m) -> m (NValue t f m) Source #

evaledSym :: VarName -> NValue t f m -> m (NValue t f m) Source #

evalCurPos :: m (NValue t f m) Source #

evalConstant :: NAtom -> m (NValue t f m) Source #

evalString :: NString (m (NValue t f m)) -> m (NValue t f m) Source #

evalLiteralPath :: Path -> m (NValue t f m) Source #

evalEnvPath :: Path -> m (NValue t f m) Source #

evalUnary :: NUnaryOp -> NValue t f m -> m (NValue t f m) Source #

evalBinary :: NBinaryOp -> NValue t f m -> m (NValue t f m) -> m (NValue t f m) Source #

evalWith :: m (NValue t f m) -> m (NValue t f m) -> m (NValue t f m) Source #

evalIf :: NValue t f m -> m (NValue t f m) -> m (NValue t f m) -> m (NValue t f m) Source #

evalAssert :: NValue t f m -> m (NValue t f m) -> m (NValue t f m) Source #

evalApp :: NValue t f m -> m (NValue t f m) -> m (NValue t f m) Source #

evalAbs :: Params (m (NValue t f m)) -> (forall a. m (NValue t f m) -> (AttrSet (m (NValue t f m)) -> m (NValue t f m) -> m (a, NValue t f m)) -> m (a, NValue t f m)) -> m (NValue t f m) Source #

evalError :: Exception s => s -> m a Source #

(Comonad f, Show a) => Show (NValue' t f m a) Source # 
Instance details

Defined in Nix.Value

Methods

showsPrec :: Int -> NValue' t f m a -> ShowS #

show :: NValue' t f m a -> String #

showList :: [NValue' t f m a] -> ShowS #

Generic (NValue' t f m a) Source # 
Instance details

Defined in Nix.Value

Associated Types

type Rep (NValue' t f m a) :: Type -> Type #

Methods

from :: NValue' t f m a -> Rep (NValue' t f m a) x #

to :: Rep (NValue' t f m a) x -> NValue' t f m a #

type Rep (NValue' t f m a) Source # 
Instance details

Defined in Nix.Value

type Rep (NValue' t f m a) = D1 ('MetaData "NValue'" "Nix.Value" "hnix-0.16.0-8yNt853wvoc5yRPRKlu02G" 'True) (C1 ('MetaCons "NValue'" 'PrefixI 'True) (S1 ('MetaSel ('Just "_nValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f (NValueF (NValue t f m) m a)))))

Show1

Traversable

sequenceNValue' :: (Functor n, Traversable f, Monad m, Applicative n) => (forall x. n x -> m x) -> NValue' t f m (n a) -> n (NValue' t f m a) Source #

sequence

Profunctor

lmapNValueF :: Functor m => (b -> a) -> NValueF a m r -> NValueF b m r Source #

lmap

Free

iterNValue' :: forall t f m a r. MonadDataContext f m => ((NValue' t f m a -> r) -> a -> r) -> (NValue' t f m r -> r) -> NValue' t f m a -> r Source #

iter

Utils

hoistNValue' :: (Functor m, Functor n, Functor f) => (forall x. n x -> m x) -> (forall x. m x -> n x) -> NValue' t f m a -> NValue' t f n a Source #

hoistFree: Back & forth hoisting in the monad stack

Monad

bindNValue' :: (Traversable f, Monad m, Monad n) => (forall x. n x -> m x) -> (a -> n b) -> NValue' t f m a -> n (NValue' t f m b) Source #

bind

MonadTrans

liftNValue' :: (MonadTrans u, Monad m, Functor (u m), Functor f) => (forall x. u m x -> m x) -> NValue' t f m a -> NValue' t f (u m) a Source #

lift

MonadTransUnlift

unliftNValue' :: (MonadTrans u, Monad m, Functor (u m), Functor f) => (forall x. u m x -> m x) -> NValue' t f (u m) a -> NValue' t f m a Source #

unlift

Bijective Hask subcategory - NValue'

F: Hask subcategory → NValue'

F: Hask → NValue'

Since Haskell and Nix are both recursive purely functional lazy languages. And since recursion-schemes. It is possible to create a direct functor between the Hask and Nix categories. Or make Nix a DLS language of Haskell, embed it into a Hask, if you would like. Of course, we mean: pick Hask subcategory and form Nix Category from it. Take subcategory of Hask, and by applying functor to it - have a Nix Category. Wouldn't it be cool and fast?

In fact - it is what we do here.

Since it is a proper way of scientific implementation, we would eventually form a lawful functor.

Facts of which are seen below:

mkNVConstant' :: Applicative f => NAtom -> NValue' t f m r Source #

Haskell constant to the Nix constant,

nvNull' :: Applicative f => NValue' t f m r Source #

Using of Nulls is generally discouraged (in programming language design et al.), but, if you need it.

mkNVStr' :: Applicative f => NixString -> NValue' t f m r Source #

Haskell text & context to the Nix text & context,

mkNVPath' :: Applicative f => Path -> NValue' t f m r Source #

Haskell Path to the Nix path,

mkNVList' :: Applicative f => [r] -> NValue' t f m r Source #

Haskell [] to the Nix [],

mkNVSet' :: Applicative f => PositionSet -> AttrSet r -> NValue' t f m r Source #

Haskell key-value to the Nix key-value,

mkNVClosure' :: (Applicative f, Functor m) => Params () -> (NValue t f m -> m r) -> NValue' t f m r Source #

Haskell closure to the Nix closure,

mkNVBuiltin' :: (Applicative f, Functor m) => VarName -> (NValue t f m -> m r) -> NValue' t f m r Source #

Haskell functions to the Nix functions!

F: NValue -> NValue'

pattern NVConstant' :: Comonad w => NAtom -> NValue' t w m a Source #

Module pattens use language PatternSynonyms: unidirectional synonyms (<-), and ViewPatterns: (->) at the same time. ViewPatterns Control.Comonad.extract extracts from the NValue (Free (NValueF a)) the NValueF a. Which is NValueF p m r. Since it extracted from the NValue, which is formed by \( (F a -> a) F a \) in the first place. So NValueF p m r which is extracted here, internally holds the next NValue.

pattern NVStr' :: Comonad w => NixString -> NValue' t w m a Source #

pattern NVPath' :: Comonad w => Path -> NValue' t w m a Source #

pattern NVList' :: forall w t m a. Comonad w => [a] -> NValue' t w m a Source #

pattern NVSet' :: forall w t m a. Comonad w => PositionSet -> AttrSet a -> NValue' t w m a Source #

pattern NVClosure' :: Comonad w => Params () -> (NValue t w m -> m a) -> NValue' t w m a Source #

pattern NVBuiltin' :: Comonad w => VarName -> (NValue t w m -> m a) -> NValue' t w m a Source #

NValue: Nix language values

type NValue t f m = Free (NValue' t f m) t Source #

'NValue t f m' is a value in head normal form (it means only the tip of it has been evaluated to the normal form, while the rest of it is in lazy not evaluated form (thunk), this known as WHNF).

An action 'm (NValue t f m)' is a pending evaluation that has yet to be performed.

An t is either: * a pending evaluation. * a value in head normal form.

The Free structure is used here to represent the possibility that Nix language allows cycles that may appear during normalization.

Free

iterNValue :: forall t f m r. MonadDataContext f m => ((NValue t f m -> r) -> t -> r) -> (NValue' t f m r -> r) -> NValue t f m -> r Source #

HOF of iter from Free

iterNValueByDiscardWith :: MonadDataContext f m => r -> (NValue' t f m r -> r) -> NValue t f m -> r Source #

iterNValueM :: (MonadDataContext f m, Monad n) => (forall x. n x -> m x) -> ((NValue t f m -> n r) -> t -> n r) -> (NValue' t f m (n r) -> n r) -> NValue t f m -> n r Source #

HOF of iterM from Free

Utils

hoistNValue :: (Functor m, Functor n, Functor f) => (forall x. n x -> m x) -> (forall x. m x -> n x) -> NValue t f m -> NValue t f n Source #

hoistFree, Back & forth hoisting in the monad stack

MonadTrans

liftNValue :: (MonadTrans u, Monad m, Functor (u m), Functor f) => (forall x. u m x -> m x) -> NValue t f m -> NValue t f (u m) Source #

lift

MonadTransUnlift

unliftNValue :: (MonadTrans u, Monad m, Functor (u m), Functor f) => (forall x. u m x -> m x) -> NValue t f (u m) -> NValue t f m Source #

unlift

Methods F: Hask → NValue

F: Hask → NValue

The morphisms of the functor Hask → NValue. Continuation of the mantra: Nix.Value

mkNVThunk :: Applicative f => t -> NValue t f m Source #

Life of a Haskell thunk to the life of a Nix thunk,

mkNVConstant :: Applicative f => NAtom -> NValue t f m Source #

Life of a Haskell constant to the life of a Nix constant,

nvNull :: Applicative f => NValue t f m Source #

Using of Nulls is generally discouraged (in programming language design et al.), but, if you need it.

mkNVStr :: Applicative f => NixString -> NValue t f m Source #

Life of a Haskell sting & context to the life of a Nix string & context,

mkNVPath :: Applicative f => Path -> NValue t f m Source #

Life of a Haskell FilePath to the life of a Nix path

mkNVList :: Applicative f => [NValue t f m] -> NValue t f m Source #

mkNVClosure :: (Applicative f, Functor m) => Params () -> (NValue t f m -> m (NValue t f m)) -> NValue t f m Source #

mkNVBuiltin :: (Applicative f, Functor m) => VarName -> (NValue t f m -> m (NValue t f m)) -> NValue t f m Source #

builtin Source #

Arguments

:: forall m f t. (MonadThunk t m (NValue t f m), MonadDataContext f m) 
=> VarName

function name

-> (NValue t f m -> m (NValue t f m))

unary function

-> m (NValue t f m) 

builtin2 Source #

Arguments

:: (MonadThunk t m (NValue t f m), MonadDataContext f m) 
=> VarName

function name

-> (NValue t f m -> NValue t f m -> m (NValue t f m))

binary function

-> m (NValue t f m) 

builtin3 Source #

Arguments

:: (MonadThunk t m (NValue t f m), MonadDataContext f m) 
=> VarName

function name

-> (NValue t f m -> NValue t f m -> NValue t f m -> m (NValue t f m))

ternary function

-> m (NValue t f m) 

F: Evaluation -> NValue

pattern NVThunk :: forall f a. a -> Free f a Source #

pattern NVValue :: f (Free f a) -> Free f a Source #

pattern NVConstant :: forall (w :: Type -> Type) t (m :: Type -> Type) a. Comonad w => NAtom -> Free (NValue' t w m) a Source #

pattern NVStr :: forall (w :: Type -> Type) t (m :: Type -> Type) a. Comonad w => NixString -> Free (NValue' t w m) a Source #

pattern NVPath :: forall (w :: Type -> Type) t (m :: Type -> Type) a. Comonad w => Path -> Free (NValue' t w m) a Source #

pattern NVList :: forall (w :: Type -> Type) t (m :: Type -> Type) a. Comonad w => [Free (NValue' t w m) a] -> Free (NValue' t w m) a Source #

pattern NVSet :: forall (w :: Type -> Type) t (m :: Type -> Type) a. Comonad w => PositionSet -> AttrSet (Free (NValue' t w m) a) -> Free (NValue' t w m) a Source #

pattern NVClosure :: forall (w :: Type -> Type) t m a. Comonad w => Params () -> (NValue t w m -> m (Free (NValue' t w m) a)) -> Free (NValue' t w m) a Source #

pattern NVBuiltin :: forall (w :: Type -> Type) t m a. Comonad w => VarName -> (NValue t w m -> m (Free (NValue' t w m) a)) -> Free (NValue' t w m) a Source #

TStringContext

ValueType

data ValueType Source #

Instances

Instances details
Show ValueType Source # 
Instance details

Defined in Nix.Value

valueType :: NValueF a m r -> ValueType Source #

Determine type of a value

describeValue :: ValueType -> Text Source #

Describe type value

showValueType :: (MonadThunk t m (NValue t f m), Comonad f) => NValue t f m -> m Text Source #

ValueFrame

data ValueFrame t f m Source #

Instances

Instances details
(Comonad f, Show t) => Show (ValueFrame t f m) Source # 
Instance details

Defined in Nix.Value

Methods

showsPrec :: Int -> ValueFrame t f m -> ShowS #

show :: ValueFrame t f m -> String #

showList :: [ValueFrame t f m] -> ShowS #

MonadDataErrorContext t f m => Exception (ValueFrame t f m) Source # 
Instance details

Defined in Nix.Value

MonadDataContext

MonadDataErrorContext

instance Eq1 NValue'

NValueF traversals, getter & setters

_NVBuiltinF :: Applicative f => ((VarName, p -> m r) -> f (VarName, p -> m r)) -> NValueF p m r -> f (NValueF p m r) Source #

Make traversals for Nix traversable structures.

_NVClosureF :: Applicative f => ((Params (), p -> m r) -> f (Params (), p -> m r)) -> NValueF p m r -> f (NValueF p m r) Source #

_NVSetF :: forall f r p (m :: Type -> Type). Applicative f => ((PositionSet, AttrSet r) -> f (PositionSet, AttrSet r)) -> NValueF p m r -> f (NValueF p m r) Source #

_NVListF :: forall f r p (m :: Type -> Type). Applicative f => ([r] -> f [r]) -> NValueF p m r -> f (NValueF p m r) Source #

_NVPathF :: forall f p (m :: Type -> Type) r. Applicative f => (Path -> f Path) -> NValueF p m r -> f (NValueF p m r) Source #

_NVStrF :: forall f p (m :: Type -> Type) r. Applicative f => (NixString -> f NixString) -> NValueF p m r -> f (NValueF p m r) Source #

_NVConstantF :: forall f p (m :: Type -> Type) r. Applicative f => (NAtom -> f NAtom) -> NValueF p m r -> f (NValueF p m r) Source #

nValue :: forall f1 f2 t1 (m1 :: Type -> Type) a1 f3 t2 (m2 :: Type -> Type) a2. Functor f1 => (f2 (NValueF (NValue t1 f2 m1) m1 a1) -> f1 (f3 (NValueF (NValue t2 f3 m2) m2 a2))) -> NValue' t1 f2 m1 a1 -> f1 (NValue' t2 f3 m2 a2) Source #

Make lenses for the Nix values

key :: (Traversable f, Applicative g) => VarName -> LensLike' g (NValue' t f m a) (Maybe a) Source #

Lens-generated getter-setter function for a traversable NValue' key-val structures. Nix value analogue of the Data-Aeson-Lens:key :: AsValue t => Text -> Traversal' t Value.