calopetreep
module TraceCompose where
import Debug.Trace
-- | Trace a value, resulting in the value itself
idTrace :: Show a => a -> a
idTrace x = trace (show x) x
traceCompose :: (Show a, Show b, Show c) =>
(b -> c) -> (a -> b) -> a -> c
traceCompose f g = h f . h g . h id
where h f x = idTrace (f $ seq x x)
-- Replace "normal" function composition using traceCompose.
test = (+1) . (*10) $ 4
where (.) = traceCompose
When you run "test", it will print:4 40 41
(i.e., the outputs of each function at each point in the composition in order of execution.)
Ah, I see the problem- automatic differentiation is not the same as symbolic differentiation- see wikipedia: http://en.wikipedia.org/wiki/Automatic_differentiation This certainly isn't a moot point :)
> Also, we've left the original topic (...)
No- again, I've been saying the same thing all along. In fact I'm only using Haskell as an example. There are things which cannot be expressed in Haskell, too- for example dependent typed programs as you might find in Agda or Idris.
> In a larger sense, wouldn't it be more praiseworthy to say that Haskell does exactly what other languages do, but much better?
This is a separate conversation entirely. My aim is not to "praise Haskell". I have used Haskell and Java only as examples.
Yes, I'm not disputing this- I'm fully in agreement that all turing-complete languages can compute all turing-computable computations. I've never been trying to argue against that. I'm sorry if I haven't explained myself clearly enough- let me give it another shot.
In Haskell, I can write a function operating on numbers like this:
f x = x**2 + x + 1
The AD library means I can do this: g = diff f
and g will behave as if I'd declared g x = 2 * x + 1
As far as I'm aware, it's not possible to write this code in Java- you can't get the differentiated version of a Java function this way.You can compute the same results, of course. You just can't write a library that will accept a function and give back its differentiation.
You can write a function that takes some representation of a mathematical function, for example as a string, and build a function from that to compute the same results, but you can't pass in an actual Java function- so you can't write the library. You can write a library which differentiates string-representations-of-functions, but you can't write one that differentiates first-class-Java-functions (well, objects with functions on, but you get the idea. I hope.)
Nope! The Turing-completeness of Haskell and Java means they can both compute the same functions. However, there are certain things which are just not possible to express directly in some languages. Possible to compute, but not express directly.
Instead of Java, consider Brainfuck. It's a turing-complete language and certainly has no notion of what a function is. There's simply no way in Brainfuck to directly express that idea.
Another example, this time with Java and Haskell. In Haskell, I can write a function to add any two numbers (regardless of their type) like this:
add' :: Num a => a -> a -> a
add' x y = x + y
As far as I'm aware in Java, there's no way to write a function with a signature that says "Take two numeric arguments of any type". Certainly pre-generics, this is impossible.
Edits: markup
I've found this to be totally the opposite: my time in Java is much less productive. There are many libraries in Haskell which aren't even possible to write in Java (automatic differentiation, parser combinators, lenses, etc.)
> very few haskell programmers that are interested in doing boring work
Nobody is interested in doing boring work, or it would be interesting work. Nothing to do with Haskell programmers.
Hiring (good) Haskellers is easy because there's a demand for jobs. It's as simple as that.
> And how many are willing to stay at your company when it becomes bigger and more boring?
I feel like this is an argument that could apply to any set of programmers- I'm not sure I see how it's relevant to Haskellers in particular.
> Many Haskell programmers come from academia, how many are willing to do boring business logic?
I don't know, but it's almost certainly non-zero. I know of a few Haskellers with PhDs working in startups.
Actually, there are many more Haskell programmers than jobs available, so it's possible to pick and choose when hiring.
"(Update: The Tesla spokeswoman Shanna Hendriks later said the company had 1,500 cancellations in the fourth quarter). Many customers were in line but pulled out when it became time to make a substantial down payment in cash."
I'd imagine this is fairly standard for reservations of any product that don't require purchase, it only remains to ask whether this is more than one might expect, and if so, whether it's related to the "cold weather" debacle. That certainly seems to be the implication here.