ogma icon indicating copy to clipboard operation
ogma copied to clipboard

[FEATURE] Implement map for user defined types

Open kurtlawrence opened this issue 3 years ago • 1 comments

Description

Implement map for user defined types.

The implementation would take a user defined type as input, a field identifier (checked at hir phase), and an expression where the input is the value found at the identifier.

The output of the expression would need to match the field's type, and the output of the map expression would be the user defined type.

  • Support a variable which gives access to the input (like $self? Probably not, given it would incur a performance penalty when cloned which might not be necessary for every use case

kurtlawrence avatar Oct 20 '21 02:10 kurtlawrence

For sum types, instead of the identifier mapping the field, the identifier would map the variant. This is kinda neat, for example a Result type could do map Err ...

kurtlawrence avatar Oct 20 '21 02:10 kurtlawrence