Skip to content

[Repo Assist] Add [(RequiresExplicitTypeArguments)] to GetRow/TryGetRow and ObjectSeries typed accessors — closes #218#654

Merged
dsyme merged 1 commit intomasterfrom
repo-assist/fix-issue-218-RequiresExplicitTypeArguments-bbf664d55740542b
Mar 19, 2026
Merged

[Repo Assist] Add [(RequiresExplicitTypeArguments)] to GetRow/TryGetRow and ObjectSeries typed accessors — closes #218#654
dsyme merged 1 commit intomasterfrom
repo-assist/fix-issue-218-RequiresExplicitTypeArguments-bbf664d55740542b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Repo Assist — implementing the API safety improvement requested in #218.

Problem

frame.GetRow(key), objSeries.As(), objSeries.GetAs("col") and their
TryGet* variants have a type parameter that controls what type the returned
series values will be. Without explicit type annotation, F# may silently infer
obj, producing a series that appears correct at a glance but is typed as
Series<_, obj> rather than the intended Series<_, float> (or whatever the
caller expected). This was agreed upon by @tpetricek back in 2014 but was
never implemented.

Solution

Add [(RequiresExplicitTypeArguments)] to the affected members. Callers are
now required to write the type argument explicitly:

// Before — 'T silently inferred as obj if no context:
let row = frame.GetRow("key")              // Series<_, obj> — silent

// After — compile error if type omitted, forces intent:
let row = frame.GetRow(float)("key")       // ✅ explicit and safe
let row = frame.GetRow("key") : Series<_, float>  // ✅ annotation also works

// ObjectSeries — same story:
let col = os.GetAs(int)("Count")           // ✅ explicit  
let col = os.As(float)()                   // ✅ explicit
```

## Scope

Members annotated with `[(RequiresExplicitTypeArguments)]`:
- `Frame.GetRow<'T>` (both overloads)
- `Frame.TryGetRow<'T>` (both overloads)
- `Frame.TryGetRowObservation<'T>`
- `ObjectSeries.As<'R>`
- `ObjectSeries.TryAs<'R>` (both overloads)
- `ObjectSeries.GetAs<'R>` (both overloads)
- `ObjectSeries.TryGetAs<'R>` (both overloads)

**Not changed**: `GetColumn`, `TryGetColumn` and related column methods.
Columns typically have clearer type constraints from surrounding code, so the
benefit is smaller and the internal refactor costs would be higher.

## Internal call-site fixes

`FrameModule.fs` wrapper functions (`getRow`, `lookupRow`, `tryLookupRow`,
`tryLookupRowObservation`) are made `inline` so their `'T` parameter is
resolved at each call site, preserving full generic inference for the `'R` and
`'C` frame key types. No public API signatures change.

One test (`Frame.fs`) updated: `dfi.TryGetRow(2)` → `dfi.TryGetRow(obj)(2)`
to explicitly state the intent (checking row existence, not reading typed
values).

## Test Status

```
Passed!  - Failed: 0, Passed: 669, Skipped: 0, Total: 669

All 669 tests pass. Deedle.Math also builds cleanly (uses row.As(float)()
which already had the explicit type argument).

Generated by Repo Assist

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@30f2254f2a7a944da1224df45d181a3f8faefd0d

…eries typed accessors — closes #218

Without this attribute, F# silently infers 'obj' when the row value type is
not constrained by context, masking type errors at compile time. The attribute
forces callers to write e.g. frame.GetRow<float>(key) rather than
frame.GetRow(key), making the intent unambiguous.

Changes:
- Frame.fs: add [<RequiresExplicitTypeArguments>] to TryGetRow<'T>,
  GetRow<'T> (both overloads), TryGetRowObservation<'T>
- Series.fs (ObjectSeries): add to As<'R>, TryAs<'R>, GetAs<'R> (both
  overloads), TryGetAs<'R> (both overloads)
- FrameModule.fs: make getRow/lookupRow/tryLookupRow/tryLookupRowObservation
  inline so their 'T parameter is resolved at each call site without
  constraining the frame's 'R/'C parameters to obj
- Frame.fs (tests): update one direct TryGetRow call to use TryGetRow<obj>

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 19, 2026 01:11
@dsyme dsyme closed this Mar 19, 2026
@dsyme dsyme reopened this Mar 19, 2026
@dsyme dsyme merged commit 7393a6b into master Mar 19, 2026
8 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-218-RequiresExplicitTypeArguments-bbf664d55740542b branch March 19, 2026 01:52
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.

1 participant