Permalink
Browse files

Cabal only

  • Loading branch information...
1 parent 1c362da commit b2179208290ef8fad338ca8454d3422d6ab5dfcd @bytbox committed May 23, 2012
Showing with 0 additions and 48 deletions.
  1. +0 −3 .gitignore
  2. +0 −8 Makefile
  3. +0 −37 main.hs
View
@@ -1,5 +1,2 @@
-*.hi
-*.o
-main
.*.swp
dist
View
@@ -1,8 +0,0 @@
-all: main
-
-main: main.hs Text/Format.hs
- ghc -W --make $@
-
-clean:
- ${RM} main *.o *.hi */*.o */*.hi
-
View
@@ -1,37 +0,0 @@
-module Main where
-
-import Text.Format
-
-formatString = "$p1 - ${p2} [$$$cost]"
-
-data Record = Record
- { p1 :: Int
- , p2 :: Int
- , cost :: (Int, Int)
- }
-
-fields :: String -> Maybe (Record -> String)
-fields "p1" = return $ show . p1
-fields "p2" = return $ show . p2
-fields "cost" = return $ (\(d, _) -> show d) . cost
-fields _ = Nothing
-
-postponeMaybe :: (a -> Maybe (b -> c)) -> a -> b -> Maybe c
-postponeMaybe f a b = do
- f' <- f a
- return $ f' b
-
-ff :: Record -> String -> Maybe String
-ff = flip $ postponeMaybe fields
-
-sample = Record 3 56 (5, 44)
-sampleString = "3 - 56 [$5]"
-
-scanMain = scanFormatString formatString sampleString
-
-renderMain = renderFormatString formatString (ff sample)
-
-main = case scanMain of
- Left s -> putStrLn s
- Right s -> print s
-

0 comments on commit b217920

Please sign in to comment.