-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
#1005 - HKT restructuring #1055
Conversation
The whole MixVariance/InitialVariance thing should be removed |
Parameters like |
Also ideally every parameter has a meaning, it almost feel like we could get away with:
Any fixed type can be supported by transformers by having parametric URIs like: interface KeyValueT<Key, Value, F extends HKT> {
type: KeyValue<Key, Value, Kind<F, this[...]>
} |
I am not even too sure we want to keep the invariant interface StateT<S, F> {
type: (s: S) => Kind<F, this["I"], this["R"], this["E"], [S, this["A"]]>
} and would even allow mixing multiple different states |
Oh, that would be cool, the simpler the And If we go down this road, should we keep the Edit: |
I gave it a try but it seems that would force us to fix the S type no? import { pipe, tuple } from "../../Function/index.js"
import * as PV2 from "../../PreludeV2"
interface StateT<S, F> extends PV2.HKT {
readonly type: (
s: S
) => PV2.Kind<F, this["X"], this["I"], this["R"], this["E"], readonly [this["A"], S]>
}
export function monad<F extends PV2.HKT>(M: PV2.Monad<F>) {
return <S>() =>
PV2.instance<PV2.Monad<StateT<S, F>>>({
any: () => (s) =>
pipe(
M.any(),
M.map((m) => tuple(m, s))
),
flatten: (ffa) => (x) =>
pipe(
x,
ffa,
PV2.DSL.chainF(M)(([f, us]) => f(us))
),
map: (f) => (fa) => (x) =>
pipe(
x,
fa,
M.map(([a, s]) => tuple(f(a), s))
)
})
} (Also, If |
That is the objective, Even with |
Thought of |
Notable changes:
|
is anything blocking this? I'm really looking forward to #1055 |
Not really I am planning it for when system next is ready given it is a breaking change |
packages/core/src/StateT/index.ts
Outdated
import * as DSL from "../PreludeV2/DSL/index.js" | ||
import * as P from "../PreludeV2/index.js" | ||
|
||
interface StateT<A, B> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to do this otherwise type inference for A
param was not working when using chain. Please let me know If there Is there a better way to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very strange indeed, also to avoid errors down the line it is good to export all the used symbols
@@ -1,22 +0,0 @@ | |||
import { pipe } from "@effect-ts/system/Function" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't see any difference with example 10 besides InvariantT which, from what I understand, can be deleted with the new HKT system. (I'll test this assumption further though)
@@ -1,75 +0,0 @@ | |||
import * as M from "@effect-ts/system/Collections/Immutable/Map" | |||
import * as Tp from "@effect-ts/system/Collections/Immutable/Tuple" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted example since I couldn't see any difference with example 11 after the move to PV2
|
I have the opposite opinion here, the reason there are no inline examples in jsdoc in effect is because I truly don't like to see them in the on-hover (I have removed the few that were left from the port of fp-ts modules). I think we will find a middle ground with paka where @schickling is planning embeddable code in docs |
export function Provide<F extends P.HKT>(_: P.Monad<F>) {
return HKT.instance<FX.Provide<XReaderTF<F>>>({
provide:
<R>(r: R) =>
<X, I, E, A>(fa: XR.XReader<R, HKT.Kind<F, X, I, R, E, A>>) => {
return pipe(
fa,
XR.provideSome(() => r)
) as XR.XReader<unknown, HKT.Kind<F, X, I, unknown, E, A>> // <- Cast required, the result is typed XR.XReader<unknown, HKT.Kind<F, X, I, unknown, E, A>>
}
})
}
|
So, the DSL import issue definitely comes from something I've done. Not sure what yet but I'll find it |
Annnd It's fixed, my IDE is drunk, I had imports of |
packages/core/src/IndexedT/index.ts
Outdated
@@ -207,57 +26,70 @@ export class Ix<I, O, A> { | |||
constructor(readonly value: A) {} | |||
} | |||
|
|||
export interface IndexedT<F extends P.HKT, _I, _O> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikearnaldi I removed the initial Indexed representation and exposed directly an IndexedT, let me know if that's an issue and I'll rework it :).
(also, this type is pretty cool and simple! I got lost in the types with the old version but the new system makes what happens very explicit)
@@ -48,7 +48,6 @@ export * as IO from "./IO/index.js" | |||
export * as Id from "./Id/index.js" | |||
export * as Identity from "./Identity/index.js" | |||
export * as IndexedT from "./IndexedT/index.js" | |||
export * as InvariantT from "./InvariantT/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikearnaldi Removed InvariantT, unless I'm mistaken this isn't needed with the new system
@mikearnaldi I think we're there, I'll have to take at everything again for the peace of mind but everything compiles, and all tests are passing (Ill update the PR with all the notable changes). |
- @effect-ts/[email protected] - @effect-ts/[email protected] - @effect-ts/[email protected]
Moved to #1162 for a cleaner commit history (I did not want to kill the history for this PR) |
(kinda) Getting close, I still have to: