Skip to content

Remove deprecations from Belt functions ending in Exn #7590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
#### :boom: Breaking Change

- The legacy rescript cli can be called through rewatch via `rewatch legacy`. Arguments to rewatch need to be passed after the subcommand. Argument `--compiler-args` is now a subcommand `compiler-args`. https://github.com/rescript-lang/rescript/pull/7551
- Rename `Belt` functions ending with `Exn` to end with `OrThrow` https://github.com/rescript-lang/rescript/pull/7581 The following `Exn` functions are now deprecated:
- `Belt.Array.getExn``Belt.Array.getOrThrow`
- `Belt.Array.setExn``Belt.Array.setOrThrow`
- `Belt.Map.getExn``Belt.Map.getOrThrow`
- `Belt.MutableMap.getExn``Belt.MutableMap.getOrThrow`
- `Belt.Set.getExn``Belt.Set.getOrThrow`
- `Belt.MutableSet.getExn``Belt.MutableSet.getOrThrow`
- `Belt.List.getExn``Belt.List.getOrThrow`
- `Belt.List.tailExn``Belt.List.tailOrThrow`
- `Belt.List.headExn``Belt.List.headOrThrow`
- `Belt.MutableQueue.peekExn``Belt.MutableQueue.peekOrThrow`
- `Belt.MutableQueue.popExn``Belt.MutableQueue.popOrThrow`
- `Belt.Option.getExn``Belt.Option.getOrThrow`
- `Belt.Result.getExn``Belt.Result.getOrThrow`
- Old functions remain available but are marked as deprecated with guidance to use the new `OrThrow` variants.

#### :rocket: New Feature

- Add `OrThrow` aliases for `Belt` functions ending with `Exn`. https://github.com/rescript-lang/rescript/pull/7581, https://github.com/rescript-lang/rescript/pull/7590 The following aliases have been added:
- `Belt.Array.getOrThrow`
- `Belt.Array.setOrThrow`
- `Belt.Map.getOrThrow`
- `Belt.MutableMap.getOrThrow`
- `Belt.Set.getOrThrow`
- `Belt.MutableSet.getOrThrow`
- `Belt.List.getOrThrow`
- `Belt.List.tailOrThrow`
- `Belt.List.headOrThrow`
- `Belt.MutableQueue.peekOrThrow`
- `Belt.MutableQueue.popOrThrow`
- `Belt.Option.getOrThrow`
- `Belt.Result.getOrThrow`

#### :bug: Bug fix

Expand Down
2 changes: 0 additions & 2 deletions runtime/Belt_Array.resi
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ let get: (t<'a>, int) => option<'a>
Raise an exception if `i` is out of range.
Otherwise return the value at index `i` in `arr`.
*/
@deprecated("Use 'getOrThrow' instead")
let getExn: (t<'a>, int) => 'a

/**
Expand Down Expand Up @@ -86,7 +85,6 @@ let set: (t<'a>, int, 'a) => bool
/**
`setExn(arr, i, x)` raise an exception if `i` is out of range.
*/
@deprecated("Use 'setOrThrow' instead")
let setExn: (t<'a>, int, 'a) => unit

/**
Expand Down
3 changes: 0 additions & 3 deletions runtime/Belt_List.resi
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ switch Belt.List.headExn(list{}) { // Raises an Error
}
```
*/
@deprecated("Use `headOrThrow` instead")
let headExn: t<'a> => 'a

/**
Expand Down Expand Up @@ -126,7 +125,6 @@ switch Belt.List.tailExn(list{}) { // Raises an Error
}
```
*/
@deprecated("Use `tailOrThrow` instead")
let tailExn: t<'a> => t<'a>

/**
Expand Down Expand Up @@ -192,7 +190,6 @@ switch abc->Belt.List.getExn(4) { // Raises an Error
}
```
*/
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'a>, int) => 'a

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_Map.resi
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ See `Belt.Map.get`
raise when `k` not exist
*/
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'k, 'v, 'id>, 'k) => 'v

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MapDict.resi
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ let getUndefined: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => Js.undefined<'a>

let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a, ~cmp: cmp<'k, 'id>) => 'a

@deprecated("Use `getOrThrow` instead")
let getExn: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a

