1{"comments":null,"declarations":[{"children":[],"comments":"This type constructor can be used to existentially quantify over a type.\n\nSpecifically, the type `Exists f` is isomorphic to the existential type `exists a. f a`.\n\nExistential types can be encoded using universal types (`forall`) for endofunctors in more general\ncategories. The benefit of this library is that, by using the FFI, we can create an efficient\nrepresentation of the existential by simply hiding type information.\n\nFor example, consider the type `exists s. Tuple s (s -> Tuple s a)` which represents infinite streams\nof elements of type `a`.\n\nThis type can be constructed by creating a type constructor `StreamF` as follows:\n\n```purescript\ndata StreamF a s = StreamF s (s -> Tuple s a)\n```\n\nWe can then define the type of streams using `Exists`:\n\n```purescript\ntype Stream a = Exists (StreamF a)\n```\n","info":{"dataDeclType":"data","declType":"data","roles":["Representational"],"typeArguments":[["t0",null]]},"kind":{"keyword":"data","kind":{"annotation":[],"contents":{"identifier":"k","kind":null,"skolem":null,"type":{"annotation":[],"contents":[{"annotation":[],"contents":[{"annotation":[],"contents":[["Prim"],"Function"],"tag":"TypeConstructor"},{"annotation":[],"contents":{"annotation":[],"contents":[{"annotation":[],"contents":[{"annotation":[],"contents":[["Prim"],"Function"],"tag":"TypeConstructor"},{"annotation":[],"contents":"k","tag":"TypeVar"}],"tag":"TypeApp"},{"annotation":[],"contents":[["Prim"],"Type"],"tag":"TypeConstructor"}],"tag":"TypeApp"},"tag":"ParensInType"}],"tag":"TypeApp"},{"annotation":[],"contents":[["Prim"],"Type"],"tag":"TypeConstructor"}],"tag":"TypeApp"},"visibility":"TypeVarInvisible"},"tag":"ForAll"}},"sourceSpan":{"end":[27,60],"name":".spago/p/exists-6.0.0/src/Data/Exists.purs","start":[27,1]},"title":"Exists"},{"children":[],"comments":"The `mkExists` function is used to introduce a value of type `Exists f`, by providing a value of\ntype `f a`, for some type `a` which will be hidden in the existentially-quantified type.\n\nFor example, to create a value of type `Stream Number`, we might use `mkExists` as follows:\n\n```purescript\nnats :: Stream Number\nnats = mkExists $ StreamF 0 (\\n -> Tuple (n + 1) n)\n```\n","info":{"declType":"value","type":{"annotation":[],"contents":{"identifier":"f","kind":null,"skolem":null,"type":{"annotation":[],"contents":{"identifier":"a","kind":null,"skolem":null,"type":{"annotation":[],"contents":[{"annotation":[],"contents":[{"annotation":[],"contents":[["Prim"],"Function"],"tag":"TypeConstructor"},{"annotation":[],"contents":[{"annotation":[],"contents":"f","tag":"TypeVar"},{"annotation":[],"contents":"a","tag":"TypeVar"}],"tag":"TypeApp"}],"tag":"TypeApp"},{"annotation":[],"contents":[{"annotation":[],"contents":[["Data","Exists"],"Exists"],"tag":"TypeConstructor"},{"annotation":[],"contents":"f","tag":"TypeVar"}],"tag":"TypeApp"}],"tag":"TypeApp"},"visibility":"TypeVarInvisible"},"tag":"ForAll"},"visibility":"TypeVarInvisible"},"tag":"ForAll"}},"kind":null,"sourceSpan":{"end":[40,40],"name":".spago/p/exists-6.0.0/src/Data/Exists.purs","start":[40,1]},"title":"mkExists"},{"children":[],"comments":"The `runExists` function is used to eliminate a value of type `Exists f`. The rank 2 type ensures\nthat the existentially-quantified type does not escape its scope. Since the function is required\nto work for _any_ type `a`, it will work for the existentially-quantified type.\n\nFor example, we can write a function to obtain the head of a stream by using `runExists` as follows:\n\n```purescript\nhead :: forall a. Stream a -> a\nhead = runExists head'\n where\n head' :: forall s. StreamF a s -> a\n head' (StreamF s f) = snd (f s)\n```\n","info":{"declType":"value","type":{"annotation":[],"contents":{"identifier":"f","kind":null,"skolem":null,"type":{"annotation":[],"contents":{"identifier":"r","kind":null,"skolem":null,"type":{"annotation":[],"contents":[{"annotation":[],"contents":[{"annotation":[],"contents":[["Prim"],"Function"],"tag":"TypeConstructor"},{"annotation":[],"contents":{"annotation":[],"contents":{"identifier":"a","kind":null,"skolem":null,"type":{"annotation":[],"contents":[{"annotation":[],"contents":[{"annotation":[],"contents":[["Prim"],"Function"],"tag":"TypeConstructor"},{"annotation":[],"contents":[{"annotation":[],"contents":"f","tag":"TypeVar"},{"annotation":[],"contents":"a","tag":"TypeVar"}],"tag":"TypeApp"}],"tag":"TypeApp"},{"annotation":[],"contents":"r","tag":"TypeVar"}],"tag":"TypeApp"},"visibility":"TypeVarInvisible"},"tag":"ForAll"},"tag":"ParensInType"}],"tag":"TypeApp"},{"annotation":[],"contents":[{"annotation":[],"contents":[{"annotation":[],"contents":[["Prim"],"Function"],"tag":"TypeConstructor"},{"annotation":[],"contents":[{"annotation":[],"contents":[["Data","Exists"],"Exists"],"tag":"TypeConstructor"},{"annotation":[],"contents":"f","tag":"TypeVar"}],"tag":"TypeApp"}],"tag":"TypeApp"},{"annotation":[],"contents":"r","tag":"TypeVar"}],"tag":"TypeApp"}],"tag":"TypeApp"},"visibility":"TypeVarInvisible"},"tag":"ForAll"},"visibility":"TypeVarInvisible"},"tag":"ForAll"}},"kind":null,"sourceSpan":{"end":[56,63],"name":".spago/p/exists-6.0.0/src/Data/Exists.purs","start":[56,1]},"title":"runExists"}],"name":"Data.Exists","reExports":[]}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list