functional-programming

Must a Language that Implements Monads be Statically Typed?

I am learning functional programming style. From this link http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/, Brian Beckman gave a brilliant introduction about Monad. He mentioned that Monad is about composition of functions so as to address complexity. A Monad includes a unit function that transfers type...

When to use a functional programming language?

In which situations should I choose to use a functional programming language over a more verbose object oriented language like C++, C# or Java? I understand what functional programming is, what I don't really understand is for what types of problems is it a perfect solution? ...

What is Hindley-Milner?

I encountered this term "Hindley-Milner" which I'm not sure if grasp what it means. I read Steve Yegge's "Dynamic Languages Strike Back" and "The Pinocchio Problem" and Daniel Spiewak's "What is Hindley-Milner? (and why is it cool?)". But there is no single entry for this term in wikipedia where usually offers me a concise explanation. ...

exercise in haskell

hi i prepare myself for the exams and i am styding on previous past papers. could anybody give me a model answer to the following question,it would be very helpful to me to work through the answer! a) Show how to read a line using getLine and use putStrLn to write out the capitalized version of the line. (15%) b) Consider the followin...

Scope of variables in a delegate

I found the following rather strange. Then again, I have mostly used closures in dynamic languages which shouldn't be suspectable to the same "bug". The following makes the compiler unhappy: VoidFunction t = delegate { int i = 0; }; int i = 1; It says: A local variable named 'i' cannot be declared in this scope because it wou...

Typed FP: Tuple Arguments and Curriable Arguments

In statically typed functional programming languages, like Standard ML, F#, OCaml and Haskell, a function will usually be written with the parameters separated from each other and from the function name simply by whitespace: let add a b = a + b The type here being "int -> (int -> int)", i.e. a function that takes an int and return...

What are some examples of LISP being used in production, outside of AI and academia?

Possible Duplicate: Lisp in the real world A search query on Google reveals that the search term 'practical lisp' returns a link for Practical Common LISP, which is a very nice starter book. However, this is not what I was looking for or had in mind when I set out to search those terms. ...

Haskell: How to compose `not` with a function of arbitrary arity?

When I have some function of type like f :: (Ord a) => a -> a -> Bool f a b = a > b I should like make function which wrap this function with not. e.g. make function like this g :: (Ord a) => a -> a -> Bool g a b = not $ f a b I can make combinator like n f = (\a -> \b -> not $ f a b) But I don't know how. *Main> let n f = (\a...

implementing type inference

well I see some interesting discussions here about static vs. dynamic typing I generally prefer static typing, due to compile type checking, better documented code,etc. However I do agree that they do clutter up the code if done the way Java does it, for example. so Im about to start building a language of my own and type inference is ...

What's your naming convention for helper functions?

In functional programming, it's often important to optimize any "looping" code to be tail recursive. Tail recursive algorithms are usually split between two functions, however - one which sets up the base case, and another that implements the actual loop. A good (albeit academic) example would be the reverse function. reverse :: [a] -> ...

What would be a good functional language to pick up?

I come from a background of a large variety of languages but my only experience with functional programming languages was a brief stint with OCaml. I want to dive a lot deeper into one of these languages (Lisp/Scheme, Erlang, Scala, Haskell, etc.) but I want it to hopefully be one that is practical in working environments and also has a ...

Ocaml List: Implement append and map functions

Hi! I'm currently trying to extend a friend's OCaml program. It's a huge collection of functions needed for some data analysis.. Since I'm not really an OCaml crack I'm currently stuck on a (for me) strange List implementation: type 'a cell = Nil | Cons of ('a * 'a llist) and 'a llist = (unit -> 'a cell);; I've figured out that t...

Does anyone have any recommendations for starting out in functional programming?

I'm looking for some ebooks that will assist in my learning of functional programming. I haven't yet decided which language I will go with, but I've noticed a fair amount of bias towards LISP, Haskell and F# amongst the community on StackOverflow. As yet, I'm unsure which direction I will take, but can anyone recommend any particular e...

What is this functional "pattern" called?

I was fooling around with some functional programming when I came across the need for this function, however I don't know what this sort of thing is called in standard nomenclature. Anyone recognizes it? function WhatAmIDoing(args...) return function() return args end end Edit: generalized the function, it takes a variabl...

passing functions as arguments in ruby

I'm trying to wrap my head around functional programming in ruby and there doesn't seem to be much good documentation out there. Essentially, I'm trying to write a combine function that would have a Haskell type signature of: [a] -> [a] -> (a -> a -> a) -> [a] So combine([1,2,3], [2,3,4], plus_func) => [3,5,7] combine([1,2,3], [2,3...

How do classes help you manage large applications?

This came up in a conversation I was having online, and it occured to me that I have no idea how this is supposed to work: Quite a lot of programmers seem to just take as a given- indeed, obvious that classes are a necessary language feature for managing huge software projects. It's not obvious to me how they do this. My question to yo...

How to reduce memory usage in a Haskell app?

I am new to functional programming, and now learn Haskell. As an exercise I decided to implement the explicit Euler method for 1D linear diffusion equation. While the code below works correctly, I am not happy about its performance. In fact, I am concerned with memory consumption. I believe that it is related to lazy evaluation, but cann...

Erlang: doing a good job

I've done a bit of functional programming, and I have a couple online references, so I'm finding basic Erlang programming pretty easy. But since I've done far more procedural/object-oriented programming than functional programming, I expect my Erlang code isn't very well styled or efficient. Can anybody recommend any resources that cov...

How/why do functional languages (specifically Erlang) scale well?

I have been watching the growing visibility of functional programming languages and features for a while. I looked into them and didn't see the reason for the appeal. Then, recently I attended Kevin Smith's "Basics of Erlang" presentation at Codemash. I enjoyed the presentation and learned that a lot of the attributes of functional p...

How can I write an app that doesn't change state (in functional language)?

I want to learn functional programming one day but I don't understand how I could use it for anything other than simple math. For example: A simple web browser add bookmark function needs to cause some sort of mutation so that next time the user clicks bookmarks the new bookmark is there in the list. ...