如何使用堆栈工具卸载全局安装的Haskell软件包?
stack --help
显示不推荐使用uninstall命令.
uninstall DEPRECATED: This command performs no actions, and is
present for documentation only
Run Code Online (Sandbox Code Playgroud) 当内容类型为“application/json”且没有给出明确的字符集时,HTTP POST 请求的默认编码是什么?
似乎有两个规范存在冲突:
我可以编写一个函数来返回作为参数给出的函数的名称吗?
let funName f: string =
// returns the name of f.
Run Code Online (Sandbox Code Playgroud)
例如,如果我printfn
作为参数传递给funName,则返回"printfn".
> funName printfn;;
val it : string = "printfn"
Run Code Online (Sandbox Code Playgroud)
编辑:我想编写一个函数doc
,它返回与给定函数关联的XML文档.
let doc f = // returns the XML documentation of the function `f`.
Run Code Online (Sandbox Code Playgroud)
要使用NuDoq之类的东西检索函数的摘要,我想知道函数的名称.
Haskell Wiki的Numeric Haskell页面的第2.3.1.1节"融合注释" 通过显示优化代码来解释循环融合,如下所示:
优化前:
import qualified Data.Vector as V
test :: V.Vector Int -> Double
test = V.foldl (\ a b -> a * sqrt (fromIntegral b)) 0
create :: Int -> V.Vector Int
create n = (V.enumFromTo 1 n)
main = print (test (create 1000000))
Run Code Online (Sandbox Code Playgroud)
优化后:
main_$s$wfoldlM_loop :: Int# -> Double# -> Double#
main_$s$wfoldlM_loop =
\ (sc_sWA :: Int#) (sc1_sWB :: Double#) ->
case <=# sc_sWA 1000000 of _ {
False -> sc1_sWB;
True ->
main_$s$wfoldlM_loop
(+# …
Run Code Online (Sandbox Code Playgroud) 是否可以将以下两个函数组合成Haskell中的一个多态函数?
mutiplyByTwoI :: Int -> Float
mutiplyByTwoI x = fromIntegral x * 2.0
mutiplyByTwoF :: Float -> Float
mutiplyByTwoF x = x * 2.0
Run Code Online (Sandbox Code Playgroud)
我试过Num a
,但我找不到转换Num a
为Float的方法.
mutiplyByTwo :: (Num a) => a -> Float
mutiplyByTwo = undefined
Run Code Online (Sandbox Code Playgroud)