Module

Perspectives.IndentParser

#ContextRoleParserState

type ContextRoleParserState = { contextInstances :: Object PerspectContext, nameCounter :: Int, namespace :: String, prefixes :: Object String, rolOccurrences :: Object Int, roleInstances :: Object PerspectRol, section :: QualifiedName, typeNamespace :: String }

A type to keep track of:

  • the number of occurrences of a role type, and
  • the namespace for context declarations. The namespace does not terminate on a $!
  • the section, i.e. the current role that should be used to stick a role in a context;
  • the prefixes: a map of prefixes to namespaces.

#defaultPrefixes

#initialContextRoleParserMonadState

#ContextRoleParserMonad

type ContextRoleParserMonad = StateT Position (StateT ContextRoleParserState (MonadPerspectives))

This is the monad stack we use for the ContextRoleParser. The underlying monad is MonadPerspectives, which we need to access couchdb. Then we have ContextRoleParserState, which we need to keep track of the number of instances of a particular role type in a context (to generate unique names). Finally, the StateT Position part is used by the IndentParser.

#IP

type IP a = ParserT String ContextRoleParserMonad a

This is the type that is produced by the ContextRoleParser. It can also be expressed in terms of the type synonym IndentParser: type IP a = IndentParser (StateT ContextRoleParserState (Aff e)) String a

#runIndentParser

runIndentParser :: forall a. String -> IP a -> MonadPerspectives (Either ParseError a)

Apply a parser, keeping only the parsed result.

#runIndentParser'

runIndentParser' :: forall a. String -> IP a -> MonadPerspectives (Tuple (Either ParseError a) ContextRoleParserState)

Apply a parser, keeping both state and the parsed result.

#liftAffToIP

liftAffToIP :: forall a. MonadPerspectives a -> IP a

As convienience, to lift functions on Aff all the way up:

#getRoleOccurrences

getRoleOccurrences :: RolName -> IP (Maybe Int)

Reach all the way into the stack to retrieve the number of times a particular role has been instantiated in a context:

#incrementRoleInstances

incrementRoleInstances :: RolName -> IP Unit

Increment the number of instances of a particular role.

#getRoleInstances

#setRoleInstances

#getNamespace

#generatedNameCounter

#setNamespace

#withExtendedNamespace

withExtendedNamespace :: forall a. String -> IP a -> IP a

#withNamespace

withNamespace :: forall a. String -> IP a -> IP a

#getTypeNamespace

#setTypeNamespace

#withExtendedTypeNamespace

withExtendedTypeNamespace :: forall a. String -> IP a -> IP a

#withTypeNamespace

withTypeNamespace :: forall a. String -> IP a -> IP a

#setSection

#setPrefix

#getPrefix

Modules