kmp-dfa-0.1.0.1: KMP algorithm implementation, based on Deterministic Finite State Automata

Safe HaskellNone
LanguageHaskell2010

Algorithms.DFA.KMP.Automaton

Description

KMP algorithm implementation based on Deterministic Finite Automaton Automata lpws = the longets suffix which is a prefix length

Synopsis

Documentation

newtype Index Source #

Index to select the DFA states

Constructors

Index Int 

data Jump a Source #

Target of a transition

Constructors

Accept

final state

Hold a

hold on the stream

Step a

step the stream

Instances

Functor Jump Source # 

Methods

fmap :: (a -> b) -> Jump a -> Jump b #

(<$) :: a -> Jump b -> Jump a #

type Process a = a -> Jump (Automaton a) Source #

Machine transition

newtype Automaton a Source #

A wrapper do deal with cycle

Constructors

Automaton (Process a) 

data Interface a Source #

API

Constructors

Interface 

Fields

type Query a = Index -> Automaton a Source #

backend

core Source #

Arguments

:: Eq a 
=> Query a

backend

-> Interface a

behavior definition

-> Process a 

create a Resolve

run Source #

Arguments

:: Automaton a

initial machine state

-> [a]

stream of input

-> Maybe (Automaton a)

reached machine state

run the automata against a stream . Nothing represent an Accept state

automaton :: Eq a => NonEmpty (Interface a) -> Automaton a Source #

build a Automaton from a pattern zipeed with the prefix