Fix isString to refrain from coercing values
Derivations can be automatically coerced to strings. They are however not strings and `isString` should return `False` on them.
This commit is contained in:
parent
48ed345075
commit
d32a6fbaf3
|
@ -1040,10 +1040,6 @@ isList
|
|||
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
|
||||
isList = hasKind @[NValue t f m]
|
||||
|
||||
isString
|
||||
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
|
||||
isString = hasKind @NixString
|
||||
|
||||
isInt
|
||||
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
|
||||
isInt = hasKind @Int
|
||||
|
@ -1060,6 +1056,12 @@ isNull
|
|||
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
|
||||
isNull = hasKind @()
|
||||
|
||||
-- isString cannot use `hasKind` because it coerces derivations to strings.
|
||||
isString :: MonadNix e t f m => NValue t f m -> m (NValue t f m)
|
||||
isString v = demand v $ \case
|
||||
NVStr{} -> toValue True
|
||||
_ -> toValue False
|
||||
|
||||
isFunction :: MonadNix e t f m => NValue t f m -> m (NValue t f m)
|
||||
isFunction func = demand func $ \case
|
||||
NVClosure{} -> toValue True
|
||||
|
|
Loading…
Reference in New Issue