Giter Club home page Giter Club logo

Comments (3)

notcome avatar notcome commented on June 18, 2024

I faced the same bug and had to derive all those things by hand. Have you found any better workarounds?

By the way, it seems that there has been no maintainer for one year...

from acid-state.

stepcut avatar stepcut commented on June 18, 2024

With acid-state 0.9.x and GHC 7.10.3 this example still fails, though with a different error:

[1 of 1] Compiling Test             ( /tmp/G.hs, interpreted )

/tmp/G.hs:28:1:
    Couldn't match type ‘IxSetStore κ’ with ‘IxSet (Entry κ)’
    arising from trying to show that the representations of
      ‘safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind
         (IxSet (Entry κ))’ and
      ‘safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind
         (IxSetStore κ)’ are the same
    Relevant role signatures:
      type role safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind nominal
      type role IxSet nominal
      type role Entry representational
      type role IxSetStore nominal
    Relevant bindings include
      kind :: safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind (IxSetStore κ)
        (bound at /tmp/G.hs:28:1)
    In the expression:
        GHC.Prim.coerce
          (kind ::
             safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind (IxSet (Entry κ))) ::
          safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind (IxSetStore κ)
    In an equation for ‘kind’:
        kind
          = GHC.Prim.coerce
              (kind ::
                 safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind (IxSet (Entry κ))) ::
              safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.Kind (IxSetStore κ)
    When typechecking the code for  ‘kind’
      in a derived instance for ‘SafeCopy (IxSetStore κ)’:
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for ‘SafeCopy (IxSetStore κ)’
Failed, modules loaded: none.
Prelude> 

using deriving to create SafeCopy instances for newtypes is known to have some issues. Attempting to use deriveSafeCopy results in:

[1 of 1] Compiling Test             ( /tmp/G.hs, interpreted )

/tmp/G.hs:29:1:
    Could not deduce (Ord κ)
      arising from a use of ‘safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafeGet’
    from the context (SafeCopy κ)
      bound by the instance declaration at /tmp/G.hs:29:1-35
    Possible fix:
      add (Ord κ) to the context of the instance declaration
    In a stmt of a 'do' block:
      safeGet_IxSetEntryκ_aeaB <- safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafeGet
    In the second argument of ‘Data.Serialize.Get.label’, namely
      ‘do { safeGet_IxSetEntryκ_aeaB <- safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafeGet;
            ((return IxSetStore) <*> safeGet_IxSetEntryκ_aeaB) }’
    In the first argument of ‘safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.contain’, namely
      ‘Data.Serialize.Get.label
         "Test.IxSetStore:"
         (do { safeGet_IxSetEntryκ_aeaB <- safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafeGet;
               ((return IxSetStore) <*> safeGet_IxSetEntryκ_aeaB) })’

/tmp/G.hs:29:1:
    Could not deduce (Ord κ)
      arising from a use of ‘safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafePut’
    from the context (SafeCopy κ)
      bound by the instance declaration at /tmp/G.hs:29:1-35
    Possible fix:
      add (Ord κ) to the context of the instance declaration
    In a stmt of a 'do' block:
      safePut_IxSetEntryκ_aeaA <- safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafePut
    In the first argument of ‘safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.contain’, namely
      ‘do { safePut_IxSetEntryκ_aeaA <- safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafePut;
            safePut_IxSetEntryκ_aeaA arg_aeaz;
            return () }’
    In the expression:
      safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.contain
        (do { safePut_IxSetEntryκ_aeaA <- safecopy-0.9.0.1:Data.SafeCopy.SafeCopy.getSafePut;
              safePut_IxSetEntryκ_aeaA arg_aeaz;
              return () })
Failed, modules loaded: none.
Prelude> 

from acid-state.

adamgundry avatar adamgundry commented on June 18, 2024

In GHC 8.4.2 and acid-state master this fails with

    • Couldn't match type ‘IxSet (Entry κ)’ with ‘IxSetStore κ’
        arising from a use of ‘GHC.Prim.coerce’
    • In the expression:
        GHC.Prim.coerce
          @(safecopy-0.9.4.1:Data.SafeCopy.SafeCopy.Kind (IxSet (Entry κ)))
          @(safecopy-0.9.4.1:Data.SafeCopy.SafeCopy.Kind (IxSetStore κ))
          kind
      In an equation for ‘kind’:
          kind
            = GHC.Prim.coerce
                @(safecopy-0.9.4.1:Data.SafeCopy.SafeCopy.Kind (IxSet (Entry κ)))
                @(safecopy-0.9.4.1:Data.SafeCopy.SafeCopy.Kind (IxSetStore κ))
                kind
      When typechecking the code for ‘kind’
        in a derived instance for ‘SafeCopy (IxSetStore κ)’:
        To see the code I am typechecking, use -ddump-deriv
      In the instance declaration for ‘SafeCopy (IxSetStore κ)’
    • Relevant bindings include
        kind :: safecopy-0.9.4.1:Data.SafeCopy.SafeCopy.Kind (IxSetStore κ)
          (bound at ParameterisedState.hs:29:1)
   |
29 | deriving instance (SafeCopy κ, Typeable κ, Ord κ) ⇒ SafeCopy (IxSetStore κ)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

which seems correct as this line of code is simply incompatible with roles-based GeneralizedNewtypeDeriving; see acid-state/safecopy#12. There may well still be issues with parameterised types and safecopy (see also acid-state/safecopy#29) but AFAICS it is now possible to use acid-state with parameterised state types, so I'm closing this.

from acid-state.

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.