我正在为haskell中的各种函数调用构建一个优化器,这是我的AST
data Expr = ExprCall { _fname :: Text, _fparams :: [Expr] }
| ExprVar { _var :: Text }
| ExprNat { _nat :: Int }
Run Code Online (Sandbox Code Playgroud)
这里是语法的例子,mod并且random是外部函数和它们的语义是不透明的哈斯克尔.
mod(random(), 10)
Run Code Online (Sandbox Code Playgroud)
所有它都是语法的AST表示,对于上面的示例,它将是:
ExprCall "mod" [ExprCall "random" [], ExprNat 10]
Run Code Online (Sandbox Code Playgroud)
我有很多类型的传递,Expr->Expr我有一个函数调用descend它遍历AST并对每个传递一个传递Expr.这是我的下降功能
{- # LANGUAGE RecordWildCards #-}
descend :: (Expr -> Expr) -> Expr -> Expr
descend f ExprCall { .. } = ExprCall _fname $ map f _fparams
-- Base expressions
descend …Run Code Online (Sandbox Code Playgroud) 我正在使用Elixir上的openssl命令行生成RSA密钥对,除了我无法抑制该命令的输出外,一切正常.
这就是我正在运行的:
{_, 0} = System.cmd "openssl", [ "genrsa", "-out", "privateKey.pem", "2048"]
Run Code Online (Sandbox Code Playgroud)
而且我一直在:
Generating RSA private key, 2048 bit long modulus .....+++
.....................................+++ e is 65537 (0x10001)
Run Code Online (Sandbox Code Playgroud)
用escript编译后运行可执行文件.
毫不奇怪,OSX Mojave的新更新中断了我在Homebrew中的llvm安装,这些是我尝试的步骤:
xcode-select --install # Complained, so I installed commandLineTools from here https://developer.apple.com/download/more/
xcode-select -p /Library/Developer/CommandLineTools
xcode-select --install # Now says installed
sudo xcodebuild -license # Fails, as it says I only have CommandLineTools installed in /Library/Developer/CommandLineTools not xcode
# Try something else (all versions)
brew uninstall --force llvm
brew install llvm # yay v7 how exciting
# Only it still don't work
clang++ -std=c++17 foo.cpp -o f
In file included from foo.cpp:1:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iostream:38:
In file …Run Code Online (Sandbox Code Playgroud) 我将我的MongoDB部署在EC2实例中,非常稳定。我(希望)很快将使用Docker启动我的Elastic Beanstalk负载平衡Web应用程序。但是,我觉得我的数据库对dockerize或beastalk-ize过于敏感,因此我想将其保存在普通的EC2实例中。
我的问题是关于安全小组的。如何创建仅接受来自Elastic Beanstalk的MongoDB通信(端口27017)的安全组?由于EC2实例将被任意创建和销毁,也许我可以获得其中最不常见的子网?
即使对于Haskell,这也是一种奇怪的行为.查看下面的代码段:
import System.Directory
import System.FilePath
-- This spins infinitely
loadCtx :: FilePath -> IO ()
loadCtx dir = do
lsfiles <- listDirectory dir
let files = mapM (dir </>) lsfiles
putStrLn $ "Files " ++ show files
-- This does what I'd expect, prepending the dir path to each file
loadCtx dir = do
lsfiles <- listDirectory dir
let files = map (dir </>) lsfiles
putStrLn $ "Files " ++ show files
Run Code Online (Sandbox Code Playgroud)
两种定义都可以从类型检查器中接受,但给出完全不同的行为.第一个是什么输出mapM?它看起来像是读取一些文件的无限循环.也可以用listDirectory一行中的前导线组成do-arrow map (dir </>) …
我在OSX 10.11上用pip安装cassandra-driver.直接从pip,cassandra-driver给出了这个错误:
traceback (most recent call last): File "syncS3ToCassandra.py", line 19, in <module>
from cassandra.cluster import Cluster File "cassandra/cluster.py", line 48, in init cassandra.cluster (cassandra/cluster.c:74747)
File "cassandra/connection.py", line 38, in init cassandra.connection (cassandra/connection.c:28007)
ImportError: No module named queue
Run Code Online (Sandbox Code Playgroud)
我没有尝试从源代码构建cassandra-driver,但pip是推荐的方法.这是我的代码:
from cassandra.cluster import Cluster
from cassandra.policies import DCAwareRoundRobinPolicy
cluster = Cluster()
session = cluster.connect('foo')
Run Code Online (Sandbox Code Playgroud) 我是Haskell的新手,我正在尝试映射检查文件是否存在的检查函数,如下所示:
check :: FilePath -> IO Bool
来自Main的argv,如下:
main :: IO Bool
main = do {
args <- getArgs;
return $ foldM (&&) True $ mapM check args;
}
Run Code Online (Sandbox Code Playgroud)
基本上逻辑是,将IO [Bool]的数组折叠成单个IO Bool并返回它.我使用地图的单子版本和折叠,因为我身边携带IO单子,但我得到了很多来自typechecker,我不能因为占位符真正破译错误的介绍,我什么都不知道关于.
src/Main.hs:15:9: error:
• Couldn't match type ‘m0 Bool’ with ‘Bool’
Expected type: IO Bool
Actual type: IO (m0 Bool)
• In a stmt of a 'do' block:
return $ foldM (&&) True $ mapM check args
In the expression:
do args <- getArgs
return $ foldM (&&) True …Run Code Online (Sandbox Code Playgroud)