Prototype of a syntax reference

Hi, I'm trying to make a syntax reference in the form of source code. It's not ready, but if someone shares the same ideas I could use some help. (Should I put this on a wiki? Where?) My “design principles” are: • It should contain just pieces of uncommented code. The idea is not to use it as a fast tutorial, but as a reminder of how to write all kinds of things, and solve all questions of type “is this allowed?”; • It should be small, and fit on a printed A4 page; • It should show the complete syntax of everything, not the most common. For instance, ‘case of’ should show the use of guards; • It should be an example of valid code, not good one. The idea is to show what can be done, not what should :) • It should use expanded code, not identation rules. Replacement of identation for code (like {} etc.) have simple rules, and the proper way to ident can be deduced from expanded code. Sometimes this is important if we are trying to solve syntax errors; • It should use Unicode. It's nice to know which kind of Unicode characters can actually be used; • It should use no predefined types or classes except Bool. I’ll write a Prelude code reference if this first attempt go right. So I came up with the weird code below. It should contain a lot more, and be more dense (more syntax examples per lines of code), but it's already usefull for a begginer like me. What do you think? Best, Maurício module Ça (Exèmplo(Åwirù,Øwet'Л,Øwet'И),aҝҧү,Clááá) where { class Clááá ú where { (⊗) :: ú -> ú -> ú; τAmber :: ú -> ú; τAmber a = a ⊗ a; }; data D١ = U1 | U2 | U3; data D٢ = Vú1 | Vú2 | JustVú; data D٤ = Opção | OutraOpção; data Exèmplo = Åwirù | Øwet'Л D٤ | Øwet'И D٢ Exèmplo; osmesmos :: D٤ -> D٤ -> Bool; osmesmos Opção Opção = True; osmesmos OutraOpção OutraOpção = True; osmesmos _ _ = False; aҝҧү = (Øwet'И Vú2 aҝҧү) ⊗ Åwirù; instance Clááá Exèmplo where { Åwirù ⊗ _ = Åwirù; a@(Øwet'Л b) ⊗ x = case x of { Åwirù -> a; y@(Øwet'Л o) | (osmesmos o Opção) -> a | otherwise -> Øwet'И Vú1 y; y@(Øwet'И _ _) -> y ⊗ a }; a@(Øwet'И Vú1 _) ⊗ _ = a; a@(Øwet'И Vú2 x) ⊗ _ = x; a@(Øwet'И JustVú _) ⊗ y = y; } }

Maurício wrote:
• It should show the complete syntax of everything, not the most common. For instance, ‘case of’ should show the use of guards;
• It should be an example of valid code, not good one. The idea is to show what can be done, not what should :)
This can help you when you will generate all the options. It can also help you when analyzing whether your options are right, or (for example) when looking where are all the places some language construct can be used in. Enable java script for the page and try to click on all the places where you see "hand" cursor: http://www.hck.sk/users/peter/HaskellEx.htm The page above is the one I used when learning Haskell. I'm curious whether you can fit it on one A4 page. Probably depends on font size :) Peter.

Maurício wrote:
• It should be an example of valid code, not good one. The idea is to show what can be done, not what should :)
then put lots of semicolons somewhere: while they are at minimum a separator, it's generally allowed to insert as many extra semicolons as you want at the beginning, end, or wherever you could put a single semicolon. (I wish the same were true for commas.) -Isaac

• It should be an example of valid code, not good one. The idea is to show what can be done, not what should :)
then put lots of semicolons somewhere: while they are at minimum a separator, it's generally allowed to insert as many extra semicolons as you want at the beginning, end, or wherever you could put a single semicolon.
(I wish the same were true for commas.)
-Isaac
I think I did that at least once (although by mistake). :) Best, Maurício
participants (3)
-
Isaac Dupree
-
Maurício
-
Peter Hercek