File tree Expand file tree Collapse file tree 3 files changed +8
-20
lines changed
Expand file tree Collapse file tree 3 files changed +8
-20
lines changed Original file line number Diff line number Diff line change 1616 " output"
1717 ],
1818 "dependencies" : {
19- "purescript-math" : " ^2.0.0"
19+ "purescript-math" : " ^2.0.0" ,
20+ "purescript-globals" : " ^3.0.0"
2021 },
2122 "devDependencies" : {
2223 "purescript-console" : " ^3.0.0" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -16,13 +16,7 @@ import Prelude
1616
1717import Data.Maybe (Maybe (..))
1818import Math (abs )
19-
20-
21- foreign import fromStringImpl
22- :: (forall a . a -> Maybe a )
23- -> (forall a . Maybe a )
24- -> String
25- -> Maybe Number
19+ import Global (readFloat , isFinite )
2620
2721
2822-- | Attempt to parse a Number from a String using JavaScript's parseFloat.
@@ -41,8 +35,11 @@ foreign import fromStringImpl
4135-- | > fromString "1.2e4"
4236-- | (Just 12000.0)
4337-- | ```
44- fromString :: String -> Maybe Number
45- fromString = fromStringImpl Just Nothing
38+ fromString ∷ String → Maybe Number
39+ fromString = readFloat >>> check
40+ where
41+ check num | isFinite num = Just num
42+ | otherwise = Nothing
4643
4744
4845-- | A type alias for (small) numbers, typically in the range *[0:1]*.
You can’t perform that action at this time.
0 commit comments