This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.dhall
136 lines (120 loc) · 4.39 KB
/
package.dhall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
let
-- A ModuleName is a dot-delimited module name corresponding to a
-- Haskell module. E.G. "Control.Monad" ModuleNames cannot be the
-- empty string.
ModuleName = Text
let
-- A TreeName is a dot-delimited module-like name corresponding to a
-- location in the directory tree. E.G. "Control.Monad" corresponds to
-- all modules beginning with "Control.Monad.", as well as "Control.Monad"
-- itself. Textually it appears the same as a ModuleName, but is used to
-- denote the tree rather than an individual module. TreeNames cannot abe
-- the empty string.
TreeName = Text
let
-- A Dependency declares that one subtree of the project depends on
-- other subtrees. This forbids any modules in the subtrees listed in
-- `dependencies` from importing any module contained within the subtree
-- indicated by `moduleTree`
Dependency =
{ moduleTree : TreeName
, dependencies : List TreeName
}
let
-- Indicates whether an allowed qualification is quailfied or unqualified
Qualification =
< Qualified
| Unqualified
>
let
-- Indicates whether an allowed qualification has an alias, and if so what
-- the alias must be.
Alias =
< WithAlias : ModuleName
| WithoutAlias
>
let
-- Describes an allowed qualification scheme for a module when it is imported.
-- When allowed qualifications are declared for a module, any import of that
-- module must match one of the `AllowedQualifications` given for it in the
-- configuration.
AllowedQualification =
{ qualification : Qualification
, alias : Alias
}
let
-- Build an `AllowedQualification` for unqualified imports without an alias
unqualified =
{ qualification = Qualification.Unqualified
, alias = Alias.WithoutAlias
}
let
-- Build an `AllowedQualification` for unqualified imports that must have the
-- provided alias
unqualifiedAs =
\(aliasName : Text) ->
{ qualification = Qualification.Unqualified
, alias = Alias.WithAlias aliasName
}
let
-- Build an `AllowedQualification` for qualified imports without an alias
qualified =
{ qualification = Qualification.Qualified
, alias = Alias.WithoutAlias
}
let
-- Build an `AllowedQualification` for qualified imports that must have the
-- provided alias
qualifiedAs =
\(aliasName : Text) ->
{ qualification = Qualification.Qualified
, alias = Alias.WithAlias aliasName
}
let
AllowedQualificationMap =
List { mapKey : ModuleName, mapValue : List AllowedQualification }
let
Config =
{ -- Paths that modulint should search for Haskell files when run
-- You most likely want to override this.
sourcePaths : List Text
-- A Dependency declares that one subtree of modules depends on another,
-- forbidding the dependency targets from importing any module from the
-- tree declaring the dependency.
, treeDependencies : List Dependency
-- Modules inside encapsulated trees may not be directly imported from
-- outside the tree. Only the root moduleo of the tree may be imported
-- by outside modules.
, encapsulatedTrees : List TreeName
-- A map of module names to the allowed qualification schemes that
-- map be used when the module is imported. If a module appears in this
-- map and is imported in a form that does not match one of the allowed
-- forms given here, modulint with report it as an error.
-- You can build the map explicitly using `mapKey` and `mapValue` for
-- the `ModuleName` and list of `AllowedQualification` respectively, or
-- use Dhall's `toMap` to write the key/values pairs as a record. Note:
-- If you `toMap`, you will neded to quote module names with backticks to
-- permit a `.` to appear in them.
, allowedQualifications : AllowedQualificationMap
}
in
{ Config =
{ Type = Config
, default =
{ treeDependencies = [] : List Dependency
, encapsulatedTrees = [] : List TreeName
, allowedQualifications = toMap {=} : AllowedQualificationMap
}
}
, Qualification = Qualification
, Alias = Alias
, AllowedQualification = AllowedQualification
, AllowedQualificationMap = AllowedQualificationMap
, unqualified = unqualified
, unqualifiedAs = unqualifiedAs
, qualified = qualified
, qualifiedAs = qualifiedAs
, Dependency = Dependency
, TreeName = TreeName
, ModuleName = ModuleName
}