Code Monkey home page Code Monkey logo

djinn's People

Contributors

augustss avatar bhrgunatha avatar joom avatar misterbeebee avatar nadiayvette avatar prophile avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

djinn's Issues

Example or README?

It would be nice if this repo included a README with a couple of examples how to use djinn.

Error: Undefined type Int

Tried to reproduce this code from help:

Djinn> foo :: Int -> Char
Djinn> bar :: Char -> Bool
Djinn> f ? Int -> Bool

but got this error:

Djinn> foo :: Int -> Char
Error: Undefined type Int

I've added new data types before executing the code from help:

Djinn> data Int
Djinn> data Char

but then got the result:

f :: Int -> Bool
f = void

not this result:

f :: Int -> Bool
f a = bar (foo a)

any ideas, how to fix it?

Failure to derive Applicative-based type

applyPure :: f (t1 -> t2) -> t1 -> f t2
-- applyPure cannot be realized.
applyPure :: Applicative f => f (t1 -> t2) -> t1 -> f t2
Error: Class not found: Applicative

It seems that Djinn does not support directly referencing the Applicative class (as well as other classes & types from Prelude) out-of-the box; instead, the class’s methods must be specified from scratch. Upon doing so for Applicative, the following correct result is produced:

applyPure :: (Applicative f) => f (t1 -> t2) -> t1 -> f t2
applyPure a b = a <*> pure b
-- or
applyPure a b = pure b *> (a <*> pure b)

Is there a possible way to import the Applicative class, or other relevant type definitions, rather than specifying them from scratch? I’m sure I must be missing something if I have to paste all of the following into Djinn in order to proceed:

class Applicative f where pure :: a -> f a; (<*>) :: f (a -> b) -> f a -> f b; liftA2 :: (a -> b -> c) -> f a -> f b -> f c; (*>) :: f a -> f b -> f b; (<*) :: f a -> f b -> f a; fmap :: (a -> b) -> f a -> f b; (<$) :: a -> f b -> f a; ($>) :: f a -> b -> f b; (<$>) :: (a -> b) -> f a -> f b; (<&>) :: f a -> (a -> b) -> f b; void :: f a -> f ()

Wrong function code generation

It seems, Djinn generates wrong function expression:

Djinn> data Int
Djinn> data Char
Djinn> data Float
Djinn> foo :: Int->Char
Djinn> bar :: Char->Float
Djinn> f ? Int->Float
f :: Int -> Float
f = foo

hackage info wrong

The url for the issue tracker has /haskell/ in the middle. I've never published a haskell package (yet), so I don't know if that's from your metadata or a bug in the whole system (seems doubtful). Throwing it your way so you can get eyeballs on it.

Error when trying to derive `Arrow (Kleisli m)`

Hello,

today I played around with Djinn a bit, and noticed what I am pretty sure is a bug:
I added a definition for an Arrow typeclass, and the Kleisli wrapper for a Monad.
Then, I tried to derive an instance Arrow (Kleisli m).

Input:

Djinn> class Arrow arr where id :: arr a a; (.) :: arr b c -> arr a b -> arr a c; toArr :: (b -> c) -> arr b c; first :: arr b c -> arr (b, d) (c, d)
Djinn> data Kleisli m a b = MkKleisli (a -> m b)
Djinn> ?instance Arrow (Kleisli m)

Expected result: an instance Arrow (Kleisli m) or a message that this is not possible.
Actual result: an error:

Djinn> ?instance Arrow (Kleisli m)
instance Arrow (Kleisli m) where
djinn: IntMap.!: key 3 is not an element of the map
CallStack (from HasCallStack):
error, called at libraries/containers/Data/IntMap/Internal.hs:569:17 in containers-0.5.10.2:Data.IntMap.Internal

I'll try to shrink the example, but so far this is all I have.

Best regards,
David Kofler

Failure to compile

Cabal-3.6.2.0, Stack-2.7.5, GHC 9.2.3, 9.0.2, 8.10.7, 8.8.4, 8.6.5.

djinn fails to compile with either Cabal (all of the above GHC versions produced same output) or Stack (using GHC-9.0.2, resolver LTS-19.18).

With Cabal:

$ cabal install djinn
Resolving dependencies...
Build profile: -w ghc-9.2.3 -O1
In order, the following will be built (use -v for more details):
 - djinn-2014.9.7 (exe:djinn) (requires download & build)
Downloading  djinn-2014.9.7
Downloaded   djinn-2014.9.7
Starting     djinn-2014.9.7 (exe:djinn)
Building     djinn-2014.9.7 (exe:djinn)

Failed to build exe:djinn from djinn-2014.9.7.
Build log ( /Users/ur20980/.cabal/logs/ghc-9.2.3/djnn-2014.9.7-f8fe2bcb.log ):
Configuring executable 'djinn' for djinn-2014.9.7..
Preprocessing executable 'djinn' for djinn-2014.9.7..
Building executable 'djinn' for djinn-2014.9.7..
[1 of 7] Compiling Help             ( src/Help.hs, dist/build/djinn/djinn-tmp/Help.dyn_o )
[2 of 7] Compiling LJTFormula       ( src/LJTFormula.hs, dist/build/djinn/djinn-tmp/LJTFormula.dyn_o )
[3 of 7] Compiling LJT              ( src/LJT.hs, dist/build/djinn/djinn-tmp/LJT.dyn_o )

