@@ -1075,7 +1075,7 @@ data Rule
1075
1075
, staticDependencies :: ! [Dependency ]
1076
1076
-- ^ Static dependencies of this rule.
1077
1077
, results :: ! (NE. NonEmpty Location )
1078
- -- ^ Results of this rule; see t'Result' .
1078
+ -- ^ Results of this rule.
1079
1079
}
1080
1080
deriving (Eq , Binary )
1081
1081
@@ -1108,7 +1108,7 @@ instance Eq (Command arg res)
1108
1108
instance Binary (Command arg res )
1109
1109
1110
1110
newtype Rules env =
1111
- Rules { runRules :: env -> RulesT IO () }
1111
+ Rules { runRules :: env -> RulesM () }
1112
1112
```
1113
1113
1114
1114
In this design, a rule stores a closure (in the sense of Cloud Haskell ) that
@@ -1123,7 +1123,7 @@ rule (with no dynamic dependencies), this constists of:
1123
1123
For example, the function might be an invocation of `happy` whose arguments
1124
1124
depend on the passed in value (e. g. which module we are compiling).
1125
1125
1126
- The specific monadic return type , `RulesT IO () `, is used internally to handle
1126
+ The specific monadic return type , `RulesM () `, is used internally to handle
1127
1127
generation of `RuleId `s as explained in [§ Identifiers ](# identifiers).
1128
1128
Ignoring these implementation details, we can think of the rules as being
1129
1129
specified by a Haskell function with the following type :
@@ -1393,7 +1393,7 @@ executions of the `IO` action that computes the set of pre-build rules.
1393
1393
We propose that users generate `RuleId `s themselves with the following API :
1394
1394
1395
1395
```haskell
1396
- registerRule :: ShortText -> Rule -> RulesT IO RuleId
1396
+ registerRule :: ShortText -> Rule -> RulesM RuleId
1397
1397
```
1398
1398
1399
1399
The `ShortText ` argument is a user- given name for the rule. Different rules
@@ -1422,7 +1422,7 @@ whenever these change, the rules as a whole are recomputed.
1422
1422
The basic API function is
1423
1423
1424
1424
```haskell
1425
- addRuleMonitors :: Monad m => [ MonitorFileOrDir ] -> RulesT m ()
1425
+ addRuleMonitors :: [ MonitorFileOrDir ] -> RulesM ()
1426
1426
```
1427
1427
1428
1428
where `MonitorFileOrDir ` is some datatype, such as the one that exists in
@@ -1451,18 +1451,18 @@ data Rules env -- definition not exposed to the user
1451
1451
instance Semigroup (Rules env )
1452
1452
instance Monoid (Rules env )
1453
1453
1454
- rules :: StaticPtr (env -> RulesT IO () ) -> Rules env
1454
+ rules :: StaticPtr label -> (env -> RulesM () ) -> Rules env
1455
1455
1456
1456
data RuleId
1457
1457
-- In practice, identifiers consists of a pair of a UnitId and
1458
1458
-- a user-supplied textual name, but the constructor is crucially
1459
1459
-- not exposed in the API in order to enforce hygiene.
1460
1460
1461
- newtype RulesT m a
1461
+ newtype RulesM a
1462
1462
deriving (Functor , Applicative , Monad , MonadTrans , MonadIO , MonadFix )
1463
1463
1464
- registerRule :: ShortText -> Rule -> RulesT IO RuleId
1465
- addRuleMonitors :: [ MonitorFileOrDir ] -> RulesT IO ()
1464
+ registerRule :: ShortText -> Rule -> RulesM RuleId
1465
+ addRuleMonitors :: [ MonitorFileOrDir ] -> RulesM ()
1466
1466
```
1467
1467
1468
1468
To illustrate, we might implement the `c2hs` preprocessor using this
@@ -1473,9 +1473,9 @@ framework (from [§ Dynamic dependencies](#dynamic-dependencies)) as follows:
1473
1473
{-# LANGUAGE StaticPointers #-}
1474
1474
1475
1475
c2HsPreBuildRules :: PreBuildComponentRules
1476
- c2HsPreBuildRules = rules $ static c2HsRules
1476
+ c2HsPreBuildRules = rules ( static () ) c2HsRules
1477
1477
1478
- c2HsRules :: PreBuildComponentInputs -> RulesT IO ()
1478
+ c2HsRules :: PreBuildComponentInputs -> RulesM ()
1479
1479
c2HsRules buildEnvt = mdo
1480
1480
1481
1481
(chsModDirs :: Map ModuleName FilePath )
@@ -1534,8 +1534,7 @@ Here, the Hooks API uses static pointers in order to tag rules by the package th
1534
1534
defines them, in order to allow combining the ` Rules ` declared by two different
1535
1535
libraries, as described in [ § Composing ` SetupHooks ` ] ( #composing-setuphooks ) .
1536
1536
The user-provided names for rules (` "r1" ` , ` "r2" ` , ` "r3" ` above) are expected
1537
- to be unique within the package that defines them (note that this is stronger
1538
- than requiring uniqueness in the ` static ` block that contains them).
1537
+ to be unique (within the scope of the label).
1539
1538
(NB: we don't use ` static ` for each individual identifier, as these are often
1540
1539
dynamically generated based on the result of an ` IO ` action, as above.)
1541
1540
0 commit comments