Annotation system for Haskell
Bulat Ziganshin
bulat.ziganshin at gmail.com
Mon Nov 13 06:29:11 EST 2006
Hello Bulat,
Monday, November 13, 2006, 2:28:09 AM, you wrote:
> in the last poll for Haskell', it was widely noted that some form of
> attribute (annotation) system for Haskell will be great, although
> there is no any design yet. i think that i've found rather good one:
i was sleepy and forgot to add some more information:
this design is obviously grown from HadDoc ideas. HadDoc adds
documentation comments to the same entities - values, types and
classes, so one of things we can do is to treat haddoc comments as one
sort of attributes, say Documentation :: String
this implies that haddoc front-end should be changed to generate xml
files that will include this Documentation attributes and haddoc
backend should parse these xml files to generate html/tex/...
documentation files
another haddoc detail that we should reuse is using comments to hold
all annotations, in order to make annotated program compilable by old
compilers
and the third detail is to simplify annotations syntax by allowing to omit
"" for String annotations, [] for annotation having type [a] and so
on. So, annotation value should be read by some smart variation of
"read" function. then, the whole example may look like:
-- |Great function
f = 1
-- *Documentation: Great function
g = 1
-- Two above annotations are equivalent, "-- |" is a legacy shortcut
for the full syntax of "-- *Documentation: "
-- *Author: Bulat
data NewAnnotationType = TextAnnotation String
| IntAnnotation Int
| PrioritiesList [Int]
| Deriving [String]
deriving Annotation
-- *TextAnnotation: It works!
-- *IntAnnotation: 31415
-- *PrioritiesList: 1,2,3,4,5
data T = X | Y
-- *^Deriving: DeepSeq, Binary, XMLizable
--
Best regards,
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Haskell-prime
mailing list