Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Paweł Świątkowski
@katafrakt@genserver.social  ·  activity timestamp 2 weeks ago

Recently I started to write #Elixir in a bit different way

https://katafrakt.me/2025/09/23/ocaml-flavoured-elixir/

katafrakt’s garden

My OCaml-flavoured Elixir style

Inline anonymous functions + result-pipeline helpers = flatter, top-down reading flow

AkkomaGenServer Social

  • Copy link
  • Flag this post
  • Block
elfenlaid
@elfenlaid@mastodon.social replied  ·  activity timestamp 2 weeks ago

@katafrakt That's a nice technique!

Though, one thing that tripped me over using a similar approach is an early result wrapping.

In other words, the code feels more conventional when `get_*` methods return `struct{} | nil` and you reach for `{:error, error}` when it's really needed, like in the post's example.

It's not that bad either way, there could be a helper that translates errors `Result.map_error`, but it feels a bit too out of place in Elixir, at least for me.

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.13 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login