src/LJT.hs:143:5: warning: [-Wnoncanonical-monad-instances]
    Noncanonical ‘pure = return’ definition detected
    in the instance declaration for ‘Applicative P’.
    Move definition from ‘return’ to ‘pure’
    See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
    |
143 |     pure = return
    |     ^^^^^^^^^^^^^

src/LJT.hs:147:5: warning: [-Wnoncanonical-monad-instances]
    Noncanonical ‘return’ definition detected
    in the instance declaration for ‘Monad P’.
    ‘return’ will eventually be removed in favour of ‘pure’
    Either remove definition for ‘return’ (recommended) or define as ‘return = pure’
    See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
    |
147 |     return x = P $ \ s -> [(s, x)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[4 of 7] Compiling HTypes           ( src/HTypes.hs, dist/build/djinn/djinn-tmp/HTypes.dyn_o )

src/HTypes.hs:221:29: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at src/HTypes.hs:6:8-13
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.HughesPJ.<>’,
              imported from ‘Text.PrettyPrint.HughesPJ’ at src/HTypes.hs:10:65-68
    |
221 | ppPat _ (HPAt s p) = text s <> text "@" <> ppPat 10 p
    |                             ^^

src/HTypes.hs:221:41: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at src/HTypes.hs:6:8-13
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.HughesPJ.<>’,
              imported from ‘Text.PrettyPrint.HughesPJ’ at src/HTypes.hs:10:65-68
    |
221 | ppPat _ (HPAt s p) = text s <> text "@" <> ppPat 10 p
    |                                         ^^
cabal: Failed to build exe:djinn from djinn-2014.9.7. See the build log above
for details.


Cabal build log: djnn-2014.9.7-f8fe2bcb.log

With Stack:

$ stack install djinn
djinn> configure
djinn> Configuring djinn-2014.9.7...
djinn> build
djinn> Preprocessing executable 'djinn' for djinn-2014.9.7..
djinn> Building executable 'djinn' for djinn-2014.9.7..
djinn> [1 of 7] Compiling Help             ( src/Help.hs, .stack-work/dist/x86_64-osx/Cabal-3.4.1.0/build/djinn/djinn-tmp/Help.o )
djinn> [2 of 7] Compiling LJTFormula       ( src/LJTFormula.hs, .stack-work/dist/x86_64-osx/Cabal-3.4.1.0/build/djinn/djinn-tmp/LJTFormula.o )
djinn> [3 of 7] Compiling LJT              ( src/LJT.hs, .stack-work/dist/x86_64-osx/Cabal-3.4.1.0/build/djinn/djinn-tmp/LJT.o )
djinn> 
djinn> /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack-6389f1b1243c3411/djinn-2014.9.7/src/LJT.hs:23:28: warning: [-Wunused-imports]
djinn>     The import of ‘Applicative’
djinn>     from module ‘Control.Applicative’ is redundant
djinn>    |
djinn> 23 | import Control.Applicative(Applicative(..), Alternative(empty, (<|>)))
djinn>    |                            ^^^^^^^^^^^^^^^
djinn> [4 of 7] Compiling HTypes           ( src/HTypes.hs, .stack-work/dist/x86_64-osx/Cabal-3.4.1.0/build/djinn/djinn-tmp/HTypes.o )
djinn> 
djinn> /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack-6389f1b1243c3411/djinn-2014.9.7/src/HTypes.hs:221:29: error:
djinn>     Ambiguous occurrence ‘<>’
djinn>     It could refer to
djinn>        either ‘Prelude.<>’,
djinn>               imported from ‘Prelude’ at src/HTypes.hs:6:8-13
djinn>               (and originally defined in ‘GHC.Base’)
djinn>            or ‘Text.PrettyPrint.HughesPJ.<>’,
djinn>               imported from ‘Text.PrettyPrint.HughesPJ’ at src/HTypes.hs:10:65-68
djinn>     |
djinn> 221 | ppPat _ (HPAt s p) = text s <> text "@" <> ppPat 10 p
djinn>     |                             ^^
djinn> 
djinn> /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack-6389f1b1243c3411/djinn-2014.9.7/src/HTypes.hs:221:41: error:
djinn>     Ambiguous occurrence ‘<>’
djinn>     It could refer to
djinn>        either ‘Prelude.<>’,
djinn>               imported from ‘Prelude’ at src/HTypes.hs:6:8-13
djinn>               (and originally defined in ‘GHC.Base’)
djinn>            or ‘Text.PrettyPrint.HughesPJ.<>’,
djinn>               imported from ‘Text.PrettyPrint.HughesPJ’ at src/HTypes.hs:10:65-68
djinn>     |
djinn> 221 | ppPat _ (HPAt s p) = text s <> text "@" <> ppPat 10 p
djinn>     |                                         ^^

--  While building package djinn-2014.9.7 (scroll up to its section to see the error) using:
      /Users/ur20980/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.4.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

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.