Skip to content

Commit 99a38c4

Browse files
Merge #938: Refactors & clean-ups
Breaking: * `Nix.Effects`: * rm `pathExits` in favour of `doesPathExist` (in `Nix.Render`: `class MonadFile`: `doesPathExist`) * Additional: * `Nix.Utils`: * added type `TransformF` * `Nix.Eval`: * added fun: * `evalContent` * `addMetaInfo` * `Nix.Types.Assumption`: * added instances: * `Assumption`: `{Semigroup,Monoid,One}` * `Nix.Type.Env`: * added instances: * `Env`: `{Semigroup,Monoid,One}`
2 parents 6b6366f + 2a3709f commit 99a38c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+728
-637
lines changed

ChangeLog.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11

22
# ChangeLog
33

4+
## [(diff)](https://github.com/haskell-nix/hnix/compare/0.13.1...master#files_bucket) WIP
5+
6+
Breaking:
7+
8+
* `Nix.Effects`:
9+
* rm `pathExits` in favour of `doesPathExist` (in `Nix.Render`: `class MonadFile`: `doesPathExist`)
10+
11+
* Additional:
12+
13+
* `Nix.Utils`:
14+
* added type `TransformF`
15+
16+
* `Nix.Eval`:
17+
* added fun:
18+
* `evalContent`
19+
* `addMetaInfo`
20+
21+
* `Nix.Types.Assumption`:
22+
* added instances:
23+
* `Assumption`: `{Semigroup,Monoid,One}`
24+
* `Nix.Type.Env`:
25+
* added instances:
26+
* `Env`: `{Semigroup,Monoid,One}`
27+
28+
429
### [(diff)](https://github.com/haskell-nix/hnix/compare/0.13.0.1...0.13.1#files_bucket) 0.13.1 (2021-05-22)
530
* [(link)](https://github.com/haskell-nix/hnix/pull/936/files) `Nix.Parser`: `annotateLocation`: Fix source location preservation.
631
* [(link)](https://github.com/haskell-nix/hnix/pull/934/files) Require Cabal dependency `relude` `>= 1.0`: since imports & Cabal file got cleaned-up & that clean-up depends on `relude` reimports introduced in aforementioned version.
@@ -135,8 +160,9 @@
135160
$ Hashable1 NonEmpty:: Nix.Expr.Types -> Void -- please use upstreamed instance
136161

137162
-- | Was upstreamed, released in `ref-tf >= 0.5`.
138-
MonadAtomicRef (Fix1T t m) :: Nix.Standard -> Void
163+
MonadAtomicRef (ST s) :: Nix.Standard -> Void
139164

165+
MonadAtomicRef (Fix1T t m) :: Nix.Standard -> Nix.Utils.Fix1
140166
MonadRef (Fix1T t m) :: Nix.Standard -> Nix.Utils.Fix1
141167
MonadEnv (Fix1T t m) :: Nix.Standard -> Nix.Effects
142168
MonadExec (Fix1T t m) :: Nix.Standard -> Nix.Effects

hnix.cabal

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,23 @@ library
465465
, vector >= 0.12.0 && < 0.13
466466
, xml >= 1.3.14 && < 1.4
467467
default-extensions:
468-
OverloadedStrings
468+
OverloadedStrings
469+
, DeriveGeneric
470+
, DeriveDataTypeable
471+
, DeriveFunctor
472+
, DeriveFoldable
473+
, DeriveTraversable
474+
, DeriveLift
475+
, FlexibleContexts
476+
, FlexibleInstances
477+
, StandaloneDeriving
478+
, TypeApplications
479+
, TypeSynonymInstances
480+
, InstanceSigs
481+
, MultiParamTypeClasses
482+
, TupleSections
483+
, LambdaCase
484+
, BangPatterns
469485
if flag(optimize)
470486
default-extensions:
471487
ApplicativeDo
@@ -511,7 +527,23 @@ executable hnix
511527
, relude (Relude as Prelude)
512528
, relude
513529
default-extensions:
514-
OverloadedStrings
530+
OverloadedStrings
531+
, DeriveGeneric
532+
, DeriveDataTypeable
533+
, DeriveFunctor
534+
, DeriveFoldable
535+
, DeriveTraversable
536+
, DeriveLift
537+
, FlexibleContexts
538+
, FlexibleInstances
539+
, StandaloneDeriving
540+
, TypeApplications
541+
, TypeSynonymInstances
542+
, InstanceSigs
543+
, MultiParamTypeClasses
544+
, TupleSections
545+
, LambdaCase
546+
, BangPatterns
515547
if flag(optimize)
516548
default-extensions:
517549
ApplicativeDo
@@ -568,7 +600,23 @@ test-suite hnix-tests
568600
, time
569601
, unix
570602
default-extensions:
571-
OverloadedStrings
603+
OverloadedStrings
604+
, DeriveGeneric
605+
, DeriveDataTypeable
606+
, DeriveFunctor
607+
, DeriveFoldable
608+
, DeriveTraversable
609+
, DeriveLift
610+
, FlexibleContexts
611+
, FlexibleInstances
612+
, StandaloneDeriving
613+
, TypeApplications
614+
, TypeSynonymInstances
615+
, InstanceSigs
616+
, MultiParamTypeClasses
617+
, TupleSections
618+
, LambdaCase
619+
, BangPatterns
572620
if flag(optimize)
573621
default-extensions:
574622
ApplicativeDo
@@ -600,7 +648,23 @@ benchmark hnix-benchmarks
600648
, template-haskell
601649
, time
602650
default-extensions:
603-
OverloadedStrings
651+
OverloadedStrings
652+
, DeriveGeneric
653+
, DeriveDataTypeable
654+
, DeriveFunctor
655+
, DeriveFoldable
656+
, DeriveTraversable
657+
, DeriveLift
658+
, FlexibleContexts
659+
, FlexibleInstances
660+
, StandaloneDeriving
661+
, TypeApplications
662+
, TypeSynonymInstances
663+
, InstanceSigs
664+
, MultiParamTypeClasses
665+
, TupleSections
666+
, LambdaCase
667+
, BangPatterns
604668
if flag(optimize)
605669
default-extensions:
606670
ApplicativeDo

main/Main.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{-# LANGUAGE MultiWayIf #-}
2-
{-# LANGUAGE FlexibleContexts #-}
3-
{-# LANGUAGE LambdaCase #-}
42
{-# LANGUAGE ScopedTypeVariables #-}
5-
{-# LANGUAGE TupleSections #-}
6-
{-# LANGUAGE TypeApplications #-}
73
{-# LANGUAGE TypeFamilies #-}
84
{-# LANGUAGE ViewPatterns #-}
95

@@ -192,10 +188,10 @@ main =
192188
((k, ) <$> forceEntry path nv)
193189
descend
194190
)
195-
(\ v -> pure (k, pure (Free v)))
191+
(\ v -> pure (k, pure $ Free v))
196192
nv
197193
)
198-
(sortWith fst (M.toList s))
194+
(sortWith fst $ M.toList s)
199195
traverse_
200196
(\ (k, mv) ->
201197
do
@@ -260,7 +256,7 @@ main =
260256
Nix.withNixContext
261257
mp
262258
(Nix.reducingEvalExpr
263-
(Eval.eval . annotated . getCompose)
259+
Eval.evalContent
264260
mp
265261
x
266262
)
@@ -275,8 +271,8 @@ main =
275271
do
276272
liftIO $
277273
do
278-
putStrLn $ "Wrote winnowed expression tree to " <> path
279-
writeFile path $ show $ prettyNix (stripAnnotation expr')
274+
putStrLn $ "Wrote sifted expression tree to " <> path
275+
writeFile path $ show $ prettyNix $ stripAnnotation expr'
280276
either
281277
throwM
282278
pure

main/Repl.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
directory for more details.
88
-}
99

10-
{-# LANGUAGE LambdaCase #-}
11-
{-# LANGUAGE FlexibleContexts #-}
1210
{-# LANGUAGE MultiWayIf #-}
1311
{-# LANGUAGE ScopedTypeVariables #-}
14-
{-# LANGUAGE TupleSections #-}
15-
{-# LANGUAGE TypeApplications #-}
1612

1713
module Repl
1814
( main

src/Nix.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{-# LANGUAGE FlexibleContexts #-}
2-
{-# LANGUAGE LambdaCase #-}
31
{-# LANGUAGE ScopedTypeVariables #-}
42
{-# LANGUAGE ViewPatterns #-}
53

@@ -82,8 +80,8 @@ nixEvalExprLoc
8280
nixEvalExprLoc mpath =
8381
nixEval
8482
mpath
85-
(Eval.addStackFrames . Eval.addSourcePositions)
86-
(Eval.eval . annotated . getCompose)
83+
Eval.addMetaInfo
84+
Eval.evalContent
8785

8886
-- | Evaluate a nix expression with tracing in the default context. Note that
8987
-- this function doesn't do any tracing itself, but 'evalExprLoc' will be
@@ -110,8 +108,8 @@ evaluateExpression mpath evaluator handler expr =
110108
args <-
111109
(traverse . traverse)
112110
eval'
113-
$ (second parseArg <$> arg opts) <>
114-
(second mkStr <$> argstr opts)
111+
$ (second parseArg <$> arg opts)
112+
<> (second mkStr <$> argstr opts)
115113
f <- evaluator mpath expr
116114
f' <- demand f
117115
val <-
@@ -143,7 +141,7 @@ processResult h val = do
143141
(\ (Text.splitOn "." -> keys) -> go keys val)
144142
(attr opts)
145143
where
146-
go :: [Text.Text] -> NValue t f m -> m a
144+
go :: [Text] -> NValue t f m -> m a
147145
go [] v = h v
148146
go ((Text.decimal -> Right (n,"")) : ks) v =
149147
(\case

src/Nix/Atoms.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE DeriveAnyClass #-}
3-
{-# LANGUAGE DeriveDataTypeable #-}
4-
{-# LANGUAGE DeriveGeneric #-}
53

64
module Nix.Atoms where
75

0 commit comments

Comments
 (0)