在使用QuickCheck测试Monadic代码时(Claessen,Hughes 2002),assert有类型:
assert :: (Monad m, Testable a) => a -> PropertyM m ()
Run Code Online (Sandbox Code Playgroud)
但是,在Test.QuickCheck.Monadic,它有类型:
assert :: (Monad m) => Bool -> PropertyM m ()
Run Code Online (Sandbox Code Playgroud)
为什么assert在库中有后一种类型?
我已经在Centos 7上运行了一个LDAP服务器.id,getent passwd,用户工作.但'ssh'失败了.从/ var/log/secure看来,身份验证似乎成功了,但是pam不喜欢其他东西.我不确定如何缩小问题所在.
在/ var /日志/安全:
May 11 16:33:40 localhost sshd[45055]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=ldapserver.abc.com user=user1
May 11 16:33:40 localhost sshd[45055]: pam_sss(sshd:auth): authentication success; logname= uid=0 euid=0 tty=ssh ruser= rhost=ldapserver.abc.com user=user1
May 11 16:33:40 localhost sshd[45055]: pam_sss(sshd:account): Access denied for user user1: 6 (Permission denied)
May 11 16:33:40 localhost sshd[45055]: Failed password for user1 from ldapserver.abc.com port 55185 ssh2
May 11 16:33:40 localhost sshd[45055]: fatal: Access denied for user user1 by PAM account configuration …Run Code Online (Sandbox Code Playgroud) 在Haskell中,使用FFI绑定到分配功能时,它是适当的避免使用IO时的外部函数分配并构建了一些值,并将该值仅依赖于函数的参数?
考虑以下功能:
/**
* The foo_create contract: if allocation succeeds, the
* return value points to a value that depends only on 'x'
* and 'name', otherwise a null pointer is returned.
*/
foo_t *foo_create(int x, const char *name);
Run Code Online (Sandbox Code Playgroud)
以下列方式导入此功能是否合适?
newtype Foo = Foo (Ptr Foo)
foreign import unsafe "foo.h foo_create"
foo_create :: CInt -> CString -> Ptr Foo
Run Code Online (Sandbox Code Playgroud)
然后可以包装此低级绑定函数以提供更好的API:
makeFoo :: CInt -> CString -> Maybe Foo
makeFoo x s =
let
ptr …Run Code Online (Sandbox Code Playgroud) 考虑类型的函数a -> b -> c和应用值a1, a2 :: (Applicative f) => f a.
我希望构造一个函数,该函数可以应用于类型的函数a -> b -> c以获得类型的值Applicative f :: f c.我可以通过以下方式执行此操作:
g :: (Applicative f) => (a -> b -> c) -> f c
g = \f -> f <$> a1 <*> a2
Run Code Online (Sandbox Code Playgroud)
(显式lambda是故意的,因为我正在考虑在任何级别构建此函数,而不仅仅是顶层).
如果我尝试g用无点样式编写:
g = (<$> a1 <*> a2)
Run Code Online (Sandbox Code Playgroud)
我得到以下编译错误:
The operator `<$>' [infixl 4] of a section
must have lower precedence than that of the operand,
namely …Run Code Online (Sandbox Code Playgroud) 以下程序类型检查:
{-# LANGUAGE RankNTypes #-}
import Numeric.AD (grad)
newtype Fun = Fun (forall a. Num a => [a] -> a)
test1 [u, v] = (v - (u * u * u))
test2 [u, v] = ((u * u) + (v * v) - 1)
main = print $ fmap (\(Fun f) -> grad f [1,1]) [Fun test1, Fun test2]
Run Code Online (Sandbox Code Playgroud)
但是这个程序失败了:
main = print $ fmap (\f -> grad f [1,1]) [test1, test2]
Run Code Online (Sandbox Code Playgroud)
带有类型错误:
Grad.hs:13:33: error:
• Couldn't match type ‘Integer’ …Run Code Online (Sandbox Code Playgroud) haskell type-systems automatic-differentiation type-mismatch
OpenSSL Cookbook中的示例openssl root ca config 定义了以下内容(p40):
[req]
...
req_extensions = ca_ext
[ca_ext]
...
Run Code Online (Sandbox Code Playgroud)
稍后(p43),生成根ca密钥,然后生成root ca自签名证书.
openssl req -new \
-config root-ca.conf \
-out root-ca.csr \
-keyout private/root-ca.key
openssl ca -selfsign \
-config root-ca.conf \
-in root-ca.csr \
-out root-ca.crt \
-extensions ca_ext
Run Code Online (Sandbox Code Playgroud)
在这个特定的用例中,req_extensions不是多余的吗?什么时候真的需要req_extension?
haskell ×4
allocation ×1
applicative ×1
csr ×1
ffi ×1
git ×1
git-rebase ×1
git-rerere ×1
linux ×1
openldap ×1
openssl ×1
pam ×1
pkcs#10 ×1
quickcheck ×1
ssh ×1
sssd ×1
type-systems ×1
x509 ×1