Questions tagged [ml]

A family of functional programming languages including SML, OCaml, and F#. For questions about machine learning, use the [machine-learning] tag please.

ML ("Meta Language") is a family of functional programming languages, created by the Turing award winning computer scientist Robin Milner. It was initially created as the metalanguage for a theorem prover (hence the name), but quickly became used as a general-purpose programming language. One of ML's most famous characteristics is type inference supporting parametric polymorphism.

Some well known dialects of ML are Standard ML (), OCaml () and F# ().

676 questions
106
votes
2 answers

What are the differences between SML and OCaml?

What sets the two ML dialects apart?
Nathan
  • 1,071
  • 2
  • 8
  • 5
61
votes
3 answers

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

It is well known that Haskell-style typeclasses and ML-style modules offer different mechanisms for specifying interfaces. They are (possibly) equivalent in power, but in practice each has their own benefits and drawbacks. Since I'm a bit of an…
Edward Z. Yang
  • 26,325
  • 16
  • 80
  • 110
43
votes
3 answers

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

My question is if there is any difference between Standard ML's module system and OCaml module system? Has OCaml all the support of functors , ascriptions etc... that SML has?
Dragno
  • 3,027
  • 1
  • 27
  • 41
42
votes
3 answers

Variants or Polymorphic variants?

I noticed that, among OCaml programmers I know, some of them always use polymorphic variants (variants that are not declared, prefixed with a backquote), while other ones never use polymorphic variants, and prefer variants declared in types. Except…
38
votes
1 answer

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

This question started out from My translating of "ML for the Working Programmer" (WorldCat) by L. C. PAULSON to F# which uses functors for the examples. Eventual desire to translate "Purely Functional Data Structures" (WorldCat) by Chris…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
31
votes
1 answer

Subsumption in polymorphic types

In ‘Practical type inference for arbitrary-rank types’, the authors talk about subsumption: I try to test things in GHCi as I read, but even though g k2 is meant to typecheck, it doesn't when I try with GHC 7.8.3: λ> :set -XRankNTypes λ> let g ::…
beta
  • 2,380
  • 21
  • 38
29
votes
6 answers

ML IDE and Compiler for Windows or Linux or Mac

I have to write some code in ML and it is my first time I`m going to use the language. Is there any Development Environment for Standard ML? (preferably under Windows). I tried googling (and stackOverFlowing ! ) but all I found was plain compilers…
Sajad Bahmani
  • 17,325
  • 27
  • 86
  • 108
28
votes
1 answer

(ML) Modules vs (Haskell) Type Classes

According to Harper (https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/), it seems that Type Classes simply do not offer the same level of abstraction that Modules offer and I'm having a hard time exactly figuring out why. And…
Rahul Manne
  • 1,229
  • 10
  • 20
28
votes
1 answer

Growth of Type Definition in SML Using Hindley Milner Type Inference

Someone once showed me a little 'trick' in SML where they wrote out about 3 or 4 functions in their REPL and the resulting type for the last value was extremely long (like many page scrolls long). Does anyone know what code generates such a long…
27
votes
4 answers

Benefit of avoiding multiple list traversals

I've seen many examples in functional languages about processing a list and constructing a function to do something with its elements after receiving some additional value (usually not present at the time the function was generated), such…
Alejandro Pulver
  • 555
  • 4
  • 13
25
votes
2 answers

Inferred type appears to detect an infinite loop, but what's really happening?

In Andrew Koenig’s An anecdote about ML type inference, the author uses implementation of merge sort as a learning exercise for ML and is pleased to find an “incorrect” type inference. Much to my surprise, the compiler reported a type of 'a list ->…
Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
19
votes
7 answers

Which English tutorial would you advise to learn OCaml?

I want to advertise OCaml to beginners, and I am looking for good tutorials in English; not that you have only heard of, but that you have actually tried and found useful...
Fabrice Le Fessant
  • 4,222
  • 23
  • 36
17
votes
1 answer

When to use semicolons in SML?

I know that semicolons are used as terminators in REPL. But I'm confused about when to use them in a source file. For example it is not necessary after val x = 1. But if I omit it after use "foo.sml", the compiler will complain about it. Then, what…
Ben
  • 3,612
  • 3
  • 19
  • 24
16
votes
6 answers

Can compilers deduce/prove mathematically?

I'm starting to learn functional programming language like Haskell, ML and most of the exercises will show off things like: foldr (+) 0 [ 1 ..10] which is equivalent to sum = 0 for( i in [1..10] ) sum += i So that leads me to…
Nyan
  • 2,360
  • 3
  • 25
  • 38
16
votes
3 answers

Is the SML `o` operator only useful on single-argument functions?

Is the o composition operator (eg. val x = foo o bar, where foo and bar are both functions), only usable on single-argument functions and/or functions with equal numbers of arguments? If not, what is the syntax for, say, composing foo(x,y) with…
GregT
  • 1,300
  • 3
  • 16
  • 25
1
2 3
44 45