<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>You could hide Prelude and define it yourself in a different
module but that would be a pretty bad idea. Everyone who wanted
to use it would have to import your module qualified and refer to
it as MyModule.+, which defeats the point of making it (+) and not
`myAdditionFunction` in the first place.</p>
<p>Haskell deliberately doesn't allow overloading. Having (+)
return something other than Num would be extremely confusing.<br>
</p>
<br>
<div class="moz-cite-prefix">On 10/07/2017 05:07 AM, PATRICK BROWNE
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAGFLrKe17aTQURpquyGH1czZz5RWNwpo1Wy4H7fQYe2he_04aA@mail.gmail.com">
<div dir="ltr">
<div>Hi,</div>
Is there a way rewriting the definition of (+) so that
testPlusArg returns a (Moving Double). My current intuition is
that the signature [(+) :: a -> a -> a] says that the
type should be the same as the arguments. And indeed (:t
testPlus) confirms this. But the type of testPlusArg is a
Double.
<div> Can I make it (Moving Double) ?
<div>Thanks,</div>
<div>Pat<br>
<div>
<div><br>
<div>
<div>{-# LANGUAGE FlexibleInstances #-}</div>
<div>{-# LANGUAGE TypeSynonymInstances #-}</div>
<div>module Moving where</div>
<div>data Time = Time Double</div>
<div>type Moving v = Time -> v</div>
<div><br>
</div>
<div>class Number a where</div>
<div> (+) :: a -> a -> a</div>
<div><br>
</div>
<div>instance Number (Moving Double) where</div>
<div> (+) a b = \t -> ((a t) Prelude.+ (b t))</div>
<div><br>
</div>
<div>a,b :: Moving Double</div>
<div>a (Time x) = 2.0</div>
<div>b (Time x) = 2.0</div>
<div>testPlus ::(Moving Double)</div>
<div>testPlus = (a Moving.+ b)</div>
<div>testPlusArg = (a Moving.+ b) (Time 2.0)</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<p><span lang="EN-GB"><font size="2">This email originated from
DIT. If you received this email in error, please delete it
from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any
action based on the contents of this email or attachments is
prohibited. <a href="http://www.dit.ie/" target="_blank"
moz-do-not-send="true">www.dit.ie</a></font></span></p>
<p><font size="2">Is ó ITBÁC
a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí
earráid, scrios
de do chóras é le do thoil. Tabhair ar aird, mura tú an seolaí
ainmnithe, go
bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon dáileadh
nó ar aon ghníomh
a dhéanfar bunaithe ar an ábhar atá sa ríomhphost nó sna
hiatáin seo. <a href="http://www.dit.ie/" target="_blank"
moz-do-not-send="true">www.dit.ie</a></font></p>
<p><a href="http://www.dit.ie/grangegorman" target="_blank"
moz-do-not-send="true"><font size="2">Tá ITBÁC ag aistriú go
Gráinseach Ghormáin – DIT is on the move to Grangegorman</font></a></p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>