我想知道,你会如何使用Functional Reactive Programming编写一个程序,每隔x个时间步,从给定的URL检索一个JSON对象?
我正在研究Elm框架,但我对更通用的解决方案持开放态度.我有一个方法
send : Signal (Request a) -> Signal (Response String)
Run Code Online (Sandbox Code Playgroud)
即它将一个HTTP请求包含在一个信号中,并返回一个包含在信号中的响应字符串.
现在,我有一个"下一个状态"功能,它接收输入信号并创建一个新的游戏状态.这些都是用foldp包裹起来的.其中一个输入信号是来自HTTP请求的响应.但是,当我运行它时,查询只运行一次,而不是每次运行一次.我怎样才能解决这个问题?
编辑:这是我如何使用非FRP(命令式)来解决这个问题:
while True:
myJson = send postRequest url
--do stuff with myJSON
sleep(timestep)
Run Code Online (Sandbox Code Playgroud)
即只是经常查询网址,无限循环.
代码使用unsafeUnbind了一堆,这导致我的问题.
我尝试过使用freshen,但是我收到以下错误:
error "fresh encountered bound name!
Please report this as a bug."
Run Code Online (Sandbox Code Playgroud)
我在想:
FreshMmonad中使用?或者他们的方式来做lambda应用程序而不是在做Fresh什么?freshen,以避免他们列出的错误?unsafeUnbind,在什么条件下使用是否安全?所以,我正在写一个像应用程序一样的dock/taskbar.我想要做的很简单,显示正在运行的程序列表.
我找到了很多方法来枚举所有正在运行的进程,但经过几个小时的谷歌搜索,我找不到一种方法来确定哪些应该在任务栏中显示.
以Windows任务管理器为例.它有两个选项卡,一个标题为Applicationss,另一个标题为进程.进程包含所有系统进程,而程序以某种方式获取计算机上运行的"应用程序"列表.我希望能够访问应用程序的列表在我的计划,而不是进程列表中,这样在我的伪taksbar我不喜欢taskhost.exe,WINLOGON.EXE等显示的东西
理想情况下,我将能够获得任务栏中显示的确切程序列表.我的程序是在Python中,我有Windows API和WMI访问,但如果我必须为C函数编写python包装器,我会这样做.
据我所知,Windows Tasksbar API更适用于将menups或进度条添加到现有图标,我无法找到访问我正在寻找的信息的方法.我错了吗?
谢谢!
我正在尝试在Windows 7中安装新的Cabal.它成功安装了1.18.02,但是当我运行"cabal --version"时它显示1.16.文件夹C:\ Users\me\AppData\Roaming\cabal\bin位于我的PATH的前面.
当我直接运行1.18可执行文件时,我得到一堆"cabal.exe不存在"错误.
如何将Cabal配置为默认使用版本1.18?
所以,我有一个包含大量案例的AST数据类型,它通过"注释"类型进行参数化
data Expr a = Plus a Int Int
| ...
| Times a Int Int
Run Code Online (Sandbox Code Playgroud)
我有注释类型S和T,以及一些功能f :: S -> T.我要带一个Expr S,并将其转换为Expr T使用我的转换f在每S其中Expr的值内发生.
有没有办法使用SYB或泛型来做到这一点,并避免在每个案例上进行模式匹配?这似乎适合的类型.我对SYB不熟悉,不知道具体的方法.
我正在尝试在Haskell中调试一个庞大而复杂的程序,我自己并没有完全写出来.
我正在尝试打印我的数据结构以诊断错误,但是当我这样做时,我收到以下错误:error: Prelude.undefined.如您所见,此错误非常无法提供信息.
我有理由相信这是来自我已"部分"初始化的记录,我正在尝试访问其值尚未设置的字段.
程序(编译器)分布在两个cabal项目,一个库和一个使用该库的可执行文件中.这使得使用GHCI/cabal-repl进行调试很困难:我无法在可执行文件上运行GHCi,因为它不是错误的来源,但重新创建可执行文件给库提供的输入太复杂了,无法手工完成.
我想知道:我该怎么做才能获得有关创建错误记录的位置,错误来源的哪个字段等的更多信息.是否有RTS选项或我可以用来提供更多错误输出信息的内容?
所以,我有一个看起来像这样的证据:
induction t; intros; inversion H ; crush.
Run Code Online (Sandbox Code Playgroud)
它解决了我的所有目标,但是当我这样做时Qed,我收到以下错误:
Cannot guess decreasing argument of fix.
因此,在生成的证明术语的某处,存在非有根据的递归.问题是,我不知道在哪里.
有没有办法调试这种错误,或者看到战术脚本生成的(可能是非暂停的)证明术语?
我正在尝试运行Haskero来使用VSCode进行Haskell编辑.但是,它在初始化时失败,出现以下错误:
Initializing Haskero...
Spawning process 'stack' with command 'stack ghci --with-ghc intero "--ghci-options=-ignore-dot-ghci -Wall" --no-build --no-load'
(node:3726) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: reason.indexOf is not a function
(node:3726) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Run Code Online (Sandbox Code Playgroud)
当我从控制台中的错误运行命令时,我收到以下错误:
$ stack ghci --with-ghc intero "--ghci-options=-ignore-dot-ghci -Wall" --no-build --no-load
The following GHC options are incompatible with GHCi and have not been passed to …Run Code Online (Sandbox Code Playgroud) 我正在尝试用Travis-CI建立我的Hakyll网站.但是,在我达到目前为止,在尝试将Hakyll安装为依赖项时,我遇到了依赖项错误.
我可以在我的机器上本地建造Hakyll而没有任何问题.什么可能导致依赖性错误,以及如何解决?有没有办法解决它而不实际硬编码每个依赖版本?
这是来自TravisCI的输出.
travis_fold:end:git.5
$ export PATH=/usr/local/ghc/$(ghc_find 7.6)/bin/:$PATH
travis_fold:start:cabal
$ cabal update
Config file path source is default config file.
Config file /home/travis/.cabal/config not found.
Writing default configuration to /home/travis/.cabal/config
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
travis_fold:end:cabal
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
$ cabal --version
cabal-install version 1.18.0.2
using version 1.18.1 of the Cabal library
travis_fold:start:before_install.1
$ cabal …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个广度优先搜索版本,它只搜索我给定图形的子图.为此,我正在尝试使用filtered_graphBoost BGL中的类.
在尝试这样做时,我遇到了巨大的,丑陋的模板类型错误.
我在想:
v原始图形中的起始顶点转换为滤波图形中的顶点?MyVisitor<Vertex, SubGraph>像我一样,或者我需要一个特定于过滤图形的不同顶点类型?(这SubGraph是过滤图表类型的typedef).下面是我的代码片段,它在BFS被注释掉时编译,但是当它没有被注释时会给出错误.
#include <cstdlib>
#include <iostream>
#include <set>
#include <climits>
#include <algorithm>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/filtered_graph.hpp>
#include <vector>
//Adapted from http://stackoverflow.com/questions/14470566/how-to-traverse-graph-in-boost-use-bfs
typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS > Graph;
typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
/**
Functor to filter vertices in a graph which are not in the given set
*/
class VertexSetFilter
{
public:
std::set<Vertex> S;
VertexSetFilter(std::set<Vertex> inputSet)
{ …Run Code Online (Sandbox Code Playgroud)