我遵循的是Liquid Haskell的官方教程,偶然发现了其中的“ bug”。
本教程中包含以下代码,而Liquid Haskell应该检查它是否安全。
{-@ type TRUE = {v:Bool | v } @-}
{-@ type FALSE = {v:Bool | not v} @-}
{-@ (==>) :: p:Bool -> q:Bool -> {v:Bool | v <=> (p ==> q)} @-}
False ==> False = True
False ==> True = True
True ==> True = True
True ==> False = False
{-@ measure f :: Int -> Int @-}
{-@ congruence :: (Int -> Int) …Run Code Online (Sandbox Code Playgroud) 我试图解决与"第一原理的Haskell编程"第15章中的另一个问题相同的练习.我已经创建了一个Semigroup实例,而且我在编写QuickCheck部分练习时遇到了麻烦.
Semigroup实例应该满足:
a <> (b <> c) == (a <> b) <> c
Run Code Online (Sandbox Code Playgroud)
<>Semigroup mappend 在哪里.
我想出了以下内容:
import Data.Semigroup
import Test.QuickCheck
semigroupAssoc :: (Eq m, Semigroup m) => m -> m -> m -> Bool
semigroupAssoc a b c = (a <> (b <> c)) == ((a <> b) <> c)
newtype Combine a b = Combine { unCombine :: (a -> b) }
instance Semigroup b => Semigroup (Combine a b) where
(Combine f) …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的 PSQL 数据库创建一个 PHP 接口,并且我希望在 PSQL 上注册的一些本地用户能够登录到我的数据库。我首先为每个用户创建每个用户名,并使用“Password123”等通用密码,然后用户可以稍后更改他/她的密码。
为此,我想到使用一个简单的 PHP 表单:
<form action="" method="post">
<table>
<tr> <td> User: </td> <td> <input type="text" name="user" /> </td> </tr>
<tr> <td> Old password: </td> <td> <input type="password" name="old" /> </td> </tr>
<tr> <td> New password: </td> <td> <input type="password" name="new1" /> </td> </tr>
<tr> <td> Repeat new password: </td> <td> <input type="password" name="new2" /> </td> </tr>
<tr> <td> <input type="submit" name="submit" value="Change password" /> </td> </tr>
</form>
<?php
if ($_POST) {
$user = $_POST["user"]; …Run Code Online (Sandbox Code Playgroud)