Jikka-5.0.11.1: 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.RestrictedPython.Convert.TypeInfer

Description

 
Synopsis

Documentation

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

run infers types of given programs.

As the interface, you can understand this function does the following:

  1. Finds a type environment \(\Gamma\) s.t. for all statement \(\mathrm{stmt}\) in the given program, \(\Gamma \vdash \mathrm{stmt}\) holds, and
  2. Annotates each variable in the program using the \(\Gamma\).

In its implementation, this is just something like a Hindley-Milner type inference.

Requirements

  • There must be no name conflicts in given programs. They must be alpha-converted. (Alpha)
  • All names must be resolved. (ResolveBuiltin)

internal types and functions

newtype Subst Source #

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

Constructors

Subst