I have experience with type classes in Haskell, interfaces in Idris, and the typeclass pattern in Scala; but I have not figured out how to use Agda's encoding of typeclasses or the typeclasses provided in the standard library. (I am aware that there are not language entities called "typeclasses" in Agda but a variety of other features that combine to allow an encoding of type classes, similar to Scala.)
I have a program in which I want to use Applicative
operators; say, for Maybe
. I get an obscure type error when I try to do so; this is a MWE:
module Example where
open import Data.Bool
open import Category.Applicative using (RawApplicative)
open RawApplicative using (pure; _⊗_)
open import Data.Maybe.Categorical using (applicative)
open import Data.Maybe using (Maybe; nothing; just)
instance
maybeApplicative = applicative
example : Maybe Bool
example = (nothing ⊗ just false) ⊗ just true
The type error I get is:
Maybe _A_9 !=< Category.Applicative.Indexed.RawIApplicative (λ _ _ → _F_7) when checking that the expression nothing has type RawApplicative _F_7
How do I make use of functions/mixfix operators from typeclasses in Agda?