forked from Effect-TS/effect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more type safe dual signature, closes Effect-TS#2967
- Loading branch information
1 parent
0ce7594
commit 6d9863c
Showing
14 changed files
with
147 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@effect/typeclass": minor | ||
"@effect/platform": minor | ||
"effect": minor | ||
"@effect/schema": minor | ||
--- | ||
|
||
more type safe `Function.dual` signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as Function from "effect/Function" | ||
|
||
// ------------------------------------------------------------------------------------- | ||
// dual | ||
// ------------------------------------------------------------------------------------- | ||
|
||
type f_data_first = (a: number, b: number) => number | ||
type f_data_last = (b: number) => (a: number) => number | ||
|
||
const f: f_data_first & f_data_last = Function.dual(2, (a: number, b: number) => a + b) | ||
// $ExpectType f_data_first & f_data_last | ||
f | ||
|
||
const f_explicit_types = Function.dual<f_data_last, f_data_first>(2, (a: number, b: number) => a + b) | ||
// $ExpectType f_data_first & f_data_last | ||
f_explicit_types | ||
|
||
const f_no_type = Function.dual(2, (a: number, b: number) => a + b) | ||
// $ExpectType (a: number, b: number) => number | ||
f_no_type | ||
|
||
// @ts-expect-error | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const f_wrong_impl: f_data_first & f_data_last = Function.dual(2, (a: string, b: string) => a + b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters