Last active
August 26, 2019 01:43
-
-
Save Porges/c8b5f8844ef9892d3b29c47c412edb0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, RecordWildCards #-} | |
import Data.Monoid | |
data DFA a r where | |
DFA :: { transition :: a -> Endo s, initial :: s, result :: s -> r } -> DFA a r | |
run :: Foldable f => DFA a r -> f a -> r | |
run DFA{..} input = result (foldMap transition input `appEndo` initial) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment