<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Feb 28, 2016 at 4:00 PM, Kristoffer Føllesdal <span dir="ltr"><<a href="mailto:kfollesdal@gmail.com" target="_blank">kfollesdal@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><div>What I want is to have the «same» function for these cases: </div><div><br></div><div>operation :: a -> a -> Vect k a</div><div>operation :: a -> Vect k a -> Vect k a</div><div>operation :: Vect k a -> a -> Vect k a</div><div>operation :: Vect k a -> Vect k a -> Vect k a</div></div></div></blockquote><br>You might be able to write it in terms of a function that can take either of these signatures<br><div><br>ensureVect :: a -> Vect k a<br></div><div>ensureVect :: Vect k a -> Vect k a<br><br></div><div>-- then you can write<br></div><div>operation x y = ensureVect x `opA` ensureVect y<br><br>I have something close to that here <<a href="https://gist.github.com/aavogt/3b295008fbcde2ea88dd">https://gist.github.com/aavogt/3b295008fbcde2ea88dd</a>>, 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.<br><br></div><div>Regards,<br></div><div>Adam<br></div></div></div></div>