Skip to content

Conversation

@7h3kk1d
Copy link
Contributor

@7h3kk1d 7h3kk1d commented Nov 7, 2025

Adds unique and pivot_table functions to the builtins context. These are implemented as Hazel functions and added for convenience.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.07%. Comparing base (cf38c33) to head (32052fa).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2005      +/-   ##
==========================================
+ Coverage   49.78%   50.07%   +0.28%     
==========================================
  Files         218      218              
  Lines       23103    23237     +134     
==========================================
+ Hits        11502    11635     +133     
- Misses      11601    11602       +1     
Files with missing lines Coverage Δ
src/language/builtins/BuiltinsList.re 99.91% <100.00%> (+<0.01%) ⬆️

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@7h3kk1d 7h3kk1d marked this pull request as ready for review November 10, 2025 14:35
@7h3kk1d 7h3kk1d self-assigned this Nov 18, 2025
@7h3kk1d 7h3kk1d force-pushed the pivot_table_builtin branch from 7132ac7 to e875f5c Compare November 20, 2025 15:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds two new convenience functions to the Hazel builtins library: unique (removes duplicate elements from a list) and pivot_table (reshapes data from long to wide format). Both functions are implemented as Hazel functions following the existing patterns in the codebase.

Key changes:

  • unique function removes duplicates from a list while preserving order
  • pivot_table function transforms tabular data by creating pivot tables with configurable row/column extractors and aggregation functions
  • Test cases added for both new functions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/language/builtins/BuiltinsList.re Adds unique and pivot_table function definitions with type signatures and implementations
test/evaluator/Test_Evaluator_Builtins_Lists.re Adds test cases verifying the behavior of both new functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

},
},
{
str: {hazel|fix pivot_table -> fun (table, new_col, index, value) ->
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter order in the str field (table, new_col, index, value) does not match the order in the imp field at lines 3045-3049, which uses (table, new_col, index, value). However, the implementation appears to expect the parameters in the order (table, index, new_col, value) based on how they're used in the test (line 466-468: first extracts row, then column). Please verify the intended parameter order is consistent between the string representation and the implementation.

Suggested change
str: {hazel|fix pivot_table -> fun (table, new_col, index, value) ->
str: {hazel|fix pivot_table -> fun (table, index, new_col, value) ->

Copilot uses AI. Check for mistakes.
7h3kk1d and others added 3 commits November 24, 2025 15:08
Add a new builtin function `group_on_key` that groups list elements by a provided key function. This function takes a list and a key extractor, then accumulates groups by key using a recursive update helper, enabling efficient clustering of data based on computed keys.

The implementation uses a fix point for the `update_groups` helper to handle membership checks and group accumulation iteratively. This enhances the language's builtin capabilities for data manipulation tasks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants