|
1 | 1 | {-# LANGUAGE CPP #-} |
2 | 2 | {-# LANGUAGE DeriveFunctor #-} |
3 | | -{-# LANGUAGE FlexibleContexts #-} |
4 | 3 | {-# LANGUAGE FlexibleInstances #-} |
5 | 4 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
6 | 5 | {-# LANGUAGE MultiParamTypeClasses #-} |
7 | | -{-# LANGUAGE RankNTypes #-} |
8 | 6 | {-# LANGUAGE TypeFamilies #-} |
9 | 7 | {-# LANGUAGE UndecidableInstances #-} |
10 | 8 |
|
|
13 | 11 |
|
14 | 12 | module Nix.Fresh where |
15 | 13 |
|
16 | | -import Control.Applicative |
17 | | -import Control.Monad.Base |
18 | | -import Control.Monad.Catch |
| 14 | +import Control.Applicative ( Alternative ) |
| 15 | +import Control.Monad.Base ( MonadBase(..) ) |
| 16 | +import Control.Monad.Catch ( MonadCatch |
| 17 | + , MonadMask |
| 18 | + , MonadThrow |
| 19 | + ) |
19 | 20 | import Control.Monad.Except |
| 21 | + ( MonadFix |
| 22 | + , MonadIO |
| 23 | + , MonadPlus |
| 24 | + , MonadTrans(..) |
| 25 | + ) |
20 | 26 | #if !MIN_VERSION_base(4,13,0) |
21 | 27 | import Control.Monad.Fail |
22 | 28 | #endif |
23 | | -import Control.Monad.Reader |
| 29 | +import Control.Monad.Reader ( ReaderT(..) |
| 30 | + , MonadReader(ask) |
| 31 | + ) |
24 | 32 | import Control.Monad.Ref |
25 | | -import Control.Monad.ST |
26 | | -import Data.Typeable |
| 33 | + ( MonadAtomicRef(..) |
| 34 | + , MonadRef(writeRef, readRef) |
| 35 | + ) |
| 36 | +import Control.Monad.ST ( ST ) |
| 37 | +import Data.Typeable ( Typeable ) |
27 | 38 |
|
28 | 39 | import Nix.Var |
29 | 40 | import Nix.Thunk |
30 | 41 |
|
| 42 | + |
31 | 43 | newtype FreshIdT i m a = FreshIdT { unFreshIdT :: ReaderT (Var m i) m a } |
32 | 44 | deriving |
33 | 45 | ( Functor |
@@ -72,7 +84,7 @@ runFreshIdT i m = runReaderT (unFreshIdT m) i |
72 | 84 | -- Orphan instance needed by Infer.hs and Lint.hs |
73 | 85 |
|
74 | 86 | -- Since there's no forking, it's automatically atomic. |
75 | | --- NOTE: MonadAtomicRef (ST s) can be upstreamed to `ref-tf` |
| 87 | +-- 2021-02-09: NOTE: Submitted upstream: https://github.com/mainland/ref-tf/pull/4 |
76 | 88 | instance MonadAtomicRef (ST s) where |
77 | 89 | atomicModifyRef r f = do |
78 | 90 | v <- readRef r |
|
0 commit comments