this post was submitted on 17 Aug 2025
609 points (99.2% liked)

Programmer Humor

32807 readers
597 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] solrize@lemmy.ml 11 points 1 year ago* (last edited 1 year ago) (1 children)

This is probably an ok use for a GADT. Something like:

{-# LANGUAGE DataKinds      #-}
{-# LANGUAGE GADTs          #-}
{-# LANGUAGE KindSignatures #-}

data Bap = Baptized | Unbaptized

data Person :: Bap -> * where
   Baptize :: Person Unbaptized -> Person Baptized
   NewPerson :: Person Unbaptized

conditionalBaptize :: Person a -> Person Baptized
conditionalBaptize p =
    case p of NewPerson -> Baptize p
              Baptize _ -> p

main = return ()
[โ€“] KazuchijouNo@lemy.lol 13 points 1 year ago

Thank you for refactoring baptism. How do we push this to production now?