lux/type/auto

Macros

:::

## Automatic structure selection (for type-class style polymorphism).
## This feature layers type-class style polymorphism on top of Lux's signatures and structures.
## When calling a polymorphic function, or using a polymorphic constant,
## this macro will check the types of the arguments, and the expected type for the whole expression
## and it will search in the local scope, the module's scope and the imports' scope
## in order to find suitable structures to satisfy those requirements.
## If a single alternative is found, that one will be used automatically.
## If no alternative is found, or if more than one alternative is found (ambiguity)
## a compile-time error will be raised, to alert the user.
## Examples:
## Nat equality
(:: lux/data/number;Eq<Nat>= x y)

(::: = x y)

## Can optionally add the prefix of the module where the signature was defined.
(::: lux/control/eq;=x y)

## (List Nat) equality
(::: =
     (lux/data/struct/list;n.range+1 +10)
     (lux/data/struct/list;n.range+1 +10))

## Functor map
(::: map n.inc (lux/data/struct/list;n.range+0 +9))

## Caveat emptor: You need to make sure to import the module of any structure you want to use.
## Otherwise, this macro won't find it.