Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated about a month ago

total matches: 88

haskell-gi-0.22.6
13 matches
lib/Data/GI/CodeGen/Code.hs
                       return (r, moduleCode new)

-- | Like `recurseCG`, giving explicitly the set of loaded APIs and C to
-- Haskell map for the subgenerator.
recurseWithAPIs :: M.Map Name API -> CodeGen () -> CodeGen ()
recurseWithAPIs apis cg = do
  cfg <- ask
  (cgs, oldInfo) <- get
  -- Start the subgenerator with no code and no submodules.

            
lib/Data/GI/CodeGen/Code.hs
transitiveModuleDeps :: ModuleInfo -> Deps
transitiveModuleDeps minfo =
    Set.unions (moduleDeps minfo
               : map transitiveModuleDeps (M.elems $ submodules minfo))

-- | Given a module name and a symbol in the module (including a
-- proper namespace), return a qualified name for the symbol.
qualified :: ModulePath -> Name -> CodeGen Text
qualified mp (Name ns s) = do

            
lib/Data/GI/CodeGen/Code.hs
minBaseVersion :: ModuleInfo -> BaseVersion
minBaseVersion minfo =
    maximum (moduleMinBase minfo
            : map minBaseVersion (M.elems $ submodules minfo))

-- | Give a friendly textual description of the error for presenting
-- to the user.
describeCGError :: CGError -> Text
describeCGError (CGErrorNotImplemented e) = "Not implemented: " <> tshow e

            
lib/Data/GI/CodeGen/Code.hs
formatExportedModules :: [Export] -> Maybe Text
formatExportedModules [] = Nothing
formatExportedModules exports =
    Just . T.concat . map (formatExport (("module " <>) . exportSymbol))
          . filter ((== ExportModule) . exportType) $ exports

-- | Format the toplevel exported symbols.
formatToplevel :: [Export] -> Maybe Text
formatToplevel [] = Nothing

            
lib/Data/GI/CodeGen/Code.hs
formatToplevel :: [Export] -> Maybe Text
formatToplevel [] = Nothing
formatToplevel exports =
    Just . T.concat . map (formatExport exportSymbol)
         . filter ((== ExportSymbol ToplevelSection) . exportType) $ exports

-- | Format the type declarations section.
formatTypeDecls :: [Export] -> Maybe Text
formatTypeDecls exports =

            
lib/Data/GI/CodeGen/Code.hs
    in if exportedTypes == []
       then Nothing
       else Just . T.unlines $ [ "-- * Exported types"
                               , T.concat . map ( formatExport exportSymbol )
                                      $ exportedTypes ]

-- | A subsection name, with an optional anchor name.
data Subsection = Subsection { subsectionTitle  :: Text
                             , subsectionAnchor :: Maybe Text

            
lib/Data/GI/CodeGen/Code.hs
    then Nothing
    else Just . T.unlines $ [" -- * " <> mainSectionName section
                            , ( T.unlines
                              . map formatSubsection
                              . M.toList ) exportedSubsections]

    where
      exportedSubsections :: M.Map Subsection (Set.Set Export)
      exportedSubsections = foldr extract M.empty exports

            
lib/Data/GI/CodeGen/Code.hs
                        Just text -> "{- | " <> text  <> "\n-}"
                        Nothing -> ""
                    , ( T.concat
                      . map (formatExport exportSymbol)
                      . Set.toList ) symbols]

-- | Format the list of exports into grouped sections.
formatSubsectionExports :: M.Map HaddockSection Text -> [Export] -> [Maybe Text]
formatSubsectionExports docs exports = map (uncurry formatSection)

            
lib/Data/GI/CodeGen/Code.hs

-- | Format the list of exports into grouped sections.
formatSubsectionExports :: M.Map HaddockSection Text -> [Export] -> [Maybe Text]
formatSubsectionExports docs exports = map (uncurry formatSection)
                                       (M.toAscList collectedExports)
  where collectedExports :: M.Map NamedSection [(Subsection, Export)]
        collectedExports = foldl classifyExport M.empty exports

        classifyExport :: M.Map NamedSection [(Subsection, Export)] ->

            
lib/Data/GI/CodeGen/Code.hs
    <> "    ) where\n"
modulePrelude docs name [] reexportedModules =
    "module " <> name <> "\n    ( "
    <> formatExportList docs (map (\m -> Export ExportModule m []) reexportedModules)
    <> "    ) where\n\n"
    <> T.unlines (map ("import " <>) reexportedModules)
modulePrelude docs name exports reexportedModules =
    "module " <> name <> "\n    ( "
    <> formatExportList docs (map (\m -> Export ExportModule m []) reexportedModules)
    <> "\n"
    <> formatExportList docs exports
    <> "    ) where\n\n"
    <> T.unlines (map ("import " <>) reexportedModules)

