Telegram Web Link
Test-only exports in Elm using Debug.todo

I've been noodling on this technique ever since I saw it used in mdgriffith/elm-ui in Element.explain. You write a function that takes Debug.todo as an argument so that you can only use it while developing locally or in your tests.

As an example of the utility of this function: we have a custom HTTP error type (it wraps up the request info with the response). We intentionally don't expose constructors for it, but I needed it to be able to use SimulatedEffect.Http.get from avh4/elm-program-test. So I need to be able to turn an Http.Error into one of our errors so that I can use our version of Expect. I wrote a helper function
httpErrorForTests :
(String -> Never)
-> Api.RequestData
-> Http.Error
-> Api.Error


Where Api.Error is our error type and that first argument can only be Debug.todo.

Anyways, here's a somewhat contrived example I cooked up for a discussion this morning that I thought might illustrate it. https://ellie-app.com/vbpDdBCfdgTa1

This is an example of how you can provide the same functionality as a caseof expression without even having to export the constructors of your opaque type. The example I can think of is if you're working with an Effect system. You might want your Effect type to be opaque. But then for your tests you need an effect handler. I think you can take this type of thing and run with it and end up with an Effect handler in your tests without needing to expose the constructors.

https://redd.it/1k02lh7

@reddit_elm
Elm Town 83 – Wonder: Meeting people where they are with Ryan Haskell

Kicking off the Wonder series, Ryan Haskell shares his approach to teaching Elm, his gap year adventures, and his current work at Brilliant. He gives insights into creating accessible learning materials, building games, and finding inspiration outside the Elm ecosystem.

Elm Town 83 – Wonder: Meeting people where they are with Ryan Haskell:

* https://elm.town/episodes/elm-town-83-wonder-meeting-people-where-they-are-with-ryan-haskell
* https://youtu.be/t40VX9rbXT0

https://redd.it/1k0uf0v

@reddit_elm
GoTutor | Online Go Debugger & Visualizer built with Elm

I've been working on Gotutor, a Go debugger and visualizer built with Elm!

Gotutor provides a visual representation of the execution flow, variable states, and goroutines, making it easier to understand concurrent code.

I can't imagine how this could be implemented using vanilla JS; writing it in a functional language like Elm was really easy and fun – just modify the model, draw it.

Choosing Elm was completely random though. Someone told me about this interesting frontend technology back in 2016, and ever since then, I wanted to try it in a side project. When the time came, I didn't even remember its name and only recalled its logo!

It's still in the early stages, but I'd love for you to check it out and give me some feedback. What features would you find most helpful?

https://gotutor.dev/

https://github.com/ahmedakef/gotutor

Happy Elming (and Go-ing)!

https://redd.it/1k5rq2c

@reddit_elm
small job!

Hi,

We're looking to hire a design-minded person to help out with a small project that is adjacent to the publishing industry. The project is actually in Gleam, Elm's descendant. Writing skills academic background are definitely a plus. This would be a part-time gig with about 5 months work, chill and possibility of more work if world domination is unlocked.

DM me if interested :)

https://redd.it/1kfc3gv

@reddit_elm
Elm Town 84 – Wonder: Elm all the way down with Justin Lubin

Justin Lubin sketches his journey from undergrad research at UChicago with Ravi Chugh on output-directed and bidirectional programming environments (Sketch-n-Sketch) to graduate work at UC Berkeley with Sarah E. Chasins, focusing on programming language theory, researching how statically-typed functional programmers write code, and beyond, to helping domain experts.

Elm Town 84 – Wonder: Elm all the way down with Justin Lubin:

* https://elm.town/episodes/elm-town-84-wonder-elm-all-the-way-down-with-justin-lubin
* https://youtu.be/tPpdckySUS8

https://redd.it/1l2o0qb

@reddit_elm
Using wrapped types in Elm is so much fun!

I really like how in Elm it's very low-effort to wrap types to make things easier to understand

For example, if I have a function like this, it doesn't tell me what each of the Int types represent
twoSum : List Int -> Int -> Maybe ( Int, Int )

twoSum_ : List Int -> Int -> Int -> Dict Int Int -> Maybe ( Int, Int )


