Makefile: Apparently Algol 68 Genie now has a compiler. Let's use it.
[fringe] / haskell-fringe.hs
index 78c6362..1054cab 100644 (file)
@@ -1,13 +1,14 @@
--- -*-haskell-*-
---
--- Haskell implementation of a `same-fringe' solver.
+--- -*-haskell-*-
+---
+--- Haskell implementation of a `same-fringe' solver.
 
-import IO
-import System
-import Monad
+import System.IO
+import System.Environment
+import System.Exit
+import Control.Monad
 
 -----------------------------------------------------------------------------
--- Parser combinators.
+--- Parser combinators.
 
 -- A very simple parser monad.
 newtype Parser t a = Parser { runparse :: [t] -> Either String (a, [t]) }
@@ -56,14 +57,14 @@ eof = do
     _ -> fail "trailing junk"
 
 -----------------------------------------------------------------------------
--- Tree data type.
+--- Tree data type.
 
-data Tree a = Leaf | Node (Tree a, a, Tree a) deriving (Show)
+data Tree a = Leaf | Node (Tree a) a (Tree a) deriving (Show)
 
 -- Return the elements inorder, as a list.
 fringe t = gather t [] where
   gather Leaf ns = ns
-  gather (Node (l, x, r)) ns = gather l (x : gather r ns)
+  gather (Node l x r) ns = gather l (x : gather r ns)
 
 -- Answer whether two trees have the same fringe.
 sameFringe t tt = fringe t == fringe tt -- trivial!
@@ -81,11 +82,11 @@ parseTree cs = parse cs $ do t <- tree; eof; return t
     case r of
       Just '(' -> do
         step; left <- tree; c <- anytok "no data"; right <- tree; delim ')'
-        return $ Node (left, c, right)
+        return $ Node left c right
       _ -> return Leaf
 
 -----------------------------------------------------------------------------
--- Main program.
+--- Main program.
 
 -- Report MSG as an error and quit.
 bail msg = do