-- | Code for loading the needed dependencies. One needs to give the
-- prefix for the namespace being currently generated, modules with
-- this prefix will be imported as {-# SOURCE #-}, and otherwise will
-- be imported normally.

            
lib/Data/GI/CodeGen/Code.hs
-- be imported normally.
importDeps :: ModulePath -> [ModulePath] -> Text
importDeps _ [] = ""
importDeps (ModulePath prefix) deps = T.unlines . map toImport $ deps
    where toImport :: ModulePath -> Text
          toImport dep = let impSt = if importSource dep
                                     then "import {-# SOURCE #-} qualified "
                                     else "import qualified "
                         in impSt <> dotWithPrefix dep <>

            
lib/Data/GI/CodeGen/Code.hs
-- `writeModuleTree`.
writeModuleInfo :: Bool -> Maybe FilePath -> ModuleInfo -> IO ()
writeModuleInfo verbose dirPrefix minfo = do
  let submodulePaths = map (modulePath) (M.elems (submodules minfo))
      -- We reexport any submodules.
      submoduleExports = map dotWithPrefix submodulePaths
      fname = modulePathToFilePath dirPrefix (modulePath minfo) ".hs"
      dirname = takeDirectory fname
      code = codeToText (moduleCode minfo)
      pragmas = languagePragmas (Set.toList $ modulePragmas minfo)
      optionsGHC = ghcOptions (Set.toList $ moduleGHCOpts minfo)

            
lib/Data/GI/CodeGen/Code.hs
-- | Construct the filename corresponding to the given module.
modulePathToFilePath :: Maybe FilePath -> ModulePath -> FilePath -> FilePath
modulePathToFilePath dirPrefix (ModulePath mp) ext =
    joinPath (fromMaybe "" dirPrefix : "GI" : map T.unpack mp) ++ ext

-- | Write down the code for a module and its submodules to disk under
-- the given base directory. It returns the list of written modules.
writeModuleTree :: Bool -> Maybe FilePath -> ModuleInfo -> IO [Text]
writeModuleTree verbose dirPrefix minfo = do

            
haskell-gi-base-0.22.2
1 matches
Data/GI/Base/ShortPrelude.hs
    , Double
    , undefined
    , error
    , map
    , length
    , mapM
    , mapM_
    , when
    , fromIntegral
    , realToFrac
    ) where


            
llvm-hs-8.0.0
6 matches
src/Control/Monad/Trans/AnyCont.hs
newtype AnyContT m a = AnyContT { unAnyContT :: forall r . ContT r m a }

instance Functor (AnyContT m) where
  fmap f p = AnyContT $ fmap f . unAnyContT $ p

instance Applicative (AnyContT m) where
  pure a = AnyContT $ pure a
  f <*> v = AnyContT $ unAnyContT f <*> unAnyContT v


            
src/Control/Monad/Trans/AnyCont.hs
withAnyContT :: (forall r . (b -> m r) -> (a -> m r)) -> AnyContT m a -> AnyContT m b
withAnyContT f m = anyContT $ runAnyContT m . f

mapAnyContT :: (forall r . m r -> m r) -> AnyContT m a -> AnyContT m a
mapAnyContT f m = anyContT $ f . runAnyContT m


            
src/LLVM/Internal/Attribute.hs
         EncodeM EncodeAST [a] (FFI.AttributeSet b) where
  encodeM as = do
    ab <- allocaAttrBuilder
    builds <- mapM encodeM as
    void (forM builds ($ ab) :: EncodeAST [()])
    Context context <- gets encodeStateContext
    anyContToM
      (bracket (FFI.getAttributeSet context ab) FFI.disposeAttributeSet)


            
src/LLVM/Internal/Coding.hs

instance (Monad m, EncodeM m h c, Storable c, MonadAnyCont IO m) => EncodeM m [h] (CUInt, Ptr c) where
  encodeM hs = do
    hs <- mapM encodeM hs
    (anyContToM $ \x -> Foreign.Marshal.Array.withArrayLen hs $ \n hs -> x (fromIntegral n, hs))

instance (Monad m, DecodeM m h c, Storable c, MonadIO m) => DecodeM m [h] (CUInt, Ptr c) where
  decodeM (n, ca) = do
    cs <- liftIO $ Foreign.Marshal.Array.peekArray (fromIntegral n) ca

            
src/LLVM/Internal/Coding.hs
instance (Monad m, DecodeM m h c, Storable c, MonadIO m) => DecodeM m [h] (CUInt, Ptr c) where
  decodeM (n, ca) = do
    cs <- liftIO $ Foreign.Marshal.Array.peekArray (fromIntegral n) ca
    mapM decodeM cs

