[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:46:20 UTC 2010
The following commit has been merged in the master branch:
commit 0371ed17bba13570bc49df80ecf4ca17332a4c7d
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Nov 13 11:44:11 2004 +0100
Updated printf
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-24)
diff --git a/ChangeLog b/ChangeLog
index 3d628ff..67e3b39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-13 04:44:11 GMT John Goerzen <jgoerzen at complete.org> patch-24
+
+ Summary:
+ Updated printf
+ Revision:
+ missingh--head--0.5--patch-24
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/Printf.hs
+
+
2004-11-13 04:26:37 GMT John Goerzen <jgoerzen at complete.org> patch-23
Summary:
diff --git a/libsrc/MissingH/Printf.hs b/libsrc/MissingH/Printf.hs
index 8d0c3ea..19f8475 100644
--- a/libsrc/MissingH/Printf.hs
+++ b/libsrc/MissingH/Printf.hs
@@ -34,6 +34,8 @@ Written by John Goerzen, jgoerzen\@complete.org
module MissingH.Printf(
) where
+import MissingH.Str
+
class PFFun a where
toFun :: a -> PFCall -> String
@@ -41,7 +43,7 @@ data Value =
ValueInt Int
| ValueString String
-data PFCall = PFCall String [Value]
+data PFCall = PFCall [Value]
class PFType a where
toValue :: a -> Value
@@ -59,11 +61,22 @@ instance PFType String where
instance PFFun String where
- toFun x (PFCall _ []) = x
+ toFun x (PFCall []) = x
toFun _ _ = error "Too many arguments"
instance (PFType a, PFFun b) => PFFun (a -> b) where
- toFun f (PFCall n (x:xs)) =
- toFun (f (fromValue x)) (PFCall n xs)
+ toFun f (PFCall (x:xs)) =
+ toFun (f (fromValue x)) (PFCall xs)
toFun _ _ = error "Too few arguments"
+----------------------------------------------------
+
+printf :: String -> PFFun
+printf "" = toFun ""
+printf ('%' : xs) = toFun (\x -> x ++ printf xs)
+printf x =
+ case split "%" x of
+ [y] -> toFun y
+ [y : z] -> toFun (\a -> y ++ a ++ printf (join "%" z))
+
+
\ No newline at end of file
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list