'Cannot import value abs from module Data.Number
The abs
method of the purescript-numbers
package is documented here:
https://pursuit.purescript.org/packages/purescript-numbers/9.0.0/docs/Data.Number#v:abs
However, consider this simple code example which implements this method:
import Data.Number (abs, toNumber, isFinite, sqrt)
j :: Number
j = abs -32.5
This produces the following error:
Cannot import value abs from module Data.Number
It either does not exist or the module does not export it.
- Is this a bug, or intended behavior?
- What is the correct way to import / use the abs method of the Data.Number library?
Solution 1:[1]
My suspicion is that you're probably using PureScript compiler v0.14.x and a corresponding package set 0.14.x, but at the same time are looking at the latest versions of the libraries on Pursuit.
Just about a week ago, the new version of PureScript compiler 0.15.0 came out, and with it came many breaking changes (most notably, ES-format foreign modules), and as is tradition in such cases, the community took the opportunity to do some refactoring while we're at it.
One instance of such refactoring was moving the abs
function (as well as many other functions) from the Math
module (in the math
library) to the Data.Number
module (in the numbers
library).
This means that if you're using PureScript 0.15 and higher, abs
is in Data.Number
, but if your version of PureScript is lower, the function is in the Math
module.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Fyodor Soikin |