Interface of Foo

This module is merely a test for the IDoc tool.

Here we test some comment block formatting. Comments can have different types of paragraphs:

We represent length values by integers

type Length = Int

This is a cool function with quite a number of sophisticated arguments

myMostImpressiveFunctionEver :: (Ord a, Show a)         
-- the context
                             => Int                     
-- the ID number
                             -> InputData
                             -> Bool                    
-- strict checking?
                             -> OutputData

A well known data type

data Maybe a = Nothing  
-- in case that there is no a
             | Just a   
-- when there is a value available

This is the data structure that we process

data InputData

The first variant is quite secret

= SecretData SomeSuperSecretData

In comparison, this one is boring

| BoringData Int

And somtimes, we just read a string

| StringData String

Some overloading of our own

class MyClass a where

Transforms stuff

transform :: a -> a

A large example taking from a C AST

C declarator (K&R A8.5) and abstract declarator (K&R A8.8)

  • We have one type qualifer list [CTypeQual] for each indirection (ie, each occurrence of * in the concrete syntax).
  • We unfold K&R's direct-declarators nonterminal into declarators. Note that *(*x) is equivalent to **x .
  • Declarators (A8.5) and abstract declarators (A8.8) are represented in the same structure. In the case of a declarator, the identifier in CVarDeclr must be present; in an abstract declarator it misses. CVarDeclr Nothing ... on its own is meaningless, it may only occur as part of a larger type (ie, there must be a pointer, an array, or function declarator around).
  • The qualifiers list in a CPtrDeclr may not be empty.
  • Old and new style function definitions are merged into a single case CFunDeclr . In case of an old style definition, the parameter list is empty and the variadic flag is False (ie, the parameter names are not stored in the tree). Remember, a new style definition with no parameters requires a single void in the argument list (according to the standard).
  • We unfold K&R's parameter-type-list nonterminal into the declarator variant for functions.
data CDeclr = CVarDeclr (Maybe Ident)           
-- declared identifier
            | CPtrDeclr [[CTypeQual]]           
-- indirections (non-empty)
            | CArrDeclr CDeclr
                        (Maybe CExpr)           
-- array size
            | CFunDeclr CDeclr
-- *parameter* declarations
-- is variadic?

This document was generated by "IDoc - A No Frills Haskell Interface Documentation System, version 0.2.5, 27 Feb 2002".