给定一组[1,2,3],功率集是唯一的.为什么我们说这是非确定性的?考虑另一个例子
[1,2] >>= \n -> ['a','b'] >>= \ch -> return (n,ch)
Run Code Online (Sandbox Code Playgroud)
为什么这个函数不确定?
如果我认为\ch -> return (n,ch)第二个功能是第一个?
如果第一个功能是
\n -> ['a','b'] >>= \ch -> return (n,ch)
Run Code Online (Sandbox Code Playgroud)
为什么从右到左进行评估.
不应该\n -> (function)吗?
这是什么功能(['a','b'] >>= \ch -> return (n,ch))?
如果它从左到右它不能在\ch不使用第一部分的情况下评估第二部分['a','b'],而第一部分不需要对'n'参数做任何事情.
我有一个接受 json 请求的服务器,它们可以与 python 客户端一起正常工作。我正在尝试在 haskell 中做同样的事情。
例如我的python客户端有以下代码
conn = JSONRPCProxy("XXX.XX.XX.XX", 5050, "2.0", 120)
print conn.request('show_attrs', [{"shortcode":"CODEWORD1","fx":'CD2'}, ["?queryattr", "queryname"]]);
Run Code Online (Sandbox Code Playgroud)
我想使用 haskell 发送相同的查询并返回 json 作为结果。现在不用担心 json 解析!
我试过 Network.Wreq,它有点工作,但总是没有响应
data MyPriceRequest = MyRequestRequest { method::String,id::Int} deriving (Show,Generic)
instance ToJSON MyPriceRequest
r <- post "http://IP.IP.IP.IP:port/" (toJSON (MyRequestRequest "codeword" [""] 1))
*** Exception: NoResponseDataReceived
Run Code Online (Sandbox Code Playgroud)
我得到异常,但相同的代码适用于 python
在python中它适用于...
conn = JSONRPCProxy("IP.IP.IP.IP", port, "2.0", 120)
print conn.request('codeword', []);
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个简单的代码来生成所有括号组合。但是我遇到了一个简单的类型错误。
\n\nbalancedParens :: Int -> [String]\nbalancedParens n\n | n==0 = []\n | otherwise = placeParens 0 1 0 n [""]\n where placeParens x lc rc n mlist\n | lc == n = mlist\n | rc == n = mlist\n | lc < n = placeParens (x+1) (lc+1) rc n ((mlist !! x) ++ "L")\n | rc < n = placeParens (x+1) lc (rc+1) n ((mlist !! x) ++ "R")\nRun Code Online (Sandbox Code Playgroud)\n\n错误有很多,但最突出的是
\n\nCouldn\'t match type \xe2\x80\x98Char\xe2\x80\x99 with \xe2\x80\x98[Char]\xe2\x80\x99\nExpected type: …Run Code Online (Sandbox Code Playgroud)