Skip to main content

AML Types

Introduction

AML includes a powerful type system that enables both a real-time feedback to analysts to help them avoid errors early, and as the basis for sophisticated reusability features such as constant declaration, functions, and extend.

Basic types

Number

  • All kind of numbers (including integer and fractional)
Number pi = 3.14159265
Number b = 2
Number c = -10

Int

  • Represents numbers without decimal
Int a = 1
Int b = 2
Int c = -100

Boolean

Boolean is_truthy = true
Boolean is_falsy = false

String

A string is a sequence of characters used to represent text.

AML supports 2 kind of strings:

  • normal string (single/double quotes)
  • multi-line string (triple quotes)
const model_name = 'ecommerce.users' // single-quote
const dataset_name = "ecommerce" // double-quote


// Multi-line string
This is
a note
that expands
on multiple
lines
'''

// "This is\na note\nthat expands\non multiple\nlines"

List

  • Stores a collection of elements, typically of the same type
  • Syntax: List<T> (where T is element’s type)
List<Int> numbers = [1, 2, 3]
List<String> names = ['Alex', 'John', 'Bob']

// access elements inside a list
numbers(0) // 1
numbers(1) // 2
numbers(2) // 3

names(1) // 'John'

Dictionary

  • Stores a collection of key-value pairs
  • Each key-value pair maps the key to its associated value
  • Syntax: Dict<K, V> where K is a key’s type, V is a value’s type
Dict<String, Number> employee_ages = {
alex: 23
bob: 30
john: 29
}

Dict<String, String> employee_addresses = {
alex: '505 SW 1st Ave'
john: ' 4070 Red Arrow Hwy'
bob: '851 St Georges Ave'
}

// access dictionary entries
employee_ages('alex') // 23
employee_addresses('bob') // '851 St Georges Ave'

Any

  • is a type that can hold any value, effectively opting out of type checking

Let us know what you think about this document :)