Fsharp does not yet support data abstraction


Fsharp is heavily influenced by OCaml. One of the most powerful features of modules in OCaml (and ML) is data abstraction. Data abstraction allows you to hide the concrete data structure that is used to implement an abstract type in a module.

For example, in OCaml, I can provide a signature for a priority queue that provides the types of the functions over the abstract type for the priority queue. I can then provide concrete implementations for the priority queue that use different structures, such as a list or a binary tree. A programmer that uses the abstract data structure of that signature does not need to know what concrete data structure is used. Indeed, this information is hidden.

On the other hand, in Fsharp, a signature must always provide the concrete data structure that is used to implement an abstract type. Furthermore, the type checker does not do the necessary substitution to match the concrete and abstract data types. Thus Fsharp does not support abstract data types. Instead, Fsharp programmers are forced to use abstract classes to approximate abstract data types. However, classes behave quite differently to modules, apparently forcing a slightly imperative style.

Programmers wishing to do modular functional programming on the .NET framework really need abstract data types to be fixed. Fixing data abstraction is of the highest priority, since it is expected by top level functional programmers used to OCaml, Haskell and Scala.
Closed Jan 27, 2013 at 11:56 PM by quasilord1