Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Data.Lens.Zoom.zoom #123

Merged

Conversation

kl0tl
Copy link
Contributor

@kl0tl kl0tl commented Dec 28, 2020

Without the type annotation Data.Lens.Zoom.zoom yields the following error:

[1/1 NoInstanceFound] src/Data/Lens/Zoom.purs:22:21

  22  zoom p = StateT <<< underF Focusing (under Star p) <<< runStateT
                          ^^^^^^^^^^^^^^^

  No type class instance was found for

    Prim.Coerce.Coercible t4
                          (m7 (Tuple r8 s6))

  The instance head contains unknown type variables. Consider adding a type annotation.

  while solving type class constraint

    Prim.Coerce.Coercible (s6 -> t4)
                          (s6 -> m7 (Tuple r8 s6))

  while applying a function underF
    of type Coercible @Type (t0 t1) (t0 t2) => Coercible @Type (t3 t4) (t3 t5) => Newtype t1 t2 => Newtype t4 t5 => (t2 -> t1) -> (t0 t1 -> t3 t4) -> t0 t2 -> t3 t5
    to argument Focusing
  while inferring the type of underF Focusing
  in value declaration zoom

  where s6 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        r8 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        m7 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        t0 is an unknown type
        t3 is an unknown type
        t1 is an unknown type
        t2 is an unknown type
        t4 is an unknown type
        t5 is an unknown type

I suspect this happens because the functional dependency computing s -> Focusing m r s from Star (Focusing m r) s s in under Star p doesn’t propagate its result, so the compiler cannot solve the Coercible constraints implied by the Newtype constraints in underF Focusing (under Star p).

Without the type annotation Data.Lens.Zoom.zoom yields the following error:

```
[1/1 NoInstanceFound] src/Data/Lens/Zoom.purs:22:21

  22  zoom p = StateT <<< underF Focusing (under Star p) <<< runStateT
                          ^^^^^^^^^^^^^^^

  No type class instance was found for

    Prim.Coerce.Coercible t4
                          (m7 (Tuple r8 s6))

  The instance head contains unknown type variables. Consider adding a type annotation.

  while solving type class constraint

    Prim.Coerce.Coercible (s6 -> t4)
                          (s6 -> m7 (Tuple r8 s6))

  while applying a function underF
    of type Coercible @type (t0 t1) (t0 t2) => Coercible @type (t3 t4) (t3 t5) => Newtype t1 t2 => Newtype t4 t5 => (t2 -> t1) -> (t0 t1 -> t3 t4) -> t0 t2 -> t3 t5
    to argument Focusing
  while inferring the type of underF Focusing
  in value declaration zoom

  where s6 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        r8 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        m7 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        t0 is an unknown type
        t3 is an unknown type
        t1 is an unknown type
        t2 is an unknown type
        t4 is an unknown type
        t5 is an unknown type
```

I suspect this happens because the functional dependency computing `s -> Focusing m r s` from `Star (Focusing m r) s s` in `under Star p` doesn’t propagate its result, so the compiler cannot solve the Coercible constraints implied by the Newtype constraints in `underF Focusing (under Star p)`.
@kl0tl
Copy link
Contributor Author

kl0tl commented Dec 28, 2020

The build fails because newtype doesn’t depend on safe-coerce in the package set but it compiles with the rc5 branch of my fork:

let upstream =
      https://raw.githubusercontent.com/kl0tl/package-sets/rc5/src/packages.dhall 

in  upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants