我很好奇是否有工具或简单的方法在给定的时间间隔内连续执行某个命令,并将其输出重新打印到屏幕上的相同位置.
促使我思考它的例子是'dropbox-cli status'.手动执行:
$> dropbox-cli status
Syncing (6,762 files remaining)
Indexing 3,481 files...
$> dropbox-cli status
Syncing (5,162 files remaining)
Indexing 2,681 files...
Run Code Online (Sandbox Code Playgroud)
我在寻找:
$> tracker --interval=1s "dropbox-cli status"
Syncing (6,743 files remaining)
Indexing 3,483 files
Run Code Online (Sandbox Code Playgroud)
虚构命令"跟踪器"将阻塞,并且每两秒输出行将连续重新打印,而不是创建附加日志输出.
为什么这不是正确的实施?
instance Monad Lock where
(Working False x) >>= _ = Working False x
(Working True x) >>= f = f x
Run Code Online (Sandbox Code Playgroud)
GHC吐出的错误是关于刚性类型变量的错误:
• Couldn't match type ‘a’ with ‘b’
‘a’ is a rigid type variable bound by
the type signature for:
(>>=) :: forall a b. Lock a -> (a -> Lock b) -> Lock b
at src/Computers.hs:32:22
‘b’ is a rigid type variable bound by
the type signature for:
(>>=) :: forall a b. Lock a -> (a …Run Code Online (Sandbox Code Playgroud)