A simple program is an interesting comparison, but it's kind odd to consider this to compare the whole typesystem. It's hard to understate that GHC has a /big/ typesystem and has had a significant amount of research done in it over the past 10 years and a a result there are a lot of very powerful non-trivial typing constructs. I think the real testament to the power of Haskell's typesystem is how well inference still works even in the presence of most of these non-trivial extensions.
If you really want it, you can get <i>safe</i> dynamic typing in Haskell using the Data.Dynamic module. However, since you <i>don't</i> really want it, it's a library that isn't introduced in basic tutorials.<p>This gives you a pragmatic equivalent to no-check, but is almost never used in practice because it turns out to be unnecessary.
> As seen at the top, it was necessary to annotate mod. It has the no-check flag on it, which is basically how you tell core.typed to just take your word on this one. That's something you can't do in Haskell, but I'm not sure whether or not that's a good thing.<p>Isn't the reason why you need to do it because you're importing a non-typed symbol? Wouldn't the only situation where you'd need to do that in Haskell be at FFI?<p>(and a nitpick: `putStrLn $ show` can be replaced with a simple `print` call)
> Integer is less useful as a type than hoped. AnyInteger seems to be more permissive, and works more often. I'm sure there is a good reason for this.<p>This is with about 15 minutes of looking at core.typed. Isn't this because the type Interger is actually java.lang.Integer, but (type 1000) is java.lang.Long?<p>Also, AnyInteger isn't that permissive. It's defined as (U Integer Long clojure.lang.BigInt BigInteger Short Byte). The big difference would be that Haskell's Int is bounded so AnyInteger is more like Haskell's Integer.
The Haskell could use a list comprehension...<p><pre><code> divBy x y = y `mod` x /= 0
divBy3or5 x = divBy 3 x || divBy 5 x
euler1 n = sum [x | x <- [0..n], divBy3or5 x]
main = print $ euler1 1000
</code></pre>
Personally, I'd switch out lines 2 and 3 to:<p><pre><code> euler1 n = sum [x | x <- [0..n], divBy 3 x, divBy 5 x]
</code></pre>
Compared with the Clojure (correct me if I'm wrong):<p><pre><code> (defn euler1 [n] (reduce + (filter (fn [x] (or (div-by 3 x) (div-by 5 x)))) (range n)))
</code></pre>
Edit: Note - Clojure code doesn't fit into a HN one-liner.
What a waste of an article. 8 lines of code for haskell, 19 lines for clojure. The problem is easily solved in one line. I seriously don't care that's he comparing core.type, when you start trying to write langauges the same way, you lose the advantage that they provide.<p>1 line of python.<p>print sum(filter(lambda x: (x % 3 == 0) or (x % 5 == 0), range(1, 1000)))<p>clojure<p>(apply + (filter #(or (= 0(mod % 3)) (= 0(mod % 5))) (range 1 1000)))