0

Why do we write f : Type -> Type instead of just f below - is it not inferred from Functor f?:

interface Functor f => Applicative (f : Type -> Type) where
    pure  : a -> f a
    (<*>) : f (a -> b) -> f a -> f b

f has already had its kind (or should I just say Type in Idris) defined in:

interface Functor (f : Type -> Type) where
    map : (m : a -> b) -> f a -> f b

I have heard that there are many situations that Idris cannot infer types where Haskell would due to Idris's dependent type system. Is this one such situation?

A related question, Failed to declare MonadPlus interface constrained on Monad, describes the same behavior, but doesn't really address why the type can't be inferred.

bbarker
  • 11,636
  • 9
  • 38
  • 62
  • 1
    i believe this is [also the case in idris 1](https://stackoverflow.com/q/63206752/5986907) – joel Oct 02 '20 at 22:49
  • Does this answer your question? [Failed to declare MonadPlus interface constrained on Monad](https://stackoverflow.com/questions/63206752/failed-to-declare-monadplus-interface-constrained-on-monad) – Sjoerd Visscher Oct 03 '20 at 10:53
  • @SjoerdVisscher it's possible the OP wants to know _why_ this is the case, and why it doesn't default to `Type` only when there's no other information – joel Oct 03 '20 at 14:13
  • That is the same behavior, but it would be good to know why it's the case, and if it is something that might be changed later (vs being a fundamental constraint of the type system). – bbarker Oct 03 '20 at 15:26
  • To reiterate, I'm curious about why the type is not inferred - the linked answer, while informative, doesn't seem to speak to this. – bbarker Oct 05 '20 at 20:20

0 Answers0