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: import question (Bob Ippolito) 2. Re: import question (Galaxy Being) 3. Re: import question (Bob Ippolito) ---------------------------------------------------------------------- Message: 1 Date: Wed, 17 Feb 2021 18:36:45 -0800 From: Bob Ippolito <b...@redivi.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] import question Message-ID: <cacwmpm8j_dorfa__gilcpv+4swpqhsm4ucgvb8r6zxe22wt...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" You don't need to do any rounding if the list is already Decimal. If you wanted to format a Double with some specific decimal representation you could look at Numeric.showFFloatAlt or similar. import Data.Decimal dList :: [Decimal] dList = [1.00,1.01..2.00] main = print dList On Wed, Feb 17, 2021 at 5:27 PM Galaxy Being <borg...@gmail.com> wrote: > I'm trying to create a list of real numbers with a two-decimal interval, a > la > > > [1.0,1.01,1.02,...1.99,2.00] > > however, I get the float approximation problem > > > [1.0,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,1.09,1.1,1.11,1.12,1.1300000000000001,1.1400000000000001,... > > So I attempted to compensate with > > import Data.Decimal > map (roundTo 2) [1.00,1.01..2.0] > > I don't have to do it this way if there is another rounding function to > correct the float overrun issue. > > > > On Wed, Feb 17, 2021 at 2:43 PM Francesco Ariis <fa...@ariis.it> wrote: > >> Il 17 febbraio 2021 alle 14:17 Galaxy Being ha scritto: >> > How would I install it globally? I'm not using projects, I'm just at the >> > ghci REPL. >> >> Most likely >> >> cabal install --lib Decimal >> >> Check what Tom has said too —F >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210217/4ef41c7d/attachment-0001.html> ------------------------------ Message: 2 Date: Wed, 17 Feb 2021 21:42:02 -0600 From: Galaxy Being <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] import question Message-ID: <cafahfsutj1unk8h4a8ikezvcyxn7z7rsa1uzwbw99ki2svj...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" As I've said, working at the ghci REPL, import Data.Decimal dList :: [Decimal] dList = [1.00,1.01..2.00] main = print dList errors out : <interactive>:76:11-17: error: : Not in scope: type constructor or class `Decimal' On Wed, Feb 17, 2021 at 8:37 PM Bob Ippolito <b...@redivi.com> wrote: > You don't need to do any rounding if the list is already Decimal. > > If you wanted to format a Double with some specific decimal representation > you could look at Numeric.showFFloatAlt or similar. > > import Data.Decimal > > dList :: [Decimal] > dList = [1.00,1.01..2.00] > > main = print dList > > > > On Wed, Feb 17, 2021 at 5:27 PM Galaxy Being <borg...@gmail.com> wrote: > >> I'm trying to create a list of real numbers with a two-decimal interval, >> a la >> >> > [1.0,1.01,1.02,...1.99,2.00] >> >> however, I get the float approximation problem >> >> >> [1.0,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,1.09,1.1,1.11,1.12,1.1300000000000001,1.1400000000000001,... >> >> So I attempted to compensate with >> >> import Data.Decimal >> map (roundTo 2) [1.00,1.01..2.0] >> >> I don't have to do it this way if there is another rounding function to >> correct the float overrun issue. >> >> >> >> On Wed, Feb 17, 2021 at 2:43 PM Francesco Ariis <fa...@ariis.it> wrote: >> >>> Il 17 febbraio 2021 alle 14:17 Galaxy Being ha scritto: >>> > How would I install it globally? I'm not using projects, I'm just at >>> the >>> > ghci REPL. >>> >>> Most likely >>> >>> cabal install --lib Decimal >>> >>> Check what Tom has said too —F >>> _______________________________________________ >>> 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 >> > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210217/46e8da10/attachment-0001.html> ------------------------------ Message: 3 Date: Wed, 17 Feb 2021 20:29:22 -0800 From: Bob Ippolito <b...@redivi.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] import question Message-ID: <cacwmpm-sat9fn+-tqzxmdupnt+o+xejxyn_fynx3ufzhq1-...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Like others said, you'll need to install the Decimal package in order to use Data.Decimal. If you really wanted to do it with a floating point type and no dependencies you can use showFFloatAlt from Numeric to display with a specified precision. import Numeric import Text.Show main = putStrLn . showListWith (showFFloatAlt (Just 2)) [1.00, 1.01 .. 2.00] $ "" On Wed, Feb 17, 2021 at 7:42 PM Galaxy Being <borg...@gmail.com> wrote: > As I've said, working at the ghci REPL, > > import Data.Decimal > dList :: [Decimal] > dList = [1.00,1.01..2.00] > main = print dList > > errors out > > : <interactive>:76:11-17: error: > : Not in scope: type constructor or class `Decimal' > > > > On Wed, Feb 17, 2021 at 8:37 PM Bob Ippolito <b...@redivi.com> wrote: > >> You don't need to do any rounding if the list is already Decimal. >> >> If you wanted to format a Double with some specific decimal >> representation you could look at Numeric.showFFloatAlt or similar. >> >> import Data.Decimal >> >> dList :: [Decimal] >> dList = [1.00,1.01..2.00] >> >> main = print dList >> >> >> >> On Wed, Feb 17, 2021 at 5:27 PM Galaxy Being <borg...@gmail.com> wrote: >> >>> I'm trying to create a list of real numbers with a two-decimal interval, >>> a la >>> >>> > [1.0,1.01,1.02,...1.99,2.00] >>> >>> however, I get the float approximation problem >>> >>> >>> [1.0,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,1.09,1.1,1.11,1.12,1.1300000000000001,1.1400000000000001,... >>> >>> So I attempted to compensate with >>> >>> import Data.Decimal >>> map (roundTo 2) [1.00,1.01..2.0] >>> >>> I don't have to do it this way if there is another rounding function to >>> correct the float overrun issue. >>> >>> >>> >>> On Wed, Feb 17, 2021 at 2:43 PM Francesco Ariis <fa...@ariis.it> wrote: >>> >>>> Il 17 febbraio 2021 alle 14:17 Galaxy Being ha scritto: >>>> > How would I install it globally? I'm not using projects, I'm just at >>>> the >>>> > ghci REPL. >>>> >>>> Most likely >>>> >>>> cabal install --lib Decimal >>>> >>>> Check what Tom has said too —F >>>> _______________________________________________ >>>> 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 >>> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210217/b5bb428c/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 151, Issue 9 *****************************************