packages feed

hfusion 0.0.3 → 0.0.4

raw patch · 9 files changed

+36/−70 lines, 9 files

Files

HFusion/HFusion.hs view
@@ -6,22 +6,24 @@ -- > import Control.Monad.Trans(lift) -- > import Language.Haskell.Parser(parseModule) -- >--- > fuseProgram :: String -> Either FusionError String--- > fuseProgram sourceCode = runFusionState newVarGen$+-- > fuseDefinitions :: String -> Either FusionError String+-- > fuseDefinitions sourceCode = runFusionState newVarGen$ -- >      -- Parse input with a Haskell parser. -- >      parseResult2FusionState (Language.Haskell.Parser.parseModule sourceCode)  -- >      -- Convert the haskell AST to the AST used by HFusion. -- >      >>= hsModule2HsSyn  -- >      -- Derive hylomorphisms for the definitions in the program. -- >      >>= lift . fmap snd . deriveHylos --- >      -- Fuse functions "zip" and "filter" composing "filter" on the second--- >      -- argument of "zip" and name "h" the resulting recursive definition.+-- >      -- Fuse functions "zip" and "filter", which are expected+-- >      -- to be defined in the sourceCode parameter, composing +-- >      -- "filter" on the second argument of "zip" and naming "zf"+-- >      -- the resulting recursive definition. -- >      >>= fuse "zip" 2 "filter" ["zf"] -- >      -- Translate the result from HFusion AST to Haskell source code. -- >      >>= return . hsSyn2HsSourceCode -- > -- > main = do cs <- readFile "examples.hs"--- >        putStr$ either (("There was an error: "++) . show) id$ fuseProgram cs+-- >           putStr$ either (("There was an error: "++) . show) id$ fuseDefinitions cs -- -- For more information on HFusion please visit <http://www.fing.edu.uy/inco/proyectos/fusion>. module HFusion.HFusion (@@ -51,15 +53,14 @@ import Control.Monad(liftM2) import Control.Arrow(first,(&&&)) --- | Transforms a composition of two recursive functions into an equivalent --- recursive function.+-- | Fuses the composition of two recursive functions producing an equivalent +-- new recursive function. ----- @fuse "f" 1 "g" [h_1 .. h_n] dfs@ yields a recursive function equivalent to @f . g@ and calls --- the resulting (possibly mutually) recursive definitions @h_1 .. h_n@. Functions @f@ and @g@--- must be hylomorphisms defined in @dfs@.+-- @fuse "f" 1 "g" [h_1 .. h_n] dfns@ yields a set of mutually recursive functions named @h_1 .. h_n@ which are equivalent to @f . g@. +-- Functions @f@ and @g@ must be hylomorphisms defined in @dfns@. ----- @fuse "f" 2 "g" [h_1 .. h_n] dfs@ yields a recursive function equivalent to @\x y -> f x (g y)@,--- @fuse "f" 3 "g" [h_1 .. h_n] dfs@ yields a recursive function equivalent to @\x y z -> f x y (g z)@,+-- @fuse "f" 2 "g" [h_1 .. h_n] dfns@ yields a recursive function equivalent to @\\x y -> f x (g y)@,+-- @fuse "f" 3 "g" [h_1 .. h_n] dfns@ yields a recursive function equivalent to @\\x y z -> f x y (g z)@, -- and so on ... fuse :: String -> Int -> String -> [String] -> [HyloT] -> FusionState [Def] fuse nombre1 inArg nombre2 resultNames hylos = env2FusionState fuseHylos  >>= lift . inline >>= return . map polishDef
HFusion/Internal/FsDeriv.lhs view
@@ -2,14 +2,6 @@  > {-# LANGUAGE PatternGuards #-} -% ------------------------------------------------------------------------------% $Id: FsDeriv.lhs,v 1.37 2005/08/26 20:59:55 fdomin Exp $-%-%  Los algoritmos que crean y modifican hilomorfismos.-%  Tomados del artículo de Onoue, Hu, Iwasaki y Takeichi.-%-% ------------------------------------------------------------------------------ >module HFusion.Internal.FsDeriv( >     aA, -- derivation algorithm >   ) where@@ -162,10 +154,10 @@      Errors of algorithm aD belong to this algorithm.    In addition, the following error is also thrown: -     NotExpected t: Thrown when any of the terms in ts is not a recursive lambda expresión.+     NotExpected t: Thrown when any of the terms in ts is not a recursive lambda expresi?n.                     t is the term being processed when the error occurred. ------------ La implementación ------------+----------- La implementaci?n ------------  Function aA calls aA', which collecs parameters from lambda expresions.
HFusion/Internal/FunctorRep.lhs view
@@ -2,12 +2,6 @@  > {-# LANGUAGE PatternGuards #-} -% ===============================================================================================-% $Id: FunctorRep.lhs,v 1.75 2006/06/21 17:04:41 fdomin Exp $ -%   Este archivo contiene las funciones que extraen la información de algebras y coalgebras-% necesaria para realizar fusión.-%-% ===============================================================================================  >module HFusion.Internal.FunctorRep where @@ -544,7 +538,7 @@ >    PcaseR i t0 c vrs ps -> sum$ map (countCases . fst) ps >    _ -> error$ "FunctorRep: countCases: " ++ (unexpected_Pattern p) -La siguiente función construye sigma, retorna las ramas del hilomorfismo correpondiente.+Constructs sigma. Returns the branches of the corresponding hylomorphism.  > getSigma :: (CHylo h, HasComponents b, TermWrappable a ) => [h a ca] -> [[(Acomponent InF,HFunctor)]] ->  >                          h a Sigma -> Int -> Int -> [h InF b] -> h InF b -> Int -> [(Acomponent a,Etai,HFunctor)] ->
HFusion/Internal/HsPrec.hs view
@@ -10,26 +10,23 @@  import Text.PrettyPrint -type Precedence = (PrecValue,Asoc) -- Caracteriza un operador.-type LeftParam = Bool   -- Se utiliza para determinar de que lado de-                        -- un operador infijo está un subtérmino.+type Precedence = (PrecValue,Asoc) -- Characterizes an operator.+type LeftParam = Bool     type PrecValue = Int data Asoc = LeftAsoc | RightAsoc | None            deriving (Eq,Show) --- Inserta paréntesis o no, de acuerdo al valor del primer parámetro,--- utilizando <> delante y detrás de la expresión en el segundo --- parámetro.+-- Inserts parethesis according to the value of the first parameter, hpar:: Bool -> Doc -> Doc hpar paren d = if paren then char '(' <> d <> char ')'                         else d --- Decide si una expresión E2, cuyo operador O2 más externo tiene la --- precedencia dada en el tercer parámetro, necesita ser parentizada,--- siendo el primer parámetro la precedencia del operador O1 del cuál E2--- es subexpresión, y el segundo parámetro indica si E2 se halla a la --- izquierda de O1.+-- Decides if an expression E2, with outermost operador O2 having +-- precedence given in the third parameter, needs parenthesis+-- being the first parameter the precedence of operador O1 which+-- contains E2 as one of its arguments, and the second parameter+-- tells if E2 is left of O1. -- parentizar (1,LeftAsoc) False (1,_) -> True parentizar::Precedence -> LeftParam -> Precedence -> Bool parentizar (p0,a0) left (p1,_) = (p0>p1)||
HFusion/Internal/HsPretty.hs view
@@ -1,14 +1,6 @@ -- Please, see the file LICENSE for copyright and license information.  {-# LANGUAGE PatternGuards #-}--{-% ------------------------------------------------------------------------------% $Id: HsPretty.lhs,v 1.39 2006/05/30 23:13:31 fdomin Exp $-%-%  Operaciones para imprimir los programas parseados.-%-% -----------------------------------------------------------------------------}- module HFusion.Internal.HsPretty(  show, -- :: Prog -> String  ShowDoc(..),@@ -66,8 +58,6 @@ -- =================================================  --- Coloca un separador entre la representación de strings de elementos de--- una lista. -- miShowList ";" [1,2,3,4] -> "1;2;3;4" mishowList:: Show a => String->[a]->String mishowList _ [] = ""@@ -82,15 +72,15 @@ showTuple [a] = showDoc a showTuple ls = char '('<> (hcat$ mapDocSeparator (char ','<>) ls)<>char ')' --- Aplica una función a todos los argumentos de una lista menos al+-- Aplica una funcion a todos los argumentos de una lista menos al -- primero. Se utiliza para insertar separadores en la lista. mapSeparator::(a->a)->[a]->[a] mapSeparator _  [] = [] mapSeparator separador (l:ls) = l:map separador ls --- Inserta paréntesis o no, de acuerdo al valor del primer parámetro,--- utilizando <> delante y ++ detrás de la expresión en el segundo --- parámetro.+-- Inserta parentesis o no, de acuerdo al valor del primer parametro,+-- utilizando <> delante y ++ detras de la expresión en el segundo +-- parametro. parlist:: Bool -> [Doc] -> Doc parlist paren content = if paren                            then  char '(' <> @@ -100,8 +90,8 @@                           else sep content  tab,stab::Int-tab=4      -- Indentación grande-stab=2     -- Indentación pequeña+tab=4      -- Indentacion grande+stab=2     -- Indentacion pequeña  -- Precedencias (ver HsPrec) ttupleprec,tlambprec,tletprec,tcaseprec,@@ -296,8 +286,8 @@                      ++ map (nest 1) (mapSeparator (char ','<>) tdocs)                      ++ [char ')'] -    -- La siguiente operación está comentada para ilustrar el -    -- comportamiento general de cada definición.+    -- La siguiente operacion esta comentada para ilustrar el +    -- comportamiento general de cada definicion.     showDocPrec prec left (Tlamb boundvar term) =                 let         -- Obtengo la representación del subtérmino.
HFusion/Internal/HsSyn.hs view
@@ -1,12 +1,5 @@ -- Please, see the file LICENSE for copyright and license information. -{-% ------------------------------------------------------------------------------% $Id: HsSyn.lhs,v 1.24 2006/05/30 23:13:31 fdomin Exp $-%-%  Un conjunto de datatypes que describen la gramática que se parsea.-%-% -----------------------------------------------------------------------------}- module HFusion.Internal.HsSyn where  import Char(isDigit)
HFusion/Internal/Inline.lhs view
@@ -565,7 +565,7 @@ >        bad = do t<-runReader (inlTW f$ unwrapA inF)$ InlAEnv ts [] >                 return$ fts$ Tcase (ttuple ts) [ptuple (map bv2pat (getVars inF))] [t] -Esta función es para hacer el inlining de cosas que tienen componentes de tipo TermWrapper.+Inlining of things containing 'TermWrapper' values.  > inlTW :: Monad m => (a->[Term]->[(Variable,Term)]->m Term) -> TermWrapper a -> Reader InlAEnv (m Term) > inlTW = inlTW' False
HFusion/Internal/Parsing/HyloParser.lhs view
@@ -46,8 +46,7 @@ >                          ,concat (map (either (const []) (:[])) ehs))  -> -- | This is a convenience function that allows to handle parsing an 'HsModule'-> -- as a 'FusionState' computation.+> -- | Allows to handle parsing of an 'HsModule' as a 'FusionState' computation. > --  > -- @parseResult2FusionState (Language.Haskell.Parser.parseModule sourceCode)@ > parseResult2FusionState :: ParseResult HsModule -> FusionState HsModule
hfusion.cabal view
@@ -1,5 +1,5 @@ name:       hfusion-version:    0.0.3+version:    0.0.4 build-type: Simple cabal-version:  >= 1.6 license:    BSD3@@ -45,5 +45,5 @@ source-repository this   type:     darcs   location: http://www.fing.edu.uy/inco/proyectos/fusion/darcs/hfusion/-  tag:      0.0.3+  tag:      0.0.4