Skip to content

Preview 5 Release Notes

Filtrera Preview 5 introduces several significant updates, including the addition of Maps, enhancements to Lists, and new macros to streamline iterator operations.'
2 min read

Maps Added

This release introduces Maps, a new data type that maps a key to a value, allowing you to define types like {text -> number}. Maps in Filtrera are also Iterators, which means you can iterate over their values directly.

Objects Implement Map Type

Objects have been adjusted to implement the Map type. Now, all Objects in Filtrera are Maps, though not all Maps are Objects. This change means any Object can satisfy a { text -> * } type, providing more flexibility in how Objects are used.

Native Dictionary Type

A new literal construct for creating the native Dictionary type has been added. Dictionaries are specialized Maps that use an internal hash for quick lookups. The syntax for declaring a Dictionary is as follows:

let myDict = {
'key1' -> 1
'key2' -> 2
}

Dictionaries differ from Objects in that they can use any value as a key. This feature supports Filtrera’s union types, allowing mixed key types within a single Dictionary:

{
'key1' -> 1
1 -> 'key1'
}

Map items can be accessed with the -> operator, returning nothing if the key is not found.

from myDict->'key1'

New Macros for Map Operations

To improve handling of Maps, the Pure standard runtime now includes two new macros: keys and entries.

  • keys retrieves a Map’s keys as an iterator.
  • entries returns an iterator of tuples, each representing a key-value pair.

Example usage:

from myDict keys
from myDict entries

Lists Enhanced

Lists have been upgraded to be a subtype of Maps. A List is now a Map with a numeric key, where the key functions as a 1-based index. While the syntax for declaring a list remains unchanged, its type has been updated to { number -> * } from an iterator [*].

Additionally, Lists are now literal types. For example:

let myList = [1,2,3]

This will define a type as { number -> 1|2|3 }, which is beneficial when passing a list to a function with a parameter type like [1|2|3].

New Standard Runtime Features

To simplify working with iterators and maps, the following features has been added to the standard runtimes:


This update to Filtrera provides new tools and improvements to help streamline your functional programming workflow. The addition of Maps and the enhancements to Lists offer greater flexibility and power. Feel free to explore these new features in Preview 5.