]> gitweb @ CieloNegro.org - blackboard-dns.git/blobdiff - DDNS/Utils.hs
Split commands off
[blackboard-dns.git] / DDNS / Utils.hs
diff --git a/DDNS/Utils.hs b/DDNS/Utils.hs
new file mode 100644 (file)
index 0000000..9c32824
--- /dev/null
@@ -0,0 +1,16 @@
+module DDNS.Utils
+    ( trim
+    )
+    where
+
+trim :: Maybe String -> Maybe String
+trim Nothing   = Nothing
+trim (Just xs) = case trimTail $ trimHead xs of
+                   "" -> Nothing
+                   ys -> Just ys
+    where
+      trimHead []       = []
+      trimHead (' ':ys) = trimHead ys
+      trimHead ys       = ys
+
+      trimTail = reverse . trimHead . reverse