我的.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上观察到同样的事情
我试图通过减少这个函数来包围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) 在下面的代码中:
\nclass 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\nRun Code Online (Sandbox Code Playgroud)\n根据常识,这应该可行,因为aGADT 和函数中的约束是相同的,并且它确定b,但是这不会编译并出现以下错误:
\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) 我试图表达一个给定的想法
\ninstance (MonadTrans t, MonadX m) => MonadX (t m)\nRun Code Online (Sandbox Code Playgroud)\n由此可见,只要所有的都有实例,任何t1 (t2 ... (tn m))也是。但是,当我尝试写下来时,它不起作用:MonadXtxMonadTrans
{-# 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) 我正在尝试定义一个类型对的每个元素都满足约束的类型类:
{-# 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) 以下代码
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移动而不是复制?