Re: [Haskell-cafe] RFC: functor-classes-compat

On Dec 13, 2016 4:01 AM, "Oleg Grenrus"

On 13.12.2016 19:06, David Feuer wrote:
On Dec 13, 2016 4:01 AM, "Oleg Grenrus"
mailto:oleg.grenrus@iki.fi> wrote: Hi,
continuing pushing the adoption Data.Functor.Classes, I wrote a small package `functor-classes-compat` [1].
It provides lifted (Eq1, Ord1, etc.) classes for types in `containers`, `vector` and `unordered-containers`(not for Sequence or Tree yet though).
Thanks for working on this. Obviously, some of these really belong in containers. I'll try to add them today.
Thanks to you!
I guess there is no way they could depend on `transformers` to provide instances in build plans with `base < 4.9`, I'm not sure when I'll have time to write patches for the actual packages myself.
No, I don't think that's likely. One option might be to add these instances to transformers when compiling with older base, but I don't know if Ross Paterson will want them.
I'm not sure we want `transformers` to depend on `containers` either, not even mentioning `vector` and `unordered-containers`. Also there are people stuck with `transformers-0.4` (GHC 7.10).
Current implementations are naive, but more obviously correct.
More than what?
It seems that implementation for Data.Map is indeed "check size, compare lists", but e.g for vector it uses streaming framework to make things fuse, I still use "check size, compare lists" approach. Also I see that my `HashMap` implementation is actually incorrect, as HashMap's `toList` may return results in different order (depends on the history)

On Dec 13, 2016 1:26 PM, "Oleg Grenrus"
Current implementations are naive, but more obviously correct.
More than what?
It seems that implementation for Data.Map is indeed "check size, compare lists", but e.g for vector it uses streaming framework to make things fuse, I still use "check size, compare lists" approach. I believe the only containers structures with non-boring instances of any of those classes are Data.IntMap, Data.IntSet, and Data.Tree. Side question: why doesn't Read1 have the ReadPrec-based methods that Read does?

On 13.12.2016 21:24, David Feuer wrote:
On Dec 13, 2016 1:26 PM, "Oleg Grenrus"
mailto:oleg.grenrus@iki.fi> wrote: I'm not sure we want `transformers` to depend on `containers` either, not even mentioning `vector` and `unordered-containers`. Also there are people stuck with `transformers-0.4` (GHC 7.10).
Good point, although practically speaking, containers currently *can't* depend on transformers, because transformers is not currently a GHC boot package. There'll probably be room for your compat package for a while, but you'll have to chase those bounds :-/.
transformers *is* boot package, `ghc` package depends on transformers directly (since GHC 7.6): https://ghc.haskell.org/trac/ghc/wiki/Commentary/Libraries/VersionHistory $ ghc-pkg describe ghc ... depends: array-0.5.1.1 base-4.9.0.0 binary-0.8.3.0 bytestring-0.10.8.1 containers-0.5.7.1 directory-1.2.6.2 filepath-1.4.1.0 ghc-boot-8.0.1 ghci-8.0.1 hoopl-3.10.2.1 hpc-0.6.0.3 process-1.4.2.0 template-haskell-2.11.0.0 time-1.6.0.1 transformers-0.5.2.0 unix-2.7.2.0
> Current implementations are naive, but more obviously correct. > > More than what?
It seems that implementation for Data.Map is indeed "check size, compare lists", but e.g for vector it uses streaming framework to make things fuse, I still use "check size, compare lists" approach.
I believe the only containers structures with non-boring instances of any of those classes are Data.IntMap, Data.IntSet, and Data.Tree.
IntSet is :: *
Side question: why doesn't Read1 have the ReadPrec-based methods that Read does?
I have been wondering the same
participants (2)
-
David Feuer
-
Oleg Grenrus