File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Breaking changes:
19
19
20
20
New features:
21
21
- Added roles declarations to allow safe coercions (#9 )
22
+ - Generalized ` Exists ` to hold non-` Type ` -kinded types (#14 )
22
23
23
24
Bugfixes:
24
25
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ module Data.Exists where
2
2
3
3
import Unsafe.Coerce (unsafeCoerce )
4
4
5
- -- | This type constructor can be used to existentially quantify over a type of kind `Type` .
5
+ -- | This type constructor can be used to existentially quantify over a type.
6
6
-- |
7
7
-- | Specifically, the type `Exists f` is isomorphic to the existential type `exists a. f a`.
8
8
-- |
@@ -24,7 +24,7 @@ import Unsafe.Coerce (unsafeCoerce)
24
24
-- | ```purescript
25
25
-- | type Stream a = Exists (StreamF a)
26
26
-- | ```
27
- foreign import data Exists :: ( Type -> Type ) -> Type
27
+ foreign import data Exists :: forall k . ( k -> Type ) -> Type
28
28
29
29
type role Exists representational
30
30
Original file line number Diff line number Diff line change @@ -25,5 +25,24 @@ head = runExists head'
25
25
head' :: forall s . StreamF a s -> a
26
26
head' (StreamF s f) = snd (f s)
27
27
28
+ data Maybe a = Nothing | Just a
29
+
30
+ count :: forall a . Maybe a -> Int
31
+ count Nothing = 0
32
+ count _ = 1
33
+
34
+ data FooF f = FooF (forall a . f a -> Int ) (f String )
35
+
36
+ type Foo = Exists FooF
37
+
38
+ foo :: Foo
39
+ foo = mkExists $ FooF count (Just " test" )
40
+
41
+ x :: Int
42
+ x = runExists runFooF foo
43
+ where
44
+ runFooF :: forall f . FooF f -> Int
45
+ runFooF (FooF f fStr) = f fStr
46
+
28
47
main :: Effect Unit
29
48
main = logShow $ head nats
You can’t perform that action at this time.
0 commit comments