Giter VIP home page Giter VIP logo

Comments (12)

phadej avatar phadej commented on June 14, 2024

Answer: There is nothing wrong with semigroupoids-6

#if HAS_FOLDABLE1_TRANSFORMERS
instance Traversable1 f => Traversable1 (IdentityT f) where
  traverse1 f = fmap IdentityT . traverse1 f . runIdentityT

instance Traversable1 f => Traversable1 (Backwards f) where
  traverse1 f = fmap Backwards . traverse1 f . forwards

instance Traversable1 f => Traversable1 (Lift f) where
  traverse1 f (Pure x)  = Pure <$> f x
  traverse1 f (Other y) = Other <$> traverse1 f y

instance Traversable1 f => Traversable1 (Reverse f) where
  traverse1 f = fmap Reverse . forwards . traverse1 (Backwards . f) . getReverse
#endif

We just don't have these compat instances anywhere.

But should we have them in e.g. transformers-compat? I don't know, this install plan is somewhat a corner case.

from lens.

RyanGlScott avatar RyanGlScott commented on June 14, 2024

I think it would make sense to add these to transformers-compat. Do you mind opening an issue on the transformers-compat side?

from lens.

RyanGlScott avatar RyanGlScott commented on June 14, 2024

Oh wait, I missed the fact that this is specifically about Traversable1, which is in a library that transformers-compat doesn't depend on. That definitely complicates things...

from lens.

phadej avatar phadej commented on June 14, 2024

@RyanGlScott I was thinking of adding foldable1-classes-compat dependency to transformers-compat.

Then the instances can be defined uniformly in semigroupoids.

from lens.

RyanGlScott avatar RyanGlScott commented on June 14, 2024

I'm a bit confused. foldable1-classes-compat doesn't provide Traversable1, right? (I might be missing some details of the plan you have in mind.)

from lens.

phadej avatar phadej commented on June 14, 2024

We don't define (non-orphan!) Traversable1 instances in semigroupoids because of missing Foldable1 instances.

from lens.

RyanGlScott avatar RyanGlScott commented on June 14, 2024

Ah, that is the part that I was missing! Indeed, that plan sounds reasonable.

from lens.

phadej avatar phadej commented on June 14, 2024

It doesn't work easily, on older GHCs (GHC-8.0 and older)

[__0] trying: transformers-compat-0.7.2 (user goal)
[__1] trying: foldable1-classes-compat-0.1 (dependency of transformers-compat)
[__2] next goal: bifunctor-classes-compat (dependency of
foldable1-classes-compat)
[__2] rejecting: bifunctor-classes-compat-0.1 (cyclic dependencies; conflict
set: bifunctor-classes-compat, foldable1-classes-compat, transformers-compat)

And the cycle is there due Data.Functor.Constant instances.

I'd propose to drop transformers(-compat) dependency from bifunctor-classes-compat, and move Constant (a somewhat useless type) instances to transformers-compat. i.e. changing the dependency graph into

bifunctor-classes-compat <- foldable1-classes-compat <- transformers-compat

from lens.

phadej avatar phadej commented on June 14, 2024

A short term solution for this particular problem is to make lens require new enough transformers on GHC-9.6

i.e.

if impl(ghc >=9.6)
  build-depends: transformers >=0.6.1

That cannot be done in a revision though, unfortunately.

In practice that shouldn't affect anyone. Only weirdos (like myself) downgrade transformers.

EDIT: we could add revisions to already released lens disallowing the GHC-9.6 build plans. At this point the 5.2.1 is the only one, AFAICT.

from lens.

RyanGlScott avatar RyanGlScott commented on June 14, 2024

Urgh, good catch. Would this mean that we would also have to remove foldable1-classes-compat's dependency on transformers-compat?

from lens.

phadej avatar phadej commented on June 14, 2024

Would this mean that we would also have to remove foldable1-classes-compat's dependency on transformers-compat?

Yeah. Now I think it's quite heavy change to go through. Easier to just require newer transformers on GHC-9,6 (as in #1028 (comment)) if Foldable1 Reverse etc. instance is needed. In fact that's probably something that can be done already in semigroupoids.

EDIT: Note, there is precedence for this already. In some packages we use similar approach of requring at least some transformers version since some GHC/base like in https://github.com/recursion-schemes/recursion-schemes/blob/3114d863197c33467c1f0d339a9c67b4ffd16e0e/recursion-schemes.cabal#L65-L72 to make our lifes a bit easier.

from lens.

RyanGlScott avatar RyanGlScott commented on June 14, 2024

I have uploaded semigroupoids-6.0.0.1 to Hackage and blacklisted semigroupoids-6. I believe that should take care of this issue, but please re-open the issue if I have forgotten something.

from lens.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.