instance Monad m => EncodeM m Bool FFI.LLVMBool where
  encodeM False = return $ FFI.LLVMBool 0
  encodeM True = return $ FFI.LLVMBool 1


            
src/LLVM/Internal/Constant.hs
      Context context <- gets encodeStateContext
      liftIO $ FFI.getConstTokenNone context
    o -> $(do
      let -- This is a mapping from constructor names to the constructor of the constant
          -- and the constructor and the definition of the instruction.
          constExprInfo :: Map.Map String (Maybe TH.Con, Maybe (TH.Con, ID.InstructionDef))
          constExprInfo =  ID.outerJoin ID.astConstantRecs (ID.innerJoin ID.astInstructionRecs ID.instructionDefs)
      TH.caseE [| o |] $
        map (\p -> TH.match p (TH.normalB [|inconsistentCases "Constant" o|]) [])

            
llvm-hs-pure-8.0.0
10 matches
src/LLVM/AST/Operand.hs
  deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

instance Functor MDRef where
  fmap _ (MDRef i) = MDRef i
  fmap f (MDInline a) = MDInline (f a)

data DWOpFragment = DW_OP_LLVM_Fragment
  { offset :: Word64
  , size :: Word64
  } deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

            
src/LLVM/AST/Typed.hs
  typeOf (C.Float t) = typeOf t
  typeOf (C.Null t)      = t
  typeOf (C.AggregateZero t) = t
  typeOf (C.Struct {..}) = StructureType isPacked (map typeOf memberValues)
  typeOf (C.Array {..})  = ArrayType (fromIntegral $ length memberValues) memberType
  typeOf (C.Vector {..}) = VectorType (fromIntegral $ length memberValues) $
                              case memberValues of
                                  []    -> error "Vectors of size zero are not allowed. (Malformed AST)"
                                  (x:_) -> typeOf x

            
src/LLVM/AST/Typed.hs
  typeOf (GlobalVariable {..}) = type'
  typeOf (GlobalAlias {..})    = type'
  typeOf (Function {..})       = let (params, isVarArg) = parameters
                                   in FunctionType returnType (map typeOf params) isVarArg
instance Typed Parameter where
  typeOf (Parameter t _ _) = t

            
src/LLVM/DataLayout.hs

import Data.Attoparsec.ByteString
import Data.Attoparsec.ByteString.Char8
import Data.ByteString.Char8 as ByteString hiding (map, foldr)
import qualified Data.List as List
import qualified Data.Map as Map
import qualified Data.Set as Set

import LLVM.AST.DataLayout

            
src/LLVM/DataLayout.hs
    ] ++ [
      "a:" <> sAlignmentInfo ai | ai <- nonDef (pure . aggregateLayout)
    ] ++
    (oneOpt (("n"<>) . (ByteString.intercalate ":") . map (pack . show) . Set.toList) nativeSizes)
    ++
    (oneOpt (("S"<>) . pack . show) stackAlignment)
  )

-- | Parse a 'DataLayout', given a default Endianness should one not be specified in the

            
src/LLVM/IRBuilder/Internal/SnocList.hs

instance Monoid (SnocList a) where
#if !(MIN_VERSION_base(4,11,0))
  mappend = (<>)
#endif
  mempty = SnocList []

snoc :: SnocList a -> a -> SnocList a
snoc (SnocList xs) x = SnocList $ x : xs

            
src/LLVM/IRBuilder/Monad.hs
-- any call to `block` and before emitting any instructions.
currentBlock :: MonadIRBuilder m => m Name
currentBlock = liftIRState $ do
  name <- gets (fmap partialBlockName . builderBlock)
  case name of
    Just n -> pure n
    Nothing -> error "Called currentBlock when no block was active"

-- | Find out if the currently active block has a terminator.

            
src/LLVM/Prelude.hs
    ) where

import Prelude hiding (
    mapM, mapM_,
    sequence, sequence_,
    concat,
    foldr, foldr1, foldl, foldl1,
    minimum, maximum, sum, product, all, any, and, or,
    concatMap,

            
src/LLVM/Prelude.hs
import Control.Applicative
import Control.Monad hiding (
    forM, forM_,
    mapM, mapM_,
    sequence, sequence_,
    msum
  )

import Data.ByteString (ByteString)

            
src/LLVM/Prelude.hs

leftBiasedZip :: [a] -> [b] -> [(a, Maybe b)]
leftBiasedZip [] _ = []
leftBiasedZip xs [] = map (, Nothing) xs
leftBiasedZip (x:xs) (y:ys) = (x, Just y) : leftBiasedZip xs ys

ifM :: Monad m => m Bool -> m a -> m a -> m a
ifM cond ifTrue ifFalse = do
  cond' <- cond