mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-23 14:55:35 +03:00
Relax the module visitor by introducing a type variable in the user-supplied function
This commit is contained in:
parent
9a983f1190
commit
5f7bf971c4
@ -987,7 +987,7 @@ fromProjectRuleSchema (ProjectRuleSchema schema) =
|
||||
Mention [`withContextFromImportedModules`](#withContextFromImportedModules)
|
||||
-}
|
||||
withModuleVisitor :
|
||||
(ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
||||
(ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { a | hasAtLeastOneVisitor : () } moduleContext)
|
||||
-> ProjectRuleSchema projectContext moduleContext { schemaState | canAddModuleVisitor : () }
|
||||
-> ProjectRuleSchema projectContext moduleContext { schemaState | canAddModuleVisitor : (), withModuleContext : Required }
|
||||
withModuleVisitor visitor (ProjectRuleSchema schema) =
|
||||
@ -1004,7 +1004,25 @@ withModuleVisitor visitor (ProjectRuleSchema schema) =
|
||||
IsPrepared _ ->
|
||||
[]
|
||||
in
|
||||
ProjectRuleSchema { schema | moduleVisitor = HasVisitors (visitor :: previousModuleVisitors) }
|
||||
ProjectRuleSchema
|
||||
{ schema
|
||||
| moduleVisitor =
|
||||
HasVisitors (removeExtensibleRecordTypeVariable visitor :: previousModuleVisitors)
|
||||
}
|
||||
|
||||
|
||||
{-| This function that is supplied by the user will be stored in the `ProjectRuleSchema`,
|
||||
but it contains an extensible record. This means that `ProjectRuleSchema` will
|
||||
need an additional type variable for no useful value. Because we have full control
|
||||
over the `ModuleRuleSchema` in this module, we can change the phantom type to be
|
||||
whatever we want it to be, and we'll change it something that makes sense but
|
||||
without the extensible record type variable.
|
||||
-}
|
||||
removeExtensibleRecordTypeVariable :
|
||||
(ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { a | hasAtLeastOneVisitor : () } moduleContext)
|
||||
-> (ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
||||
removeExtensibleRecordTypeVariable function =
|
||||
function >> (\(ModuleRuleSchema param) -> ModuleRuleSchema param)
|
||||
|
||||
|
||||
{-| Used for phantom type constraints. You can safely ignore this type.
|
||||
|
Loading…
Reference in New Issue
Block a user