generated at
Data.Exists
PureScript存在型をするmodule







>



使い方
purs(hs)
newtype ShowBox' a = SB { value :: a, show :: a -> String } newtype ShowBox = ShowBox (Exists ShowBox')
普通の書き方でいったん ShowBox' a を定義しておいてから、 Exists ShowBox' で本命を作る
こういう気持ちで読めばいい
purs(hs)
newtype ShowBox = ShowBox (exsits a. a)
あるいは
purs(hs)
newtype ShowBox = ∀ a. ShowBox a
これはまさにHaskellの存在型の定義の仕方mrsekut


実装
purs(hs)
type role Exists representational mkExists :: forall f a. f a -> Exists f mkExists = unsafeCoerce runExists :: forall f r. (forall a. f a -> r) -> Exists f -> r runExists = unsafeCoerce
いろいろ見どころがあるmrsekut
type roleを使っている
mkExists の型
runExistsの型
forall を二重に使っている





Exists Stack Safety for Freeに出てきたmrsekut
purs(hs)
data GosubF f a b = GosubF (Unit -> Free f b) (b -> Free f a) data Free f a = Free (Either a (f (Free f a))) | Gosub (Exists (GosubF f a))