hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.5K
active users

I hate it when I make an official release of a program with an ugly snippet of code that I can't figure out how to write more cleanly, only to come up with a solution 10 minutes after pushing the release. I just make the change in the dev branch so it gets incorporated into the next version.

In my defense, the thing I was overlooking was that #Haskell's Maybe type is an instance of Foldable. It's not the kind of data type that exactly screams Foldable, is it?

Side note: I should use Hoogle's search by type signature feature more frequently. I needed a function that looked like this: Monad m => (a -> m ()) -> Maybe a -> m (), which is literally just mapM_.

hoogle.haskell.orgHoogle
Boyd Stephen Smith Jr.

@me When in doubt, always check to see if `traverse` matches the function you need. It's odd how often `traverse` (or some variant, like `mapM` or `traverse_`) is what you want.

@me That's kinda like forgetting that `for` / `foreach` loops exist. But, ya know, it happens. :)

@BoydStephenSmithJr Yeah hlint is my friend. It tends to remind me of stuff like that.

@me I like that hlint + hls can go ahead an apply the transform for you a lot of time.

I do which it provided a code action for ignore (just) this hint for (just) this definition, tho.

@BoydStephenSmithJr I haven't really looked into HLS. Does it integrate well with Emacs?

@me I don't use emacs, but it works well in Neovim and VS Codium. I've heard it's better in emacs than in vim, but haven't verified that.