On Sun, Feb 28, 2016 at 4:00 PM, Kristoffer Føllesdal <kfollesdal@gmail.com> wrote:
What I want is to have the «same» function for these cases: 

operation :: a -> a -> Vect k a
operation :: a -> Vect k a -> Vect k a
operation :: Vect k a -> a -> Vect k a
operation :: Vect k a -> Vect k a -> Vect k a

You might be able to write it in terms of a function that can take either of these signatures

ensureVect :: a -> Vect k a
ensureVect :: Vect k a -> Vect k a

-- then you can write
operation x y = ensureVect x `opA` ensureVect y

I have something close to that here <https://gist.github.com/aavogt/3b295008fbcde2ea88dd>, except it uses Maybe. The example wouldn't work with (+) and numeric literals [there could be an instance Num a => Num (Maybe a), after all], and I think it's likely that the code you want to write will run into the same problem.

Regards,
Adam