]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/StringUtils.hs
Use a more flexible curl function to make HTTP requests.
[dead/halcyon.git] / src / StringUtils.hs
1 -- |Miscellaneous functions for manipulating string.
2 module StringUtils
3 where
4
5 import Test.HUnit
6
7
8 -- |Takes a list of strings, call them string1, string2, etc. and
9 -- numbers them like a list. So,
10 -- 1. string1
11 -- 2. string2
12 -- 3. etc.
13 listify :: [String] -> [String]
14 listify items =
15 zipWith (++) list_numbers items
16 where
17 list_numbers = map show_with_dot [1::Integer ..]
18 show_with_dot x = (show x) ++ ". "
19
20
21
22 string_utils_tests :: [Test]
23 string_utils_tests = [ test_listify ]
24
25
26 test_listify :: Test
27 test_listify =
28 TestCase $ assertEqual "All items are numbered correctly." expected_items actual_items
29 where
30 actual_items = listify [ "item1", "item2" ]
31 expected_items = ["1. item1", "2. item2" ]