[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 4d91505829acf0c88832efccf599c4848102a1b6
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Nov 13 11:26:37 2004 +0100
Added experimental printf
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-23)
diff --git a/ChangeLog b/ChangeLog
index da829ba..3d628ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-13 04:26:37 GMT John Goerzen <jgoerzen at complete.org> patch-23
+
+ Summary:
+ Added experimental printf
+ Revision:
+ missingh--head--0.5--patch-23
+
+
+ new files:
+ libsrc/MissingH/Printf.hs
+
+ modified files:
+ ChangeLog
+
+
2004-10-29 13:37:13 GMT John Goerzen <jgoerzen at complete.org> patch-22
Summary:
diff --git a/libsrc/MissingH/Parsec.hs b/libsrc/MissingH/Printf.hs
similarity index 50%
copy from libsrc/MissingH/Parsec.hs
copy to libsrc/MissingH/Printf.hs
index 8d64b55..8d0c3ea 100644
--- a/libsrc/MissingH/Parsec.hs
+++ b/libsrc/MissingH/Printf.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Parsec utilities
+{- arch-tag: Printf utilities main file
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
- Module : MissingH.Parsec
+ Module : MissingH.Printf
Copyright : Copyright (C) 2004 John Goerzen
License : GNU GPL, version 2 or above
@@ -26,30 +26,44 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Stability : provisional
Portability: portable
-Written by John Goerzen, jgoerzen\@complete.org
+This module provides various helpful utilities for using a C-style printf().
+Written by John Goerzen, jgoerzen\@complete.org
-}
-module MissingH.Parsec(notMatching)
-where
-
-import Text.ParserCombinators.Parsec
-
-{- | Running @notMatching p msg@ will try to apply parser p.
-If it fails, returns (). If it succeds, cause a failure and raise
-the given error message. It will not consume input in either case. -}
-notMatching :: GenParser a b c -> String -> GenParser a b ()
-notMatching p errormsg =
- let maybeRead = try (do
- x <- p
- return (Just x)
- )
- <|> return Nothing
- workerFunc = do
- x <- maybeRead
- case x of
- Nothing -> return ()
- Just x -> unexpected errormsg
- in
- try workerFunc
+module MissingH.Printf(
+ ) where
+
+class PFFun a where
+ toFun :: a -> PFCall -> String
+
+data Value =
+ ValueInt Int
+ | ValueString String
+
+data PFCall = PFCall String [Value]
+
+class PFType a where
+ toValue :: a -> Value
+ fromValue :: Value -> a
+
+instance PFType Int where
+ toValue = ValueInt
+ fromValue (ValueInt x) = x
+ fromValue _ = error "fromValue int"
+
+instance PFType String where
+ toValue = ValueString
+ fromValue (ValueString x) = x
+ fromValue _ = error "fromValue string"
+
+
+instance PFFun String where
+ 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 _ _ = error "Too few arguments"
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list