If SML.NET had functors why can’t F#?

There’s no fundamental limitation of .NET that stops functors from being implemented in F#. True, they can’t be represented directly in .NET metadata, but neither can other F# language features like union types. Compilers for languages with functors (e.g., Standard ML, OCaml) have a pass called defunctorize; it works just like C++ template expansion, in … Read more

Warning: calling polyEqual

‘a means “any type”, while ”a means “any type that can be compared for equality”. Since your alreadyVisited function compared x and v using =, x and v need to have a type that supports comparing them for equality, so you get the type ”a. The warning means that you’re comparing two values with polymorphic … Read more

Encoding Standard ML modules in OO

There are a few fundamental differences that you cannot overcome easily: ML signatures are structural types, Scala traits are nominal: an ML signature can be matched by any appropriate module after the fact, for Scala objects you need to declare the relation at definition time. Likewise, subtyping between ML signatures is fully structural. Scala refinements … Read more

What’s the difference (if any) between Standard ML’s module system and OCaml module system?

There are some differences feature-wise, as well as semantically. Features SML supports but not OCaml: transparent signature ascription module-level let symmetric sharing constraints syntactic sugar for functors over types and values Features OCaml 4 has but not SML: higher-order functors recursive modules local modules nested signatures modules as first-class values general module sharing (sig with … Read more

SML-NJ, how to compile standalone executable

Both MosML and MLton also have the posibility to create standalone binary files. MosML through mosmlc command and MLton through the mlton command. Note that MLton doesn’t have an interactive loop but is a whole-program optimising compiler. Which in basic means that it takes quite some time to compile but in turn it generates incredibly … Read more

What are the primary theoretical difficulties with adding ML-style modules to Haskell?

The main place to do the comparison is, ML Modules and Haskell Type Classes: A Constructive Comparison. Stefan Wehr and Manuel M.T. Chakravarty. In Proceedings of The Sixth ASIAN Symposium on Programming Languages and Systems – APLAS 2008, Springer-Verlag, LNCS, 2008. Modular Type Classes. Derek Dreyer, Robert Harper, and Manuel M. T. Chakravarty. In Proceedings … Read more

Explaining pattern matching vs switch

Having formerly been one of “those people”, I don’t know that there’s a succinct way to sum up why pattern-matching is such tasty goodness. It’s experiential. Back when I had just glanced at pattern-matching and thought it was a glorified switch statement, I think that I didn’t have experience programming with algebraic data types (tuples … Read more

Haskell or Standard ML for beginners? [closed]

Much as I love Haskell, here are the reasons I would prefer SML for a class in discrete math and data structures (and most other beginners’ classes): Time and space costs of Haskell programs can be very hard to predict, even for experts. SML offers much more limited ways to blow the machine. Syntax for function … Read more

tech