Rewrite update_lexicon script in Haskell