-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Modular C code generator -- -- Modulo is a tool that generates modular, standard C interfaces based -- on a high-level description language. The idea is to specify -- functionality in the module language and implement it in any language -- that supports C-style calling conventions. This package include -- generators for C, Haskell, Common Lisp and NodeJS-style JavaScript. @package modulo @version 1.9.1 -- | Renders module descriptions as JavaScript imports, using Node package -- ffi. -- -- See https://github.com/rbranson/node-ffi module Language.Modulo.JavaScript module Language.Modulo.Util -- | Synonym for toUpper toUpperChar :: Char -> Char -- | Synonym for toLower toLowerChar :: Char -> Char -- | Synonym for 'fmap Char.toUpper' toUpperString :: String -> String -- | Synonym for 'fmap Char.toLower' toLowerString :: String -> String -- | Convert a string to use upper case for the leading letter and lower -- case for remaining letters. toCapitalString :: String -> String -- | Synonym for '(++)' withPrefix :: [a] -> [a] -> [a] -- | Synonym for 'flip (++)' withSuffix :: [a] -> [a] -> [a] -- | Separate a list by the given element. -- -- Equivalent to intersperse sep :: a -> [a] -> [a] -- | Initiate and separate a list by the given element. pre :: a -> [a] -> [a] -- | Separate and terminate a list by the given element. post :: a -> [a] -> [a] -- | Separate and terminate a list by the given element. wrap :: a -> a -> [a] -> [a] -- | Combination of concat and sep. concatSep :: [a] -> [[a]] -> [a] -- | Combination of concat and pre. concatPre :: [a] -> [[a]] -> [a] -- | Combination of concat and post. concatPost :: [a] -> [[a]] -> [a] -- | Combination of concat and wrap. concatWrap :: [a] -> [a] -> [[a]] -> [a] -- | Divide a list into parts of maximum length n. divideList :: Int -> [a] -> [[a]] -- | Break up a list into parts of maximum length n, inserting the given -- list as separator. Useful for breaking up strings, as in breakList -- 80 n str. breakList :: Int -> [a] -> [a] -> [a] -- | Break up a list into parts of maximum length n, inserting the given -- list as separator. Useful for breaking up strings, as in breakList -- 80 n str. concatMapM :: (Monad f, Functor f) => (a -> f [b]) -> [a] -> f [b] -- | Manglers for various kinds of identifiers. module Language.Modulo.Util.Mangle -- | Mangle an indentifier in mixed case, i.e. [foo, bar] becomes -- fooBar. mixedCase :: [String] -> String -- | Mangle an indentifier in capital case, i.e. [foo, bar] -- becomes FooBar. capitalCase :: [String] -> String -- | Mangle an indentifier using the underscore as separator, i.e. -- [foo, bar] becomes foo_bar. sepCase :: [String] -> String -- | Unmanglers for various kinds of identifiers. module Language.Modulo.Util.Unmangle -- | Unmangle an indentifier in mixed or separarated case. unmangle :: String -> [String] -- | Unmangle an indentifier in mixed case, i.e. fooBar becomes -- [foo, bar]. uncase :: String -> [String] -- | Unmangle an indentifier using the underscore as separator, i.e. -- foo_bar becomes [foo, bar]. -- --
-- unsep (sep a) = a, iff a /= [] --unsep :: String -> [String] -- | This Haskell module defines the Modulo description language. -- Typically, modules are created by writing .module files and -- using the parser defined in Language.Modulo.Parser, or the -- modulo command-line tool. The abstract syntax tree is given -- below. -- -- The module language is very simple. Each module consists of a name -- followed by eventual import declarations, followed by all other -- declarations. Here is an example module: -- --
-- module Scl.List
-- {
-- opaque Elem;
-- opaque List;
--
-- nil : () -> List;
-- cons : (Elem, List) -> List;
-- head : (List) -> Elem;
-- tail : (List) -> List;
--
-- empty : (List) -> Bool;
-- lenght : (List) -> Int;
--
-- reverse : (List) -> List;
-- sort : (List) -> List;
-- }
--
--
-- Like C, the module language uses structural typing for pointers and
-- functions, but nominal typing for structures and unions. Thus in the
-- following example values of type A and B are
-- interchangeable, but values of type C and D are not.
--
--
-- type A = Ptr Int
-- type B = Ptr Int
-- type C = struct { x : Int, y : Int }
-- type D = struct { x : Int, y : Int }
--
--
-- The pointer type constructor can be used with any type:
--
-- -- type IntPtr = Int* -- type FloatPtr = Float* ---- -- The array type constructor need an explicit length: -- --
-- type IntVec = [Int x 10] ---- -- Functions are written as in Haskell, except for the parentheses -- enclosing the arguments. Thus, higher-arity functions are easily -- distinguished. -- --
-- type NoCurry = (A, B) -> C -- type Curry = (A) -> (B) -> C ---- -- Compound types are written in a uniform manner: -- --
-- type IntCounter = struct { a : Int, b : Int -> Int }
-- type NumValue = union { left : Int, right : Float }
-- type Color = enum { Red, Green, Blue }
--
--
-- The following primitive types are provided:
--
-- -- Void Size Ptrdiff Intptr UIntptr -- Char Short Int Long LongLong -- UChar UShort UInt ULong ULongLong -- Float Double LongDouble -- Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 --module Language.Modulo -- | A module is a named container of imports and declarations. -- -- Each module can depend on a set of other modules (translated as -- include directives). Recursive dependencies are not allowed for now. data Module Module :: ModuleName -> ModuleOptions -> Doc -> [(ModuleName, Maybe String)] -> [(Doc, Decl)] -> Module -- | Name of module modName :: Module -> ModuleName -- | Module options. modOptions :: Module -> ModuleOptions -- | Module documentation. modDoc :: Module -> Doc -- | Imports with optional import conventions modImports :: Module -> [(ModuleName, Maybe String)] -- | List of declarations modDecls :: Module -> [(Doc, Decl)] data ModuleOptions ModuleOptions :: Bool -> ModuleOptions -- | If true, this module does not incur any C prefix. optTransient :: ModuleOptions -> Bool -- | A module name is a non-empty list of strings. newtype ModuleName ModuleName :: (NonEmpty String) -> ModuleName getModuleName :: ModuleName -> (NonEmpty String) toModuleName :: [String] -> ModuleName getModuleNameList :: ModuleName -> [String] newtype Doc Doc :: String -> Doc getDoc :: Doc -> String -- | Name of a type, function or constant value. -- -- Note that any Unicode string may be used as a name. data Name Name :: String -> Name QName :: ModuleName -> String -> Name getName :: Name -> String -- | An declaration maps a name to type and optionally a value. data Decl -- | Declares a type or opaque. TypeDecl :: Name -> (Maybe Type) -> Decl -- | Declares a function. FunctionDecl :: Name -> FunType -> Decl -- | Declares a struct or enum tag. TagDecl :: Type -> Decl -- | Declares a constant value. ConstDecl :: Name -> (Maybe Value) -> Type -> Decl -- | Declares a global variable. GlobalDecl :: Name -> (Maybe Value) -> Type -> Decl getDeclName :: Decl -> Maybe Name -- | A value is anything that can be declared as a C constant. data Value CInt :: Integer -> Value CFloat :: Double -> Value CStr :: String -> Value CWStr :: String -> Value CInitList :: [Value] -> Value -- | A type is either an alias, a primitive or a compound type. data Type -- | An alias, introduced by a former type declaration. AliasType :: Name -> Type PrimType :: PrimType -> Type RefType :: RefType -> Type FunType :: FunType -> Type CompType :: CompType -> Type -- | A primitive type. data PrimType Void :: PrimType Size :: PrimType Ptrdiff :: PrimType Intptr :: PrimType UIntptr :: PrimType Char :: PrimType Short :: PrimType Int :: PrimType Long :: PrimType LongLong :: PrimType SChar :: PrimType Bool :: PrimType UChar :: PrimType UShort :: PrimType UInt :: PrimType ULong :: PrimType ULongLong :: PrimType Float :: PrimType Double :: PrimType LongDouble :: PrimType Int8 :: PrimType Int16 :: PrimType Int32 :: PrimType Int64 :: PrimType UInt8 :: PrimType UInt16 :: PrimType UInt32 :: PrimType UInt64 :: PrimType data RefType -- | The C pointer type t*. Pointer :: Type -> RefType -- | The C array type t[n]. Array :: Type -> Natural -> RefType -- | A function type. data FunType -- | The C function type Tn(T1, ... Tn-1). Function :: [(Maybe Name, Type)] -> Type -> FunType data CompType -- | A C enum type. Enum :: (NonEmpty Name) -> CompType -- | A C struct type. Struct :: (NonEmpty (Name, Type)) -> CompType -- | A C union type. Union :: (NonEmpty (Name, Type)) -> CompType -- | A C bitfield type. BitField :: (NonEmpty (Name, Type, Natural)) -> CompType instance Eq Doc instance Ord Doc instance Show Doc instance IsString Doc instance Eq ModuleOptions instance Ord ModuleOptions instance Show ModuleOptions instance Eq ModuleName instance Ord ModuleName instance Eq Name instance Ord Name instance Eq Value instance Show Value instance Eq PrimType instance Show PrimType instance Eq CompType instance Show CompType instance Eq Type instance Show Type instance Eq FunType instance Show FunType instance Eq RefType instance Show RefType instance Eq Decl instance Show Decl instance Eq Module instance Show Module instance Show Name instance Show ModuleName instance Ord Module instance Default ModuleOptions -- | Renders module descriptions as C header files. module Language.Modulo.C data GuardStyle -- | Write pragma guards Pragma :: GuardStyle -- | Write conditional guards Ifndef :: GuardStyle data ImportStyle -- | Import external modules using system paths SystemPath :: ImportStyle -- | Import external modules using local paths LocalPath :: ImportStyle data CStyle CStyle :: GuardStyle -> ImportStyle -> String -> ([String] -> String) -> ([String] -> String -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> ([String] -> String) -> Maybe (String, String) -> CStyle -- | How to write guards guardStyle :: CStyle -> GuardStyle -- | How to write import declarations includeStyle :: CStyle -> ImportStyle -- | Import directive, usually include. includeDirective :: CStyle -> String -- | Mangler for names of header guards guardMangler :: CStyle -> [String] -> String -- | Inner header mangler (receives module name, documentation) innerHeader :: CStyle -> [String] -> String -> String -- | Inner footer mangler (receives module name) innerFooter :: CStyle -> [String] -> String -- | Prefix for types typePrefixMangler :: CStyle -> [String] -> String -- | Prefix for values valuePrefixMangler :: CStyle -> [String] -> String -- | Mangler for implementation struct names typeMangler :: CStyle -> [String] -> String -- | Mangler for struct fields structFieldMangler :: CStyle -> [String] -> String -- | Mangler for union fields unionFieldMangler :: CStyle -> [String] -> String -- | Mangler for enum fields enumFieldMangler :: CStyle -> [String] -> String -- | Mangler for constant values constMangler :: CStyle -> [String] -> String -- | Mangler for global variables globalMangler :: CStyle -> [String] -> String -- | Mangler for global functions funcMangler :: CStyle -> [String] -> String funcAttr :: CStyle -> Maybe (String, String) -- | Style used in the C standard library. -- --