diff options
| author | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-28 11:00:50 +0000 |
|---|---|---|
| committer | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-28 11:00:50 +0000 |
| commit | 6f5773590d2a1453aba3c47bcca286c4ffeb93bd (patch) | |
| tree | be510250bd3afee9167d1ec6dc4f63808b172cae /HsBot/General | |
| parent | 08e80e41af814eb3d6bc21c72e0830f0fc1e8c6c (diff) | |
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@48 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'HsBot/General')
| -rw-r--r-- | HsBot/General/Render.hs | 5 | ||||
| -rw-r--r-- | HsBot/General/Tools.hs | 32 |
2 files changed, 37 insertions, 0 deletions
diff --git a/HsBot/General/Render.hs b/HsBot/General/Render.hs new file mode 100644 index 0000000..5768942 --- /dev/null +++ b/HsBot/General/Render.hs @@ -0,0 +1,5 @@ +module HsBot.General.Render where + +class Render a where + render :: a -> String + diff --git a/HsBot/General/Tools.hs b/HsBot/General/Tools.hs new file mode 100644 index 0000000..bd13271 --- /dev/null +++ b/HsBot/General/Tools.hs @@ -0,0 +1,32 @@ +module HsBot.General.Tools where + +uniq :: (Eq a) => [a] -> [a] +uniq list = + let r = u' list 0 + u' [] _ = [] + u' (x:list) n + | member x r n = u' list n + | otherwise = x:(u' list (n + 1)) + member e list 0 = False + member y (x:list) n = x == y || member y list (n - 1) + in r + +split :: String -> Char -> [String] +split [] delim = [""] +split (c:cs) delim + | c == delim = "" : rest + | otherwise = (c : head rest) : tail rest + where rest = split cs delim + +empty :: String -> Bool +empty str = length str == 0 + +contains :: String -> Char -> Bool +contains str char = takeWhile (/= char) str /= str + +isMultiline :: String -> Bool +isMultiline str = contains str '\n' + +showL :: Show a => [a] -> [String] +showL = map (\x -> show x ++ "\n") + |
