File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change 1
1
module Data.Exists where
2
2
3
+ import Prelude
4
+
3
5
-- | This type constructor can be used to existentially quantify over a type of kind `*`.
4
6
-- |
5
7
-- | Specifically, the type `Exists f` is isomorphic to the existential type `exists a. f a`.
@@ -33,10 +35,7 @@ foreign import data Exists :: (* -> *) -> *
33
35
-- | nats :: Stream Number
34
36
-- | nats = mkExists $ StreamF 0 (\n -> Tuple (n + 1) n)
35
37
-- | ```
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
40
39
41
40
-- | The `runExists` function is used to eliminate a value of type `Exists f`. The rank 2 type ensures
42
41
-- | that the existentially-quantified type does not escape its scope. Since the function is required
@@ -51,9 +50,4 @@ foreign import mkExists
51
50
-- | head' :: forall s. StreamF a s -> a
52
51
-- | head' (StreamF s f) = snd (f s)
53
52
-- | ```
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
Original file line number Diff line number Diff line change 1
1
module Main where
2
2
3
+ import Prelude
4
+
3
5
import Console
4
6
import Data.Exists
5
7
You can’t perform that action at this time.
0 commit comments