Skip to content

Commit 2863921

Browse files
committed
Updates for 1.0 core libraries (#5)
* Updates for 1.0 core libraries * Fix tests
1 parent 5fd4627 commit 2863921

File tree

5 files changed

+23
-64
lines changed

5 files changed

+23
-64
lines changed

bower.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"tests"
1515
],
1616
"dependencies": {
17-
"purescript-maybe": "^0.3.0",
18-
"purescript-functions": "^0.1.0"
17+
"purescript-maybe": "^1.0.0-rc.1",
18+
"purescript-functions": "^1.0.0-rc.1"
1919
},
20-
"repository": {
21-
"type": "git",
22-
"url": "git://github.com/paf31/purescript-nullable.git"
23-
}
20+
"repository": {
21+
"type": "git",
22+
"url": "git://github.com/paf31/purescript-nullable.git"
23+
}
2424
}

docs/Data/Nullable.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Data/Nullable.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* global exports */
22
"use strict";
33

4-
// module Data.Nullable
5-
64
exports["null"] = null;
75

86
exports.nullable = function(a, r, f) {
@@ -11,4 +9,4 @@ exports.nullable = function(a, r, f) {
119

1210
exports.notNull = function(x) {
1311
return x;
14-
};
12+
};

src/Data/Nullable.purs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ module Data.Nullable
77
, toNullable
88
) where
99

10-
import Prelude
10+
import Prelude (class Ord, class Eq, class Show, compare, eq, show)
1111

12-
import Data.Maybe
13-
import Data.Function
12+
import Data.Function (on)
13+
import Data.Function.Uncurried (Fn3, runFn3)
14+
import Data.Maybe (Maybe(..), maybe)
1415

1516
-- | A nullable type.
1617
-- |
@@ -20,17 +21,17 @@ foreign import data Nullable :: * -> *
2021

2122
-- | The null value.
2223
foreign import null :: forall a. Nullable a
23-
24+
2425
foreign import nullable :: forall a r. Fn3 (Nullable a) r (a -> r) r
2526

2627
-- | Wrap a non-null value.
2728
foreign import notNull :: forall a. a -> Nullable a
28-
29+
2930
-- | Takes `Nothing` to `null`, and `Just a` to `a`.
3031
toNullable :: forall a. Maybe a -> Nullable a
3132
toNullable = maybe null notNull
3233

33-
-- | Represent `null` using `Maybe a` as `Nothing`.
34+
-- | Represent `null` using `Maybe a` as `Nothing`.
3435
toMaybe :: forall a. Nullable a -> Maybe a
3536
toMaybe n = runFn3 nullable n Nothing Just
3637

test/Main.purs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ module Test.Main where
22

33
import Prelude
44

5-
import Data.Maybe
6-
import Data.Nullable
5+
import Data.Maybe (Maybe(..))
6+
import Data.Nullable (toNullable, toMaybe)
77

8-
import Control.Monad.Eff.Console
8+
import Control.Monad.Eff.Console (logShow)
99

1010
main = do
11-
print $ toNullable (Nothing :: Maybe Number)
12-
print $ toNullable (Just 42)
11+
logShow $ toNullable (Nothing :: Maybe Number)
12+
logShow $ toNullable (Just 42)
1313

14-
print $ toMaybe $ toNullable (Nothing :: Maybe Number)
15-
print $ toMaybe $ toNullable (Just 42)
14+
logShow $ toMaybe $ toNullable (Nothing :: Maybe Number)
15+
logShow $ toMaybe $ toNullable (Just 42)
1616

17-
print $ toNullable Nothing == toNullable (Just 42)
18-
print $ toNullable Nothing `compare` toNullable (Just 42)
17+
logShow $ toNullable Nothing == toNullable (Just 42)
18+
logShow $ toNullable Nothing `compare` toNullable (Just 42)

0 commit comments

Comments
 (0)