graph-rewriting-ww 0.3.7 → 0.3.8
raw patch · 8 files changed
+57/−38 lines, 8 filesdep +indentparserdep +mtldep −IndentParserdep ~GLUTdep ~OpenGLdep ~base
Dependencies added: indentparser, mtl
Dependencies removed: IndentParser
Dependency ranges changed: GLUT, OpenGL, base, graph-rewriting, graph-rewriting-gl, graph-rewriting-layout
Files
- GL.hs +0/−1
- Rules.hs +0/−1
- Term.hs +35/−18
- examples/WW-beta-saving-0.l +1/−1
- examples/WW-beta-saving-1.l +1/−1
- examples/levy-1988-p184bottom.l +1/−1
- examples/vincent-1-ww.l +2/−2
- graph-rewriting-ww.cabal +17/−13
GL.hs view
@@ -17,7 +17,6 @@ Duplicator {} → [sd n, (sw, s), (se, s)] where n = Vector2 0 1- w = Vector2 (-1) 0 e = Vector2 1 0 s = Vector2 0 (-1) sw = Vector2 (-1) (-1)
Rules.hs view
@@ -6,7 +6,6 @@ import GraphRewriting.Rule as Rule import GraphRewriting.Pattern import GraphRewriting.Graph.Read-import Control.Applicative import Data.Monoid.Unicode
Term.hs view
@@ -2,11 +2,10 @@ module Term where import Prelude.Unicode-import Text.ParserCombinators.Parsec as Parsec-import Text.ParserCombinators.Parsec.IndentParser as Indent-import Text.ParserCombinators.Parsec.Language-import Text.ParserCombinators.Parsec.IndentParser.Token-import Control.Monad (liftM)+import Text.Parsec+import Text.Parsec.Token (makeTokenParser, GenLanguageDef(..))+import Text.Parsec.IndentParsec+import Control.Monad.Identity data Λ = A Λ Λ -- ^ application@@ -15,20 +14,38 @@ | L [(String,Λ)] Λ -- ^ let binding deriving (Show,Eq,Ord) -parse ∷ String → Λ-parse str = either (error ∘ show) id (Indent.parse parser "(null)" str)- parseFile ∷ FilePath → IO Λ-parseFile = liftM (either (error ∘ show) id) ∘ Indent.parseFromFile parser+parseFile f = do+ file ← readFile f+ let parseErrorOrExpr = runIdentity $ runGIPT parser () f file+ return $ either (error ∘ show) id parseErrorOrExpr -parser ∷ IndentCharParser st Λ+type IndentCharParser a = IndentParsec String () a++langDef = LanguageDef { commentStart = "{-"+ , commentEnd = "-}"+ , commentLine = "--"+ , identStart = letter <|> char '_'+ , identLetter = alphaNum <|> char '_'+ , opStart = oneOf "-+/*=<>"+ , opLetter = oneOf "-+/*=<>"+ , reservedNames = ["let", "in", "case", "of"]+ , reservedOpNames = ["=", "->", "→", "."]+ , caseSensitive = False+ , nestedComments = True+ }++tokP :: IndentTokenParser String () Identity+tokP = makeTokenParser langDef++parser ∷ IndentCharParser Λ parser = expression where expression = flip label "expression" $ application <|> letBinding application = liftM (foldl1 A) $ many1 $ choice [parenthetic, abstraction, variable] - parenthetic = parens haskell expression+ parenthetic = parens tokP expression abstraction = flip label "abstraction" $ do _ ← sym "λ" <|> sym "\\"@@ -37,7 +54,7 @@ body ← expression return $ foldr Λ body vars - variable = liftM V $ ident <|> operator haskell <|> liftM (either show show) (naturalOrFloat haskell)+ variable = liftM V $ ident <|> operator tokP <|> liftM (either show show) (naturalOrFloat tokP) -- Ugly, but works. Keyword "in" terminates binding blocks and bindings. Allows empty lets letBinding = flip label "let binding" $ do@@ -47,7 +64,7 @@ case e of Just je → return ([], Just je) Nothing → do- (b,e) ← lineFold $ do+ (b,e) ← foldedLinesOf $ do b ← binding e ← optionMaybe $ keyword "in" >> expression return (b,e)@@ -58,18 +75,18 @@ Nothing → return ([b], Nothing) Just (bs, me) → return (b:bs, me) Just je → return ([b], Just je)- (binds, e) ← block parseBindings+ (binds, e) ← blockOf parseBindings case e of Nothing → liftM (L binds) (keyword "in" >> expression) Just je → return $ L binds je - binding ∷ IndentCharParser st (String,Λ)+ binding ∷ IndentCharParser (String,Λ) binding = flip label "binding" $ do funct ← ident params ← many ident body ← sym "=" >> expression return (funct, foldr Λ body params) - keyword = reserved haskell- ident = identifier haskell- sym = symbol haskell+ keyword = reserved tokP+ ident = identifier tokP+ sym = symbol tokP
examples/WW-beta-saving-0.l view
@@ -1,1 +1,1 @@-(\F. (\f. f (f 0)) (F 0)) (\y. \x. x) +(\F. (\f. f (f 0)) (F 0)) (\y. \x. x)
examples/WW-beta-saving-1.l view
@@ -1,1 +1,1 @@-(\F. (\f. f (f 0)) (F (F 0 0))) (\y. \x. x) +(\F. (\f. f (f 0)) (F (F 0 0))) (\y. \x. x)
examples/levy-1988-p184bottom.l view
@@ -1,6 +1,6 @@ let I0 = \x0.x0 I1 = \x1.x1 J = \z.b- Delta = \y.I1 (y y) + Delta = \y.I1 (y y) in (\f.(f I0)(f J)) (\x. Delta (x a))
examples/vincent-1-ww.l view
@@ -1,4 +1,4 @@-let G = \g. g (g x) +let G = \g. g (g x) F x = F x- I x = x + I x = x in G (F I)
graph-rewriting-ww.cabal view
@@ -1,31 +1,35 @@ Name: graph-rewriting-ww-Version: 0.3.7+Version: 0.3.8 Copyright: (c) 2010, Jan Rochel License: BSD3 License-File: LICENSE Author: Jan Rochel Maintainer: jan@rochel.info-Homepage: http://rochel.info/#graph-rewriting+Homepage: https://github.com/jrochel/graph-rewriting+Bug-Reports: https://github.com/jrochel/graph-rewriting/issues Build-Type: Simple-Synopsis: Evaluator of the lambda-calculus in an interactive graph rewriting system with explicit sharing-Description: Evaluate a given λ-term (letrecs may be used) interactively. It uses duplicators to explicitly render fully-lazy sharing according to Wadsworth's approach. The reduction rules are split into two groups, safe rules and unsafe rules, which implement the procedure for unsharing the MFE under one duplicator.+Synopsis: Interactive evaluator of the lambda-calculus with explicit sharing+Description: Evaluate a given λ-term (letrecs may be used) interactively in a port-graph rewriting system. It uses duplicators to explicitly render fully-lazy sharing according to Wadsworth's approach. The reduction rules are split into two groups, safe rules and unsafe rules, which implement the procedure for unsharing the MFE under one duplicator. Category: Application, Compilers/Interpreters-Cabal-Version: >= 1.6+Cabal-Version: >= 1.10 Data-Files: examples/*.l Executable ww+ Default-Language: Haskell2010 Main-Is: Main.hs Build-Depends:- base >= 4.8 && < 4.10,+ base >= 4.9 && < 5, base-unicode-symbols >= 0.2 && < 0.3,- graph-rewriting >= 0.7.8,- graph-rewriting-layout >= 0.5.4,- graph-rewriting-gl >= 0.7.6,+ graph-rewriting >= 0.7.8 && < 0.9,+ graph-rewriting-layout >= 0.5.4 && < 0.6,+ graph-rewriting-gl >= 0.7.6 && < 0.8,+ mtl >= 1.1 && < 2.3, parsec >= 3.1 && < 3.2,- GLUT >= 2.2 && < 2.8,- OpenGL >= 3.0 && < 3.1,- IndentParser >= 0.2 && < 0.3- Extensions:+ GLUT >= 2.2 && < 3,+ OpenGL >= 3.0 && < 4,+ indentparser >= 0.1 && < 0.2+ Default-Extensions: UnicodeSyntax+ Other-Extensions: UnicodeSyntax FlexibleInstances FlexibleContexts