j      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~None&+-./2346BHM Type used to generate an  $ with arbitrary allowed type names.C@All the parsing is done using the type classes provided by the parsersh package. You can use the parsing routines with any of the parsers that implement the classes, such as parsec or trifecta.EWe parametrize the parsing by the type of the variable identifiers, i. We do so because we use this parser to implement anti-quoters referring to Haskell variables, and thus we need to parse Haskell identifiers in certain positions.DA type for C identifiers.I@Function used to determine whether an identifier is a type name.J@Parses an identifier, *without consuming whitespace afterwards*.L&A collection of named types (typedefs)ORuns a C using parsec.P Useful for quick testing. Uses "quickCParser" as source name, and throws an  if parsing fails.QLike P , but uses N ( ) as F.Same as =, but does not check that the identifier is not a type name.This parser parses a DG and nothing else -- it does not consume trailing spaces and the like.$Precondition: there is at least one  in the list.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO Source name.String to parse.Parser. Anything with type forall m. CParser i m => m a is a valid argument.PString to parse.Parser. Anything with type forall m. CParser i m => m a is a valid argument.QString to parse.Parser. Anything with type forall m. CParser i m => m a is a valid argument.RSTUVWXYZ[\]^_`abcd     e  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdfLFGHIJKDEEMNCOPQX>BA@?U8=<;:9V+76543210/.-,W'*)(Y%&Z!"#$[ ^\]_  a` bcSTRdY   !"#$%&'*)(+ 76543210/.-,8=<;:9>BA@?CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcd     None&+3BMe(A possibly qualified Haskell identifier.See  Lhttps://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-160002.2.iSee  Lhttps://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-160002.2.j Mangles an e to produce a valid D$ which still sort of resembles the e. efghijefghijeffghij efghijNone&+-./0234EM6klmnopqrstuvwxyz{|}~ !"#$%&'(E%&'()*89:;<=CDEFLMNOPQklmnopqrstuvwxyz{|}~FDEEM8=<;:9'*)(%&{|}~vzyxwsutopqrLCFNOPQknmlknmlopqrsutvzyxw{|}~  !"#$%&'(None$( [t| CDouble -> ) CDouble |] , generates a foreign import wrapper of type (CDouble -> ) CDouble) -> ) (* (CDouble -> ) CDouble)) And invokes it.$( 'foo), if foo :: CDouble -> ) CDouble#, splices in an expression of type ) (* (CDouble -> ) CDouble)).$( [t| CDouble -> ) CDouble |]), generates a foreign import dynamic of type * (CDouble -> ) CDouble) -> (CDouble -> ) CDouble) And invokes it.+++None&234:=HKM1Type class used to implement the anti-quoters in . An alias for ,.A l stores various information needed to produce the files with the C code derived from the inline C snippets.s can be composed with their - instance, where . is right-biased -- in . x y y will take precedence over x.+Needed to convert C types to Haskell types.+Needed to parse and process antiquotations.KWill determine the extension of the file containing the inline C snippets.This function is used to post-process the functions generated from the C snippets. Currently just used to specify C linkage when generating C++ code.Existential wrapper around .An identifier for a .BSpecifies how to parse and process an antiquotation in the C code.BAll antiquotations (apart from plain variable capture) have syntax  $XXX:YYY Where XXX# is the name of the antiquoter and YYY+ is something parseable by the respective .Parses the body of the antiquotation, returning a hint for the name to assign to the variable that will replace the anti-quotation, the type of said variable, and some arbitrary data which will then be fed to .The v has Void@ as an identifier type to make sure that no names appear in it.(Takes the requested purity, the current ), and the type and the body returned by .pReturns the Haskell type for the parameter, and the Haskell expression that will be passed in as the parameter.If the the type returned is ty, the / must have type forall a. (ty -> IO a) -> IO a?. This allows to do resource handling when preparing C values.Care must be taken regarding M. Specifically, the generated IO computation must be idempotent to guarantee its safety when used in pure code. We cannot prevent the IO computation from being inlined, hence potentially duplicated. If non-idempotent marshallers are required (e.g. if an update to some global state is needed), it is best to throw an error when  is . (for example "you cannot use context X with pure'"), which will show up at compile time.TA data type to indicate whether the user requested pure or IO function from HaskellA mapping from Ys to Haskell types. Needed both to parse C types, and to convert them to Haskell types.7Context useful to work with vanilla C. Used by default.3: converts C basic types to their counterparts in Foreign.C.Types.No .Given a , it uses its  to convert arbitrary C types.This  includes a 1 that removes the need for explicitely creating * s, named "fun".%For example, we can capture function f of type CInt -> CInt -> IO CInt in C code using $fun:(int (*f)(int, int)).When used in a puree embedding, the Haskell function will have to be pure too. Continuing the example above we'll have CInt -> CInt -> IO CInt.Does not include the O, since most of the time it's going to be included as part of larger contexts.This  includes two 1s that allow to easily use Haskell vectors in C.Specifically, the vec-len and vec-ptr: will get the length and the pointer underlying mutable (  ) and immutable (0) storable vectors.Note that if you use c to manipulate immutable vectors you must make sure that the vector is not modified in the C code.To use vec-len, simply write  $vec-len:x, where x is something of type    a or 0 a , for some a . To use vec-ptr4 you need to specify the type of the pointer, e.g. $vec-len:(int *x) will work if x has type    1.$ serves exactly the same purpose as , but only for 2. vec-ptr becomes bs-ptr, and vec-len becomes bs-len9. You don't need to specify the type of the pointer in bs-ptr, it will always be char*.*3456789:;<=>?3456789:;<=>?None &3:EHJKMVData type representing a list of C definitions with a typed and named entry function./We use it as a basis to inline and call C code.Safety of the foreign call.Type of the foreign call./Name of the function to call in the code below. The C code.@EIdentifier for the current module. Currently we use the file name. Since we're pairing Haskell files with C files, it makes more sense to use the file name. I'm not sure if it's possible to compile two modules with the same name in one run of GHC, but in this way we make sure that we don't run into trouble even it is.AB storing the state for all the modules we visited. Note that currently we do not bother with cleaning up the state after we're done compiling a module. TODO if there is an easy way, clean up the state.CMake sure that A- and the respective C file are up to date.Gets the current ;. Also makes sure that the current module is initialised. Sets the  for the current module. This function, if called, must be called before any of the other TH functions in this module. Fails if that's not the case.D,Return the path in which to emit C code. Or Er if emitting should be inhibited, say because we're only type checking the module, not emitting code (e.g. with  -fno-code or in haddock)BSimply appends some string to the module's C file. Use with care./Inlines a piece of code inline. The resulting /& will have the type specified in the .oIn practice, this function outputs the C code to the module's C file, and then inserts a foreign call of type  calling the provided .Example:  c_add :: Int -> Int -> Int c_add = $(inlineCode $ Code TH.Unsafe -- Call safety [t| Int -> Int -> Int |] -- Call type "francescos_add" -- Call name -- C Code "int francescos_add(int x, int y) { int z = x + y; return z; }") Same as  inlineCItems, but with a single expression. c_cos :: Double -> Double c_cos = $(inlineExp TH.Unsafe [t| Double -> Double |] (quickCParser_ "double" parseType) [("x", quickCParser_ "double") parseType] "cos(x)") Same as \, but accepts a string containing a list of C statements instead instead than a full-blown Q. A function containing the provided statement will be automatically generated. c_cos :: Double -> Double c_cos = $(inlineItems TH.Unsafe [t| Double -> Double |] (quickCParser_ "double" parseType) [("x", quickCParser_ "double" parseType)] "return cos(x);") -F@GHIJKACThe ) to use if we initialise the module. If E,  will be used.LMDNOSafety of the foreign callType of the foreign callReturn type of the C exprParameters of the C exprThe C expressionSafety of the foreign callType of the foreign callReturn type of the C exprParameters of the C expr The C items>Returns the return type, the captured variables, and the body.P The parser-Function building an Haskell expression, see ! for guidance on the other args.QRSTF@GHIJKACLMDNOPQRSTNoneC expressions. Variant of 9, for use with expressions known to have no side effects.BEWARE: use this function with caution, only when you know what you are doing. If an expression does in fact have side-effects, then indiscriminate use of K may endanger referential transparency, and in principle even type safety. C code blocks (i.e. statements).None!"=JKMOType class with methods useful to allocate and peek multiple pointers at once: withPtrs_ :: (Storable a, Storable b) => ((Ptr a, Ptr b) -> IO ()) -> IO (a, b) withPtrs_ :: (Storable a, Storable b, Storable c) => ((Ptr a, Ptr b, Ptr c) -> IO ()) -> IO (a, b, c) ... C expressions. Variant of 9, for use with expressions known to have no side effects.BEWARE: use this function with caution, only when you know what you are doing. If an expression does in fact have side-effects, then indiscriminate use of K may endanger referential transparency, and in principle even type safety. C code blocks (i.e. statements).Emits a CPP include directive for C code associated with the current module. To avoid having to escape quotes, the function itself adds them when appropriate, so that %include "foo.h" ==> #include "foo.h" but #include "<foo>" ==> #include <foo> ^Emits an arbitrary C string to the C code associated with the current module. Use with care.Like U%, but also peeks the contents of the ,9 and returns them once the provided action has finished. Sets the  for the current module. This function, if called, must be called before any of the other TH functions in this module. Fails if that's not the case.VWXYZ[I\]^_`abcdef1ghijklmnopqrstuvwxyz{|}~VWXYZ[     !"#$%!&''()*+,-./0123456789:;<=>?@ABC*,0=DEFGGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrst"#u0vvwxy0231z{|}~E e    u !"#$%&'()*+,-./0123456789:;<=>>?@ABCDEFGHIJKLMNOPQ$R$R$S$S$T$T$U$U$V$V$%$W$W$X$X$Y$Y$Z$Z$[$[$\$\$]$]$^$^$_$_$`$`$a$a$b$b$c$c$d$d$e$e$f$g$h$i$i$j$j$k$k$l$lminline-c-0.5.4.1Language.C.Types.Parse#Language.C.Inline.HaskellIdentifierLanguage.C.TypesLanguage.C.InlineLanguage.C.Inline.ContextLanguage.C.Inline.InternalLanguage.C.Inline.UnsafeLanguage.C.Inline.FunPtrVIOVector!ParameterDeclarationWithTypeNamespdwtnTypeNamespdwtnParameterDeclarationDirectAbstractDeclaratorAbstractDeclaratorParensArrayOrProtoThereArrayOrProtoHereAbstractDeclaratorabstractDeclaratorPointersabstractDeclaratorDirectDeclaratorOrAbstractDeclaratorIsAbstractDeclarator IsDeclaratorParameterDeclarationparameterDeclarationSpecifiersparameterDeclarationDeclaratorPointer ArrayTypeSizedByIdentifierSizedByIntegerUnsized VariablySized ArrayOrProtoProtoArrayDirectDeclaratorDeclaratorParensDeclaratorRoot DeclaratordeclaratorPointersdeclaratorDirectFunctionSpecifierINLINE TypeQualifierVOLATILERESTRICTCONST TypeSpecifierTypeNameEnumStructUNSIGNEDSIGNEDDOUBLEFLOATLONGINTSHORTCHARVOIDStorageClassSpecifierREGISTERAUTOSTATICEXTERNTYPEDEFDeclarationSpecifierCParser CIdentifier unCIdentifierCParserContext cpcIdentName cpcTypeNames cpcParseIdentcpcIdentToString TypeNamescIdentifierFromStringcCParserContext runCParser quickCParser quickCParser_cReservedWords cIdentStart cIdentLetterdeclaration_specifiersstorage_class_specifiertype_specifieridentifier_no_lextype_qualifierfunction_specifier declaratorarray_or_proto array_typedirect_declaratorpointerparameter_listparameter_declarationabstract_declaratordirect_abstract_declarator*arbitraryParameterDeclarationWithTypeNamesHaskellIdentifierunHaskellIdentifierhaskellIdentifierFromStringhaskellCParserContextparseHaskellIdentifiermangleHaskellIdentifier UntangleErrIllegalSpecifiers NoDataTypesMultipleDataTypesparameterDeclarationIdparameterDeclarationTypeSignUnsignedSignedTypePtr SpecifiersstorageClassSpecifierstypeQualifiersfunctionSpecifiersLDoubleDoubleFloatLLongLongIntShortCharVoiduntangleParameterDeclarationtangleParameterDeclarationdescribeParameterDeclaration describeTypeparseParameterDeclarationparseParameterListparseIdentifier parseTypemkFunPtrmkFunPtrFromName peekFunPtrVecCtx VecCtxScalar vecCtxLengthvecCtxUnsafeWithCArrayContext ctxTypesTablectxAntiQuotersctxFileExtension ctxOutput AntiQuotersSomeAntiQuoter AntiQuoterId AntiQuoteraqParser aqMarshallerPurityIOPure TypesTablebaseCtx convertTypetypeNamesFromTypesTablefunCtxvecCtxbsCtx ParseTypedC ptcReturnType ptcParametersptcBody ParameterType AntiQuotePlainSomeEqCodecodeCallSafetycodeType codeFunNamecodeDefs getContext setContext emitVerbatim inlineCode inlineExp inlineItems runParserInQtoSomeEq fromSomeEq parseTypedC genericQuoteexppureblockWithPtrs WithPtrsPtrswithPtrs withPtrs_includeverbatimwithPtrwithPtr_contextQuickCheck-2.8.1Test.QuickCheck.Arbitrary ArbitrarybaseGHC.ErrerrorGHC.Baseconstghc-prim GHC.TypesFalsecidentifier_rawcidentifier_no_lex oneOfSizedAnyhowArbitraryContext acTypeNamesacIdentToString OneOfSized IfPositive cIdentStyle identifier isTypeName cidentifier type_nameprettyPointers prettyParams halveSize!arbitraryDeclarationSpecifierFromarbitraryTypeSpecifierFromarbitraryDeclaratorFromarbitraryCIdentifierFromarbitraryIdentifierFromarbitraryDirectDeclaratorFromarbitraryArrayOrProtoFromarbitraryArrayTypeFrom!arbitraryParameterDeclarationFromarbitraryAbstractDeclaratorFrom%arbitraryDirectAbstractDeclaratorFrommany1 identNoLex$fArbitraryPointer$fArbitraryFunctionSpecifier$fArbitraryTypeQualifier $fArbitraryStorageClassSpecifier$fArbitraryCIdentifier $fPrettyDirectAbstractDeclarator$fPrettyAbstractDeclarator$fPrettyParameterDeclaration$fPrettyArrayType$fPrettyArrayOrProto$fPrettyDirectDeclarator$fPrettyPointer$fPrettyDeclarator$fPrettyFunctionSpecifier$fPrettyTypeQualifier$fPrettyTypeSpecifier$fPrettyStorageClassSpecifier$fPrettyDeclarationSpecifier$fPrettyCIdentifier$fIsStringCIdentifierhaskellIdentStylehaskellReservedWords$fArbitraryHaskellIdentifier$fPrettyHaskellIdentifier$fIsStringHaskellIdentifierfailConversionuntangleDeclarationSpecifiersuntangleDeclaratoruntangleAbstractDeclaratortangleTypeSpecifieruntangleParameterDeclaration'pretty80 $fPrettyType$fPrettyUntangleErr$fMonoidSpecifiersGHC.PtrFunPtruniqueFfiImportName Data.MonoidMonoidmappendtemplate-haskellLanguage.Haskell.TH.SyntaxExpvector-0.10.12.3Data.Vector.StorableVectorForeign.C.TypesCIntbytestring-0.10.4.0Data.ByteString.Internal ByteStringbaseTypesTable getHsVariable convertType_funPtrAntiQuotervecPtrAntiQuotervecLenAntiQuoterbsPtrAntiQuoterbsLenAntiQuoter cDeclAqParserdeHaskellifyCType$fVecCtxMVector$fVecCtxVector$fMonoidContextModuleIdmoduleStatesVarGHC.MVarMVarinitialiseModuleState cSourceLoc Data.MaybeNothing ModuleState msContextmsGeneratedNames getModuleIdmodifyModuleStatebumpGeneratedNamesremoveIfExists uniqueCName quoteCode prettyOneLine $fShowSomeEq $fEqSomeEqForeign.Marshal.Allocalloca$fWithPtrs(,,,,,,)$fWithPtrs(,,,,,)$fWithPtrs(,,,,)$fWithPtrs(,,,)$fWithPtrs(,,) $fWithPtrs(,)CCharCSCharCUCharCShortCUShortCUIntCLongCULongCLLongCULLongCFloatCDoubleCPtrdiffCSizeCWchar CSigAtomicCClockCTime CUSeconds CSUSecondsCFileCFposCJmpBufCIntPtrCUIntPtrCIntMaxCUIntMax