Reputation
9,540
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
9 42 95
Impact
~504k people reached

Aug
17
answered What is the difference between business and application logic?
Aug
17
comment Why is Lisp useful?
@ Dan Dyer: I do not get all the jokes about the nested parens. Why don't these joke apply to C, Java, C#, and so on? All those (, ), {, }.
Aug
17
comment How does Functional Programming's immutability feature work with CQS?
@koenmetsu: I suppose what you would do in Haskell would be to define your commands as IO actions that return a value of type Either, so that you can represent both the error and success result of each action. Then you would sequence these actions and use a writer monad to collect all the result codes. I am not familiar enough with the writer monad to produce an example. Maybe there is some Haskell expert that can confirm if this idea is correct and sketch a solution.
Aug
14
comment Is return-type-(only)-polymorphism in Haskell a good thing?
+1: Only came across this answer now.
Aug
14
revised What is State, Mutable State and Immutable State?
Added reference to related talk.
Aug
14
comment What is State, Mutable State and Immutable State?
@Doval: You mentioned stateful functions that remember values across different calls. One example I can think of are static local variables in C. Another example is closures (functions that capture variables defined in their context). Closures are somewhat dual to objects: a closure is an object with exactly one method, whereas an object is a collection of closures defined over the same variables. You probably know all this but I wanted to summarize it here. In general, you can store state in some memory location and access it using different mechanisms, as you pointed out.
Aug
14
comment Can higher order functions ever be pure?
In my intuition map is always a pure function. The result of applying map to a function may be pure or impure, according to the function that is being mapped.
Aug
14
comment Can higher order functions ever be pure?
@delnan: If you know the distinction, I find it misleading to say that Haskell's map function "... implicitly requires that the function to be mapped is pure." Also, what about this expression: map putStrLn ["a", "b"] In this example, is map forcing the function to be mapped to be pure?
Aug
14
comment Can higher order functions ever be pure?
A function of type a -> IO b is still a pure function i.e., given a value of type a, it always produces the same action of type IO b. Executing the action resulting from function application may not be pure, but executing an action and evaluating a function are two different things in Haskell.
Aug
14
comment Can higher order functions ever be pure?
"...the Haskell function map :: (a -> b) -> [a] -> [b] does, implicitly, require that the function to be mapped is pure.": To be more precise, I would say that all functions in Haskell are pure, and therefore map and the function being mapped are pure.
Aug
13
comment Why do Haskell functors only have derived types in their target category?
@jozefg: I occasionally think about this question again and again. I suppose the Haskell restriction does not affect the expressive power of functors. For example, suppose that we have a functor that is isomorphic to the list functor, but does not map, say, Int -> [Int] but Int -> <fancy type using no type constructor>. Then I guess one could prove that <fancy type using no type constructor> is isomorphic to [Int]. So choosing objects that are defined using a type constructor is just convenient and does not sacrifice the expressive power.
Aug
12
answered Is there any practical way for a linked node structure to be immutable?
Aug
3
comment Is there a Haskell idiom for trying several functions and stop as soon as one succeeds?
@JimmyHoffa: I am reading about monoids in learnyouahaskell.com/… The First a type seems what I am looking for. Then I could use mconcat in that monoid to defined tryFunctions. tryFunctions fs x = mconcat [First (f x) | f <- fs]. Maybe this can work.
Aug
2
comment Is there a Haskell idiom for trying several functions and stop as soon as one succeeds?
Great paper by Wadler! Thanks (+1)
Jul
30
awarded  Popular Question
Jul
28
comment Is there a Haskell idiom for trying several functions and stop as soon as one succeeds?
@JimmyHoffa: Thanks a lot for your answer (+1). I will review monoids during the coming days and then take a close look at your examples.
Jul
27
comment Is there a Haskell idiom for trying several functions and stop as soon as one succeeds?
I do not understand why <|> treats the identity of a monoid in a special way. Couldn't one pick an arbitrary element of an arbitrary set to play that special role? Why does the set have to be a monoid and the special element wrt <|> its identity?
Jul
27
asked Is there a Haskell idiom for trying several functions and stop as soon as one succeeds?
Jul
25
awarded  Popular Question
Jul
19
comment Is this data model a list or tree?
"Are you considering each element of any list pointed by tree as node ?": tree points to one list only. This list is a node but not a leaf node. It contains three subnodes, the first two are internal nodes, the third is a leaf-node. And so on. The leaf-nodes of the tree are therefore the one marked by 1, 2, 3, 4, 5, 6, 7, and the empty list.