Does literate programming in haskell (.lhs) support the idea in Knuth's WEB of using aliases for blocks of code? In other words doing something like main = do <part 1> <part 2> <part 1> === putStrLn "foo" <part 2> === putStrLn "bar" (except I don't know what the actual syntax is) -Dennis
On Sat, Sep 1, 2012 at 6:46 PM, Dennis Raddle <dennis.raddle@gmail.com>wrote:
Does literate programming in haskell (.lhs) support the idea in Knuth's WEB of using aliases for blocks of code? In other words doing something like
main = do <part 1> <part 2>
<part 1> === putStrLn "foo" <part 2> === putStrLn "bar"
(except I don't know what the actual syntax is)
No, and it's not as necessary in Haskell as it was in Pascal because it's easier (and preferred) to break programs up into smaller functions anyway. So your <part 1> is just part1, and the definition of part1 follows later. (Consider that we don't throw around state in variables quite as wontonly; and when we *do* need to, we can stuff it in a state monad.) -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
participants (2)
-
Brandon Allbery -
Dennis Raddle