the dreaded offside rule

Doaitse Swierstra doaitse at
Thu Mar 9 05:06:29 EST 2006

On 2006 mrt 09, at 1:54, Lennart Augustsson wrote:
> I agree with it being complicated.  I don't know of any compiler
> that implements it correctly.  Do you say your combinators do?

At least we think so. The way to use it is e.g.:

pExprPrefix     =    sem_Expr_Let  <$ pKey "let" <*> pDecls  <* pKey  

pDecls          =    foldr sem_Decls_Cons sem_Decls_Nil
                                          <$>  pBlock pOCurly pSemi  
pCCurly pDecl

pDecl           =    sem_Decl_Val        <$>  pPatExprBase  <*   pKey  
"="   <*> pExpr
                 <|>  sem_Decl_TySig      <$>  pVar          <*    
pKey "::"  <*> pTyExpr

in which the pBlock takes care of the offside rule, in cooperation  
with the scanner.

> That said, I don't think it can be replaced easily without breaking
> existing code, so I'm unwilling to change unless someone can show
> an alternative that handles 99.9% of the existing code.

There are solutions to this kind of transitions. Compilers could  
admit the old rule, and emit a warning when e.g. the --this-is- 
supposed-to-be-strictly-haskell-prime flag is passed. One might also  
equip a compiler to transform one's program into the new standard.


More information about the Haskell-prime mailing list