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

Failure to derive Applicative-based type #7

Open
ron-wolf opened this issue Aug 2, 2018 · 2 comments
Open

Failure to derive Applicative-based type #7

ron-wolf opened this issue Aug 2, 2018 · 2 comments

Comments

@ron-wolf
Copy link

ron-wolf commented Aug 2, 2018

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 ()
@midirhee12
Copy link

I had a similar scenario with the following:

f ? (Num a, Num ((a -> Maybe b) -> Maybe b)) =>
     Maybe ((a -> Maybe b) -> Maybe b)

with the following error:
Error: Class not found: Num

I then tried a simple example:

foo ? Num a => a -> a -> a

And still the same error appears.

@jwaldmann
Copy link

jwaldmann commented Jan 17, 2022

Even if we could import these definitions, they would not work?

$ djinn 
Welcome to Djinn version 2011-07-23.
Type :h to get help.
Djinn> :verboseHelp
...
there is no instantiation of polymorphic functions, 
so classes where the methods are polymorphic do not work as expected.
...

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

No branches or pull requests

3 participants