Note that there are some explanatory texts on larger screens.

plurals
  1. POHaskell tuple constructor (GHC) and the separation between a language and its implementation
    primarykey
    data
    text
    <p>Haskell blew my mind yet again when I realised that </p> <pre><code>(x,y) </code></pre> <p>Is just syntactic sugar for</p> <pre><code>(,) x y </code></pre> <p>Naturally I wanted to extend this to larger tuples. But</p> <pre><code>(,) x ((,) y z) </code></pre> <p>Gave me</p> <pre><code>(x,(y,z)) </code></pre> <p>Which was not what I was looking for. On a whim, I tried</p> <pre><code>(,,) x y z </code></pre> <p>And it worked, giving exactly what I wanted:</p> <pre><code>(x,y,z) </code></pre> <p>This raised the question: How far can you take it? Much to my astonishment, there seemed to be no limit. All of the below are valid operators:</p> <pre><code>(,) (,,) (,,,) (,,,,) --etc (,,,,,,,,,,,,,,) (,,,,,,,,,,,,,,,) --etc (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) --etc </code></pre> <p>This behaviour is amazing and leads to my actual question: Is it something which can be emulated in my own functions? Or is it just a GHC-specific feature of the tuple operator? I'm thinking it's the latter as I've read the haskell98 specification and iirc it says that implementations only have to define the tuple operator for up to 15 items. Whereas GHC has gone the whole hog and let you do it up to arbitrary limits.</p> <p>So, would it be possible to define this family of operators/functions from within the haskell implementation itself, using nothing but the type system and existing language features (declarations, type signatures, function definitions etc.)? And if so, how? Or is it impossible and you have to instead look into the compiler to find the supporting framework for this collection of functions?</p> <p>This leads to an even more general question: How much of Haskell is supported by Haskell itself, through type and function definitions, declarations etc; and how much is supported by the compiler/implementation? (I am aware that GHC was written in Haskell, that doesn't answer the question)</p> <p>That is, if you were to abandon the standard libraries (including the prelude) and do everything from the ground up in raw Haskell; would it be possible to build a complete implementation that has all the features of GHC, using only that minimal set of features? What are the mimimum set of language features that you need in order to build a haskell implementation using Haskell? Would I be able to abandon the prelude and then <strong>completely</strong> rebuild it <strong>manually</strong> from within GHC? If you abandon the prelude and never import anything, what is left over for you to work with? </p> <p>It may seem like I'm asking a million questions, but they're really all trying to ask the same thing with different wording. Give it your best shot SO!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload