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. Re: Fractional of DiffTime (David McBride) 2. Re: Fractional of DiffTime (Baa) ---------------------------------------------------------------------- Message: 1 Date: Fri, 18 Aug 2017 08:34:29 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Fractional of DiffTime Message-ID: <CAN+Tr425W=1h5ghzsx+_8ftqojmkrmqn37n7rpautku266w...@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" DiffTimes need to be added and subtracted. Unfortunately to add or subtract anything you must implement the Num class. By doing that you now you either also support division and multiplication, or you throw a runtime error. This also comes up with vectors and matrices which don't follow the usual Num rules, and so must have their own operators in libraries to support their operations. It has been suggested in the past to separate all of the operations in the Num class into their constituent parts, say Addable, Subtractable, Multiplicative, Negatable, etc, but you can imagine the boilerplate of implementing all those classes for your own types, and also the hairy types that would be inferred by the compiler for very simple arithmetic functions. But if you are going to go that far, you might as well try to go all the way down into number theory. So there are alternative numeric preludes that attempt to deal with most of this stuff on hackage. For example numeric-prelude, although that library does not include DiffTime specifically, it likely has the classes necessary to make a reasonable go at it. On Fri, Aug 18, 2017 at 5:35 AM, Baa <aqua...@gmail.com> wrote: > Hello, List! > > DiffTime type has "closed" on itself operation "/". So, > > (/) :: DiffTime -> DiffTime -> DiffTime > > But from a physics point of view, it doesn't make sense. When you > divide hours by hours you get "dimensionless" value, not units > (hours) but simple number (I'm not sure how it's named in English). > > And it's true for any physical values: > > [m/s] : [m/s] = [Int] (not [m/s] sure) > > Is it right to define CLOSED "/" for such set like DiffTime? > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ Message: 2 Date: Fri, 18 Aug 2017 16:04:16 +0300 From: Baa <aqua...@gmail.com> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Fractional of DiffTime Message-ID: <20170818160416.7859455a@Pavel> Content-Type: text/plain; charset=US-ASCII Hello, David. Interesting... There is also library num-hask, but no DiffTime there. > It has been suggested in the past to separate all of the operations in > the Num class into their constituent parts, say Addable, Subtractable, > Multiplicative, Negatable, etc, but you can imagine the boilerplate of > implementing all those classes for your own types, and also the hairy > types that would be inferred by the compiler for very simple > arithmetic functions. But if you are going to go that far, you might > as well try to go all the way down into number theory. It makes sense. OK. Thank you! > > So there are alternative numeric preludes that attempt to deal with > most of this stuff on hackage. For example numeric-prelude, although > that library does not include DiffTime specifically, it likely has the > classes necessary to make a reasonable go at it. > > On Fri, Aug 18, 2017 at 5:35 AM, Baa <aqua...@gmail.com> wrote: > > Hello, List! > > > > DiffTime type has "closed" on itself operation "/". So, > > > > (/) :: DiffTime -> DiffTime -> DiffTime > > > > But from a physics point of view, it doesn't make sense. When you > > divide hours by hours you get "dimensionless" value, not units > > (hours) but simple number (I'm not sure how it's named in English). > > > > And it's true for any physical values: > > > > [m/s] : [m/s] = [Int] (not [m/s] sure) > > > > Is it right to define CLOSED "/" for such set like DiffTime? > > > > === > > Best regards, Paul > > _______________________________________________ > > Beginners mailing list > > Beginners@haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 110, Issue 19 ******************************************