This journal is generated by AI

Haskell Type Classes: Functors, Applicatives, and Monoids

This week I dove deep into Haskell’s type class hierarchy, working through Learn You a Haskell and the CIS 194 course materials. The key insight is understanding how these abstractions compose to enable powerful, generic programming.- Functors are types that can be mapped over. The fmap function can be viewed as “lifting” a function: fmap :: (a -> b) -> (f a -> f b) transforms an ordinary function into one that works inside a functor context

  • The functor laws ensure predictable behavior: fmap id = id (identity preservation) and fmap (f . g) = fmap f . fmap g (composition preservation)
  • Applicatives extend functors by allowing wrapped functions to be applied to wrapped values using <*>. Lists as applicatives represent non-deterministic computations where [(+3),(*2)] <*> [1,2] produces all combinations
  • ZipList provides an alternative applicative instance for lists using pairwise application instead of all combinations
  • Monoids provide an identity element (mempty) and an associative binary operation (mappend). The foldMap function reveals why monoids matter: the identity handles empty structures and the associative operation combines values reliably
  • Use foldl' from Data.List instead of foldl to avoid building huge thunks; foldr is better when the folding function can short-circuit

Sources:

Using tmux for PowerShell in Windows Terminal

I published a blog post on getting tmux session persistence in Windows Terminal while keeping PowerShell as the default shell. The solution runs tmux through WSL but configures it to spawn pwsh.exe for new panes.

  • Create thin wrapper scripts (tmux.ps1, tmux.cmd) so tmux from Windows means wsl tmux
  • A helper script tmux-pwsh.ps1 creates or attaches to named sessions with pwsh.exe -nologo as the default command
  • The key trick: send set-option default-command via tmux -C attach because running wsl tmux set-option immediately after session creation has a race condition where the session isn’t ready
  • After setup, splitting panes and creating windows in that session will all start PowerShell in the Windows environment

Elite Performance Through Preparation

An insightful thread by Sandeep Palakodeti on what separates elite performers from amateurs. The core message: greatness is not about taking risks but eliminating variance through preparation.

  • When experts operate at their limit, they’re not “trying hard”—they’re executing scripts that have been debugged for decades through deliberate, high-fidelity repetition
  • Fear is the biological response to the unknown; when you’ve accounted for every variable, fear is replaced by focus
  • Elite performers aim below the edge of their ability because that’s where consistency lives
  • Every question gets answered upstream, every branch point gets a playbook—by the time the moment arrives, they’re executing state changes, not solving problems
  • “Don’t worship the risk. Worship the work that made the risk irrelevant.”