-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
42 lines (31 loc) · 1.18 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
import Head
import Type
import Parser
import ConstraintGenerator
import ConstraintSolver
solve' g e = runTI (generateAndSolve (context /+/ g) e)
generate' g e = cleanConstraints (runTI (conGen (context /+/ g) e))
generateAndSolve g e = do (t,cs,s) <- conGen g e
u <- solveAll (clean (apply s cs))
return (apply (u @@ s) 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