Open justin-hackin opened 3 years ago
Hi!
The Vec
type is implemented as readonly array. Just tried your code snippet and it works if you import * as array from "fp-ts/ReadonlyArray"
No, there was no specific reason to not to include a getEq
into the library. I guess some others are missing, too.
I think it would be something like this:
const getEq: <A>(E: Eq<A>) => <N extends number>() => Eq<Vec<N, A>> = (
E
) => () => array.getEq(E)
Thanks for posting this. PR's are always welcome :)
Also created this one: https://github.com/no-day/fp-ts-number-instances/issues/1
Thanks for letting me know about read-only array feature. I decided that I only needed one size and thus I opted out of this library for now. Glad it was worth marking this in the number library.
Yes, this makes sense. I actually had in mind to create a library that provides the fixed sized vectors. (Vec2, Vec3).
What exists though is one that has the non-generic Vec2n
, Vec3n
types:
https://github.com/no-day/fp-ts-numeric-vectors (unfortunately Eq
and other instances missing, too)
In future there should be easy conversion between those types by adding fromTuple
/toTuple
everywere.
I'm very new to fp-ts so I hope I'm not overlooking something obvious here. I'm looking for how to implement a fp-ts compatible equality operation for the sized vectors. I tried this
and this complains that a
number[]
can't be assigned to Vec<2, number>. Is there a particular reason why this library doesn't seem to implement equality for the vectors?