Are the return values the Ints from the List or are they the indexes in the List? Which Int in twoSum\_ is an index? What do the keys and values in the Dict represent?

So I can add more information in the types by wrapping them in types which adds documentation because these wrapped types are more meaningfully-named types
type Target = Target Int
type Index = Index Int

twoSum : List Int -> Target -> Maybe ( Index, Index )

twoSum_ : List Int -> Target -> Index -> Dict Int Index -> Maybe ( Index, Index )


So now it's much easier to understand what each Int is for just by looking at the type signature, which makes it easier to implement the functions correctly

We can see twoSum takes in a List of Ints and a Target, then returns Maybe 2 Indexes

We can also see twoSum\ takes in the same parameters with an extra Index parameter and extra Dict Int Index parameter, so we know that twoSum\ keeps track of the current Index and the mappings of Int to Index

Implementing is more straightforward now, we can't as easily accidentally pass incorrect parameters
type Target = Target Int
type Index = Index Int

twoSum : List Int -> Target -> Maybe ( Index, Index )
twoSum nums target = twoSum_ nums target (Index 0) Dict.empty

twoSum_ : List Int -> Target -> Index -> Dict Int Index -> Maybe ( Index, Index )
twoSum_ nums (Target target) (Index i) toIndex =
case nums of
[] -> Nothing
first :: rest ->
case Dict.get (target - first) toIndex of
Just prevIndex -> Just ( prevIndex, Index i )
Nothing -> twoSum_ rest (Target target) (Index (i + 1)) (Dict.insert first (Index i) toIndex)


It's easy to see which Int is a value from the List Int, which is a Target, and which is an Index

This is a simple example, but this technique when used in larger codebases makes things much easier to understand

Rather than wondering "What does this Int represent?", you can know whether it's a Target or Index or UserId or a ProductId or whatever else, so you can't as easily mix them up

This makes writing Elm code more enjoyable and one of the many reasons why I find writing Elm code so much fun!

https://redd.it/1l6v9dd

@reddit_elm
What have you learned about hiring or working with Elm devs?

I’m doing some research on functional-first teams, especially ones that use Elm in production.

I’m curious:

* If you’ve hired Elm devs, what made someone stand out?
If you are* an Elm dev, what’s made you successful in interviews or teams?
* Any red flags or hidden strengths you’ve noticed?

Would love to hear your experiences 🙏

https://redd.it/1l865qx

@reddit_elm
Elm optimizations ideas

Elm is fast, and generally fast enough for making web applications, where handling things in less than 1/60th of a second is all the performance you need.

I have long worked on elm-review, where every 100ms speedup translates to... well, a 100ms speedup. During this work, I have often wondered how to make things faster, and I started writing the ideas I came up (or sometimes that others came up with).

Some of these made it into pull requests to elm-optimize-level-2, but most haven't.

I recently went through all of these notes, and decided it would be best if those were shared. I have therefore created this repository: jfmengels/elm-optimizations, where I will try to keep these ideas up to date.

I don't know that this is the best organization or medium yet, but it's probably better somewhere than nowhere. These ideas are meant to be discussed. Feel free to discuss them, in issues, in pull requests, on Slack, in the appropriate GitHub repository, etc.
(Also, ideas on how to organize or present the ideas is welcome)

Hopefully some of these will excite some of you, enough to help turn them into reality. See the README for a bit more details.

https://github.com/jfmengels/elm-optimizations

https://redd.it/1lbkuj8

@reddit_elm
A rewrite of L-System Studio
https://www.youtube.com/watch?v=dvPQ54irm4M

L-System Studio (source)

Features:

- 30+ presets
- Including the Koch Curve, Quadratic Gosper, and Square Sierpinski
- Unlimited iterations
- It uses lazy evaluation to generate, translate, and render L-Systems with billions trillions infinitely many symbols
- 2D camera
- Supports an infinite canvas since you can position the camera anywhere you want
- Supports panning horizontally and vertically
- Supports zooming in and out
- Performant
- Render 1,000,000 instructions per frame at 60 frames per second

https://redd.it/1lf8m6c

@reddit_elm
2025/10/19 18:42:29
Back to Top
HTML Embed Code: