小编Ryb*_*yba的帖子

在zle reset-prompt之后,Zsh菜单完成会导致问题

我的.zshrc中有以下代码:

TMOUT=1
TRAPALRM() { zle reset-prompt }
Run Code Online (Sandbox Code Playgroud)

触发菜单完成后,菜单中的所有项目,除了突出显示的项目在触发后消失,TRAPALRM并且我在短时间后继续在菜单zsh segvaults中导航

这有什么修复或解决方法吗?

编辑:Linux Mint 17上的zsh版本是5.0.2

编辑:我在Gentoo上的zsh版本5.0.7上观察到同样的事情

linux shell zsh segmentation-fault

10
推荐指数
1
解决办法
1290
查看次数

打结的平等推理

我试图通过减少这个函数来包围Cont和callCC:

s0 = (flip runContT) return $  do
    (k, n) <- callCC $ \k -> let f x = k (f, x)
                             in  return (f, 0)
    lift $ print n
    if n < 3
        then k (n+1) >> return ()
        else return ()
Run Code Online (Sandbox Code Playgroud)

我设法达到了这一点:

s21 = runContT (let f x = ContT $ \_ -> cc (f, x) in ContT ($(f,0))) cc where
    cc = (\(k,n) -> let
        iff = if n < 3 then k (n+1) else ContT ($()) …
Run Code Online (Sandbox Code Playgroud)

monads continuations haskell lazy-evaluation tying-the-knot

7
推荐指数
1
解决办法
133
查看次数

在 GADT 中绑定时,函数依赖不统一

在下面的代码中:

\n
class FD a b | a -> b\n\ndata Foo a where\n  Foo :: FD a b => b -> Foo a\n\nunFoo :: FD a b => Foo a -> b\nunFoo (Foo x) = x\n
Run Code Online (Sandbox Code Playgroud)\n

根据常识,这应该可行,因为aGADT 和函数中的约束是相同的,并且它确定b,但是这不会编译并出现以下错误:

\n
    \xe2\x80\xa2 Couldn't match expected type \xe2\x80\x98b\xe2\x80\x99 with actual type \xe2\x80\x98b1\xe2\x80\x99\n      \xe2\x80\x98b1\xe2\x80\x99 is a rigid type variable bound by\n        a pattern with constructor:\n          Foo :: forall a b. FD a b => b -> Foo a,\n        in …
Run Code Online (Sandbox Code Playgroud)

haskell typeclass functional-dependencies gadt

7
推荐指数
1
解决办法
193
查看次数

实例归纳性作为约束

我试图表达一个给定的想法

\n
instance (MonadTrans t, MonadX m) => MonadX (t m)\n
Run Code Online (Sandbox Code Playgroud)\n

由此可见,只要所有的都有实例,任何t1 (t2 ... (tn m))也是。但是,当我尝试写下来时,它不起作用:MonadXtxMonadTrans

\n
{-# LANGUAGE BasicallyEverything #-}\n\ndata Dict c where\n  Dict :: c => Dict c\n\nclass (forall m . Monad m => Monad (t m)) => MonadTrans t where\n  lift :: Monad m => m a -> t m a\n\nclass    (c m, Monad m, forall t . (MonadTrans t, Monad (t m)) => c (t m)) => Foo c m\ninstance …
Run Code Online (Sandbox Code Playgroud)

haskell typeclass monad-transformers quantified-constraints

5
推荐指数
1
解决办法
82
查看次数

类型对的约束

我正在尝试定义一个类型对的每个元素都满足约束的类型类:

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances #-}

data a ::: b = a ::: b

class    (c1 x, c2 y) => CP c1 c2 (k :: x ::: y)
instance (c1 x, c2 y) => CP c1 c2 (k :: x ::: y)
Run Code Online (Sandbox Code Playgroud)

然而,这不是我需要的,因为 CP 是错误的

:kind CP
CP :: (* -> Constraint) -> …
Run Code Online (Sandbox Code Playgroud)

haskell typeclass type-level-computation

1
推荐指数
1
解决办法
94
查看次数

无法移动std :: any

以下代码

using vptr = std::vector<std::unique_ptr<int>>;
auto m = std::unordered_map<int, std::any>{};
m.try_emplace(0, move(vptr{}));
Run Code Online (Sandbox Code Playgroud)

无法编译,抱怨使用的已删除副本构造函数unique_ptr。在模板参数中替换std::any为之后,vptr此代码将编译,因此问题显然与any

如何强制std::any移动而不是复制?

c++ move move-semantics c++17 stdany

0
推荐指数
1
解决办法
87
查看次数