existential-type

    2热度

    2回答

    {-# LANGUAGE DataKinds, ExistentialQuantification, KindSignatures #-} import Data.Proxy data Type t= forall (a :: t). Type (Proxy a) 给出了错误 Type variable ‘t’ used in a kind In the kind ‘t’ In th

    1热度

    1回答

    我试图创建与依赖类型_ >: a.type相关的类型别名。 Scala编译器报告,我不明白的错误: scala> def foo[A](a: A) = { | type F = Function1[_ >: a.type, Unit] | } <console>:12: error: type mismatch; found : a.type (with underlyin

    13热度

    1回答

    在我的(威力不正确)的理解,下面的两个表应该是等价的: [1, "a"] :: [forall a. Show a => a] data V = forall a. Show a => V a [V 1, V "a"] :: [V] 然而,第一个是不能接受的,但第二个工作正常(与ExistentialQuantification)。 如果第一个列表不存在,map V :: ??? ->

    4热度

    1回答

    我对以下程序感到困惑。 {-# LANGUAGE RankNTypes #-} newtype A a = A (forall f. Applicative f => f a) good :: a -> A a good x = A $ pure $ x bad :: a -> A a bad x = A . pure $ x 当尝试编译,我得到这个错误讯息,抱怨bad: Cou

    2热度

    1回答

    我正在通过Prompt及其Bind实例中描述的here的定义工作,并试图弄清楚Purescript会如何显示。 我正在使用Purescript.Exists作为存在类型。我确定指标则是: data PromptAskF p r a = PromptAskF (p a) (a -> Prompt p r) type PromptAsk p r = Exists (PromptAskF

    0热度

    1回答

    考虑以下类型类定义的类型的对: class Constraint a b where g :: a -> b 对于约束所有的情况下,我们可以推导出一组类型a,基本上是一个隐含的类型类,姑且称之为A。对于类型类别A的每个实例,存在另一个隐式类型B,其包括Constraint A b的所有可能类型b。 所以这里是一段代码。 {-# LANGUAGE ExistentialQuantifi

    9热度

    1回答

    在Scala中的Skolemization,下面的表达式提出了一个错误类型: val pair: (A => String, A) forSome { type A } = ({ a: Int => a.toString }, 19) pair._1(pair._2) 如SI-9899提到这answer,根据该规范,这是正确的: I think this is working as desi

    1热度

    1回答

    可以这样做吗? case class Foo[T](value: T) case class Bar[T](value: T) val map = mutable.Map.empty[Foo[_], Bar[_]] map(Foo(1)) = Bar(1) // correct map(Foo(1)) = Bar(1.1) // should cause a compiler erro

    2热度

    1回答

    下面的函数编译: onlyModByFive : (n : Nat) -> (k : Nat ** 5 * k = n) -> Nat onlyModByFive n k = 100 但到底是什么k代表其Nat ** 5 * k = n语法? 另外,我怎样称呼它?这是我的尝试,但我不明白输出。答案的 *Test> onlyModByFive 5 5 When checking an app

    1热度

    1回答

    我只是在学习关于存在性量化,GADT和KindSignatures等的所有事情。为此,我尝试想出一些小程序,这些程序可以帮助我更好地理解所有内容。 现在我有了这个小片段(这实际上编译,所以你可以尝试一下你自己,需要矢量和MTL包),并想知道它是否是在所有可能做的我是什么试图完成或指导我如何使它工作 {-# LANGUAGE KindSignatures #-} {-# LANGUAGE Exis