Constraint solver loop? - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Asad Saeeduddin

I was screwing around with some stuff and I think I ended up putting the constraint solver into a loop:

module Whatever where

import Data.Profunctor

class (forall p. Profunctor p => thing (t p)) => Free thing t
  where
  fwd :: (Profunctor p, thing q) => (p :-> q) -> t p :-> q
  bwd :: (Profunctor p, thing q) => (t p :-> q) -> p :-> q

data TheFree thing p a b = TheFree { runFree :: forall q. thing q => (p :-> q) -> q a b }

instance (forall q. thing q => Profunctor q, Profunctor p) => Profunctor (TheFree thing p)
  where
  dimap f g (TheFree x) = TheFree $ \cb -> dimap f g $ x cb
[typecheck] [E] /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10: error:
    • Could not deduce: thing (TheFree thing p)
        arising from a use of ‘Data.Profunctor.Unsafe.$dm#.’
      from the context: (forall (q :: * -> * -> *).
                         thing q =>
                         Profunctor q,
                         Profunctor p)
        bound by the instance declaration
        at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10-90
      or from: Coercible c b
        bound by the type signature for:
                   (Data.Profunctor.Unsafe.#.) :: forall a b c (q :: * -> * -> *).
                                                  Coercible c b =>
                                                  q b c
                                                  -> TheFree thing p a b -> TheFree thing p a c
        at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10-90
    • In the expression:
        Data.Profunctor.Unsafe.$dm#. @(TheFree thing p)
      In an equation for ‘Data.Profunctor.Unsafe.#.’:
          (Data.Profunctor.Unsafe.#.)
            = Data.Profunctor.Unsafe.$dm#. @(TheFree thing p)
      In the instance declaration for ‘Profunctor (TheFree thing p)’
    • Relevant bindings include
        (#.) :: q b c -> TheFree thing p a b -> TheFree thing p a c
          (bound at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10)
——————————————————————————————————————————————————————————————————————————————
[typecheck] [E] /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10: error:
    • Could not deduce: thing (TheFree thing p)
        arising from a use of ‘Data.Profunctor.Unsafe.$dm.#’
      from the context: (forall (q :: * -> * -> *).
                         thing q =>
                         Profunctor q,
                         Profunctor p)
        bound by the instance declaration
        at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10-90
      or from: Coercible b a
        bound by the type signature for:
                   (Data.Profunctor.Unsafe..#) :: forall a b c (q :: * -> * -> *).
                                                  Coercible b a =>
                                                  TheFree thing p b c
                                                  -> q a b -> TheFree thing p a c
        at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10-90
    • In the expression:
        Data.Profunctor.Unsafe.$dm.# @(TheFree thing p)
      In an equation for ‘Data.Profunctor.Unsafe..#’:
          (Data.Profunctor.Unsafe..#)
            = Data.Profunctor.Unsafe.$dm.# @(TheFree thing p)
      In the instance declaration for ‘Profunctor (TheFree thing p)’
    • Relevant bindings include
        (.#) :: TheFree thing p b c -> q a b -> TheFree thing p a c
          (bound at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10)
——————————————————————————————————————————————————————————————————————————————
[typecheck] [E] /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10: error:
    • Could not deduce: thing (TheFree thing p)
        arising from a use of ‘Data.Profunctor.Unsafe.$dmlmap’
      from the context: (forall (q :: * -> * -> *).
                         thing q =>
                         Profunctor q,
                         Profunctor p)
        bound by the instance declaration
        at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10-90
    • In the expression:
        Data.Profunctor.Unsafe.$dmlmap @(TheFree thing p)
      In an equation for ‘lmap’:
          lmap = Data.Profunctor.Unsafe.$dmlmap @(TheFree thing p)
      In the instance declaration for ‘Profunctor (TheFree thing p)’
    • Relevant bindings include
        lmap :: (a -> b) -> TheFree thing p b c -> TheFree thing p a c
          (bound at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10)
——————————————————————————————————————————————————————————————————————————————
[typecheck] [E] /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10: error:
    • Could not deduce: thing (TheFree thing p)
        arising from a use of ‘Data.Profunctor.Unsafe.$dmrmap’
      from the context: (forall (q :: * -> * -> *).
                         thing q =>
                         Profunctor q,
                         Profunctor p)
        bound by the instance declaration
        at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10-90
    • In the expression:
        Data.Profunctor.Unsafe.$dmrmap @(TheFree thing p)
      In an equation for ‘rmap’:
          rmap = Data.Profunctor.Unsafe.$dmrmap @(TheFree thing p)
      In the instance declaration for ‘Profunctor (TheFree thing p)’
    • Relevant bindings include
        rmap :: (b -> c) -> TheFree thing p a b -> TheFree thing p a c
          (bound at /mnt/data/depot/git/haskell/repos/monoidal/test/Whatever.hs:12:10)

is that what's going on here?

TheMatten

These seem to be all coming from different method implementations

Asad Saeeduddin

durr, you're right. i didn't read it closely enough