<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1505" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi,</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Just as we can define infix operators as syntactic sugar,
could we not also have a similar mechanism for programmable fancy
brackets?</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>There could be a keyword for the bracket declaration and a
function definition, in this way ana- and catamorphisms, Template Haskell-like
syntax, and set notation could become a regular feature of the language. I
am more interested in the general idea than the syntax of this specific
example:</FONT></DIV>
<DIV><FONT size=2> </FONT></DIV>
<DIV><FONT size=2>\begin{code}</FONT></DIV>
<DIV><FONT size=2>bracket (( _ )) :: a -> Ana a</FONT></DIV>
<DIV><FONT size=2>bracket (| _ |) :: a -> Cata a</FONT></DIV>
<DIV><FONT size=2>bracket [ _ | _ |] :: Char -> b
-> Splice -- or whatever </FONT></DIV>
<DIV><FONT size=2>bracket {[ _ , .. ]} :: [a] -> SList a</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>((( _ ))) :: a -> Ana a</FONT></DIV>
<DIV><FONT size=2>(( x )) = Ana x</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>((| _ |)) :: a -> Cata a</FONT></DIV>
<DIV><FONT size=2>(| x |) = Cata x</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>([ _ | _ |]) :: Char -> b -> Splice</FONT></DIV>
<DIV><FONT size=2>[ c | t |] = case c of</FONT></DIV>
<DIV><FONT
size=2> b
-> doC t</FONT></DIV>
<DIV><FONT
size=2> d
-> doD t -- or whatever</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>-- the idea of this bracket is to create a user-defined
list-type structure</FONT></DIV>
<DIV><FONT size=2>-- {[ "the" , "lambda" , "calculus"
]}</FONT></DIV>
<DIV><FONT size=2>-- would have the value</FONT></DIV>
<DIV><FONT size=2>-- (SCons "the" (SCons "lambda" (SCons
"calculus" SEmpty)))</FONT></DIV>
<DIV><FONT size=2>({[ _ , .. ]} :: [a] -> SList a</FONT></DIV>
<DIV><FONT size=2>{[ [] ]} = sempty</FONT></DIV>
<DIV><FONT size=2>{[ x:xs ]} = scons x {[ xs ]}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>\end{code}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Any thoughts?</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Vivian</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV></BODY></HTML>