def hash(a: A): Intmakes me sad. What about hashing to 64 bits or SL2 Fp?def MapHash[A, B: Hash]: Hash[Map[A, B]]is a bit odd. Why notA: Hash?reflexiveLaw + symmetryLaw + transitivityLawis too weak for "equality". This defines a general equivalence relationship only.val AnyEqual: Equal[Any]is worrisome, considering all the resolution bugs!val DoubleEqual: Equal[Double]should be implemented usingjava.lang.Double.doubleToRawLongBits.- A combintation of
trait Ord[-A] extends Equal[A]andtrait Hash[-A] extends Equal[A]is a recipe for ambigious implicit resolution problem. There is no good solution though (Scato encoding is not modular, compiler plugin requires evil reflection, defining intersection subtypes is not scalable). EDIT: There isHashOrdin thecoherentpackage. val DoubleOrd: Ord[Double]is good, though there are more than one NaN and I wonder howcomparehandles those 🤔.[F[+_]]is making a statement for sure, though I am not sure if it is justified. You can use covariant type constructor as an argument to a typeclass accepting invariantF[_]but not vice versa.Ord[B].contramap(f)instances violate the laws. Of course it does not matter in this case, but... 👺 At the very least it tells you that something is wrong with the abstractions if we have to coerce them like that. Same thing here.foldMap(fa)(a => Or(f(a)))is too eager and will always consume the wholeF[A]sincefoldMapis defined throughfoldLeft. Laziness is hard.Map[A @uncheckedVariance, B]is almost guaranteed to result in CCEs if someone passes aSortedMap[A, B]in.- Well-known issue with this particular encoding of newtypes is casting wrapping / unwrapping arrays. Consider
trait Tag extends Any. The rest of the newtype implementation has too much indirection for me to follow, it's unnecessarily complex, perhaps for educational reasons. Please ask @edmundnoble for a ResponsibleasInstanceOfUser license, and don't be afraid to use it for low-level implementation details. Equivalence[A, B]should be calledIso[A, B]. Come on, this simplification of the language is going too far 😅!Debug.Repris a really cool innovation in this area. Butn.startsWith("Tuple")is probably insufficiently precise (thinkTupleConverterShit).Map[A, B]won't work with newtypes that require a custom equality or hashing. Not very common, but when it happens (newtypes overDouble), you'll know it.- Are people THAT afraid of the word
Profunctor? - zio.prelude.coherent is for ... "coherent" typeclasses?
- Pretend-"associativity" of
Doublealways makes me sad, but I have not seen a better solution than just ignoring the problem so far. Not a criticism, just a general remark.
Last active
August 11, 2020 22:08
-
-
Save sir-wabbit/28dd6a0693c2d92d45528a62f7df9e0e to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment