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_
.
like this
Roufnichan LeGauf 🌈
in reply to Jonathan Lamothe • • •whenJust
(which is provided by various libraries on hackage), but in the end, I realized I could just usefor_
from base. It's amazing how many functions are justtraverse
(ortraverse_
).Jonathan Lamothe likes this.
Jonathan Lamothe
in reply to Roufnichan LeGauf 🌈 • •case
statement on aMaybe
orEither
and one of the branches is-> return ()
, I die a little inside, because I know there's probably a better way that I'm just not seeing.Boyd Stephen Smith Jr.
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Boyd Stephen Smith Jr. • •traverse
even exists. 🙃Boyd Stephen Smith Jr.
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Boyd Stephen Smith Jr. • •hlint
is my friend. It tends to remind me of stuff like that.Boyd Stephen Smith Jr.
in reply to Jonathan Lamothe • • •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.
Jonathan Lamothe
in reply to Boyd Stephen Smith Jr. • •Boyd Stephen Smith Jr.
in reply to Jonathan Lamothe • • •