Hello list,
I'm new to Haskell and I'm trying to learn how to write elegant code
using Haskell.
I decided to convert the following small tool, written in ruby:
===
#! /usr/bin/env ruby
require 'pathname'
BASENAMES = %w{ mail.log
On Mon, Jan 29, 2007 at 08:14:55PM +0100, Michael Roth wrote:
Hello list,
Hi!
Just to simplify one function...
logdir = /var/log
...
makeOldname :: String - String
makeOldname fn = logdir ++ '/' : fn
...
main :: IO ()
main = do
files - liftM (filter isLogfile)
-- Here's my contribution to the Haskell way to do it
import Directory (renameFile)
import System.FilePath
import System.Path.Glob (glob)
import System.Time
basenames= [ mail.log, thttpd.log ]
logdir = /var/log
archivedir = /var/log/archive
main = forM_ bases $ \base - do
olds -
-- here was my original before I allowed someone (no names) to mangle
mine for me ;)
import Control.Monad (liftM, forM_)
import Directory (getModificationTime, renameFile)
import Text.Printf (printf)
import System.FilePath ((/),(.))
import System.Locale (defaultTimeLocale)
import
On Mon, Jan 29, 2007 at 05:30:41PM -0600, Eric Mertens wrote:
import Control.Monad (liftM, forM_)
import Directory (getModificationTime, renameFile)
import Text.Printf (printf)
import System.FilePath ((/),(.))
import System.Locale (defaultTimeLocale)
import System.Path.Glob (glob)
import
On Mon, 2007-29-01 at 20:14 +0100, Michael Roth wrote:
Ok, the tool written in Haskell works. But, to me, the source doesn't
look very nice and even it is larger than the ruby solution, and more
imporant, the programm flow feels (at least to me) not very clear.
I am by no means a Haskell (or
Hello,
I think that whole program flow thing is something you get used to. In
true, pure functional programming (i.e. Haskell) program flow is a
meaningless term, basically. Haskell is a declarative language, not an
imperative one. You have to learn to give up that control and trust the