5 | import public Idrall.FC
7 | import public Data.SortedMap
14 | data FieldName = MkFieldName String
17 | Show FieldName where
18 | show (MkFieldName x) = "(MkFieldName " ++ show x ++ ")"
21 | prettyFieldName : FieldName -> String
22 | prettyFieldName (MkFieldName x) = x
26 | (==) (MkFieldName x) (MkFieldName y) = x == y
30 | compare (MkFieldName x) (MkFieldName y) = compare x y
34 | Namespace = List (Name, Integer)
35 | %name Namespace
ns1, ns2, ns3
38 | data U = CType | Sort | Kind
42 | (==) CType CType = True
43 | (==) Sort Sort = True
44 | (==) Kind Kind = True
49 | show CType = "CType"
56 | data ImportStatement
57 | = LocalFile FilePath
67 | | Resolved (Expr Void)
70 | data Chunks a = MkChunks (List (String, Expr a)) String
78 | | ELam FC Name (Expr a) (Expr a)
80 | | EPi FC Name (Expr a) (Expr a)
82 | | EApp FC (Expr a) (Expr a)
85 | | ELet FC Name (Maybe (Expr a)) (Expr a) (Expr a)
87 | | EAnnot FC (Expr a) (Expr a)
93 | | EBoolAnd FC (Expr a) (Expr a)
95 | | EBoolOr FC (Expr a) (Expr a)
97 | | EBoolEQ FC (Expr a) (Expr a)
99 | | EBoolNE FC (Expr a) (Expr a)
101 | | EBoolIf FC (Expr a) (Expr a) (Expr a)
105 | | ENaturalLit FC Nat
111 | | ENaturalIsZero FC
117 | | ENaturalToInteger FC
119 | | ENaturalSubtract FC
123 | | ENaturalPlus FC (Expr a) (Expr a)
125 | | ENaturalTimes FC (Expr a) (Expr a)
129 | | EIntegerLit FC Integer
135 | | EIntegerNegate FC
137 | | EIntegerToDouble FC
141 | | EDoubleLit FC Double
147 | | ETextLit FC (Chunks a)
149 | | ETextAppend FC (Expr a) (Expr a)
157 | | EListLit FC (Maybe (Expr a)) (List (Expr a))
159 | | EListAppend FC (Expr a) (Expr a)
177 | | ESome FC (Expr a)
181 | | EEquivalent FC (Expr a) (Expr a)
183 | | EAssert FC (Expr a)
185 | | ERecord FC (SortedMap FieldName (Expr a))
187 | | ERecordLit FC (SortedMap FieldName (Expr a))
190 | | EUnion FC (SortedMap FieldName (Maybe (Expr a)))
192 | | ECombine FC (Expr a) (Expr a)
194 | | ECombineTypes FC (Expr a) (Expr a)
196 | | EPrefer FC (Expr a) (Expr a)
198 | | ERecordCompletion FC (Expr a) (Expr a)
201 | | EMerge FC (Expr a) (Expr a) (Maybe (Expr a))
204 | | EToMap FC (Expr a) (Maybe (Expr a))
206 | | EField FC (Expr a) FieldName
209 | | EProject FC (Expr a) (Either (List FieldName) (Expr a))
211 | | EWith FC (Expr a) (List1 FieldName) (Expr a)
213 | | EImportAlt FC (Expr a) (Expr a)
214 | | EEmbed FC (Import a)
217 | HasFC (Expr a) where
218 | getFC (EConst fc x) = fc
219 | getFC (EVar fc x y) = fc
220 | getFC (ELam fc x y z) = fc
221 | getFC (EPi fc x y z) = fc
222 | getFC (EApp fc x y) = fc
223 | getFC (ELet fc x y z w) = fc
224 | getFC (EAnnot fc x y) = fc
225 | getFC (EBool fc) = fc
226 | getFC (EBoolLit fc x) = fc
227 | getFC (EBoolAnd fc x y) = fc
228 | getFC (EBoolOr fc x y) = fc
229 | getFC (EBoolEQ fc x y) = fc
230 | getFC (EBoolNE fc x y) = fc
231 | getFC (EBoolIf fc x y z) = fc
232 | getFC (ENatural fc) = fc
233 | getFC (ENaturalLit fc k) = fc
234 | getFC (ENaturalFold fc) = fc
235 | getFC (ENaturalBuild fc) = fc
236 | getFC (ENaturalIsZero fc) = fc
237 | getFC (ENaturalEven fc) = fc
238 | getFC (ENaturalOdd fc) = fc
239 | getFC (ENaturalToInteger fc) = fc
240 | getFC (ENaturalSubtract fc) = fc
241 | getFC (ENaturalShow fc) = fc
242 | getFC (ENaturalPlus fc x y) = fc
243 | getFC (ENaturalTimes fc x y) = fc
244 | getFC (EInteger fc) = fc
245 | getFC (EIntegerLit fc x) = fc
246 | getFC (EIntegerShow fc) = fc
247 | getFC (EIntegerClamp fc) = fc
248 | getFC (EIntegerNegate fc) = fc
249 | getFC (EIntegerToDouble fc) = fc
250 | getFC (EDouble fc) = fc
251 | getFC (EDoubleLit fc x) = fc
252 | getFC (EDoubleShow fc) = fc
253 | getFC (EText fc) = fc
254 | getFC (ETextLit fc x) = fc
255 | getFC (ETextAppend fc x y) = fc
256 | getFC (ETextShow fc) = fc
257 | getFC (ETextReplace fc) = fc
258 | getFC (EList fc) = fc
259 | getFC (EListLit fc x xs) = fc
260 | getFC (EListAppend fc x y) = fc
261 | getFC (EListBuild fc) = fc
262 | getFC (EListFold fc) = fc
263 | getFC (EListLength fc) = fc
264 | getFC (EListHead fc) = fc
265 | getFC (EListLast fc) = fc
266 | getFC (EListIndexed fc) = fc
267 | getFC (EListReverse fc) = fc
268 | getFC (EOptional fc) = fc
269 | getFC (ESome fc x) = fc
270 | getFC (ENone fc) = fc
271 | getFC (EEquivalent fc x y) = fc
272 | getFC (EAssert fc x) = fc
273 | getFC (ERecord fc x) = fc
274 | getFC (ERecordLit fc x) = fc
275 | getFC (EUnion fc x) = fc
276 | getFC (ECombine fc x y) = fc
277 | getFC (ECombineTypes fc x y) = fc
278 | getFC (EPrefer fc x y) = fc
279 | getFC (ERecordCompletion fc x y) = fc
280 | getFC (EMerge fc x y z) = fc
281 | getFC (EToMap fc x y) = fc
282 | getFC (EField fc x y) = fc
283 | getFC (EProject fc x y) = fc
284 | getFC (EWith fc x xs y) = fc
285 | getFC (EImportAlt fc x y) = fc
286 | getFC (EEmbed fc x) = fc
289 | Show ImportStatement where
290 | show (LocalFile x) = "(LocalFile " ++ show x ++ ")"
291 | show (EnvVar x) = "(EnvVar " ++ x ++ ")"
292 | show (Http x) = "(Http " ++ x ++ ")"
293 | show Missing = "Missing"
296 | Show (Import ImportStatement) where
297 | show (Raw x) = "(Raw \{show x}"
298 | show (Text x) = "(Text \{show x}"
299 | show (Location x) = "(Location \{show x}"
300 | show (Resolved x) = "(Resolved x)"
304 | Show (Import a) where
305 | show (Raw x) = "(Raw)"
306 | show (Text x) = "(Text)"
307 | show (Location x) = "(Location)"
308 | show (Resolved x) = "(Resolved " ++ show x ++ ")"
311 | Show (Expr a) where
312 | show (EConst fc x) = "(EConst " ++ show x ++ ")"
313 | show (EVar fc x i) = "(EVar " ++ show x ++ " " ++ show i ++ ")"
314 | show (ELam fc x y z) = "(ELam " ++ x ++ " " ++ show y ++ " " ++ show z ++ ")"
315 | show (EPi fc x y z) = "(EPi " ++ x ++ " " ++ show y ++ " " ++ show z ++ ")"
316 | show (EApp fc x y) = "(EApp " ++ show x ++ " " ++ show y ++ ")"
317 | show (ELet fc x y z w) = "(ELet " ++ show x ++ " " ++ show y ++ " " ++ show z ++ " " ++ show w ++ ")"
318 | show (EAnnot fc x y) = "(EAnnot " ++ show x ++ " " ++ show y ++ ")"
319 | show (EBool fc) = "EBool"
320 | show (EBoolLit fc False) = "(EBoolLit False)"
321 | show (EBoolLit fc True) = "(EBoolLit True)"
322 | show (EBoolAnd fc x y) = "(EBoolAnd " ++ show x ++ " " ++ show y ++ ")"
323 | show (EBoolOr fc x y) = "(EBoolOr " ++ show x ++ " " ++ show y ++ ")"
324 | show (EBoolEQ fc x y) = "(EBoolEQ " ++ show x ++ " " ++ show y ++ ")"
325 | show (EBoolNE fc x y) = "(EBoolNE " ++ show x ++ " " ++ show y ++ ")"
326 | show (EBoolIf fc x y z) = "(EBoolIf " ++ show x ++ " " ++ show y ++ " " ++ show z ++ ")"
327 | show (ENatural fc) = "ENatural"
328 | show (ENaturalLit fc k) = "(ENaturalLit " ++ show k ++ ")"
329 | show (ENaturalFold fc) = "ENaturalFold"
330 | show (ENaturalBuild fc) = "ENaturalBuild"
331 | show (ENaturalIsZero fc) = "ENaturalIsZero"
332 | show (ENaturalEven fc) = "ENaturalEven"
333 | show (ENaturalOdd fc) = "ENaturalOdd"
334 | show (ENaturalToInteger fc) = "ENaturalToInteger"
335 | show (ENaturalSubtract fc) = "ENaturalSubtract"
336 | show (ENaturalShow fc) = "NaturalShow"
337 | show (ENaturalPlus fc x y) = "(ENaturalPlus " ++ show x ++ " " ++ show y ++ ")"
338 | show (ENaturalTimes fc x y) = "(ENaturalTimes " ++ show x ++ " " ++ show y ++ ")"
339 | show (EInteger fc) = "EInteger"
340 | show (EIntegerLit fc x) = "(EIntegerLit " ++ show x ++ ")"
341 | show (EIntegerClamp fc) = "EIntegerClamp"
342 | show (EIntegerShow fc) = "EIntegerShow"
343 | show (EIntegerNegate fc) = "EIntegerNegate"
344 | show (EIntegerToDouble fc) = "EIntegerToDouble"
345 | show (EDouble fc) = "EDouble"
346 | show (EDoubleLit fc k) = "(EDoubleLit " ++ show k ++ ")"
347 | show (EDoubleShow fc) = "EDoubleShow"
348 | show (EText fc) = "EText"
349 | show (ETextLit fc x) = "(ETextLit " ++ show x ++ ")"
350 | show (ETextAppend fc x y) = "(ETextAppend " ++ show x ++ " " ++ show y ++ ")"
351 | show (ETextShow fc) = "ETextShow"
352 | show (ETextReplace fc) = "ETextReplace"
353 | show (EList fc) = "EList"
354 | show (EListLit fc Nothing xs) = "(EListLit Nothing " ++ show xs ++ ")"
355 | show (EListLit fc (Just x) xs) = "(EListLit (Just " ++ show x ++ ") " ++ show xs ++ ")"
356 | show (EListAppend fc x y) = "(EListAppend " ++ show x ++ " " ++ show y ++ ")"
357 | show (EListBuild fc) = "EListBuild"
358 | show (EListFold fc) = "EListFold"
359 | show (EListHead fc) = "EListHead"
360 | show (EListLength fc) = "EListLength"
361 | show (EListLast fc) = "EListLast"
362 | show (EListIndexed fc) = "EListIndexed"
363 | show (EListReverse fc) = "EListReverse"
364 | show (EOptional fc) = "EOptional"
365 | show (ENone fc) = "ENone"
366 | show (ESome fc x) = "(ESome " ++ show x ++ ")"
367 | show (EEquivalent fc x y) = "(EEquivalent " ++ show x ++ " " ++ show y ++ ")"
368 | show (EAssert fc x) = "(EAssert " ++ show x ++ ")"
369 | show (ERecord fc x) = "(ERecord " ++ show x ++ ")"
370 | show (ERecordLit fc x) = "(ERecordLit " ++ show x ++ ")"
371 | show (EUnion fc x) = "(EUnion $ " ++ show x ++ ")"
372 | show (ECombine fc x y) = "(ECombine " ++ show x ++ " " ++ show y ++ ")"
373 | show (ECombineTypes fc x y) = "(ECombineTypes " ++ show x ++ " " ++ show y ++ ")"
374 | show (EPrefer fc x y) = "(EPrefer " ++ show x ++ " " ++ show y ++ ")"
375 | show (ERecordCompletion fc x y) = "(ERecordCompletion " ++ show x ++ " " ++ show y ++ ")"
376 | show (EMerge fc x y z) = "(EMerge " ++ show x ++ " " ++ show y ++ " " ++ show z ++ ")"
377 | show (EToMap fc x y) = "(EToMap " ++ show x ++ " " ++ show y ++ ")"
378 | show (EField fc x y) = "(EField " ++ show x ++ " " ++ show y ++ ")"
379 | show (EProject fc x y) = "(EProject " ++ show x ++ " " ++ show y ++ ")"
380 | show (EWith fc x ks y) = "(EWith " ++ show x ++ " " ++ show ks ++ " " ++ show y ++ ")"
381 | show (EImportAlt fc x y) = "(EImportAlt " ++ show x ++ " " ++ show y ++ ")"
382 | show (EEmbed fc x) = "(EEmbed " ++ show x ++ ")"
384 | public export covering
385 | Show (Chunks a) where
386 | show (MkChunks xs x) = "MkChunks " ++ (show xs) ++ " " ++ show x
391 | Semigroup (Chunks a) where
392 | (<+>) (MkChunks xysL zL) (MkChunks [] zR) = MkChunks xysL (zL <+> zR)
393 | (<+>) (MkChunks xysL zL) (MkChunks ((x, y) :: xysR) zR) =
394 | MkChunks (xysL ++ (zL <+> x, y)::xysR) zR
397 | Monoid (Chunks a) where
398 | neutral = MkChunks [] neutral