Skip to content

Commit 302af6d

Browse files
committed
Value: form section "F: NValue -> NValue'"
1 parent a93c09a commit 302af6d

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/Nix/Value.hs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,30 +335,26 @@ unliftNValue' = hoistNValue' lift
335335

336336

337337
-- | Haskell constant to the Nix constant,
338-
pattern NVConstant' x <- NValue (extract -> NVConstantF x)
339338
nvConstant' :: Applicative f
340339
=> NAtom
341340
-> NValue' t f m r
342341
nvConstant' = NValue . pure . NVConstantF
343342

344343

345-
pattern NVStr' ns <- NValue (extract -> NVStrF ns)
346344
-- | Haskell text & context to the Nix text & context,
347345
nvStr' :: Applicative f
348346
=> NixString
349347
-> NValue' t f m r
350348
nvStr' = NValue . pure . NVStrF
351349

352350

353-
pattern NVPath' x <- NValue (extract -> NVPathF x)
354351
-- | Haskell @FilePath@ to the Nix path,
355352
nvPath' :: Applicative f
356353
=> FilePath
357354
-> NValue' t f m r
358355
nvPath' = NValue . pure . NVPathF
359356

360357

361-
pattern NVList' l <- NValue (extract -> NVListF l)
362358
-- | Haskell @[]@ to the Nix @[]@,
363359
nvList' :: Applicative f
364360
=> [r]
@@ -367,7 +363,6 @@ nvList' = NValue . pure . NVListF
367363

368364

369365
-- | Haskell key-value to the Nix key-value,
370-
pattern NVSet' s x <- NValue (extract -> NVSetF s x)
371366
nvSet' :: Applicative f
372367
=> HashMap Text r
373368
-> HashMap Text SourcePos
@@ -376,7 +371,6 @@ nvSet' s x = NValue $ pure $ NVSetF s x
376371

377372

378373
-- | Haskell closure to the Nix closure,
379-
pattern NVClosure' x f <- NValue (extract -> NVClosureF x f)
380374
nvClosure' :: (Applicative f, Functor m)
381375
=> Params ()
382376
-> (NValue t f m
@@ -387,7 +381,6 @@ nvClosure' x f = NValue $ pure $ NVClosureF x f
387381

388382

389383
-- | Haskell functions to the Nix functions!
390-
pattern NVBuiltin' name f <- NValue (extract -> NVBuiltinF name f)
391384
nvBuiltin' :: (Applicative f, Functor m)
392385
=> String
393386
-> (NValue t f m -> m r)
@@ -398,6 +391,24 @@ nvBuiltin' name f = NValue $ pure $ NVBuiltinF name f
398391
-- So above we have maps of Hask subcategory objects to Nix objects,
399392
-- and Hask subcategory morphisms to Nix morphisms.
400393

394+
-- *** @F: NValue -> Nvalue'
395+
396+
-- | Module pattens use @language PatternSynonyms@: unidirectional synonyms (@<-@),
397+
-- and @ViewPatterns@: (@->@) at the same time.
398+
-- @ViewPatterns Control.Comonad.extract@ extracts
399+
-- from the @NValue (Free (NValueF a))@
400+
-- the @NValueF a@. Which is @NValueF p m r@. Since it extracted from the
401+
-- @NValue@, which is formed by \( (F a -> a) F a \) in the first place.
402+
-- So @NValueF p m r@ which is extracted here, internally holds the next NValue.
403+
pattern NVConstant' x <- NValue (extract -> NVConstantF x)
404+
pattern NVStr' ns <- NValue (extract -> NVStrF ns)
405+
pattern NVPath' x <- NValue (extract -> NVPathF x)
406+
pattern NVList' l <- NValue (extract -> NVListF l)
407+
pattern NVSet' s x <- NValue (extract -> NVSetF s x)
408+
pattern NVClosure' x f <- NValue (extract -> NVClosureF x f)
409+
pattern NVBuiltin' name f <- NValue (extract -> NVBuiltinF name f)
410+
411+
401412
-- * @__NValue__@: Nix language values
402413

403414
-- | 'NValue t f m' is

0 commit comments

Comments
 (0)