[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:47:10 UTC 2010


The following commit has been merged in the master branch:
commit beac713da55d75df7e15d4bcd7c1f6ca0b4bc9b6
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Nov 16 04:31:21 2004 +0100

    Updated control file to use more recent haskell-devscripts
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.5--patch-65)

diff --git a/ChangeLog b/ChangeLog
index 311ed29..a48b8cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
 #
 
+2004-11-15 21:31:21 GMT	John Goerzen <jgoerzen at complete.org>	patch-65
+
+    Summary:
+      Updated control file to use more recent haskell-devscripts
+    Revision:
+      missingh--head--0.5--patch-65
+
+
+    modified files:
+     ChangeLog debian/changelog debian/control
+     libsrc/MissingH/Printf.hs libsrc/MissingH/Printf/Types.hs
+
+
 2004-11-15 21:05:53 GMT	John Goerzen <jgoerzen at complete.org>	patch-64
 
     Summary:
diff --git a/debian/changelog b/debian/changelog
index 2f16412..bb85632 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+missingh (0.6.0) unstable; urgency=low
+
+  * Major new feature: Printf module.
+
+ -- John Goerzen <jgoerzen at complete.org>  Mon, 15 Nov 2004 15:28:29 -0600
+
 missingh (0.5.4) unstable; urgency=low
 
   * Added build-dep-indep on libhugs-hunit and re-enabled Hugs unit tests.
diff --git a/debian/control b/debian/control
index 49f1002..24e1b89 100644
--- a/debian/control
+++ b/debian/control
@@ -1,8 +1,8 @@
 Source: missingh
 Priority: optional
 Maintainer: John Goerzen <jgoerzen at complete.org>
-Build-Depends: debhelper (>= 4.0.0), ghc6 (>= 6.2.2), ghc6 (<< 6.2.3), haskell-devscripts (>= 0.5.1), libghc6-hunit-dev
-Build-Depends-Indep: debhelper (>= 4.0.0), haddock, hugs, haskell-devscripts (>= 0.5.1), libhugs-hunit
+Build-Depends: debhelper (>= 4.0.0), ghc6 (>= 6.2.2), ghc6 (<< 6.2.3), haskell-devscripts (>= 0.5.2), libghc6-hunit-dev
+Build-Depends-Indep: debhelper (>= 4.0.0), haddock, hugs, haskell-devscripts (>= 0.5.2), libhugs-hunit
 Standards-Version: 3.6.1
 Section: devel
 
diff --git a/libsrc/MissingH/Printf.hs b/libsrc/MissingH/Printf.hs
index 3b944d8..af06e12 100644
--- a/libsrc/MissingH/Printf.hs
+++ b/libsrc/MissingH/Printf.hs
@@ -56,9 +56,17 @@ module MissingH.Printf(-- * Introduction
                        sprintf,
                        printf,
                        fprintf,
-                       sprintfAL,
-                       sprintfFM,
-                       -- ** Utility Function
+
+                       -- ** Mapping Output Types
+                       -- $mappingoutput
+
+                       -- *** Association List Output
+                       sprintfAL, printfAL, fprintfAL,
+
+                       -- *** FiniteMap Output
+                       sprintfFM, printfFM, fprintfFM,
+
+                       -- * Utility Function
                        v,
                        -- * Differences from C
                        -- $differencesfromc
@@ -70,11 +78,7 @@ module MissingH.Printf(-- * Introduction
                        -- $fullexamples
 
                        -- * Underlying Types
-                       Value(..),
-                       PFRun,
-                       PFType(..),
-                       IOPFRun
-
+                       Value(..)
                        ) where
 
 import MissingH.Str
@@ -83,7 +87,7 @@ import System.IO
 import MissingH.Printf.Types
 import MissingH.Printf.Printer(get_conversion_func, fix_width)
 import Text.Regex
-import Data.FiniteMap(lookupFM)
+import Data.FiniteMap(lookupFM, FiniteMap)
 
 v :: PFType a => a -> Value
 v = toValue
@@ -156,7 +160,7 @@ sprintf ('%' : xs) y =
 sprintf (x:xs) y = x : sprintf xs y
 
 {- | Association list version of 'sprintf'. -}
-sprintfAL :: String -> PrintfAL -> String
+sprintfAL :: String -> [(String, Value)] -> String
 sprintfAL [] _ = []
 sprintfAL ('%' : '%' : xs) y = '%' : sprintfAL xs y
 sprintfAL ('%' : xs) y =
@@ -166,7 +170,7 @@ sprintfAL ('%' : xs) y =
 sprintfAL (x:xs) y = x : sprintfAL xs y
 
 {- | Finite map version of 'sprintf'. -}
-sprintfFM :: String -> PrintfFM -> String
+sprintfFM :: String -> FiniteMap String Value -> String
 sprintfFM [] _ = []
 sprintfFM ('%' : '%' : xs) y = '%' : sprintfFM xs y
 sprintfFM ('%' : xs) y =
@@ -186,11 +190,31 @@ to the given Handle. -}
 fprintf :: Handle -> String -> [Value] -> IO ()
 fprintf h f v = hPutStr h $ sprintf f v
 
