monocle-ts
monocle-ts copied to clipboard
iso.iso constructor is not equivalent to iso class constructor
🐛 Bug report
Current Behavior
composeIso does not accept an instance created via the iso.iso constructor.
Expected behavior
Both constructors must work with composeIso method.
Reproducible example
import { iso, Iso, Lens } from "monocle-ts";
type Input = { data: [string, string][] };
type Output = { data: { [id: string]: string } };
const data = Lens.fromProp<Input>()("data");
const iso1 = new Iso<Input["data"], Output["data"]>(
() => {
throw new Error("unimplemented");
},
() => {
throw new Error("unimplemented");
}
);
const iso2 = iso.iso<Input["data"], Output["data"]>(
() => {
throw new Error("unimplemented");
},
() => {
throw new Error("unimplemented");
}
);
data.composeIso(iso1); // this works!
data.composeIso(iso2); // type check error: Type 'Iso<[string, string][], { [id: string]: string; }>' is missing the following properties from type 'Iso<[string, string][], { [id: string]: string; }>': _tag, unwrap, to, wrap, and 19 more.
My environment
| Software | Version(s) |
|---|---|
| monocle-ts | 2.3.10 |
| fp-ts | 2.11.1 |
| TypeScript | 3.9.10 |