At first, thanks to all of you about this nice insight into FP used
programmers. It was really a suprise to me to see that that what Sven
wrote seems to be easily understood. I would really like to see such
code-snippets to found on a central site what about www.haskell.org ?

I reread my book and there the chapte about functional composition or
the like and I found  the stuff I didn't understand. So maybe it's time
to re-read the book again ;-)



> 
>   longerThan fn lenlim
>     = readFile fn >>= procFile
> 
>   procFile
>     = putStr                                 .
>       unlines                                .
>       (map (\ (n,l) -> show n ++ ") " ++ l)) .
>       (zip [1..])                            .
>       (filter ( (>lenlim) . length ) )       .
>       lines


This seems to be not workable and I tried it by myself. 

this is my Result:
lt1 fn lenlim = readFile fn >>= procFile lenlim

procFile lenlim  = putStr .
                   unlines .
                   (map(\(n,l) -> show n ++ ")" ++ l)) .
                         (filter ((> lenlim) . length . snd )) .
                   (zip [1..]) .
                   lines


this seems to to the thing I would like it to do. I now have to check if
the given fn is valid and raise an error if not so I do think I'll make
it;-)

Another thing is that I prefer for 
(.|) = flip (.) 
(>.>) = flip(.)

I think that's a matter of tast an both are familar. The .| reminds me
of a pipe-symbol and > shows me the flow. So ok Both are quite ok
althought I'm quite aware taht f . g maybe well known in mathematics.
But it's quite amazing how many possibilities you have to express that.
This makes it very expressive but IMO terrible difficult to understand.
I hope I get used to use the "right" mental  model for FP someday. And I
hope I then won't the obfuscatd code but the beauty of Functions.

Thanks to Keith to explain to me in detail what is meant by the code
excepts. I rethink about it, read it again and now it's getting clearer
and clearer each time. Another 1000 examples and I may be familia with
it ;-)


So please allow me another question. Is that a way such functions are
build? How it that reused? Does it make sense to write some extra
functions for intermediate steps or should I try to learn that kind of
programming.


I have some problems with it because  a lot of work is just done in one
Method. My knowledge comes from OO-programming and there it wouldn't be
good style to do so much in one function.

Regards
Friedrich


Reply via email to