Skip to content

Commit 08f7232

Browse files
committed
Updates for 0.7
1 parent 68b0f00 commit 08f7232

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/Data/Exists.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* global exports */
2+
"use strict";
3+
4+
// module Data.Exists
5+
6+
exports.mkExists = function(fa) {
7+
return fa;
8+
};
9+
10+
exports.runExists = function(f) {
11+
return function(fa) {
12+
return f(fa);
13+
};
14+
};

src/Data/Exists.purs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module Data.Exists where
22

3+
import Prelude
4+
35
-- | This type constructor can be used to existentially quantify over a type of kind `*`.
46
-- |
57
-- | Specifically, the type `Exists f` is isomorphic to the existential type `exists a. f a`.
@@ -33,10 +35,7 @@ foreign import data Exists :: (* -> *) -> *
3335
-- | nats :: Stream Number
3436
-- | nats = mkExists $ StreamF 0 (\n -> Tuple (n + 1) n)
3537
-- | ```
36-
foreign import mkExists
37-
"function mkExists(fa) {\
38-
\ return fa;\
39-
\}" :: forall f a. f a -> Exists f
38+
foreign import mkExists :: forall f a. f a -> Exists f
4039

4140
-- | The `runExists` function is used to eliminate a value of type `Exists f`. The rank 2 type ensures
4241
-- | that the existentially-quantified type does not escape its scope. Since the function is required
@@ -51,9 +50,4 @@ foreign import mkExists
5150
-- | head' :: forall s. StreamF a s -> a
5251
-- | head' (StreamF s f) = snd (f s)
5352
-- | ```
54-
foreign import runExists
55-
"function runExists(f) {\
56-
\ return function(fa) {\
57-
\ return f(fa);\
58-
\ };\
59-
\}" :: forall f r. (forall a. f a -> r) -> Exists f -> r
53+
foreign import runExists :: forall f r. (forall a. f a -> r) -> Exists f -> r

tests/Tests.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module Main where
22

3+
import Prelude
4+
35
import Console
46
import Data.Exists
57

0 commit comments

Comments
 (0)