|
1 | | -{-# LANGUAGE AllowAmbiguousTypes #-} |
2 | | -{-# LANGUAGE ConstraintKinds #-} |
3 | | -{-# LANGUAGE DataKinds #-} |
4 | 1 | {-# LANGUAGE DeriveAnyClass #-} |
5 | | -{-# LANGUAGE DeriveDataTypeable #-} |
| 2 | +{-# LANGUAGE KindSignatures #-} |
| 3 | +{-# LANGUAGE ConstraintKinds #-} |
6 | 4 | {-# LANGUAGE DeriveGeneric #-} |
7 | 5 | {-# LANGUAGE DeriveTraversable #-} |
8 | 6 | {-# LANGUAGE FlexibleContexts #-} |
9 | 7 | {-# LANGUAGE FlexibleInstances #-} |
10 | | -{-# LANGUAGE FunctionalDependencies #-} |
11 | | -{-# LANGUAGE GADTs #-} |
12 | 8 | {-# LANGUAGE LambdaCase #-} |
13 | | -{-# LANGUAGE OverloadedStrings #-} |
14 | 9 | {-# LANGUAGE PatternSynonyms #-} |
15 | 10 | {-# LANGUAGE RankNTypes #-} |
16 | 11 | {-# LANGUAGE ScopedTypeVariables #-} |
17 | 12 | {-# LANGUAGE StandaloneDeriving #-} |
18 | 13 | {-# LANGUAGE TemplateHaskell #-} |
19 | | -{-# LANGUAGE TypeApplications #-} |
20 | | -{-# LANGUAGE TypeFamilies #-} |
21 | | -{-# LANGUAGE TypeOperators #-} |
22 | | -{-# LANGUAGE UndecidableInstances #-} |
23 | 14 | {-# LANGUAGE ViewPatterns #-} |
24 | 15 |
|
25 | 16 | {-# OPTIONS_GHC -Wno-missing-signatures #-} |
@@ -242,12 +233,11 @@ iterNValue' |
242 | 233 | -> r |
243 | 234 | iterNValue' k f = f . fmap (\a -> k a (iterNValue' k f)) |
244 | 235 |
|
245 | | --- | An 'NValueNF' is a fully evaluated value in normal form. An 'NValue f t m' is |
| 236 | +-- | A 'NValue t f m' is |
246 | 237 | -- a value in head normal form, where only the "top layer" has been |
247 | | --- evaluated. An action of type 'm (NValue f t m)' is a pending evaluation that |
| 238 | +-- evaluated. An action of type 'm (NValue t f m)' is a pending evaluation that |
248 | 239 | -- has yet to be performed. An 't' is either a pending evaluation, or |
249 | | --- a value in head normal form. A 'NThunkSet' is a set of mappings from keys |
250 | | --- to thunks. |
| 240 | +-- a value in head normal form. |
251 | 241 | -- |
252 | 242 | -- The 'Free' structure is used here to represent the possibility that |
253 | 243 | -- cycles may appear during normalization. |
@@ -307,64 +297,63 @@ pattern NVConstant' x <- NValue (extract -> NVConstantF x) |
307 | 297 | pattern NVConstant x <- Free (NVConstant' x) |
308 | 298 |
|
309 | 299 | nvConstant' :: Applicative f => NAtom -> NValue' t f m r |
310 | | -nvConstant' x = NValue (pure (NVConstantF x)) |
| 300 | +nvConstant' = NValue . pure . NVConstantF |
311 | 301 | nvConstant :: Applicative f => NAtom -> NValue t f m |
312 | | -nvConstant x = Free (NValue (pure (NVConstantF x))) |
| 302 | +nvConstant = Free . nvConstant' |
313 | 303 |
|
314 | 304 | pattern NVStr' ns <- NValue (extract -> NVStrF ns) |
315 | 305 | pattern NVStr ns <- Free (NVStr' ns) |
316 | 306 |
|
317 | 307 | nvStr' :: Applicative f => NixString -> NValue' t f m r |
318 | | -nvStr' ns = NValue (pure (NVStrF ns)) |
| 308 | +nvStr' = NValue . pure . NVStrF |
319 | 309 | nvStr :: Applicative f => NixString -> NValue t f m |
320 | | -nvStr ns = Free (NValue (pure (NVStrF ns))) |
| 310 | +nvStr = Free . nvStr' |
321 | 311 |
|
322 | 312 | pattern NVPath' x <- NValue (extract -> NVPathF x) |
323 | 313 | pattern NVPath x <- Free (NVPath' x) |
324 | 314 |
|
325 | 315 | nvPath' :: Applicative f => FilePath -> NValue' t f m r |
326 | | -nvPath' x = NValue (pure (NVPathF x)) |
| 316 | +nvPath' = NValue . pure . NVPathF |
327 | 317 | nvPath :: Applicative f => FilePath -> NValue t f m |
328 | | -nvPath x = Free (NValue (pure (NVPathF x))) |
| 318 | +nvPath = Free . nvPath' |
329 | 319 |
|
330 | 320 | pattern NVList' l <- NValue (extract -> NVListF l) |
331 | 321 | pattern NVList l <- Free (NVList' l) |
332 | 322 |
|
333 | 323 | nvList' :: Applicative f => [r] -> NValue' t f m r |
334 | | -nvList' l = NValue (pure (NVListF l)) |
| 324 | +nvList' = NValue . pure . NVListF |
335 | 325 | nvList :: Applicative f => [NValue t f m] -> NValue t f m |
336 | | -nvList l = Free (NValue (pure (NVListF l))) |
| 326 | +nvList = Free . nvList' |
337 | 327 |
|
338 | 328 | pattern NVSet' s x <- NValue (extract -> NVSetF s x) |
339 | 329 | pattern NVSet s x <- Free (NVSet' s x) |
340 | 330 |
|
341 | 331 | nvSet' :: Applicative f |
342 | 332 | => HashMap Text r -> HashMap Text SourcePos -> NValue' t f m r |
343 | | -nvSet' s x = NValue (pure (NVSetF s x)) |
| 333 | +nvSet' s x = NValue $ pure $ NVSetF s x |
344 | 334 | nvSet :: Applicative f |
345 | 335 | => HashMap Text (NValue t f m) -> HashMap Text SourcePos -> NValue t f m |
346 | | -nvSet s x = Free (NValue (pure (NVSetF s x))) |
| 336 | +nvSet s x = Free $ nvSet' s x |
347 | 337 |
|
348 | 338 | pattern NVClosure' x f <- NValue (extract -> NVClosureF x f) |
349 | 339 | pattern NVClosure x f <- Free (NVClosure' x f) |
350 | 340 |
|
351 | 341 | nvClosure' :: (Applicative f, Functor m) |
352 | 342 | => Params () -> (NValue t f m -> m r) -> NValue' t f m r |
353 | | -nvClosure' x f = NValue (pure (NVClosureF x f)) |
| 343 | +nvClosure' x f = NValue $ pure $ NVClosureF x f |
354 | 344 | nvClosure :: (Applicative f, Functor m) |
355 | 345 | => Params () -> (NValue t f m -> m (NValue t f m)) -> NValue t f m |
356 | | -nvClosure x f = Free (NValue (pure (NVClosureF x f))) |
| 346 | +nvClosure x f = Free $ nvClosure' x f |
357 | 347 |
|
358 | 348 | pattern NVBuiltin' name f <- NValue (extract -> NVBuiltinF name f) |
359 | 349 | pattern NVBuiltin name f <- Free (NVBuiltin' name f) |
360 | 350 |
|
361 | 351 | nvBuiltin' :: (Applicative f, Functor m) |
362 | 352 | => String -> (NValue t f m -> m r) -> NValue' t f m r |
363 | | -nvBuiltin' name f = NValue (pure (NVBuiltinF name f)) |
| 353 | +nvBuiltin' name f = NValue $ pure $ NVBuiltinF name f |
364 | 354 | nvBuiltin :: (Applicative f, Functor m) |
365 | 355 | => String -> (NValue t f m -> m (NValue t f m)) -> NValue t f m |
366 | | -nvBuiltin name f = |
367 | | - Free (NValue (pure (NVBuiltinF name f))) |
| 356 | +nvBuiltin name f = Free $ nvBuiltin' name f |
368 | 357 |
|
369 | 358 | builtin |
370 | 359 | :: forall m f t |
|
0 commit comments