aboutsummaryrefslogtreecommitdiff
path: root/backend/CC/Backend/Dumb.hs
blob: 822fb8428d9b684e8561e993479feffa724d5fbf (plain)
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
module CC.Backend.Dumb(builtins) where

import qualified Data.Map.Strict as Map

import CC.AST.Typed
import CC.Context


builtins :: Builtins
builtins =
    let values = Map.fromList
            [ ("print", TInt ==> TTup [])
            , ("fst", TTup [t1, t2] ==> t1)
            , ("snd", TTup [t1, t2] ==> t2)
            , ("_add", TInt ==> TInt ==> TInt)
            , ("_sub", TInt ==> TInt ==> TInt)
            , ("_mul", TInt ==> TInt ==> TInt) ]
        prelude = "type Nil = ()\n\
                  \type Cons a = (a, List a)\n\
                  \alias List a = { Nil | Cons a }\n"
    in Builtins values prelude
  where
    t1 = TyVar Instantiable 1
    t2 = TyVar Instantiable 2
    infixr ==>
    (==>) = TFun