
I'm trying to use Decimal but (I'm guessing) I don't know how to import it. import Data.Decimal dList :: [Decimal] dList = [1.1,1.2..2.0] : <interactive>:70:11-17: error: : Not in scope: type constructor or class `Decimal' Obviously I was asleep the day the teacher told us how to do this. . . . LB

Il 17 febbraio 2021 alle 11:13 Galaxy Being ha scritto:
I'm trying to use Decimal but (I'm guessing) I don't know how to import it.
import Data.Decimal
dList :: [Decimal] dList = [1.1,1.2..2.0]
: <interactive>:70:11-17: error: : Not in scope: type constructor or class `Decimal'
Works here. You need to add `Decimal` the dependencies of your project or install it globally first —F

How would I install it globally? I'm not using projects, I'm just at the
ghci REPL.
On Wed, Feb 17, 2021 at 12:57 PM Francesco Ariis
Il 17 febbraio 2021 alle 11:13 Galaxy Being ha scritto:
I'm trying to use Decimal but (I'm guessing) I don't know how to import it.
import Data.Decimal
dList :: [Decimal] dList = [1.1,1.2..2.0]
: <interactive>:70:11-17: error: : Not in scope: type constructor or class `Decimal'
Works here. You need to add `Decimal` the dependencies of your project or install it globally first —F _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

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
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

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
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
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

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
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
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
wrote: How would I install it globally? I'm not using projects, I'm just at
Il 17 febbraio 2021 alle 14:17 Galaxy Being ha scritto: 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

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
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
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
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
wrote: How would I install it globally? I'm not using projects, I'm just at
Il 17 febbraio 2021 alle 14:17 Galaxy Being ha scritto: 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

On Wed, Feb 17, 2021 at 02:17:32PM -0600, Galaxy Being wrote:
How would I install it globally? I'm not using projects, I'm just at the ghci REPL.
Even for such small tests it's simpler to just use a cabal project: mkdir decimal-test cd decimal-test cabal init -p decimal-test -d base -d Decimal cabal repl If you need further dependencies you can then extend the 'build-depends' list in the file 'decimal-test.cabal'. Greetings, Daniel

Is it possible you mean to use Double or Float instead of Decimal? Tom On Wed, Feb 17, 2021 at 11:13:19AM -0600, Galaxy Being wrote:
I'm trying to use Decimal but (I'm guessing) I don't know how to import it.
import Data.Decimal
dList :: [Decimal] dList = [1.1,1.2..2.0]
: <interactive>:70:11-17: error: : Not in scope: type constructor or class `Decimal'
Obviously I was asleep the day the teacher told us how to do this. . . .
LB
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (5)
-
amindfv@mailbox.org
-
Bob Ippolito
-
Daniel Trstenjak
-
Francesco Ariis
-
Galaxy Being