Giter VIP home page Giter VIP logo

dependent-sum-template's People

Contributors

ali-abrar avatar ericson2314 avatar mokus0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dependent-sum-template's Issues

"No instance for (Applicative (GComparing a b))" on GHC 7.10.1

# cabal install
Resolving dependencies...
Configuring dependent-sum-template-0.0.0.2...
Building dependent-sum-template-0.0.0.2...
Preprocessing library dependent-sum-template-0.0.0.2...
[1 of 2] Compiling Data.GADT.Show.TH ( src/Data/GADT/Show/TH.hs, dist/build/Data/GADT/Show/TH.o )
[2 of 2] Compiling Data.GADT.Compare.TH ( src/Data/GADT/Compare/TH.hs, dist/build/Data/GADT/Compare/TH.o )

src/Data/GADT/Compare/TH.hs:92:10:
    No instance for (Applicative (GComparing a b))
      arising from the superclasses of an instance declaration
    In the instance declaration for ‘Monad (GComparing a b)’
Failed to install dependent-sum-template-0.0.0.2
cabal: Error: some packages failed to install:
dependent-sum-template-0.0.0.2 failed during the building phase. The exception
was:
ExitFailure 1

Upload to hackage

dependent-sum-template must be uploaded to Hackage, since lambdabot now depends on it.

Polymorphic value support?

Here I've asked a question initially about polymorphism with dependent-maps.

And we've found that the following definitions can work.

data Foo1 a where
  AnInt :: Foo1 Int
  AString :: Foo1 String
  ANum :: (Num n, Typeable n, Show n) => Foo1 n
data Foo2 n a where
  AnInt :: Foo2 n Int
  AString :: Foo2 n String
  ANum :: (Num n, Typeable n, Show n) => Foo2 n

If one defines instances by hand, e.g.:

instance GEq (Foo2 n) where
  geq AnInt AnInt = return Refl
  geq AString AString = return Refl
  geq ANum ANum = return Refl
  geq _ _ = Nothing

instance GCompare (Foo2 n) where
  gcompare AnInt AnInt = GEQ
  gcompare AnInt _ = GLT
  gcompare _ AnInt = GGT
  gcompare AString AString = GEQ
  gcompare AString _ = GLT
  gcompare _ AString = GGT
  gcompare (ANum :: Foo2 n a) (ANum :: Foo2 n b) = (eqT @a @b) & \case
    Just (Refl :: a :~: b) -> GEQ
    Nothing   -> error "This shouldn't happen"
  gcompare ANum _ = GLT
  gcompare _ ANum = GGT

But I wonder, doesn't/couldn't deriveGEq, deriveGCompare support deriving these kinds of instances somehow? Because hand-defining these doesn't scale much. E.g.

deriveGEq      ''Foo2
deriveGCompare ''Foo2
deriveGEq      ''(Foo2 n)
deriveGCompare ''(Foo2 n)

These give me the following kinds of errors, respectively:

exp-dep-map.hs:39:1: error:
     Expecting one more argument to Foo2
      Expected kind ‘* -> *’, but Foo2 has kind ‘* -> * -> *’
     In the first argument of GEq, namely Foo2
      In the instance declaration for GEq Foo2
   |
39 | deriveGEq      ''Foo
   | ^^^^^^^^^^^^^^^^^^^^
exp-dep-map.hs:40:19: error: parse error on input Foo2
   |
40 | deriveGEq      ''(Foo2 n)
   |                   ^^^

Also, is #6 relevant? PolyKinds makes me think that it may be, as one of the type errors is a kind-error.

cc obsidiansystems/dependent-map#16, because it would be nice to see a small self-contained example in the readme/docs if/when pol'ism is supported.

p.s. If it turns out that this is hard to solve with TH, maybe instances can be derived via generics too?

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.