packages feed

lhs2TeX-hl 0.1.3.1 → 0.1.3.2

raw patch · 8 files changed

+175/−32 lines, 8 filesdep −MissingHdep ~haskell-src-exts

Dependencies removed: MissingH

Dependency ranges changed: haskell-src-exts

Files

README.asciidoc view
@@ -143,6 +143,8 @@  CHANGES -------+1.3.2::+  * Removed the MissingH dependency. 1.3.1::   * Added the file Language.Markup 1.3.0::
lhs2TeX-hl.cabal view
@@ -1,5 +1,5 @@ Name:               lhs2TeX-hl-Version:            0.1.3.1+Version:            0.1.3.2 Cabal-Version:      >= 1.6 License:            MIT Author:             Alessandro Vermeulen <me@alessandrovermeulen.me>@@ -24,10 +24,10 @@   Main-Is:          LiterateHighlighter.hs   Build-Depends:    base >= 4 && <= 5                   , haskell98-                  , haskell-src-exts >= 1.9.3+                  , haskell-src-exts >= 1.10.2                   , syb >= 0.1.0.1                   , cmdargs >= 0.1-                  , MissingH   hs-source-dirs:   src-  Other-Modules:    Language.LaTeX, Language.Markup, Literate.Agda, Literate.Haskell,+  Other-Modules:    Data.List.Utils, Data.String.Utils, Language.LaTeX, +                    Language.Markup, Literate.Agda, Literate.Haskell,                     Literate.SimpleInfo, Base.CLI, Base.Common
src/Base/Common.hs view
@@ -1,4 +1,4 @@ module Base.Common where   -programVersion = "0.1.3.1"+programVersion = "0.1.3.2" programName    = "lhs2TeX-hl"
+ src/Data/List/Utils.hs view
@@ -0,0 +1,123 @@+{- |+   Module     : Data.List.Utils+   Copyright  : Copyright (C) 2004-2006 John Goerzen+   License    : GNU GPL, version 2 or above++   Maintainer : John Goerzen <jgoerzen@complete.org> +   Stability  : provisional+   Portability: portable++This module provides various helpful utilities for dealing with lists.++Written by John Goerzen, jgoerzen\@complete.org++----++Scavenged from the MissingH Data.List.Utils module, with only the things we need+here, in order to keep our dependencies to a minumum.+-}+module Data.List.Utils where+  +import Data.List ( intersperse, isPrefixOf )++{- | Returns true if the given list starts with the specified elements;+false otherwise.  (This is an alias for "Data.List.isPrefixOf".)++Example:++> startswith "He" "Hello" -> True++-}++startswith :: Eq a => [a] -> [a] -> Bool+startswith = isPrefixOf++{- | Similar to Data.List.span, but performs the test on the entire remaining+list instead of just one element. ++@spanList p xs@ is the same as @(takeWhileList p xs, dropWhileList p xs)@ +-}+spanList :: ([a] -> Bool) -> [a] -> ([a], [a])++spanList _ [] = ([],[])+spanList func list@(x:xs) =+    if func list+       then (x:ys,zs)+       else ([],list)+    where (ys,zs) = spanList func xs+  +{- | Similar to Data.List.break, but performs the test on the entire remaining+list instead of just one element.+-}+breakList :: ([a] -> Bool) -> [a] -> ([a], [a])+breakList func = spanList (not . func)++{- | Given a delimiter and a list (or string), split into components.++Example:++> split "," "foo,bar,,baz," -> ["foo", "bar", "", "baz", ""]++> split "ba" ",foo,bar,,baz," -> [",foo,","r,,","z,"]+-}+split :: Eq a => [a] -> [a] -> [[a]]+split _ [] = []+split delim str =+    let (firstline, remainder) = breakList (startswith delim) str+        in +        firstline : case remainder of+                                   [] -> []+                                   x -> if x == delim+                                        then [] : []+                                        else split delim +                                                 (drop (length delim) x)+++{- | Given a list and a replacement list, replaces each occurance of the search+list with the replacement list in the operation list.++Example:++>replace "," "." "127,0,0,1" -> "127.0.0.1"++This could logically be thought of as:++>replace old new l = join new . split old $ l+-}++replace :: Eq a => [a] -> [a] -> [a] -> [a]+replace old new l = join new . split old $ l++{- | Given a delimiter and a list of items (or strings), join the items+by using the delimiter.++Example:++> join "|" ["foo", "bar", "baz"] -> "foo|bar|baz"+-}+join :: [a] -> [[a]] -> [a]+join delim l = concat (intersperse delim l)+++rtrim :: String -> String -> String+rtrim chars inp = rtrim' inp+  where+    rtrim' ""  = []+    rtrim' [x] = case elem x chars of+                   True  -> []+                   False -> [x]+    rtrim' (x:xs) = let tail = rtrim' xs+                    in+                      case tail of+                        []   -> case elem x chars of+                                  True  -> []+                                  False -> [x]+                        xs   -> x :  tail+                        +ltrim :: String -> String -> String+ltrim chars = ltrim'+  where ltrim' s = case s of+                     [] -> []+                     (x:xs) -> if elem x chars+                               then ltrim' xs+                               else s
+ src/Data/String/Utils.hs view
@@ -0,0 +1,24 @@+module Data.String.Utils where++rtrim :: String -> String -> String+rtrim chars inp = rtrim' inp+  where+    rtrim' ""  = []+    rtrim' [x] = case elem x chars of+                   True  -> []+                   False -> [x]+    rtrim' (x:xs) = let tail = rtrim' xs+                    in+                      case tail of+                        []   -> case elem x chars of+                                  True  -> []+                                  False -> [x]+                        xs   -> x :  tail+                        +ltrim :: String -> String -> String+ltrim chars = ltrim'+  where ltrim' s = case s of+                     [] -> []+                     (x:xs) -> if elem x chars+                               then ltrim' xs+                               else s
src/Language/LaTeX.hs view
@@ -2,7 +2,7 @@   ----------import Data.String.Utils+import Data.List.Utils ( replace )  import Language.Markup ---------
src/Language/Markup.hs view
@@ -2,33 +2,10 @@  import Data.Char (isDigit) +import Data.String.Utils ( rtrim, ltrim )+ markup :: String -> String markup = m' . b . break (\ a -> a == '_' || isDigit a) . rtrim "_"   where m' (str, [])   = str         m' (str, sub)  = str ++ "_{" ++ sub ++ "}"         b (a , b) = (a , ltrim "_" b)-               ---rtrim :: String -> String -> String-rtrim chars inp = rtrim' inp-  where-    rtrim' ""  = []-    rtrim' [x] = case elem x chars of-                   True  -> []-                   False -> [x]-    rtrim' (x:xs) = let tail = rtrim' xs-                    in-                      case tail of-                        []   -> case elem x chars of-                                  True  -> []-                                  False -> [x]-                        xs   -> x :  tail-                        -ltrim :: String -> String -> String-ltrim chars = ltrim'-  where ltrim' s = case s of-                     [] -> []-                     (x:xs) -> if elem x chars-                               then ltrim' xs-                               else s
src/Literate/Haskell.hs view
@@ -39,6 +39,12 @@     getData :: Type -> [QName]     getData (TyCon n) = [n]     getData _         = []+    -- getType :: Decl -> [QName]+    -- getType (DataDecl _ _ _ _ decl _ _)  = let  f (Ident n)  = [n]+    --                                             f _          = []+    --                                        in   f decl+    --   +    -- getType _                        = []  listConstructors ::  Module -> [String] listConstructors =  nub . everything (++) ([] `mkQ`  listConstructor @@ -56,12 +62,23 @@         listConstructorUse _                 = []  listFunctions ::  Module -> [String]-listFunctions =  nub . everything (++) ([] `mkQ` functionBinding `extQ` functionUse)+listFunctions =  nub . everything (++) ([] `mkQ` functionBinding +                                           `extQ` functionUse +                                           `extQ` functionTypeSig)  where  functionBinding :: Match -> [String]         functionBinding (Match _ (i) _ _ _ _)  = [prettyPrint i]         functionUse :: Exp -> [String]          functionUse (App (Var qname) _) = [prettyPrint qname]         functionUse _                   = []+        functionTypeSig :: Decl -> [String]+        functionTypeSig (TypeSig _ names t)  = case t of+                                                 TyParen (TyFun _ _)  -> map nameToString names+                                                 TyFun   _    _       -> map nameToString names+                                                 _                    -> []+        functionTypeSig _                    = []+        nameToString :: Name -> String+        nameToString (Ident s) = s+        nameToString (Symbol s) = s          listOperators ::  Module -> [String] listOperators =  nub . everything (++) ([] `mkQ` operatorUse)