Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Kill FUtil dependency, and syb-with-class was unused.

Also apparently don't need to repeat the deps for the test mode either.
  • Loading branch information...
commit d925942df41bd5bcbb45953b7ee12347bbf26a58 1 parent 596b437
@dancor dancor authored
View
8 install
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
+
echo 'Detecting transformers...'
-cd src
-./do-codegen
-cd ..
-cabal install --enable-optimization=2 --global --root-cmd=sudo
+(cd src; ./do-codegen)
+
+cabal install --enable-optimization=2 "$@"
View
20 lex-pass.cabal
@@ -28,7 +28,6 @@ executable lex-pass
, containers
, directory
, filepath
- , FUtil
, GenericPretty
, HSH
, MissingH
@@ -36,7 +35,6 @@ executable lex-pass
, parsec
, process
, syb
- , syb-with-class
ghc-options: -threaded
executable lex-pass-test
@@ -44,21 +42,3 @@ executable lex-pass-test
buildable: False
hs-source-dirs: src
main-is: Lang/Php/Ast/Test.hs
- build-depends:
- base
- , binary
- , binary-generic
- , bytestring
- , containers
- , directory
- , filepath
- , FUtil
- , GenericPretty
- , HSH
- , MissingH
- , mtl
- , parsec
- , process
- , syb
- , syb-with-class
- ghc-options: -threaded
View
2  src/Lang/Php/Ast/StmtParse.hs
@@ -5,7 +5,6 @@
module Lang.Php.Ast.StmtParse where
import Control.Monad.Identity
-import FUtil
import Text.ParserCombinators.Parsec.Expr
import qualified Data.Intercal as IC
@@ -14,6 +13,7 @@ import Lang.Php.Ast.Common
import Lang.Php.Ast.Lex
import Lang.Php.Ast.LexWS
import Lang.Php.Ast.StmtTypes
+import Util
-- Val
View
4 src/Lang/Php/Transf.hs
@@ -1,13 +1,13 @@
module Lang.Php.Transf where
import Control.Applicative
-import FUtil
import Numeric
+import qualified Data.Intercal as IC
import Lang.Php.Ast
import Lang.Php.Ast.Stmt
import LexPassUtil
-import qualified Data.Intercal as IC
+import Util
-- ignores single-statement if/etc blocks currently
-- (we _could_ convert them out of single-statement-ness on change)
View
22 src/LexPassUtil.hs
@@ -5,19 +5,20 @@ import Control.Applicative
import Control.Arrow
import Control.Monad.State
import Data.Binary
+import qualified Data.ByteString.Char8 as BSC
import Data.Data
import Data.Generics
-import FUtil
import HSH
-import Lang.Php.Ast
import Options
import System.Directory
import System.FilePath
import System.IO
import System.Process
import Text.Parsec.Prim (Parsec)
-import qualified Data.ByteString.Char8 as BSC
+
import qualified Data.Intercal as IC
+import Lang.Php.Ast
+import Util
--
-- transf framework
@@ -70,17 +71,18 @@ argless f args dir subPath = if null args then f dir subPath
lexPass :: (Binary a, Parse a, Unparse a) => (a -> Transformed a) ->
Options -> FilePath -> FilePath -> Int -> Int -> CanErrStrIO (Bool, [String])
lexPass transf opts codeDir subPath total cur = do
- io . hPutStrLn stderr $ "Checking (" ++ show cur ++ "/" ++ show total ++
+ liftIO . hPutStrLn stderr $ "Checking (" ++ show cur ++ "/" ++ show total ++
") " ++ subPath
- ast <- io $ parseAndCache (optCacheAsts opts) codeDir subPath
+ ast <- liftIO $ parseAndCache (optCacheAsts opts) codeDir subPath
case transf ast of
Transformed {infoLines = infoLines, transfResult = Nothing} ->
return (False, infoLines)
- Transformed {infoLines = infoLines, transfResult = Just ast'} -> io $ do
- hPutStrLn stderr "- Saving"
- writeSrcFile (codeDir </> subPath) $ unparse ast'
- encodeFile (astPath codeDir subPath) ast'
- return (True, infoLines)
+ Transformed {infoLines = infoLines, transfResult = Just ast'} ->
+ liftIO $ do
+ hPutStrLn stderr "- Saving"
+ writeSrcFile (codeDir </> subPath) $ unparse ast'
+ encodeFile (astPath codeDir subPath) ast'
+ return (True, infoLines)
--
-- basic transf-building tools
View
6 src/Main.hs
@@ -5,7 +5,6 @@ import Control.Monad.Error
import Data.Char
import Data.List
import Data.Maybe
-import FUtil
import System.Console.GetOpt
import System.Directory
import System.Environment
@@ -14,10 +13,11 @@ import System.IO
import System.Process
import CodeGen.Transf
+import qualified Config
import LexPassUtil
import Options
import TaskPool
-import qualified Config
+import Util
endSpan :: (a -> Bool) -> [a] -> ([a], [a])
endSpan p = uncurry (flip (,)) . bothond reverse . span p . reverse
@@ -47,7 +47,7 @@ usage err =
showStRes :: CanErrStrIO (Bool, [String]) -> CanErrStrIO Bool
showStRes f = do
(ret, st) <- f
- io . putStr $ unlines st
+ liftIO . putStr $ unlines st
return ret
lookupTrans :: String -> Transf
View
1  src/Transf/AntiPattern.hs
@@ -8,6 +8,7 @@ module Transf.AntiPattern where
import Lang.Php
import TransfUtil
+import Util
import qualified Data.Intercal as IC
transfs :: [Transf]
View
2  src/TransfUtil.hs
@@ -2,13 +2,11 @@ module TransfUtil (
module Common,
module Control.Applicative,
module Data.List,
- module FUtil,
module LexPassUtil
) where
import Common
import Control.Applicative hiding (Const, (<|>), many, optional)
import Data.List
-import FUtil
import LexPassUtil
View
35 src/Util.hs
@@ -0,0 +1,35 @@
+module Util where
+
+import Control.Arrow
+import Control.Monad.Error
+
+type CanErrStrIO a = ErrorT String IO a
+
+rePairRight :: ((a, b), c) -> (a, (b, c))
+rePairRight ((a, b), c) = (a, (b, c))
+
+rePairLeft :: (a, (b, c)) -> ((a, b), c)
+rePairLeft (a, (b, c)) = ((a, b), c)
+
+swap :: (a, b) -> (b, a)
+swap (a, b) = (b, a)
+
+uncons :: [a] -> (a, [a])
+uncons (x:xs) = (x, xs)
+uncons [] = error "uncons: empty list"
+
+bothond :: (Arrow a) => a b c -> a (b, b) (c, c)
+bothond f = f *** f
+
+onHead :: (a -> a) -> [a] -> [a]
+onHead _ [] = []
+onHead f (x:xs) = f x : xs
+
+-- Reversify (work from end instead of beginning) a function.
+reversify :: ([a] -> [a]) -> [a] -> [a]
+reversify f = reverse . f . reverse
+
+-- Reversify (work from end instead of beginning) a function that makes a tuple
+-- (such as span).
+reversifyTup :: ([a] -> ([b], [b])) -> [a] -> ([b], [b])
+reversifyTup f = swap . bothond reverse . f . reverse
View
3  src/do-codegen
@@ -5,10 +5,11 @@
import Control.Applicative
import Data.List
import Data.Maybe
-import FUtil
import System.FilePath
import System.Directory
+import Util
+
doDir :: FilePath -> IO ([String], [String])
doDir dir = do
files <- map (reversify $ drop 3) . filter (".hs" `isSuffixOf`) <$>
Please sign in to comment.
Something went wrong with that request. Please try again.