我是榆树的新人.看到一种允许你开发前端内容的函数式语言很有意思.现在,即使我很好地遵循这里描述的步骤,我仍然遇到模块问题.
代码是
module Main where
import Html exposing ( Html )
import Signal
main : Signal Html.Html
main = Html.text "This should work."
|> Signal.constant
Run Code Online (Sandbox Code Playgroud)
我以前elm-reactor -a='localhost'
能够查看我的输出.但我收到一个错误,无法找到模块"HTML":
I cannot find find module 'Html'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json
Run Code Online (Sandbox Code Playgroud)
(注意双重"发现"嘿嘿)修复建议没有帮助我.或者可能是因为我无法正确理解.json文件的使用.
ELM-的package.json:
{
"version": "1.0.0",
"summary": "testing elm",
"license": "BSD3",
"source-directories": [
".",
"./bin/"
], …
Run Code Online (Sandbox Code Playgroud) 根据HTML5拖放API 的文档,删除元素时会触发两个事件:
drop
事件是由放置目标发射dragend
事件从拖动源发射在进行简单的测试(参见片段)时,drop
事件总是在事件发生之前触发dragend
(至少在Chrome中),但我在规范中找不到有关这些事件排序的任何信息.
是定义了这些事件的顺序,还是可以按任意顺序自由发射?
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
console.log("drop at " + Date.now());
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
function dragend(ev) {
console.log("dragend at " + Date.now());
}
Run Code Online (Sandbox Code Playgroud)
#div1 {
background-color: red;
height: 100px;
width: 100px;
}
#drag1 {
background-color: green;
height: 50px;
width: 50px;
}
Run Code Online (Sandbox Code Playgroud)
<div>Drag the green square in to the red one</div>
<div id="div1" ondrop="drop(event)" …
Run Code Online (Sandbox Code Playgroud)我用脚本在我的表上创建了一些约束而没有指定约束名.结果,我最终遇到了限制FK__DOC_OBGS___kntr___54E63309
,例如.
是否可以在不指定确切约束名称的情况下删除约束?
例如,像这样的东西(不起作用)
ALTER TABLE DOC_OBGS_10 DROP CONSTRAINT LIKE 'FK__DOC_OBGS___kntr%'
Run Code Online (Sandbox Code Playgroud)
问题是我们有很多数据库与这个表,我需要从表中删除所有约束,但显然每个表的名称是不同的.
我得到了榆树的一瞥,但我一直在努力应对信号和键盘按键.下面的代码是start-app包的示例.当我按下空格键时,我希望计数器增加.在下面的例子中如何完成?
import Html exposing (div, button, text)
import Html.Events exposing (onClick)
import StartApp.Simple as StartApp
main =
StartApp.start { model = model, view = view, update = update }
model = 0
view address model =
div []
[ button [ onClick address Decrement ] [ text "-" ]
, div [] [ text (toString model) ]
, button [ onClick address Increment ] [ text "+" ]
]
type Action = Increment | Decrement
update action model =
case …
Run Code Online (Sandbox Code Playgroud) 在Haskell中,您可以使用:t
在ghci中查找函数的类型,在elm repl中是否存在等效函数?
要在elm中创建列表,您可以执行以下操作:
list = ["test","test2"]
Run Code Online (Sandbox Code Playgroud)
但是如何为测试目的创建Dict?
有没有办法在Elm中定义没有参数的订阅端口?
就像是:
port updateTime : () -> Sub msg
Run Code Online (Sandbox Code Playgroud)
使用此代码,我收到"端口'updateTime'具有无效类型"的错误
随着代码:
port updateTime : (String -> msg) -> Sub msg
Run Code Online (Sandbox Code Playgroud)
它正在工作,但我不需要从javascript函数向Elm发送任何内容.
如果我定义monad变换器类型Identity
,它就能够派生Show
实例.
newtype IdentityT f a =
IdentityT { runIdentityT :: f a }
deriving (Show)
Run Code Online (Sandbox Code Playgroud)
将衍生出来
instance Show (f a) => Show (IdentityT f a)
Run Code Online (Sandbox Code Playgroud)
但是,如果我定义monad变压器类型 Maybe
newtype MaybeT m a =
MaybeT { runMaybeT :: m (Maybe a) }
deriving (Show)
Run Code Online (Sandbox Code Playgroud)
我收到了错误
• No instance for (Show (m (Maybe a)))
arising from the first field of ‘MaybeT’ (type ‘m (Maybe a)’)
Run Code Online (Sandbox Code Playgroud)
既然Maybe a
有一个Show
实例,我希望它可以工作和派生
instance Show (m (Maybe a)) => Show (MaybeT …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 RVM 安装 ruby-1.9.3-p194 但它失败了。看起来原因是它试图从错误的 url 下载源。我得到的输出是:
% rvm install ruby-1.9.3-p194
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-1.9.3-p194.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/robertlooby/.rvm/rubies/ruby-1.9.3-p194, this may take a while depending on your cpu(s)...
ruby-1.9.3-p194 - #downloading ruby-1.9.3-p194, this may take a while …
Run Code Online (Sandbox Code Playgroud) elm ×5
clojure ×1
constraints ×1
elm-port ×1
function ×1
haskell ×1
html ×1
html5 ×1
javascript ×1
keyboard ×1
rvm ×1
sql ×1
sql-server ×1
types ×1