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) andfmap (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). ThefoldMapfunction reveals why monoids matter: the identity handles empty structures and the associative operation combines values reliably - Use
foldl'fromData.Listinstead offoldlto avoid building huge thunks;foldris better when the folding function can short-circuit
Sources:
- Learn You a Haskell: Functors, Applicative Functors and Monoids
- CIS 194: Higher-order programming and type inference
- Haskell Wiki: Foldr Foldl Foldl’
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) sotmuxfrom Windows meanswsl tmux - A helper script
tmux-pwsh.ps1creates or attaches to named sessions withpwsh.exe -nologoas the default command - The key trick: send
set-option default-commandviatmux -C attachbecause runningwsl tmux set-optionimmediately 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.”
Obsidian Links
- Haskell Applicative
- Haskell Pattern Matching
- Haskell High-Order Function Composition
- Miran Lipovača - Learn You a Haskell for Great Good Chapter 11. Functors, Applicative Functors and Monoids (Highlights)
- Miran Lipovača - Learn You a Haskell for Great Good Chapter 6. Higher Order Functions (Highlights)
- Haskell Authors - Foldl (Highlights)
- Sandeep Palakodeti - The Tippy Top (Highlights)
- ♯ Use tmux for PowerShell in Windows Terminal