Difference between revisions of "Open research problems"

From HaskellWiki
Jump to navigation Jump to search
m
(I/O problem added)
Line 10: Line 10:
 
<br>
 
<br>
 
Can purely functional languages like L can implement all algorithms that can be implemented in a language like C as efficiently in an amortized sense, ignoring space-usage?
 
Can purely functional languages like L can implement all algorithms that can be implemented in a language like C as efficiently in an amortized sense, ignoring space-usage?
  +
|}
  +
  +
=== I/O ===
  +
  +
:{|
  +
Some pertinent quotes:
  +
<br>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
This is hard stuff. Two years ago I spent several hours to write 3 lines invoking <code>IO</code> computations.
  +
  +
<tt>[https://discourse.haskell.org/t/trying-to-understand-the-io/1172/8 Trying to understand the <code>IO ()</code>]; ''"belka"'', Haskell Discourse.</tt>
  +
</div>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
Once you’re in the <code>IO</code> monad, you’re stuck there forever, and are reduced to Algol-style imperative programming. You cannot easily convert between functional and monadic style without a radical restructuring of code.
  +
  +
<tt>[https://existentialtype.wordpress.com/2011/05/01/of-course-ml-has-monads Of Course ML Has Monads!], Robert Harper.</tt>
  +
</div>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
Functional programmers used to worry about how to solve “the I/O problem”. Functional programming (FP) eschews any notion of side-effect or order of <i>execution</i>, and instead has an order-independent notion of <i>evaluation</i>. In contrast, input & output (I/O) seems to be an inherently effectful, ordered notion.
  +
  +
[...]
  +
  +
In a sense, I see us as in a worse position than before. Since the adoption of monadic IO, it’s been less immediately apparent that we’re still enslaved [...] Our current home is not painful enough to goad us onward, as were continuation-based I/O and stream-based I/O. (See [https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.168.4008&rep=rep1&type=pdf A History of Haskell], section 7.1.) Nor does it fully liberate us.
  +
  +
<tt>[http://conal.net/blog/posts/can-functional-programming-be-liberated-from-the-von-neumann-paradigm Can functional programming be liberated from the von Neumann paradigm?], Conal Elliott.</tt>
  +
</div>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
Stream transformers are fragile to use, continuations are powerful but somewhat clutter the syntax of functions. Monads and uniqueness types both present a trade-off, do we accept the over-sequentialisation imposed by monads, or the visual disorder of explicit environment passing? We believe that a compromise is still to be found [...]
  +
  +
<tt>[https://www.owenstephens.co.uk/assets/static/research/masters_report.pdf Approaches to Functional I/O], Owen Stephens.</tt>
  +
</div>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
The common method to relieve the programming language designer from the inherent IO-problems is to shift responsibility to the programmer who has to sequentialize all IO-requests. This is also true for the monadic approach implemented in Haskell.
  +
  +
<tt>[https://core.ac.uk/download/pdf/14504553.pdf FUNDIO: A Lambda-Calculus With <i>letrec</i>, <i>case</i>, Constructors, and an IO-Interface:], Manfred Schmidt-Schauß.</tt>
  +
</div>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
The programming style in a lazy functional language is heavily influenced by the supported I/O-mechanism. Modifying the I/O-behaviour or debugging some lazy functional program that uses I/O is a black art. It is interesting that novices in lazy functional programming in general expect that there is some direct (side-effecting) I/O using a function call.
  +
  +
<tt>[https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.55.1076&rep=rep1&type=pdf A Partial Rehabilitation of Side-Effecting I/O:], Manfred Schmidt-Schauß.</tt>
  +
</div>
  +
<br>
  +
  +
<div style="border-left:1px solid lightgray; padding: 1em" alt="blockquote">
  +
The downside of I/O using monads is the need for a monad that can not be unwrapped. So, when using monadic I/O there is no way to get rid of the I/O monad. Furthermore, it is not as intuitive as one would like it to be. A prerequisite to good software design is a thorough understanding of the structures and glues of the implementation language. [...] Yet the understanding of monads is not trivial. The extensive amount of tutorials and questions on the Internet strengthen this thought.
  +
  +
<tt>[https://essay.utwente.nl/57287/1/scriptie_Rorije.pdf Input/Output in Functional Languages (Using Algebraic Union Types)], R.J. Rorije.</tt>
  +
</div>
  +
<br>
  +
  +
Questions:
  +
* Is there an alternate standalone model of I/O with less problems than each of the current models?
  +
* If not, can I/O be moved away from the language (as a model) and into the implementation (making the language [https://www.cs.cmu.edu/~crary/819-f09/Landin66.pdf denotative]), while keeping the resulting language [https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.628.7053&rep=rep1&type=pdf practical] to use?
  +
* Or would any denotative language be [https://www.oreilly.com/library/view/programming-perl-3rd/0596000278/ch01s04.html solipsistic?]
 
|}
 
|}
   

Revision as of 04:25, 22 October 2021


General problems

Efficiency of lazy functional languages

This is a problem that came up during IRC discussions. We consider a purely functional language L:
  • By "purely functional" we mean a language that has value semantics; that is, there is no function such that after evaluation of the function the value that was referred to by something else changed. (Also known as "No Side Effects").
  • A value is "changed" when it is not the case during an evaluation that when the old value and the new value would both be fully evaluated, there wouldn't be the same result. This should make sure that laziness is allowed in the purely functional language.

Can purely functional languages like L can implement all algorithms that can be implemented in a language like C as efficiently in an amortized sense, ignoring space-usage?

I/O

Some pertinent quotes:

This is hard stuff. Two years ago I spent several hours to write 3 lines invoking IO computations.

Trying to understand the IO (); "belka", Haskell Discourse.


Once you’re in the IO monad, you’re stuck there forever, and are reduced to Algol-style imperative programming. You cannot easily convert between functional and monadic style without a radical restructuring of code.

Of Course ML Has Monads!, Robert Harper.


Functional programmers used to worry about how to solve “the I/O problem”. Functional programming (FP) eschews any notion of side-effect or order of execution, and instead has an order-independent notion of evaluation. In contrast, input & output (I/O) seems to be an inherently effectful, ordered notion.

[...]

In a sense, I see us as in a worse position than before. Since the adoption of monadic IO, it’s been less immediately apparent that we’re still enslaved [...] Our current home is not painful enough to goad us onward, as were continuation-based I/O and stream-based I/O. (See A History of Haskell, section 7.1.) Nor does it fully liberate us.

Can functional programming be liberated from the von Neumann paradigm?, Conal Elliott.


Stream transformers are fragile to use, continuations are powerful but somewhat clutter the syntax of functions. Monads and uniqueness types both present a trade-off, do we accept the over-sequentialisation imposed by monads, or the visual disorder of explicit environment passing? We believe that a compromise is still to be found [...]

Approaches to Functional I/O, Owen Stephens.


The common method to relieve the programming language designer from the inherent IO-problems is to shift responsibility to the programmer who has to sequentialize all IO-requests. This is also true for the monadic approach implemented in Haskell.

FUNDIO: A Lambda-Calculus With letrec, case, Constructors, and an IO-Interface:, Manfred Schmidt-Schauß.


The programming style in a lazy functional language is heavily influenced by the supported I/O-mechanism. Modifying the I/O-behaviour or debugging some lazy functional program that uses I/O is a black art. It is interesting that novices in lazy functional programming in general expect that there is some direct (side-effecting) I/O using a function call.

A Partial Rehabilitation of Side-Effecting I/O:, Manfred Schmidt-Schauß.


The downside of I/O using monads is the need for a monad that can not be unwrapped. So, when using monadic I/O there is no way to get rid of the I/O monad. Furthermore, it is not as intuitive as one would like it to be. A prerequisite to good software design is a thorough understanding of the structures and glues of the implementation language. [...] Yet the understanding of monads is not trivial. The extensive amount of tutorials and questions on the Internet strengthen this thought.

Input/Output in Functional Languages (Using Algebraic Union Types), R.J. Rorije.


Questions:

  • Is there an alternate standalone model of I/O with less problems than each of the current models?
  • If not, can I/O be moved away from the language (as a model) and into the implementation (making the language denotative), while keeping the resulting language practical to use?
  • Or would any denotative language be solipsistic?

Specific problems

Implement encapsulated-state interface entirely in Haskell (no primitives)

Implement Data.STRef and Control.Monad.ST.runST without using the built-in monadic ST or IO types. This needs to happen with operations that all run in O(1) amortized time.