Good #haskell #gamedev session last night. I finished the map animation support nicely; at least until I followed a suggestion from the chat to use Vector instead of List, for performance.

I mean, it was a good suggestion, but the JSON library didn't support decoding lists into vectors and finding the derived typeclass was a bit tricky (because I don't know much about that 😅 ).

Anyway, good stuff and learned a lot (again @dpwiz is to blame for that!).

Follow

@reidrac writing parsers is a good way to understand the language. It trains a few things about composition, assembling code from smaller parts.

Type classes are Haskell's power tools of the trade (:
They encode many common patterns about types and make that distinct coding flow of "delegate this away and let me focus on my types here" (that you did with the Vector instance).

You can use the Typeclassopedia for an overview of what you can encounter in the wild and where they can be helpful. You don't have to remember everything, just the names of the things and maybe the context where you may encounter them.

The most important are Semigroup/Monoid, Functor/Applicative/Monad, and Functor/Foldable/Traversable. Recently dual-variable classes like Bifunctor are starting to get prominence too.

wiki.haskell.org/Typeclassoped

@reidrac Just found something that can be a good kata on parsers and typeclasses.

And not without utility! You can add some CLI options to your game while getting acquainted with the basics.

lhbg-book.link/05-glue/04-optp

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.