Jikka-5.6.0.0: A transpiler from Python to C++ for competitive programming
Copyright(c) Kimiyuki Onaka 2021
LicenseApache License 2.0
Maintainerkimiyuki95@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Jikka.Core.Convert.TypeInfer

Description

 
Synopsis

Documentation

run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #

run does type inference.

  • This assumes that program has no name conflicts.

Before:

let f = fun y -> y
in let x = 1
in f(x + x)

After:

let f: int -> int = fun y: int -> y
in let x: int = 1
in f(x + x)

internal types and functions

sortEquations :: [Equation] -> ([(Type, Type, [Hint])], [(VarName, Type)]) Source #

mergeAssertions :: [(VarName, Type)] -> [(Type, Type, [Hint])] Source #

newtype Subst Source #

Subst is type substituion. It's a mapping from type variables to their actual types.

Constructors

Subst 

Instances

Instances details
Eq Subst Source # 
Instance details

Defined in Jikka.Core.Convert.TypeInfer

Methods

(==) :: Subst -> Subst -> Bool #

(/=) :: Subst -> Subst -> Bool #

Ord Subst Source # 
Instance details

Defined in Jikka.Core.Convert.TypeInfer

Methods

compare :: Subst -> Subst -> Ordering #

(<) :: Subst -> Subst -> Bool #

(<=) :: Subst -> Subst -> Bool #

(>) :: Subst -> Subst -> Bool #

(>=) :: Subst -> Subst -> Bool #

max :: Subst -> Subst -> Subst #

min :: Subst -> Subst -> Subst #

Read Subst Source # 
Instance details

Defined in Jikka.Core.Convert.TypeInfer

Show Subst Source # 
Instance details

Defined in Jikka.Core.Convert.TypeInfer

Methods

showsPrec :: Int -> Subst -> ShowS #

show :: Subst -> String #

showList :: [Subst] -> ShowS #

substDefault :: Type -> Type -> Type Source #

substDefault replaces all undetermined type variables with the given default type.

solveEquations :: MonadError Error m => [(Type, Type, [Hint])] -> m Subst Source #