Skip to content

Failure to derive Applicative-based type #7

@ron-wolf

Description

@ron-wolf
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 ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions