Why doesn't GHCi allow type arguments for this version of join?

Viewed 307

I've tried toying around with TypeApplications, and used the following:

 join = (>>= id)
 :t join
join :: Monad m => m (m a) -> m a
 :t join @[]

But I get the following error:

<interactive>:1:1: error:
    * Cannot apply expression of type `m0 (m0 b0) -> m0 b0'
      to a visible type argument `[]'
    * In the expression: join @[]

This, in my view, should work, as

 :t fmap @[]
fmap @[] :: (a -> b) -> [a] -> [b]

works.

1 Answers

Type applications only work for definitions that have explicit type signatures.

>>> join :: (Monad m) => m (m a) -> m a; join = (>>= id)
>>> :t join @[]
join @[] :: [[a]] -> [a]

All the gory details (and there are quite a few) of this extension are in the paper Visible Type Application.

Related