News for hackers. Stuff that matters.
Re:How I Learned to Stop Worrying and Love the State Machine by eschew on Tuesday February 27, 2018 @03:14AM (#16471859)
mkPlayer can be simplified further!

  mkPlayer :: Maybe Weapon -> Class -> Either Error Player

  mkPlayer (Just Staff) Warrior = Left "A Warrior cannot equip a Staff"
  mkPlayer (Just Sword) Wizard = Left "A Wizard cannot equip a Sword"
  mkPlayer weapon klass = Right (Player weapon klass)
Re:How I Learned to Stop Worrying and Love the State Machine by yen223 on Tuesday February 27, 2018 @03:51AM (#16472026)
You lose exhaustiveness checks if new weapons or classes were added though. May or may not be worth the trade-off.