On Thu, Jun 01, 2000 at 07:23:55PM +0200, Ketil Malde wrote:
> Jan Skibinski <[EMAIL PROTECTED]> writes:
> 
> > On Thu, 1 Jun 2000, S.D.Mechveliani wrote:
> 
> >> If you require the single functions
> >>                      sort_merge, sort_insert, sort_quick,
> >> do you also require
> >>                      tar_x, tar_xv, tar_v   instead of   tar <mode>
> >> ?
> 
> If tar was implemented in Haskell, it'd be a module with functions
> like "extract" (tar_x) "extractVerbose" (tar_xv) and "uselessFunction" 
> (tar_v).  IMHO.  So, I think the comparision is flawed.
> 
> I could accept "mode flags" if the algorithm is extremely similar,
> e.g. passing a comparator function to a sort is a kind of mode flag
> (think ordered/reversed) which I think is perfectly acceptable.
> Having flags indicating algorithm to use (sort Merge (s:ss)) is IMHO
> silly. 
> 

It seems to me that mode flags only really make sense when we're combining
modes. To continue the tar example it might be a bit much to have
extractVerbosePreserve, extractPreserve etc etc. This is also done in C by
|'ing 'flags' together for things like open(). So mode flags make sense in
UNIX and C. In Haskell we combine functions and use higher order functions,
à la sortBy. For tar probably the best would be generating a list of the
files in the archive, including information like modification time and
permissions and then mapping onto that the composition of funtions that have
type FileInfo -> IO FileInfo. So if you wanted to extract and preserve you'd
do 'mapTar (extract . preserve)', adding in verbose and so on if you wanted.
-- 
-Simon Raahauge DeSantis

Reply via email to