I posted my feelings about Scala to a question on Quora.
Is there a programming language that's as elegant and supported as Haskell, and as practically useful as Erlang?
Tuesday, March 12, 2013
Friday, March 8, 2013
When to use Applicative vs Monad
A nice rule of as to when you must use Monad and when you can use Applicative style:
How do you use Control.Applicative to write cleaner Haskell?
Update: May be another way to look at this is to think of >>= as combinator that applies the mapping function then flattens the result of application of (a -> mb), and (in some implementations) change the computation based on the value of the "a". In computations where the >>= is only flattening the types, it can be converted to an Applicative computation.
How do you use Control.Applicative to write cleaner Haskell?
Update: May be another way to look at this is to think of >>= as combinator that applies the mapping function then flattens the result of application of (a -> mb), and (in some implementations) change the computation based on the value of the "a". In computations where the >>= is only flattening the types, it can be converted to an Applicative computation.
Tuesday, March 5, 2013
Adding numbers as digits in a list
In a phone interview with an un-named company :) I was asked to come up with solution for hypothetical adder where input data are integers but are given as list of single digits. For instance 345 would be [3,4,5]. Problem is to write an adder for the numbers. I kind of like the simplicity of the solution in Haskell ( as oppose to my java-like doodle in the interview).
You can find my code Here
You can find my code Here
Friday, March 1, 2013
Refreshing my statistics
I am watching a nice set of lectures of Harvard's Stat 110 class.
Watch the Lectures
Professor Joe Blitzstein is great. One particularly puzzling problem is presented at 36:00 minute of Stat 123 teaser.
I have not been able to figure out the puzzle in the expected value of Euro and $. If you happen to have any ideas on this I would appreciate it.
Watch the Lectures
Professor Joe Blitzstein is great. One particularly puzzling problem is presented at 36:00 minute of Stat 123 teaser.
I have not been able to figure out the puzzle in the expected value of Euro and $. If you happen to have any ideas on this I would appreciate it.
Tuesday, October 2, 2012
Yet another good use of delimited continuation
Scope herding with delimited continuations
One confusing aspect to the continuation discussion is that in Scheme (where continuation got its start) future of computation is what is to the left of the shift. For instance in (reset (foo (bar ( shift....)))) the bar and foo functions are the rest of the computation after the shift (thus the context that is passed to the shift function). Whereas in Haskell's do notation we have
shift $ do
.....
shift ( some function here )
bar
foo
Here the rest of the continuation (the bar, and foo) are what follows the shift to the end of the do block. Seems more intuitive, doesn't it?
Friday, March 16, 2012
Tutorial on Continuation and Delimited Continuation
A nice tutorial on Continuation and delimited Continuation here.
Wednesday, January 4, 2012
I like this post on what monadic parsers are and where they are useful.
This exchange further explains when you need monadic power.
This exchange further explains when you need monadic power.
....use the simplest tool which gets the job done. Don't use a fork lift when a dolly will do. Don't use a table saw to cut out coupons. Don't write code in IO when it could be pure. Keep it simple.
But sometimes, you need the extra power of Monad. A sure sign of this is when you need to change the course of the computation based on what has been computed so far. In parsing terms, this means determining how to parse what comes next based on what has been parsed so far; in other words you can construct context-sensitive grammars this way.
Subscribe to:
Posts (Atom)