假设我有一个参数只为类型系统的利益而存在,例如在这个小程序中:
{-# LANGUAGE GADTs #-}
module Main where
import Data.Proxy
import Data.List
data MyPoly where
MyConstr :: Proxy a -> a -> (Proxy a -> a -> Int -> Int) -> MyPoly
listOfPolys :: [MyPoly]
listOfPolys = [MyConstr Proxy 5 (const (+))
, MyConstr Proxy 10 (const (+))
, MyConstr Proxy 15 (const (+))]
main = print $ foldl' (\v (MyConstr p n a) -> a p n v) 0 listOfPolys
Run Code Online (Sandbox Code Playgroud)
结构中的 Proxy 参数和成员只需要在编译时真正需要存在,以帮助进行类型检查,同时维护多态 MyPoly(在这种情况下,程序将在没有它的情况下编译,但这个人为的示例是一个更普遍的问题,其中存在仅在编译时需要的证明或代理)- Proxy 只有一个构造函数,并且类型参数是幻像类型。
用 ghc with …
我有一个只用过两个不同参数的GADT,ForwardPossible和():
-- | Used when a forward definition is possible.
data ForwardPossible = ForwardPossible deriving (Eq, Ord, Typeable, Data, Show)
-- | GADT which accepts forward definitions if parameter is ForwardPossible.
data OrForward t forward where
OFKnown :: t -> OrForward t forward
OFForward :: NamespaceID -> SrcSpan -> BS.ByteString -> OrForward t ForwardPossible
deriving instance Eq t => Eq (OrForward t forward)
deriving instance Ord t => Ord (OrForward t forward)
deriving instance Typeable2 OrForward
deriving instance Show t …
Run Code Online (Sandbox Code Playgroud) 当尝试使用ghc-7.6.1编译gtk Haskell包时,我收到以下错误(当尝试构建pango时,其中一个依赖项,但如果我尝试手动安装它们,它也会出现在其他依赖包中):
[ 1 of 14] Compiling Graphics.Rendering.Pango.Types ( dist/build/Graphics/Rendering/Pango/Types.hs, dist/build/Graphics/Rendering/Pango/Types.o )
Graphics/Rendering/Pango/Types.chs:249:1:
Unacceptable result type in foreign declaration: CULong
When checking declaration:
foreign import ccall unsafe "static pango_context_get_type" pango_context_get_type
:: CULong
Run Code Online (Sandbox Code Playgroud)
我以前安装了旧版本的gtk2hs,因此在升级期间会发生这种情况.
我该如何修复错误?
我有两个随机变量:
X ~ binom(n, p1)
Y ~ binom(n, p2)
Run Code Online (Sandbox Code Playgroud)
n是已知参数(试验总数),而p1和p2未知.
我从每个分布中得到一个样本(x来自X,y来自Y).为了给出一些上下文,x和y是来自两个不同分类器的真阳性数,具有固定的选择性.
我想用R来测试零假设p1 = p2对p1> p2.
特别地,我希望能够找到p值P(XY = xy | p1 = p2),并且如果可能的话,能够找到p1和p2之间的差的置信区间.
最好的方法是什么?