let getOrThrow: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MapInt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ let getUndefined: (t<'v>, key) => Js.undefined<'v>

let getWithDefault: (t<'v>, key, 'v) => 'v

@deprecated("Use `getOrThrow` instead")
let getExn: (t<'v>, key) => 'v

let getOrThrow: (t<'v>, key) => 'v
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MapString.resi
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ let getUndefined: (t<'v>, key) => Js.undefined<'v>

let getWithDefault: (t<'v>, key, 'v) => 'v

@deprecated("Use `getOrThrow` instead")
let getExn: (t<'v>, key) => 'v

let getOrThrow: (t<'v>, key) => 'v
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MutableMap.resi
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ let maxUndefined: t<'k, 'a, _> => Js.undefined<('k, 'a)>
let get: (t<'k, 'a, 'id>, 'k) => option<'a>
let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a>
let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'k, 'a, 'id>, 'k) => 'a
let getOrThrow: (t<'k, 'a, 'id>, 'k) => 'a
/** Raise when invariant is not held. */
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MutableMapInt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ let maxUndefined: t<'a> => Js.undefined<(key, 'a)>
let get: (t<'a>, key) => option<'a>
let getUndefined: (t<'a>, key) => Js.undefined<'a>
let getWithDefault: (t<'a>, key, 'a) => 'a
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'a>, key) => 'a
let getOrThrow: (t<'a>, key) => 'a

Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MutableMapString.resi
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ let maxUndefined: t<'a> => Js.undefined<(key, 'a)>
let get: (t<'a>, key) => option<'a>
let getUndefined: (t<'a>, key) => Js.undefined<'a>
let getWithDefault: (t<'a>, key, 'a) => 'a
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'a>, key) => 'a
let getOrThrow: (t<'a>, key) => 'a

Expand Down
2 changes: 0 additions & 2 deletions runtime/Belt_MutableQueue.resi
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ let peekUndefined: t<'a> => Js.undefined<'a>
/**
`peekExn(q)` raises an exception if `q` is empty.
*/
@deprecated("Use `peekOrThrow` instead")
let peekExn: t<'a> => 'a

/**
Expand All @@ -83,7 +82,6 @@ let popUndefined: t<'a> => Js.undefined<'a>
/**
`popExn(q)` raise an exception if q is empty.
*/
@deprecated("Use `popOrThrow` instead")
let popExn: t<'a> => 'a

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MutableSet.resi
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value>
/**
Same as `Belt.MutableSet.get` but raise when element does not exist.
*/
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'value, 'id>, 'value) => 'value

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MutableSetInt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ let maxUndefined: t => Js.undefined<value>

let get: (t, value) => option<value>
let getUndefined: (t, value) => Js.undefined<value>
@deprecated("Use `getOrThrow` instead")
let getExn: (t, value) => value
let getOrThrow: (t, value) => value

Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_MutableSetString.resi
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ let maxUndefined: t => Js.undefined<value>

let get: (t, value) => option<value>
let getUndefined: (t, value) => Js.undefined<value>
@deprecated("Use `getOrThrow` instead")
let getExn: (t, value) => value
let getOrThrow: (t, value) => value

Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_Option.resi
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ switch Belt.Option.getExn(None) { // Raises an exception
}
```
*/
@deprecated("Use `getOrThrow` instead")
let getExn: option<'a> => 'a

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_Result.resi
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ switch Belt.Result.getExn(Belt.Result.Error("Invalid data")) { // raise a except
}
```
*/
@deprecated("Use `getOrThrow` instead")
let getExn: t<'a, 'b> => 'a

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_Set.resi
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value>
/**
Same as [get](#get) but raise when element does not exist.
*/
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'value, 'id>, 'value) => 'value

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_SetDict.resi
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ let getUndefined: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => Js.undefin
/**
Same as [get](#get) but raise when element does not exist.
*/
@deprecated("Use `getOrThrow` instead")
let getExn: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value

/**
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_SetInt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ let get: (t, value) => option<value>

let getUndefined: (t, value) => Js.undefined<value>

@deprecated("Use `getOrThrow` instead")
let getExn: (t, value) => value

let getOrThrow: (t, value) => value
Expand Down
1 change: 0 additions & 1 deletion runtime/Belt_SetString.resi
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ let get: (t, value) => option<value>

let getUndefined: (t, value) => Js.undefined<value>

@deprecated("Use `getOrThrow` instead")
let getExn: (t, value) => value

let getOrThrow: (t, value) => value
Expand Down