Skip to content

Commit edaec8e

Browse files
Merge #945: Refactors
I've switched to "pre 0.9" type of ChangeLog. *(no logging)* Huge release `0.13` - tested the waters & showed from reality that we do not need to maintain that kind of open API and so that volume of ChangeLog, as those who use HNix as a library (mainly DHall) - use `Shorthands` module & that is pretty much all, and all others were notified & not showed-up to show any concerns. People were notified in ChangeLog & the channel & I frequently talk about that we need to close the API to be able to not keep & dump that volume of changelog & "major API (no one uses) functionality breakage releases" on ourselves (me) & users, and there is no other way to make reorganization to form multiple packages, multiple packages - is a major breakage anyway, we would need to untie uncycle all dependencies between created packages & that in itself can be a big effort. So, in short - do not see need from users, the point or the possibility to keep a changelog during that volume of breakage & reorganization. As always, if someone would need help - happy to help to migrate. This is needed to save everyone's efforts upfront: ["Internal" modules is a mistake](http://nikita-volkov.github.io/internal-convention-is-a-mistake/) That is why I stand for #823, package splitting would save a lot of effort for maintainers & for users.
2 parents 70a8e14 + 3d98471 commit edaec8e

37 files changed

+610
-491
lines changed

ChangeLog.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33

44
## [(diff)](https://github.com/haskell-nix/hnix/compare/0.13.1...master#files_bucket) WIP
55

6-
Breaking:
6+
* Breaking:
77

88
* `Nix.Effects`:
99
* rm `pathExits` in favour of `doesPathExist` (in `Nix.Render`: `class MonadFile`: `doesPathExist`)
1010

11+
* `Nix.Var`: was found being superflous ([report](https://github.com/haskell-nix/hnix/issues/946)), so reduced. use `Control.Monad.Ref` instead.
12+
13+
* `Nix.Normal`
14+
* rename `opaque(,->Val)`, indicate that it is a literal.
15+
16+
* `Nix.Thunk`:
17+
* `class MonadThunkId m => MonadThunk{,F} t m a`:
18+
* rename `query(M->){,F}`
19+
1120
* Additional:
1221

1322
* `Nix.Utils`:
@@ -25,6 +34,7 @@ Breaking:
2534
* `Nix.Type.Env`:
2635
* added instances:
2736
* `Env`: `{Semigroup,Monoid,One}`
37+
2838
* `Nix`:
2939
* changed argument order:
3040
* `nixEval`:
@@ -38,8 +48,9 @@ Breaking:
3848

3949
* `Nix.Normal`
4050
* add `thunkVal` literal & use it where appropriate `{deThunk, removeEffects}`
41-
* rename `opaque(,->Val)`, indicate that it is a literal.
42-
51+
52+
* `Nix.Thunk.Basic`:
53+
* export `deferred`
4354

4455

4556
### [(diff)](https://github.com/haskell-nix/hnix/compare/0.13.0.1...0.13.1#files_bucket) 0.13.1 (2021-05-22)

hnix.cabal

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ library
400400
base hiding (Prelude)
401401
, relude (Relude as Prelude)
402402
, relude
403-
ghc-options: -Wall -fprint-potential-instances
403+
ghc-options:
404+
-Wall
405+
-fprint-potential-instances
404406
build-depends:
405407
aeson >= 1.4.2 && < 1.6
406408
, array >= 0.4 && < 0.6
@@ -485,7 +487,10 @@ library
485487
if flag(optimize)
486488
default-extensions:
487489
ApplicativeDo
488-
ghc-options: -fexpose-all-unfoldings -fspecialise-aggressively -O2
490+
ghc-options:
491+
-O2
492+
-fexpose-all-unfoldings
493+
-fspecialise-aggressively
489494
-- if !flag(profiling)
490495
-- build-depends:
491496
-- ghc-datasize
@@ -500,7 +505,8 @@ executable hnix
500505
Paths_hnix
501506
autogen-modules:
502507
Paths_hnix
503-
ghc-options: -Wall
508+
ghc-options:
509+
-Wall
504510
build-depends:
505511
aeson
506512
, base
@@ -547,7 +553,10 @@ executable hnix
547553
if flag(optimize)
548554
default-extensions:
549555
ApplicativeDo
550-
ghc-options: -fexpose-all-unfoldings -fspecialise-aggressively -O2
556+
ghc-options:
557+
-O2
558+
-fexpose-all-unfoldings
559+
-fspecialise-aggressively
551560
if impl(ghc < 8.10)
552561
-- GHC < 8.10 comes with haskeline < 0.8, which we don't support.
553562
-- To simplify CI, we just disable the component.
@@ -571,7 +580,9 @@ test-suite hnix-tests
571580
, relude
572581
hs-source-dirs:
573582
tests
574-
ghc-options: -Wall -threaded
583+
ghc-options:
584+
-Wall
585+
-threaded
575586
build-depends:
576587
Diff
577588
, Glob
@@ -620,7 +631,10 @@ test-suite hnix-tests
620631
if flag(optimize)
621632
default-extensions:
622633
ApplicativeDo
623-
ghc-options: -fexpose-all-unfoldings -fspecialise-aggressively -O2
634+
ghc-options:
635+
-O2
636+
-fexpose-all-unfoldings
637+
-fspecialise-aggressively
624638
default-language: Haskell2010
625639

626640
benchmark hnix-benchmarks
@@ -634,7 +648,8 @@ benchmark hnix-benchmarks
634648
base hiding (Prelude)
635649
, relude (Relude as Prelude)
636650
, relude
637-
ghc-options: -Wall
651+
ghc-options:
652+
-Wall
638653
build-depends:
639654
base
640655
, criterion
@@ -668,5 +683,8 @@ benchmark hnix-benchmarks
668683
if flag(optimize)
669684
default-extensions:
670685
ApplicativeDo
671-
ghc-options: -fexpose-all-unfoldings -fspecialise-aggressively -O2
686+
ghc-options:
687+
-O2
688+
-fexpose-all-unfoldings
689+
-fspecialise-aggressively
672690
default-language: Haskell2010

main/Main.hs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import Control.Comonad ( extract )
1010
import qualified Control.DeepSeq as Deep
1111
import qualified Control.Exception as Exc
1212
import GHC.Err ( errorWithoutStackTrace )
13+
import Control.Monad.Free
14+
import Control.Monad.Ref ( MonadRef(readRef) )
1315
import Control.Monad.Catch
1416
import System.IO ( hPutStrLn, getContents )
15-
import Control.Monad.Free
1617
import qualified Data.HashMap.Lazy as M
1718
import qualified Data.Map as Map
1819
import Data.Maybe ( fromJust )
@@ -27,9 +28,9 @@ import Nix.Json
2728
import Nix.Options.Parser
2829
import Nix.Standard
2930
import Nix.Thunk.Basic
30-
import qualified Nix.Type.Env as Env
31+
import Nix.Type.Env ( Env(..) )
32+
import Nix.Type.Type ( Scheme )
3133
import qualified Nix.Type.Infer as HM
32-
import Nix.Var
3334
import Nix.Value.Monad
3435
import Options.Applicative hiding ( ParserResult(..) )
3536
import Prettyprinter hiding ( list )
@@ -43,7 +44,7 @@ main :: IO ()
4344
main =
4445
do
4546
time <- getCurrentTime
46-
opts <- execParser (nixOptionsInfo time)
47+
opts <- execParser $ nixOptionsInfo time
4748

4849
runWithBasicEffectsIO opts $ execContentsFilesOrRepl opts
4950

@@ -103,9 +104,9 @@ main =
103104
either
104105
(\ err -> errorWithoutStackTrace $ "Type error: " <> PS.ppShow err)
105106
(\ ty -> liftIO $ putStrLn $ "Type of expression: " <> PS.ppShow
106-
(fromJust $ Map.lookup "it" $ Env.types ty)
107+
(fromJust $ Map.lookup "it" (coerce ty :: Map Text [Scheme]))
107108
)
108-
(HM.inferTop Env.empty [("it", stripAnnotation expr')])
109+
(HM.inferTop mempty [("it", stripAnnotation expr')])
109110

110111
-- liftIO $ putStrLn $ runST $
111112
-- runLintM opts . renderSymbolic =<< lint opts expr
@@ -177,23 +178,26 @@ main =
177178
xs <-
178179
traverse
179180
(\ (k, nv) ->
181+
(k, ) <$>
180182
free
181183
(\ (StdThunk (extract -> Thunk _ _ ref)) ->
182184
do
183185
let
184186
path = prefix <> k
185187
(_, descend) = filterEntry path k
186188

187-
val <- readVar @(StandardT (StdIdT IO)) ref
188-
case val of
189-
Computed _ -> pure (k, Nothing)
190-
_ ->
191-
bool
192-
(pure (k, Nothing))
193-
((k, ) <$> forceEntry path nv)
194-
descend
189+
val <- readRef @(StandardT (StdIdT IO)) ref
190+
bool
191+
(pure Nothing)
192+
(forceEntry path nv)
193+
(descend &&
194+
deferred
195+
(const False)
196+
(const True)
197+
val
198+
)
195199
)
196-
(\ v -> pure (k, pure $ Free v))
200+
(pure . pure . Free)
197201
nv
198202
)
199203
(sortWith fst $ M.toList s)
@@ -278,7 +282,4 @@ main =
278282
do
279283
putStrLn $ "Wrote sifted expression tree to " <> path
280284
writeFile path $ show $ prettyNix $ stripAnnotation expr'
281-
either
282-
throwM
283-
pure
284-
eres
285+
either throwM pure eres

main/Repl.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ exec update source = do
208208
-- import qualified Nix.Type.Env as Env
209209
-- import Nix.Type.Infer
210210
--
211-
-- let tyctx' = inferTop Env.empty [("repl", stripAnnotation expr)]
211+
-- let tyctx' = inferTop mempty [("repl", stripAnnotation expr)]
212212
-- liftIO $ print tyctx'
213213

214214
mVal <- lift $ lift $ try $ pushScope (replCtx st) (evalExprLoc expr)
@@ -225,7 +225,7 @@ exec update source = do
225225

226226
-- If the result value is a set, update our context with it
227227
case val of
228-
NVSet xs _ -> put st { replCtx = Data.HashMap.Lazy.union xs (replCtx st) }
228+
NVSet xs _ -> put st { replCtx = xs <> replCtx st }
229229
_ -> pass
230230

231231
pure $ pure val

src/Nix.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ nixEval
6060
-> Maybe FilePath
6161
-> Fix g
6262
-> m a
63-
nixEval transform alg mpath = withNixContext mpath . adi alg transform
63+
nixEval transform alg mpath = withNixContext mpath . adi transform alg
6464

6565
-- | Evaluate a nix expression in the default context
6666
nixEvalExpr

src/Nix/Atoms.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
module Nix.Atoms where
55

6-
#ifdef MIN_VERSION_serialise
76
import Codec.Serialise ( Serialise )
8-
#endif
97

108
import Data.Data ( Data)
119
import Data.Fixed ( mod' )
@@ -48,9 +46,7 @@ data NAtom
4846
, Hashable
4947
)
5048

51-
#ifdef MIN_VERSION_serialise
5249
instance Serialise NAtom
53-
#endif
5450

5551
instance Binary NAtom
5652
instance ToJSON NAtom

0 commit comments

Comments
 (0)