我想像这样计算binom:
let t = seq { 1..10 } |> Seq.takeWhile (fun e -> e % 2 == 0)
Run Code Online (Sandbox Code Playgroud)
但编译器抱怨
playground.fsx(27,59): error FS0001: The type 'int' does not support the operator '=='
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在尝试安装
stack install ghc-mod
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
In the dependencies for ghc-mod-5.8.0.0:
Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 (latest matching version is 1.24.2.0)
base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10 (latest matching version is 4.9.1.0)
cabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has no specified version (latest matching version is 0.7.3.0)
extra-1.6.2 from stack configuration does not match <1.6 && >=1.4 (latest matching version is 1.5.3)
ghc-8.2.2 from stack configuration does not …Run Code Online (Sandbox Code Playgroud) 我有以下代码,没有编译:
import React from 'react';
import { AppBar, Toolbar } from 'material-ui';
import { Typography } from 'material-ui';
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
import {cyan, red} from 'material-ui/colors';
import { red400 } from 'material-ui/styles/colors';
const theme = createMuiTheme({
palette: {
primary: red400,
secondary: cyan,
},
});
const View = (props) => (
<MuiThemeProvider theme={theme}>
<AppBar position="static">
<Toolbar>
<Typography variant="title">
{props.title}
</Typography>
</Toolbar>
</AppBar>
</MuiThemeProvider>
);
export default View;
Run Code Online (Sandbox Code Playgroud)
它说:
Failed to compile
./src/Dashboard/AppBar/Views/View.js
Module not found: Can't resolve …Run Code Online (Sandbox Code Playgroud) 我有以下来自互联网的代码片段:
calculateLength :: LengthMonad Int
calculateLength = do
-- all the IO operations have to be lifted to the IO monad in the monad stack
liftIO $ putStrLn "Please enter a non-empty string: "
s <- liftIO getLine
if null s
then throwError "The string was empty!"
else return $ length s
Run Code Online (Sandbox Code Playgroud)
并不能理解,为什么作者使用liftIO?
的目的是liftIO什么?
它的定义如下:
class (Monad m) => MonadIO m where
-- | Lift a computation from the 'IO' monad.
liftIO :: IO a -> …Run Code Online (Sandbox Code Playgroud) 我写了一个设置cookie并删除它的Web应用程序.为了澄清方案,我的意思是看下面的代码片段.
package main
import (
"fmt"
"github.com/gorilla/mux"
"net/http"
"time"
)
func rootHandler(rw http.ResponseWriter, r *http.Request) {
fmt.Fprintf(rw, "Hello Foo")
}
func setCookieHandler(rw http.ResponseWriter, r *http.Request) {
c := &http.Cookie{
Name: "storage",
Value: "value",
Path: "/",
MaxAge: 0,
HttpOnly: true,
}
http.SetCookie(rw, c)
}
func deleteCookieHandler(rw http.ResponseWriter, r *http.Request) {
c, err := r.Cookie("storage")
if err != nil {
panic(err.Error())
}
c.Name = "Deleted"
c.Value = "Unuse"
c.Expires = time.Unix(1414414788, 1414414788000)
}
func readCookieHandler(rw http.ResponseWriter, r *http.Request) {
c, err := …Run Code Online (Sandbox Code Playgroud) 我试图在编程环境中理解同构和同态,需要一些帮助.
在FPiS一书中,它解释了:
让我们从同态开始:
"foo".length + "bar".length == ("foo" + "bar").length
Run Code Online (Sandbox Code Playgroud)
这里,长度是String to Int保留幺半群结构的函数.
为什么这是一个同态?
为什么它保留了幺半群结构?
例如map在list函数上是同态吗?
关于同构,我从一本书中得到了以下解释:
M和N之间的幺半群同构具有两个同态f和g,其中f和T g以及g和T f都是同一性函数.例如,串联的String和List [Char] monoid是同构的.两个布尔幺半群(假,||)和(真,&&)也是同构的,通过!(否定)功能.
为什么(false, ||), (true, &&)和String and List[Char] monoids with concatenation同构?
我正在使用Webpack 4并安装" font-awesome": "^4.7.0"in package.json.然后我尝试将其导入到我的内容中index.scss,如下所示:
@import '~font-awesome/scss/font-awesome.scss';
@import '~bootstrap/scss/bootstrap.scss';
Run Code Online (Sandbox Code Playgroud)
我有以下错误消息:
ERROR in ./src/index.scss (./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss)
Module not found: Error: Can't resolve '../fonts/fontawesome-webfont.eot' in '/Volumes/Develop/react-reason/cockpit/src'
@ ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss 7:414-457
ERROR in ./src/index.scss (./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss)
Module not found: Error: Can't resolve '../fonts/fontawesome-webfont.eot?v=4.7.0' in '/Volumes/Develop/react-reason/cockpit/src'
@ ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss 7:332-383
ERROR in ./src/index.scss (./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss)
Module not found: Error: Can't resolve '../fonts/fontawesome-webfont.svg?v=4.7.0' in '/Volumes/Develop/react-reason/cockpit/src'
@ ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss 7:806-857
ERROR in ./src/index.scss (./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss)
Module not found: Error: Can't resolve '../fonts/fontawesome-webfont.ttf?v=4.7.0' in '/Volumes/Develop/react-reason/cockpit/src'
@ ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./src/index.scss 7:711-762
ERROR in …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用https://www.testcontainers.org/固有的https://github.com/testcontainers/testcontainers-scala,如下所示:
final class MessageSpec extends BddSpec
with ForAllTestContainer
with BeforeAndAfterAll {
override val container = GenericContainer("sweetsoft/sapmock").configure{ c =>
c.addExposedPort(8080)
c.withNetwork(Network.newNetwork())
}
override def beforeAll() {
}
feature("Process incoming messages") {
Run Code Online (Sandbox Code Playgroud)
当我使用命令运行测试时sbt test,出现以下异常:
15:22:23.171 [pool-7-thread-2] ERROR [sweetsoft/sapmock:latest] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [32775] should be listening)
at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:582)
Run Code Online (Sandbox Code Playgroud)
该图像是本地图像:
docker images
REPOSITORY TAG IMAGE ID CREATED …Run Code Online (Sandbox Code Playgroud)