on master help sign in
Get rid of Type.Constrain.Literal

All this logic moves to constraining expressions and patterns specifically. This makes it easier to give nice errors in each of those cases.

commita4e25604db7d95844bc6ddad471e0be31a607a85 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 8 Nov 2017, 17:29 (9 years ago) parente28d01e
1 file changed−58
src/Type/Constrain/Literal.hs−58
src/Type/Constrain/Literal.hsdeleted−58
@@ -1,58 +0,0 @@
1−{-# OPTIONS_GHC -Wall #-}
2−{-# LANGUAGE OverloadedStrings #-}
3−module Type.Constrain.Literal (constrain) where
4−
5−import qualified AST.Literal as Lit
6−import qualified Reporting.Error.Type as Error
7−import qualified Reporting.Region as R
8−import qualified Type.Constraint as T
9−import qualified Type.Type as T
10−
11−
12−
13−-- CONSTRAIN LITERALS
14−
15−
16−constrain :: R.Region -> Lit.Literal -> T.Type -> IO T.Constraint
17−constrain region literal tipe =
18− case literal of
19− Lit.IntNum _ ->
20− do var <- T.mkFlexNumber
21− return $ T.CEqual numberError region (T.VarN var) tipe
22−
23− Lit.FloatNum _ ->
24− return $ T.CEqual floatError region T.float tipe
25−
26− Lit.Chr _ ->
27− return $ T.CEqual charError region T.char tipe
28−
29− Lit.Str _ ->
30− return $ T.CEqual stringError region T.string tipe
31−
32−
33−
34−-- LITERAL ERRORS
35−
36−
37−{-# NOINLINE numberError #-}
38−numberError :: Error.Hint
39−numberError =
40− Error.Literal "number"
41−
42−
43−{-# NOINLINE floatError #-}
44−floatError :: Error.Hint
45−floatError =
46− Error.Literal "float"
47−
48−
49−{-# NOINLINE charError #-}
50−charError :: Error.Hint
51−charError =
52− Error.Literal "character"
53−
54−
55−{-# NOINLINE stringError #-}
56−stringError :: Error.Hint
57−stringError =
58− Error.Literal "string"