[Fencommits] fenfire-hs: add Utils.updateWithDefault (for maps); add run-ghci to Makefile
Benja Fallenstein
benja.fallenstein at gmail.com
Sun Mar 18 17:53:20 EET 2007
Sun Mar 18 17:52:35 EET 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* add Utils.updateWithDefault (for maps); add run-ghci to Makefile
diff -rN -u old-fenfire-hs/Fenfire/Utils.hs new-fenfire-hs/Fenfire/Utils.hs
--- old-fenfire-hs/Fenfire/Utils.hs 2007-03-18 17:53:19.000000000 +0200
+++ new-fenfire-hs/Fenfire/Utils.hs 2007-03-18 17:53:19.000000000 +0200
@@ -28,6 +28,8 @@
import Control.Monad.Trans
import Control.Monad.Writer (WriterT(..), MonadWriter(..), execWriterT)
+import Data.Map (Map)
+import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.Monoid (Monoid(..))
@@ -54,6 +56,10 @@
l !? i | i < 0 = Nothing
| i >= length l = Nothing
| otherwise = Just (l !! i)
+
+
+updateWithDefault :: Ord k => a -> (a -> a) -> k -> Map k a -> Map k a
+updateWithDefault x f = Map.alter (Just . f . fromMaybe x)
maybeReturn :: MonadPlus m => Maybe a -> m a
diff -rN -u old-fenfire-hs/Makefile new-fenfire-hs/Makefile
--- old-fenfire-hs/Makefile 2007-03-18 17:53:19.000000000 +0200
+++ new-fenfire-hs/Makefile 2007-03-18 17:53:19.000000000 +0200
@@ -46,6 +46,9 @@
run-latex2png: latex2png
run-%: %
./dist/build/$</$< $(ARGS)
+
+run-ghci: build install
+ ghci -lraptor
run-project: fenfire ../fenfire-project/project.turtle darcs.nt
./dist/build/fenfire/fenfire ../fenfire-project/project.turtle darcs.nt $(ARGS)
More information about the Fencommits
mailing list