-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
46 lines (34 loc) · 1.2 KB
/
Main.hs
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
import Head
import Type
import Parser
import ConstraintGenerator
import ConstraintSolver
solve' g e = runTI (solver (context /+/ g) e)
generate' g e = clean (snd (runTI (conGen (context /+/ g) e)))
solver g e = do (t,cs) <- conGen g e
let u = solveAll (clean cs)
return (apply u t)
solve a = do as <- parseFile a
inferFile' solve' as
return()
generate a = do as <- parseFile a
inferFile' generate' as
return()
inferFile' f (ds,e) = case e of
Left err -> print err
Right e -> case (extract ds) of
Right s -> print (f (fold s) e)
Left errs -> print errs
-- ugly stuff down here
fromRight (Right x) = x
extract ds = if (extract' ds) then Right (map fromRight ds) else Left ([extractErr ds])
extract' [] = True
extract' (d:ds) = case d of
Left err -> False
Right a -> True && (extract' ds)
extractErr (d:ds) = case d of
Left err -> err
Right a -> extractErr ds
-- foldr1 doesn't like empty lists
fold [] = []
fold (f:fs) = f ++ fold fs