Skip to content

Commit 764c4f4

Browse files
ad-sisharkdp
authored andcommitted
Fixes for PureScript 0.12
1 parent 814f38b commit 764c4f4

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

bower.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
"test"
1616
],
1717
"dependencies": {
18-
"purescript-strings": "^3.0.0",
19-
"purescript-arrays": "^4.0.1",
20-
"purescript-math": "^2.0.0",
21-
"purescript-unfoldable": "^3.0.0",
22-
"purescript-integers": "^3.0.0"
23-
}
24-
,
18+
"purescript-arrays": "^5.0.0",
19+
"purescript-effect": "^2.0.0",
20+
"purescript-integers": "^4.0.0",
21+
"purescript-math": "^2.1.1",
22+
"purescript-prelude": "^4.1.0",
23+
"purescript-strings": "^4.0.0",
24+
"purescript-unfoldable": "^4.0.0"
25+
},
2526
"devDependencies": {
26-
"purescript-test-unit": "^11.0.0"
27+
"purescript-test-unit": "^14.0.0"
2728
}
2829
}

src/Text/Format.purs

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ import Control.Alt ((<|>))
1818
import Data.Unfoldable (replicate)
1919
import Data.Int as Int
2020
import Data.Maybe (Maybe(..), fromMaybe)
21-
import Data.Monoid (class Monoid)
22-
import Data.String (length, fromCharArray, dropWhile, singleton, replace, Pattern(..), Replacement(..))
21+
import Data.String (length, dropWhile, replace, Pattern(..), Replacement(..))
22+
import Data.String.CodePoints (singleton, fromCodePointArray, codePointFromChar)
2323
import Math (round, pow, abs)
2424

2525
-- | Pad a string on the left up to a given maximum length. The padding
2626
-- | character can be specified.
2727
padLeft :: Char -> Int -> String -> String
2828
padLeft c len str = prefix <> str
29-
where prefix = fromCharArray (replicate (len - length str) c)
29+
where prefix = fromCodePointArray $
30+
map codePointFromChar (replicate (len - length str) c)
3031

3132
type PropertiesRecord =
3233
{ width :: Maybe Int
@@ -153,13 +154,13 @@ instance formatNumber :: Format Number where
153154
numAbsStr'' = show (abs num)
154155
numAbsStr' = case rec.decimalMark of
155156
Nothing -> numAbsStr''
156-
Just d -> replace (Pattern ".") (Replacement (singleton d)) numAbsStr''
157+
Just d -> replace (Pattern ".") (Replacement (singleton $ codePointFromChar d)) numAbsStr''
157158
numAbsStr = case rec.precision of
158159
Nothing -> numAbsStr'
159160
Just p -> numAbsStr' <> paddedZeros p
160-
usedDelimiter = fromMaybe '.' rec.decimalMark
161+
usedDelimiter = codePointFromChar $ fromMaybe '.' rec.decimalMark
161162
paddedZeros p = let d = length (dropWhile (_ /= usedDelimiter) numAbsStr') - 1
162-
in fromCharArray (replicate (p - d) '0')
163+
in fromCodePointArray $ map codePointFromChar (replicate (p - d) '0')
163164
numSgn = if nonNegative
164165
then (if isSigned then "+" else "")
165166
else "-"

test/Main.purs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
module Test.Main where
22

3-
import Prelude
4-
5-
import Data.Monoid (mempty)
3+
import Prelude (Unit, discard, mempty, negate, ($), (*), (<>), (==))
64
import Math (pi)
7-
5+
import Effect (Effect)
86
import Text.Format (width, signed, zeroFill, precision, decimalMark, format)
9-
10-
import Control.Monad.Eff (Eff)
11-
import Control.Monad.Eff.Console (CONSOLE)
12-
import Control.Monad.Aff.AVar (AVAR)
13-
147
import Test.Unit (test)
158
import Test.Unit.Main (runTest)
16-
import Test.Unit.Console (TESTOUTPUT)
179
import Test.Unit.Assert (assert, equal)
1810

19-
main :: Eff (console :: CONSOLE, testOutput :: TESTOUTPUT, avar :: AVAR) Unit
11+
12+
main :: Effect Unit
2013
main = runTest do
2114
test "Semigroup instance" do
2215
assert "right option should take precendence" $

0 commit comments

Comments
 (0)