Skip to content

Commit d30dfe0

Browse files
committed
jack's suggestions
1 parent 85b5d8d commit d30dfe0

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

copy/entries/five-point-haskell-1.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,11 @@ _deep_ inside a function inside a function inside a function, which itself is
209209
called against the prod database. I guarantee it.
210210

211211
To ensure this never happens, we can use closed phantom types using
212-
`DataKinds`:
212+
`DataKinds` (made nicer with `TypeData` post-GHC 9.6):
213213

214214
```haskell
215-
data Env = Prod | Test
215+
-- type data = declare a closed kind and two type constructors at the type level using -XTypeData
216+
type data Env = Prod | Test
216217

217218
newtype DbConnection (a :: Env) = DbConnection Connection
218219

@@ -560,6 +561,11 @@ getUser conn uid = do
560561
Pushing it to the driver level will also unify everything with the driver's
561562
error-handling system.
562563

564+
These ideas are elaborated further in one of the best Haskell posts of all
565+
time, [Parse, Don't Validate][parse-dont-validate].
566+
567+
[parse-dont-validate]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
568+
563569
### Boolean Blindness
564570

565571
At the heart of it, the previous examples' cardinal sin was "boolean
@@ -608,6 +614,13 @@ data LegState = Extended | Retracted
608614
deployThrusters :: LegState -> IO ()
609615
```
610616

617+
Note that `Maybe` itself is not immune from "semantic blindness" --- if you
618+
find yourself using a lot of anonymous combinators like `Maybe` and `Either` to
619+
get around boolean blindness, be aware of falling into [algebraic
620+
blindness][algebraic-blindness]!
621+
622+
[algebraic-blindness]: https://github.com/quchen/articles/blob/master/algebraic-blindness.md
623+
611624
### Resource Cleanup
612625

613626
Clean-up of finite system resources is another area that is very easy to assume
@@ -840,3 +853,8 @@ for me to devote time to researching and writing these posts. Very special
840853
thanks to my supporter at the "Amazing" level on [patreon][], Josh Vera! :)
841854

842855
[patreon]: https://www.patreon.com/justinle/overview
856+
857+
Also thanks to [_jackdk_'s comment][jackdk] for highlighting extra resources
858+
and context that I believe are very useful and relevant!
859+
860+
[jackdk]: https://www.reddit.com/r/haskell/comments/1qtxnsm/comment/o3889uy

copy/entries/five-point-haskell.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ church encodings?
223223
* Typed holes to help program
224224
* Instance resolution to auto-derive programs, Deriving Via, etc.
225225

226+
Actually yeah maybe we should go all-in on Code Gen.
227+
226228
Perseverance of the Saints
227229
---------------------------
228230

0 commit comments

Comments
 (0)