3 ms·
Granted, it's not exactly the same. > I seem to need to rewrite half my code to use a very similar, but subtly different syntax. Half is a massive over exagge
by tome 13y ago
Granted, it's not exactly the same.
> I seem to need to rewrite half my code to use a very similar, but subtly different syntax.
Half is a massive over exaggeration if you've written it in the right way, i.e. the in the composable manner, preferring (.) and (<=<) over function application and (>>=). However, this I don't know how widely appreciated this style is. It's certainly not taught first in functional programming, unfortunately.
- prof_hobart 13y agoI certainly don't think it's the style I've picked up from any of the books/tutorials I've seen. But even changing several levels of call from "." to "<=<" (and presumably back again when I've finished) because I've added a temporary logging call somewhere in the stack, still seems rather a pain.
- polymatter 13y agoI am not an expert by any stretches of the imagination, but I have some experience of Haskell at least. Currently writing a web app with Yesod (go check it out!). Outside of the trivial pure functions, pretty much all real work is done inside or one monad or another. At which point there is no change in syntax or level at all. If you just want a temporary log consider using Haskell's debug features: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Debug-Trace.html http://www.haskell.org/ghc/docs/latest/html/libraries/base/D... "For example, this returns the value of f x but first outputs the message. trace ("calling f with x = " ++ show x) (f x)" A good analogy is moving from procedural to object oriented code. It seems like a massive transition to organise code into separate objects which are instantiated rather than just using function pointers or gotos where you need to. But objects allow you to talk about frameworks and different architectures, separation of responsibilities and in general manipulate your code at a much higher level. Its worth pushing through to understand objects even if initially they are harder than naive procedural code. Similarly its worth taking the investment to understand monads rather than try to avoid them. In the longer run, they provide a higher level structure to the code.