+{- | Like 'sprintfAL', but instead of returning a string, directs output
+to the given Handle. -}
+fprintfAL :: Handle -> String -> [(String, Value)] -> IO ()
+fprintfAL h f v = hPutStr h $ sprintfAL f v
+
+{- | Like 'sprintfFM', but instead of returning a string, directs output
+to the given Handle. -}
+fprintfFM :: Handle -> String -> FiniteMap String Value -> IO ()
+fprintfFM h f v = hPutStr h $ sprintfFM f v
+
 {- | Like 'fprintf', but directs output to standard out instead of
 taking an explicit Handle. -}
 printf :: String -> [Value] -> IO ()
 printf f v = fprintf stdout f v
 
+{- | Like 'fprintfAL', but directs output to standard out instead of
+taking an explicit Handle. -}
+printfAL :: String -> [(String, Value)] -> IO ()
+printfAL = fprintfAL stdout
+
+{- | Like 'fprintfFM', but directs output to standard out instead of
+taking an explicit Handle. -}
+printfFM :: String -> FiniteMap String Value -> IO ()
+printfFM = fprintfFM stdout
+
 {- | Like 'vsprintf', but instead of returning a string, directs output to
 the given Handle. -}
 vfprintf :: IOPFRun a => Handle -> String -> a
@@ -235,6 +259,13 @@ Or, using the list-passing method:
 >sprintf "%s, your age is %d\n" [v "John", v (10::Integer)]
 >> "John, your age is 10\n"
 
+Or, using the association list method:
+
+>sprintfAL "%(name)s, your age is %(age)d\n"
+>  [("name", v "John"),
+>   ("age", v (10::Integer))]
+>> "John, your age is 10\n"
+
 You can also work with I\/O with these:
 
 >main :: IO ()
@@ -284,7 +315,34 @@ would have been required there as well.
 
 These special cases apply only to the \"v\" functions.
 -}
-   
+
+{- $mappingoutput
+
+As a special extension to the printf() format string syntax, special functions
+can take a key name in the format string.  This key will then be looked up
+in an association list or FiniteMap passed in.  Python programmers will
+find this very similar to Python's @%@ operator, which can look up inside
+dicts.
+
+#alexample#
+
+Here's an example:
+
+>import MissingH.Printf
+>
+>al = [("item1", v "Test One"),
+>      ("blah", v (5::Int)),
+>      ("zip", v (3.14::Float))]
+>
+>main :: IO ()
+>main = do
+>       printfAL "%(item1)s: %(blah)03d, %(zip)06.3f; %(item1)s\n" al
+
+This will print:
+
+>Test One: 005, 03.140; Test One
+
+-}   
 
 {- $differencesfromc
 These functions are very similar to the C functions.  Here is a list of the
@@ -403,4 +461,8 @@ When applied to the same example file as before, the output will be:
 >3          0000000015 000000000F
 >4          0000000023 0000000017
 
--}
\ No newline at end of file
+There's a full association list example at
+"MissingH.Printf#alexample".
+
+-}
+
diff --git a/libsrc/MissingH/Printf/Types.hs b/libsrc/MissingH/Printf/Types.hs
index 0a75389..9ce65f2 100644
--- a/libsrc/MissingH/Printf/Types.hs
+++ b/libsrc/MissingH/Printf/Types.hs
@@ -50,10 +50,7 @@ data Value =
            ValueRational Rational
            | ValueString String
            | ValueChar Char
-             deriving (Eq, Show)
-
-type PrintfAL = [(String, Value)]
-type PrintfFM = FiniteMap String Value
+             deriving (Eq, Show, Ord)
 
 showValue :: Value -> String
 showValue (ValueRational x) = show x

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list