hledger/Utils.hs

42 lines
1.1 KiB
Haskell
Raw Normal View History

2007-02-16 14:51:30 +03:00
module Utils (
module Utils,
module Data.List,
2007-03-10 06:16:19 +03:00
module Data.Tree,
2007-02-16 14:51:30 +03:00
module Debug.Trace,
module Text.Printf,
module Text.Regex,
quickCheck,
)
where
import System.Directory
2007-02-16 14:51:30 +03:00
import Data.List
2007-03-10 06:16:19 +03:00
import Data.Tree
2007-02-16 14:51:30 +03:00
import Debug.Trace
import Test.QuickCheck (quickCheck)
import Text.Printf
import Text.Regex
rhead = head . reverse
rtail = reverse . tail . reverse
splitAtElement :: Eq a => a -> [a] -> [[a]]
splitAtElement e l =
case dropWhile (e==) l of
[] -> []
l' -> first : splitAtElement e rest
where
(first,rest) = break (e==) l'
-- courtesy of allberry_b
tildeExpand :: FilePath -> IO FilePath
tildeExpand ('~':[]) = getHomeDirectory
tildeExpand ('~':'/':xs) = getHomeDirectory >>= return . (++ ('/':xs))
-- ~name, requires -fvia-C or ghc 6.8
--import System.Posix.User
-- tildeExpand ('~':xs) = do let (user, path) = span (/= '/') xs
-- pw <- getUserEntryForName user
-- return (homeDirectory pw ++ path)
tildeExpand xs = return xs