Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Return type from class method (PATRICK BROWNE) ---------------------------------------------------------------------- Message: 1 Date: Sat, 7 Oct 2017 13:07:43 +0100 From: PATRICK BROWNE <patrick.bro...@dit.ie> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Return type from class method Message-ID: <cagflrke17atqurpquygh1czzz5rwnwpo1wy4h7fqye2he_0...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi, 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. Can I make it (Moving Double) ? Thanks, Pat {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances #-} module Moving where data Time = Time Double type Moving v = Time -> v class Number a where (+) :: a -> a -> a instance Number (Moving Double) where (+) a b = \t -> ((a t) Prelude.+ (b t)) a,b :: Moving Double a (Time x) = 2.0 b (Time x) = 2.0 testPlus ::(Moving Double) testPlus = (a Moving.+ b) testPlusArg = (a Moving.+ b) (Time 2.0) -- 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. www.dit.ie 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. www.dit.ie Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to Grangegorman <http://www.dit.ie/grangegorman> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20171007/e03d5933/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 112, Issue 9 *****************************************