Boiled Egg
Deterministic boiled egg. Cold egg direct from refrigeration (4°C) into boiling water (100°C).
Inputs
- 1 large egg (approx. 60g, refrigerated)
- Water: sufficient volume to submerge egg with 25mm clearance
- Ice water bath: 50/50 ice and tap water
Execution
- Bring water to a vigorous rolling boil.
- Pierce the air cell at the blunt end using a pin to relieve internal pressure.
- Lower egg directly into the boil on a slotted spoon. Reduce heat slightly to prevent shell fracture against the pan.
- Timer begins on immersion:
- 6m 00s: Jammy yolk, fully set white.
- 7m 30s: Warm custardy center.
- 10m 00s: Hard set, zero grey ring.
- Plunge immediately into the ice bath for 180 seconds to arrest cooking.
- Peel submerged or under cold running water starting from the blunt end.
module BoiledEgg where
data Firmness = Soft | Medium | Hard deriving (Show, Eq)
data Raw = Raw deriving (Show)
data Pricked = Pricked deriving (Show)
data Boiled = Boiled Firmness deriving (Show)
data Chilled = Chilled Firmness deriving (Show)
data Peeled = Peeled Firmness deriving (Show)
newtype Egg state = Egg state deriving (Show)
data ColdWater = ColdWater deriving (Show)
data RollingBoil = RollingBoil deriving (Show)
data GentleBoil = GentleBoil deriving (Show)
data IceBath = IceBath deriving (Show)
boilWater :: ColdWater -> RollingBoil
boilWater ColdWater = RollingBoil
prick :: Egg Raw -> Egg Pricked
prick (Egg Raw) = Egg Pricked
reduceHeat :: RollingBoil -> GentleBoil
reduceHeat RollingBoil = GentleBoil
cook :: Firmness -> Egg Pricked -> GentleBoil -> Egg Boiled
cook firmness (Egg Pricked) GentleBoil = Egg (Boiled firmness)
chill :: Egg Boiled -> IceBath -> Egg Chilled
chill (Egg (Boiled f)) IceBath = Egg (Chilled f)
peel :: Egg Chilled -> Egg Peeled
peel (Egg (Chilled f)) = Egg (Peeled f)
makeBoiledEgg :: Firmness -> Egg Raw -> ColdWater -> IceBath -> Egg Peeled
makeBoiledEgg firmness rawEgg coldWater iceBath =
let rollingBoil = boilWater coldWater
gentleBoil = reduceHeat rollingBoil
prickedEgg = prick rawEgg
boiledEgg = cook firmness prickedEgg gentleBoil
chilledEgg = chill boiledEgg iceBath
in peel chilledEggLet the boiling process be modeled as a sequence of typed state transformations given parameters , , and :
where parameters and heat preparation are specified by:
The composite transformation is defined by function composition:
The commutative diagram below illustrates the sequential state pipeline:
graph TD
R["Egg Raw"] -->|"prick"| P["Egg Pricked"]
P -->|"cook with f and b(w)"| B["Egg Boiled"]
B -->|"chill in i"| C["Egg Chilled"]
C -->|"peel"| E["Egg Peeled"]
R -.->|"makeBoiledEgg with f, w, i"| E