elm

Effects.tick replacement for elm 0.17

梦想的初衷 提交于 2019-12-24 15:39:22
问题 As it's stated in the upgrade guide, Effects is being replaced by this new Applicative Functor-like thing Cmd . I don't see any trace of a clue as to where Effects.tick might be hiding, or how it could be reimplemented. From the looks of things, Process.sleep might be the right answer, something like Task.perform errorHandler (\x -> x) <| Process.sleep <| 500 * Time.millisecond would allow the process to wait 500 milliseconds before issuing the next message / action. I'm just not sure if this

How to use Fields in Elm 0.13

三世轮回 提交于 2019-12-24 12:39:05
问题 I have been trying to get the fields to work, but keep failing. I have also been trying to look for examples, but the only examples I could find are using Elm 0.14, which use the new Channel API which isn't available in Elm 0.13. So I started from the example offered in the catalog import Graphics.Input.Field (..) import Graphics.Input (..) name : Input Content name = input noContent nameField : Signal Element nameField = field defaultStyle name.handle identity "Name" <~ name.signal And in

How do I get the current date in elm?

懵懂的女人 提交于 2019-12-24 06:44:15
问题 I'm trying to figure out how to get the current date in elm in version .17. I see that they added a Date module to .17 but I haven't found any examples on how it's used. Has anyone figured out how to do this? Edit: In trying to retrofit this solution, I hit another stumbling block. I'm trying to trigger setting the date and then calling another Msg to do something else. But I'm still getting {} for a date. import Html.App as App import Html exposing (..) import Time exposing (Time) import

Submitting a form from elm code

走远了吗. 提交于 2019-12-24 05:29:06
问题 I have this frameset division: <frameset cols="*,200"> <frame name="main" src="/main.html"> <frame name="sidebar" src="/sidebar"> </frameset> And this is my elm logic is inside main.html : import Html exposing (..) import Html.Attributes exposing (..) view : Model -> Html Msg view model = Html.form [method "POST", action "/sidebar", target "sidebar" ] [ input [ type_ "text" ,placeholder "user"] [], input [ type_ "password", placeholder "password"] [], input [ type_ "submit" ,value "Submit"] [

Elm: how to use an iframe

旧城冷巷雨未停 提交于 2019-12-23 15:39:25
问题 I want to render an iframe given a String input. For example, I have some string of HTML like this: str = "<!DOCTYPE html><html><head></head><body>HELLO ELM</body></html>" In JS I would do this by setting innerHtml on the iframe . For now, I'm trying to just get the iframe to render anything at all, but haven't had success. I'm trying this sort of thing: iframe [] [ body [] [ div [][text "hi"], div [][text "hi"] ] ] Once I get it working with a list of HTML nodes, I'll move onto making it

Elm - Check the Type of a value

a 夏天 提交于 2019-12-23 12:35:40
问题 Does a function exists that checks the Type of a variable in an Elm? For example (repl): numberTwo = 2 ..... returnType numberTwo "number" : String The motivation for this is that when you are using Signal.map[n] the situation usually arises that not all of the arguments to the function to be applied are Signals - they then usually have to be 'promoted' to Signals using Signal.constant - if I could check the type of such arguments, I could create a function Signal.allSigMap[n] that would turn

How to add an onClick event handler to a canvas shape in Elm?

馋奶兔 提交于 2019-12-23 12:04:43
问题 Is it possible to add an onClick event handler to Graphics.Collage.square ? I'd like to know the relative position of the click. In Javascript, I could do something like this: var canvas = document.getElementById('canvas'); var canvasPosition = { x: canvas.offsetLeft, y: canvas.offsetTop }; canvas.addEventListener('click', function(event) { console.log(event.x - canvasPosition.x, event.y - canvasPosition.y); }, false); Is that possible to do something similar in Elm? Example would be

Mock dependency in Elm

怎甘沉沦 提交于 2019-12-23 11:24:14
问题 In every elm file, dependencies to be imported are declared at the top. Is there a way, while testing the application, to mock a dependency? For example, suppose I have an application using the HTTP module to make an ajax request. When I test my module, I would like to avoid to make the actual ajax request, but I'd like to have a mocked HTTP module which will return a fake response just for the sake of testing. How could I do this? 回答1: Since Elm is a pure functional language, you often don't

Simple program compiled without error gives a white page

跟風遠走 提交于 2019-12-23 10:06:34
问题 I compiled the "Hello world" program import Html exposing (text) main = text "Hello, World!" with elm 0.17 on Windows, without compile errors: elm make hello.elm --output index.html When I open Chrome on index.html, I get a blank page. Chrome's console shows 2 errors in index.html : Uncaught ReferenceError: _elm_lang$virtual_dom$VirtualDom$text is not defined Uncaught ReferenceError: Elm is not defined If I run the elm-reactor on that file, I also get a white page, and similar errors in the

Simple program compiled without error gives a white page

给你一囗甜甜゛ 提交于 2019-12-23 10:06:12
问题 I compiled the "Hello world" program import Html exposing (text) main = text "Hello, World!" with elm 0.17 on Windows, without compile errors: elm make hello.elm --output index.html When I open Chrome on index.html, I get a blank page. Chrome's console shows 2 errors in index.html : Uncaught ReferenceError: _elm_lang$virtual_dom$VirtualDom$text is not defined Uncaught ReferenceError: Elm is not defined If I run the elm-reactor on that file, I also get a white page, and similar errors in the