Program StructureImports and Modules
Blorp by Example

Imports and Modules

Imports make module boundaries explicit while the prelude keeps common names available.

Prelude

Core types, Option, Result, List, Dict, Set, String, and console helpers are available by default.

prelude.brp
items: List[Int] = [1, 2, 3]
print(items.length().to_string())

Selective Imports

Import just the functions you want with module: name.

selective-import.brp
import:
    json: parse_json

Qualified Imports

Use module as Alias for a qualified namespace.

qualified-import.brp
import:
    json as Json

parsed = Json.parse_json("{}")

File-as-module

A .brp file can be imported as a module by path.

module-import.brp
import:
    ./scores as Scores

print(Scores.classify(82))

Visibility

private keeps helpers inside their module.

private.brp
private pure func helper(n: Int) -> Int:
    n + 1

Example

scores.brp + main.brp
import:
	./scores as Scores


func main(args: List[String]) -> Void:
	print(Scores.classify(82))

Try It

terminal
blorp run main.brp