typeclass

    2热度

    1回答

    下面的代码犯规编译: class Foo f where getInt :: f -> Int class Bar b where getFooFromBar :: Foo f => b -> f someFunction :: Bar b => b -> Int someFunction bar = getInt $ getFooFromBar bar 的错误是

    1热度

    1回答

    我有这样的数据结构: data Fraction = Fraction Integer Integer | NaF deriving (Show) 它应该代表小数,我试图使它民实例。除“fromInteger”之外,我没有任何操作问题。我不会理解它应该做什么以及它应该是什么样子。我可以请求帮忙吗?

    1热度

    1回答

    我刚开始与数学类库玩弄和我想证明以下引理: Require Import MathClasses.interfaces.abstract_algebra MathClasses.interfaces.vectorspace MathClasses.interfaces.canonical_names. Lemma Munit_is_its_own_negation `{Module

    2热度

    2回答

    我最近看到这种错误的一个很好的协议: Error: Tactic failure: setoid rewrite failed: Unable to satisfy the following constraints: UNDEFINED EVARS: ?X1700==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm

    9热度

    2回答

    我对Sum和Product newtypes的理解是它们用作数字类型的monoidial包装。我会明白Functor实例,但为什么还有Applicative,Monad其他任何看似无用的实例?我知道他们在数学上没问题(同构于Identity modad,对吧?)但是用例是什么?例如,如果有Applicative Sum实例,我预计会在某处遇到类型为Sum (a -> b)的值。我无法想象这可能会有

    2热度

    1回答

    我想知道为什么email-validate包在下面的代码推导公式: data EmailAddress = EmailAddress ByteString ByteString deriving (Eq, Ord, Data, Typeable, Generic) 我的意思是,我是用Text电子邮件地址,直到我意识到我需要让他们不区分大小写(所以我不” t保存[email prote

    0热度

    1回答

    我想编译Idris中的interface的简单示例。 interface Foo a where foo : a -> String 但我不断收到这种类型检查错误: error: expected: "with", argument expression, function right hand side, implicit function argument, with p

    2热度

    1回答

    我写在Haskell模块化和可扩展的文本编辑器,我想实现这样的插件:插件的作者提供了一个单一的功能,看起来是这样的: handleEvent :: (PluginState, EditorState) -> Event -> (PluginState, EditorState) 由于每个事件都会发生,插件可以使用当前编辑器状态和自己状态的自定义块来计算新的编辑器状态和新的插件状态。当然,每个插

    1热度

    1回答

    所以我在斯卡拉多态数据类型树定义如下 sealed trait Tree[+A] final case class Node[A](value: A) extends Tree[A] final case class Branch[A](value: A, left: Tree[A], right: Tree[A]) extends Tree[A] object Tree{ i

    1热度

    2回答

    我觉得我要有效地做这样的事情: class (forall z. ListZip z) => PlaneZip p where... --functions using z excluded 在短,但更确切地说,我想有 class A p where ... --definition excluded class C p where foo :: (A z) => p (z a)