├── .gitignore ├── ChangeLog.md ├── LICENSE ├── README.md ├── Setup.hs ├── app └── Main.hs ├── package.yaml ├── publish.sh ├── src ├── DFA.hs ├── NFA.hs ├── Regex.hs └── RegexEquality.hs ├── stack.yaml └── test └── Spec.hs /.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work/ 2 | regex-equality.cabal 3 | *~ -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Changelog for regex-equality 2 | 3 | ## Unreleased changes 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Joonatan Saarhelo (c) 2018 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Author name here nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Regex Equivalence Checker 2 | 3 | [Try it online!](https://regex-equality.herokuapp.com) 4 | 5 | Understands `+`, `*`, `|` and parens. The aforementioned characters can be escaped with a backslash. 6 | 7 | Build with `stack build`. -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /app/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | {-# LANGUAGE QuasiQuotes #-} 3 | 4 | import Network.Wai 5 | import Network.Wai.Handler.Warp 6 | import Network.HTTP.Types (status200) 7 | import Network.HTTP.Types.URI (queryToQueryText) 8 | import Control.Monad (join) 9 | import System.Environment (getEnv) 10 | import Text.Hamlet 11 | import Text.Blaze.Html.Renderer.Utf8 (renderHtmlBuilder) 12 | import Prelude hiding (null) 13 | import Data.Text 14 | 15 | import qualified RegexEquality as R 16 | 17 | main = do 18 | port <- getEnv "PORT" 19 | run (read port) app 20 | 21 | app :: Network.Wai.Request 22 | -> (Network.Wai.Response -> IO ResponseReceived) 23 | -> IO ResponseReceived 24 | app req respond = respond $ responseBuilder status200 headers content where 25 | headers = 26 | [("Content-Type", "text/html")] 27 | content = 28 | renderHtmlBuilder $ template result render 29 | result = 30 | handle $ queryToQueryText $ queryString req 31 | 32 | data Route = Frontpage 33 | 34 | render :: Route -> [(Text, Text)] -> Text 35 | render Frontpage _ = "/" 36 | 37 | template :: Maybe (Either Text Comparison) -> HtmlUrl Route 38 | template result = [hamlet| 39 | $doctype 5 40 | 41 | 42 |
43 |Find out if two regular expressions match the same language 50 | 51 |