Haskell and F#: Language Design

After watching a taste of Haskell by Simon Peyton-Jones and having a look at PDFA History of Haskell: being lazy with class, I am left with some open questions regarding the design of F#:

  • Why is F# not lazy?: What is the advantage of eagerness?

  • Is there a point in encapsulating side-effectful operations in monads while programming in F#? IO Monads etc.?

    #light

    // Sample F# IO Monad : OSCON Haskell Video Part 2

    type IO<'a> = IO of 'a

    // get: unit -> IO<string>
    let get () = IO(read_line ())

    // put: string -> IO<unit>
    let put x = IO(print_string x)

    // bind.e: IO<'a> -> 'a
    // bind: IO<'a> -> ('a -> IO<'b>) -> IO<'b>
    let bind (x:IO<'a>) (y:('a -> IO<'b>)) = let e (IO(a)) = a in y (e x)
    let (>>=) = bind

    // gp: unit -> IO<unit>
    let gp () = get () >>= put

    gp ()

  • Why did the F# team chose ML and OCaml over Haskell?

I hope someone from the F# team enlightens me on all these. I am still scrutinizing the 55-pages-long history of Haskell to create a list of questions I want to ask.

Comments

Anonymous said…
Why is F# not lazy?:
---------------
because it's based on ML ?

What is the advantage of eagerness?
---------------------------
Efficient implementation of lazy language is fairly recent (80s). Also strictness might be less disturbing to the average programmer


Is there a point in encapsulating side-effectful operations in monads while programming in F#? IO Monads etc.?
-------------------
Monads are used to encapsulate side-effect in Haskell because of its purity.
AFAIK monads are not so useful with regard to side-effects in an impure language, but monads have a lot of other uses...

Why is F# based on ML ?
-------------------
dunno, because of OCaml success ?
Anonymous said…
F# is not based on ML but has the syntax and the influence from ML. It is still possible to use lazy construct with F# if you really need.
let a = lazy 5
In case you missed that.
On the other hand because it runs on .NET, its impureness and multiparadigm support led to have the optional lazy.
Also pure HAskell implementation on a fully object oriented framework is not a feasable research I reckon. Actually before F# Ms Research started with HAskell.net, but quit the project
Cetin Sert said…
Phoa, thank you all for your answers! ^o^

@can:
I am still new to the whole functional programming business but I am definitely dumb-struck by its compositional power and beauty. As for F#, I was just being picky about its impure nature but it nonetheless seems to fit into the .NET environment very well. It is interesting to learn that MS Research had set its mind first on Haskell though.

I admit that I do not know (yet) much about the practical impact of lazy or eager evaluation in large-scale projects.

I did not miss the 'lazy' construct but have not had enough time to experiment with it so far. Still trying to attain syntactical fluency in Haskell and F#.

---

Somewhere in Expert F#, let me see... on page 112 in the side note box... it is stated that the designers of F# are planning to introduce type classes a lá Haskell.

So Haskell seems to be a test bed for constructs that other languages eventually come to embrace too.

How about the other way around: is there anything in the syntax or implementation of F# that makes it unique, anything that 'F# gives to the world' of functional languages?

Don't get me wrong on that. I am fully aware that an officially supported first-class functional language on a platform as popular as .NET is going to set things going for all things FP but with your experience from the F# team, you might just be the man to reveal some not so obvious details about the language.

---

On the homepage of the F#, I came across some powerpoint presentations in which it was stated at least twice that it is easier to use .NET types written in other languages from F# than it is to use libraries written in F# from other .NET languages. Maybe there is ongoing work to polish-up the CIL F# produces. Or else other .NET programmers might find it awkward programming against libraries etc written in F#.

---

Sorry for my mess reply which does not even constitue a coherent text o_O!

Popular posts from this blog

Levenshtein Distance Algorithm: Fastest Implementation in C#

Mono 1.2.5 binaries for Solaris 10/x86

WordSmith Tools 5.0, Tenka Text in China