-------------------------------------------------------------------------------- -- $Id: ReportType.hs,v 1.4 2004/02/10 20:57:32 graham Exp $ -- -- Copyright (c) 2003, G. KLYNE. All rights reserved. -- See end of this file for licence information. -------------------------------------------------------------------------------- -- | -- Module : ReportType -- Copyright : (c) 2003, Graham Klyne -- License : GPL V2 -- -- Maintainer : Graham Klyne -- Stability : provisional -- Portability : H98 -- -- This module defines a Haskell representation for a -- Semafor report definition. -- -- These type declarations allow a Semafor report definition to be -- expressed as a collection of Haskell value definitions. -- Separate modules may be provided to generate RDF/N3 output for -- Semafor to process, to process the report directly, or to parse -- a more convenient format into this structure. -- -------------------------------------------------------------------------------- module ReportType ( Named, name, anon , Report, RepSequence, RepCommand(..) , RepPattern, RepMatch(..) , RepString, RepItem(..) , RepChan, RepFile, RepVar, RepUri ) where import Namespace ( Namespace(..), ScopedName(..) ) -- SemaFor type and auxilliary definitions type Named a = (Maybe ScopedName,a) anon :: a -> Named a anon a = (Nothing,a) name :: Namespace -> String -> a -> Named a name ns ln a = (Just (ScopedName ns ln),a) type Report = RepSequence type RepSequence = Named [RepCommand] data RepCommand = OPEN RepChan RepFile | CLOSE RepChan | WRITE RepChan RepString | DEBUG RepString | IF (Maybe RepVar) (Maybe RepPattern) [RepCommand] -- if matched/defined (Maybe [RepCommand]) -- alternative | IFANY [RepVar] (Maybe RepPattern) [RepCommand] -- if any var defined (Maybe [RepCommand]) -- alternative | FOR RepPattern [RepCommand] -- do for each (Maybe [RepCommand]) -- before first match (Maybe [RepCommand]) -- between each match (Maybe [RepCommand]) -- after last match (Maybe [RepCommand]) -- else if no match | DO RepSequence | CMD RepSequence type RepChan = String type RepFile = RepString type RepVar = String type RepUri = (Namespace,String) type RepPattern = Named [RepMatch] data RepMatch = MEMBER -- Container member | ELEMENT -- List element | URI RepUri -- Uri property or node | LIT String -- Literal node | VAR RepVar -- Variable property or node | ALL [RepPattern] | ALT [RepPattern] RepPattern | OPT [RepPattern] type RepString = Named [RepItem] data RepItem = TEXT String | NL | TRIM | VALUE RepVar | LOCAL RepVar | TAB Integer | TABSP Integer | TABNL Integer | LEFT Integer | INDENT Integer | WRAP Integer -- | IFDEF RepVar RepString | ALLDEF [RepVar] RepString (Maybe RepString) | ANYDEF [RepVar] RepString (Maybe RepString) | DEFER RepString | FLUSH RepString | PUTURI RepUri | SEQ RepString ---------------------------------------------------------------------- -- $Log: ReportType.hs,v $ -- Revision 1.4 2004/02/10 20:57:32 graham -- Report compiler passes all tests. -- -- Revision 1.3 2004/02/09 22:24:09 graham -- Part tested report compiler logic. -- One test case still fails, can't see why yet until function to -- highlight graph differences is available. -- -- Revision 1.2 2004/01/14 21:34:08 graham -- Work-in-progress on RDF report compiler -- -- Revision 1.1 2004/01/12 15:57:58 graham -- Report datatypes initially created. --