Feed Aggregator Page 672
Rendered on Thu, 25 Nov 2021 18:33:57 GMT
Rendered on Thu, 25 Nov 2021 18:33:57 GMT
via Erlang/OTP | News by Henrik Nord on Wed, 24 Feb 2021 00:00:00 GMT
OTP 24 Release Candidate 1via Erlang/OTP | News by Henrik Nord on Wed, 16 Dec 2020 00:00:00 GMT
Erlang/OTP 23.2 is the second maintenance patch release for OTP 23, with mostly bug fixes as well as a few improvements.via Elm - Latest posts by @terezka Tereza Sokol on Mon, 26 Jul 2021 10:26:36 GMT
You have to add a margin
! Let me know if that solves your problem.
via Elm - Latest posts by @John_Orford John Orford on Mon, 26 Jul 2021 08:47:53 GMT
OK, it looks like Elm owns it’s own div tag while running with Chrome
I.e. this does not work:
<div >
<div id="elm-app" style="height: 500px;"></div>
</div>
but this does:
<div style="height: 500px;">
<div id="elm-app" ></div>
</div>
via Elm - Latest posts by @John_Orford John Orford on Mon, 26 Jul 2021 08:22:56 GMT
OK, I noticed an issue…
On Chrome the whole page is filled (I avoided “height fill”).
But Firefox render fine.
Hmm. Any more tips would be super helpful. Thanks!
via Elm - Latest posts by @John_Orford John Orford on Mon, 26 Jul 2021 07:38:19 GMT
Perfect! Thanks.
I am getting back to Elm after a long time out. Still my favourite language - Elm-UI is such a great lib also : )
via Elm - Latest posts by @jfmengels Jeroen Engels on Mon, 26 Jul 2021 06:43:59 GMT
Cool example for Debug.log! I hadn’t thought of that.
elm-review
uses the same idea for its testing module. For instance, when your rule suggests a fix, the testing module checks whether the source code after the fix matches what was expected. If it doesn’t, it lets you know by showing you the actual and expected source code.
But sometimes, this can be hard to read when the difference is only whitespace, which is why when that happens a special message shows up where the whitespace is highlighted, and it looks like this:
The red at the top is the test title (colored by elm-test
), then comes the error type (Fixed code mismatch) colored by the test module.
I have been made aware of that these colors don’t disappear when you run elm-test
with --no-color
, which is not ideal. I further described this approach in Great compiler messages? Great test failure messages!
via Elm - Latest posts by @jxxcarlson James Carlson on Mon, 26 Jul 2021 03:56:09 GMT
I’d like to put in a few words for Richard Feldman’s console-print library, which gives a convenient way to “print formatted text to the console using ANSI escape sequences.” This can be quite helpful in debugging or otherwise peering into the operation of your code.
As a silly example, consider the Collatz function. If n == 1
, then collatz n == 1
. If n is even, then collatz n = n // 2
, otherwise collatz n = 3n + 1
. Then in elm repl
we have this:
Nice colors! No big deal here, but this comes in quite handy when the output is complicated and you need to be able to scan through it to find what you want.
Below is the code. The important part is Console.magenta
, which prints its argument to the terminal in magenta. You could also use, say Console.bgCyan >> Console.white
in place of this to have white text on a cyan background.
collatz n =
let
_ = Debug.log (Console.magenta "collatz") n
in
if n == 1 then
1
else if modBy 2 n == 0 then
collatz (n // 2)
else
collatz (3 * n + 1)
Below is a more substantial example from a parser project I was working on. I needed a way to track the state of the parser as it was chugging along. Different background colors were used to highlight different fields in the state. The gain in readability was a life-saver for me.
With Albert Dahlin’s elm-posix, there are likely many more uses of the console-print library.
via Elm - Latest posts by @razze Kolja Lampe on Mon, 26 Jul 2021 03:18:35 GMT
I’ve hit the same problem on friday, so I would be interested in that too
via Elm - Latest posts by @ratata rara on Sun, 25 Jul 2021 18:15:02 GMT
finaly i have reached my rank in valornat by using https://proboosting.net/
via Elm - Latest posts by @system system on Sun, 25 Jul 2021 14:22:16 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @MeWhit on Sun, 25 Jul 2021 00:52:33 GMT
I succeed to format your code and i cant realy tell you whats was wrong but, this code work.
https://ellie-app.com/dPJrVG4Pbv5a1
via Elm - Latest posts by @MeWhit on Sun, 25 Jul 2021 00:50:27 GMT
You can share your code with https://ellie-app.com/new.
Its will be more easier for us to help you.
via Elm - Latest posts by @Zack_slm zack on Sat, 24 Jul 2021 23:01:45 GMT
Hello,
I have the error can’t find element #input when trying to compile this code.
Can anyone help please
The code
import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onSubmit, onInput)import String exposing (fromInt)import Basicsimport Array exposing (Array)type alias Model = { input : Maybe Int , output : Maybe Int }-- We initialize the default value of our modelinit : Modelinit = { input = Nothing , output = Nothing }-- We render a view given the modelview : Model -> Html Msgview model = div [] [ input [ type_ "number", placeholder "Enter a number", value (maybeIntToString model.input), onInput SetValue ] [] , br [] [] , button [ onClick SubmitForm, id "compute" ] [text "Calculate"] , div [] [ text "output : ", span [id "output"] [ text <| maybeIntToString model.output]] ]-- Helper functionmaybeIntToString : Maybe Int -> StringmaybeIntToString model = case model of Nothing -> "" Just v -> fromInt vtype Msg = NoOp | SubmitForm | SetValue Stringupdate : Msg -> Model -> Modelupdate msg model = -- With Debug.log we log into the browser console, see https://package.elm-lang.org/packages/elm-lang/core/3.0.0/Debug case Debug.log "msg" msg of NoOp -> model SetValue v -> { model | input = String.toInt v } SubmitForm -> { model | output = Maybe.map computeNextValue model.input }-- To implementcomputeNextValue : Int -> IntcomputeNextValue x = List.sum (numberToList x) + xnumberToList : Int -> List IntnumberToList number = String.fromInt number -- convert our Int to a String |> String.split "" |> List.filterMap String.toInt main : Program () (Model) Msgmain = Browser.sandbox({ init = init, view = view, update = update})
via Elm - Latest posts by @IloSophiep on Sat, 24 Jul 2021 19:35:14 GMT
First of all: Thanks for the awesome looking library! I recently wanted to do some charts for a private project but ended up not being sure what to use in Elm for that. Because it wasn’t that important i just went with some table display instead. Seeing this announcement made me go back and try it with some fancy charts!
My problem: I might be missing something real obvious, but i can’t seem to get the charts to respect the given amount of space? I have the elm app embeded:
<div id="elm-history-graph"></div>
and
main : Program String Model Msg
main =
Browser.element
and stuff and i am just trying for starters to render it inside:
view _ =
let
data =
[ ...
]
content =
C.chart
[ CA.width 300
]
[ C.xLabels []
, C.yLabels [ CA.withGrid ]
, C.series .x
[ C.interpolated .y [ CA.monotone ] []
, C.interpolated .z [ CA.monotone ] []
]
data
]
in
Html.div
[ Html.Attributes.style "width" "300px" ]
[ content ]
With most of the the charts stuff taking from a github example. But the chart’s labels are rendering outside of their container. Is that normal?
via Elm - Latest posts by @albertdahlin Albert Dahlin on Sat, 24 Jul 2021 15:28:17 GMT
It looks like the Elm package and the npm package are different versions. Try updating both, latest version is 1.0.2
.
via Elm - Latest posts by @kraklin Tomáš Látal on Fri, 23 Jul 2021 18:31:14 GMT
Hey @albertdahlin,
I have finally get to try your elm-posix
out. I have tried the HelloUser
example got two problems. First problem was when I have tried to run it I have got:
You found a bug!
Please report at https://github.com:albertdahlin/elm-posix/issues
Copy the information below into the issue:
IO Function "sleep" not implemented.
and second one was when I have tried to make and run the compiled version which gave me:
test.js:3518
fn.apply(app.ports.recv, msg.args);
^
TypeError: Cannot read property 'apply' of undefined
at Array.<anonymous> (/Users/tomas.latall/workspace/scrive/kontrakcja/frontend-elm/test.js:3518:8)
at Function.f (/Users/tomas.latall/workspace/scrive/kontrakcja/frontend-elm/test.js:2228:19)
at A3 (/Users/tomas.latall/workspace/scrive/kontrakcja/frontend-elm/test.js:68:28)
at Object.b (/Users/tomas.latall/workspace/scrive/kontrakcja/frontend-elm/test.js:1987:7)
any hints what I might have missed?
via Elm - Latest posts by @klemola Matias Klemola on Fri, 23 Jul 2021 16:46:26 GMT
Thank you! The idea of restarting cars that are in a gridlock is worth considering. Currently the cars have no way to escape in terms of pathfinding, as the rails they follow are blocked. One of the cars could reverse to clear the gridlock while others wait, or there might be an alternative path that the car can follow that bypasses the gridlock. Once I have improved the pathfinding to allow one of the solutions above, I can elect one of the cars as the leader (which is similar to stoppping/restarting) to avoid gridlocking again.
via Elm - Latest posts by @supermario Mario Rogic on Fri, 23 Jul 2021 15:32:51 GMT
The videos from the last Elm Online Meetup are now up!
I had some unfortunate technical issues so audience audio and a bit of Martin’s intro video wasn’t recorded (pro tip: never agree to upgrade audio drivers), but I think they should still be enjoyable for folks who couldn’t make it!
via Elm - Latest posts by @joelq Joël Quenneville on Fri, 23 Jul 2021 15:19:57 GMT
Yes, you can convert your Element msg
into an Html msg
using the Element.layout function.
You can also convert the other way, embedding HTML inside an element via the Element.html function. This means you can have HTML inside an element inside HTML inside an element …
You can see an example in this old gamejam project. I have an elm/html button
inside an elm-ui row
inside an elm/html div
.