Aelve Codesearch

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

total matches: more than 1000

abcBridge-0.15
13 matches
src/Data/ABC/AIG.hs
          0 -> do
            p1 <- peek pp
            pModel <- abcNtkModel p1
            AIG.Sat . fmap toBool <$> peekArray ic pModel
          1 -> return AIG.Unsat
          _ -> error $ "Unrecognized return code " ++ show r ++ " from abcNtkIvyProve"

memoFoldAIG :: AIG s -> (LitView a -> IO a) -> IO (Lit s -> IO a)
memoFoldAIG g view = do

            
src/Data/ABC/AIG.hs
        ciCount <- aigManCiNum pMan
        forM [0..(ciCount - 1)] $ \i -> do
          ci <- aigManCi pMan (fromIntegral i)
          ((vars V.!) . fromIntegral) `fmap` (aigObjId ci)

  checkSat g l = do
    withNetworkPtr (AIG.Network g [l]) $ \p ->
      alloca $ \pp ->
        bracket_

            
src/Data/ABC/AIG.hs
withNetworkPtr (AIG.Network x o) m = do
  withAIGPtr x $ \p ->
    bracket_
      (mapM_ (addPo p) o)
      (deletePos p)
      (m p)

addPo :: Abc_Ntk_t -> Lit s -> IO ()
addPo p (Lit ptr) = do

            
src/Data/ABC/AIG.hs
          h

-- | Convert the network referred to by an AIG manager into CNF format
-- and write to a file, returning a mapping from ABC object IDs to CNF
-- variable numbers.
writeAIGManToCNFWithMapping :: Aig_Man_t -> FilePath -> IO (V.Vector Int)
writeAIGManToCNFWithMapping pMan path =
  withCnfDerive pMan 0 $ \pCnf -> do
    cnfDataWriteIntoFile pCnf path 1 nullPtr nullPtr

            
src/Data/ABC/AIG.hs
    cnfDataWriteIntoFile pCnf path 1 nullPtr nullPtr
    getCNFMapping pMan pCnf

-- | Return the array mapping AIG network objects (indices) to CNF
-- variable numbers (entries) for a CNF data object derived from the
-- given AIG manager.
getCNFMapping :: Aig_Man_t -> Cnf_Dat_t -> IO (V.Vector Int)
getCNFMapping pMan pCnf = do
    objCount <- fmap fromIntegral $ aigManObjNumMax pMan

            
src/Data/ABC/AIG.hs
-- given AIG manager.
getCNFMapping :: Aig_Man_t -> Cnf_Dat_t -> IO (V.Vector Int)
getCNFMapping pMan pCnf = do
    objCount <- fmap fromIntegral $ aigManObjNumMax pMan
    varsPtr <- cnfVarNums pCnf
    V.generateM objCount $ \i -> fromIntegral <$> peekElemOff varsPtr i

            
src/Data/ABC/GIA.hs
      ciCount <- aigManCiNum pMan
      forM [0..(ciCount - 1)] $ \i -> do
        ci <- aigManCi pMan (fromIntegral i)
        ((vars SV.!) . fromIntegral) `fmap` (aigObjId ci)

  checkSat ntk l = do
    giaNetworkAsAIGMan (AIG.Network ntk [l]) $ \pMan -> do
    -- Allocate a pointer to an ABC network.
    alloca $ \pp -> do

            
src/Data/ABC/GIA.hs
     ncos <- vecIntSize =<< giaManCos p
     assert( ncos == 0 ) $ do
     bracket (giaManDupNormalize p) giaManStop
         (\p' -> mapM_ (\(L o) -> giaManAppendCo p' o) out >> m p')


-- This is a somewhat risky method to build a Gia network containing
-- the required output COs.  Initially, we assume the network has no COs.
-- Then, we add enough COs to account for the list of "out" literals.

            
src/Data/ABC/GIA.hs
    -- Run computation, then reset.
    bracket_
      -- Add combinational outputs.
      (mapM_ (\(L o) -> giaManAppendCo p o) out)
      -- reset the graph afterwards
      reset
      -- Run computation.
      (m p)


            
tests/Tests/Basic.hs
      removeFile path

  , testProperty "unfold_fold" $ \litForest -> ioProperty $ do
      let maxInput = foldr max 0 $ map ABC.getMaxInput litForest

      n1@(ABC.Network g ls) <- ABC.buildNetwork proxy litForest

      litForest' <- ABC.toLitForest g ls


            
tests/Tests/Basic.hs
      (path, hndl) <- openTempFile tmpdir "aiger.aig"
      hClose hndl

      x <- fmap ABC.bvFromList $ sequence $ replicate 32 (ABC.newInput g)
      y <- ABC.zipWithM (ABC.lAnd' g) x (ABC.bvFromInteger g 32 0x12345678)

      ABC.writeAiger path (ABC.Network g (ABC.bvToList y))

      let tobool :: Int -> Bool

            
tests/Tests/Basic.hs
      let tobool :: Int -> Bool
          tobool i = if i == 0 then False else True

      let inputs = map tobool $ reverse $
                   [ 0,1,1,0,1,0,0,0,
                     0,0,0,0,0,0,0,0,
                     0,0,0,0,0,0,0,0,
                     0,0,0,0,0,0,0,0 ]


            
tests/Tests/Basic.hs
                     0,0,0,0,0,0,0,0,
                     0,0,0,0,0,0,0,0 ]

      let outputs = fmap tobool $ reverse $
                    [ 0,0,0,0,1,0,0,0,
                      0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0 ]


            
aeson-compat-0.3.9
5 matches
src/Data/Aeson/Compat.hs
#if MIN_VERSION_aeson(0,10,0)
                  modifyFailure addKeyName $ parseJSON v -- <?> Key key
  where
    addKeyName = mappend $ mconcat ["failed to parse field ", T.unpack key, ": "]
#else
                  parseJSON v
#endif
{-# INLINE (.:?) #-}


            
src/Data/Aeson/Compat.hs
#if MIN_VERSION_aeson(0,10,0)
                  modifyFailure addKeyName $ Just <$> parseJSON v -- <?> Key key
  where
    addKeyName = mappend $ mconcat ["failed to parse field ", T.unpack key, ": "]
#else
                  Just <$> parseJSON v
#endif
{-# INLINE (.:!) #-}
#endif

            
src/Data/Aeson/Compat.hs

instance FromJSON b => FromJSON (Tagged a b) where
    {-# INLINE parseJSON #-}
    parseJSON = fmap Tagged . parseJSON

instance ToJSON a => ToJSON (Const a b) where
    toJSON (Const x) = toJSON x
    {-# INLINE toJSON #-}


            
src/Data/Aeson/Compat.hs

instance FromJSON a => FromJSON (Const a b) where
    {-# INLINE parseJSON #-}
    parseJSON = fmap Const . parseJSON

instance (ToJSON a) => ToJSON (NonEmpty a) where
    toJSON = toJSON . NonEmpty.toList
    {-# INLINE toJSON #-}


            
test/Tests.hs
newtype T2 = T2 (Maybe Int) deriving (Eq, Show)
newtype T3 = T3 (Maybe Int) deriving (Eq, Show)

instance FromJSON T1 where parseJSON = fmap T1 . withObject "T1" (.: "value")
instance FromJSON T2 where parseJSON = fmap T2 . withObject "T2" (.:? "value")
instance FromJSON T3 where parseJSON = fmap T3 . withObject "T3" (.:! "value")

dotColonMark :: TestTree
dotColonMark = testGroup "Operators" $ fmap t [
    assertEqual ".:  not-present" Nothing               (decode ex1 :: Maybe T1)
  , assertEqual ".:  42"          (Just (T1 (Just 42))) (decode ex2 :: Maybe T1)
  , assertEqual ".:  null"        (Just (T1 Nothing))   (decode ex3 :: Maybe T1)

  , assertEqual ".:? not-present" (Just (T2 (Nothing))) (decode ex1 :: Maybe T2)

            
aeson-diff-generic-0.0.3
4 matches
Data/Aeson/Diff/Generic/PathOptics.hs
         -> (((Path, a) -> f (Path, a)) ->  (Path, s) -> f (Path, s))
         -- ^ the output optic with path information
withPath p2 orig f (p, v) =
  fmap (over _1 (p <>)) $ getCompose $
  orig (\a -> Compose $ f (p2,a)) v

-- | remove the path from an optic annotated with path information.
-- 
-- > withoutPath . withPath ≡ id

            
Data/Aeson/Diff/Generic/PathOptics.hs
           => Index a -> IxValue a -> PathTraversal s a -> s
           -> (Patch, s)
insertPath key v lns s =
  fmap snd $
  lns (\(p2, a) ->
         let a2 = insertKey key v a
         in ( Patch [Add (Pointer $ p2 <>
                           [toKey key a]) (toJSON v)]
            , (p2, a2)))

            
Data/Aeson/Diff/Generic/PathOptics.hs
           => Index a -> PathTraversal s a -> s
           -> (Patch, s)
deletePath key lns s =
  fmap snd $
  lns (\(p2, a) ->
         case deleteKey key a of
           Nothing -> (Patch [], (p2, a))
           Just (_, a2) ->
             ( Patch [Rem (Pointer $ p2 <> [toKey key a])]

            
Data/Aeson/Diff/Generic/PathOptics.hs
              KeyIndexed (s a))
          => Traversal' (Path, (s a)) (Path, a)
traverseP f (p, s) =
  fmap (over _1 (p <>)) $ getCompose $
  itraverse (\i a -> Compose (f ([toKey i s], a))) s

_1P :: Field1 s s a a  => PathLens s a
_1P = withPath [AKey 0] _1


            
aeson-extra-0.4.1.3
8 matches
src/Data/Aeson/Extra/CollapsedList.hs
        Nothing   -> pure Control.Applicative.empty
        Just v    -> modifyFailure addKeyName $ (getCollapsedList <$> parseJSON v) -- <?> Key key
  where
    addKeyName = (mappend ("failed to parse field " `mappend` T.unpack key `mappend`": "))

#else
instance (FromJSON a, FromJSON (f a), Alternative f) => FromJSON (CollapsedList f a) where
    parseJSON Null         = pure (CollapsedList Control.Applicative.empty)
    parseJSON v@(Array _)  = CollapsedList <$> parseJSON v

            
src/Data/Aeson/Extra/CollapsedList.hs
#if MIN_VERSION_aeson(0,10,0)
        Just v    -> modifyFailure addKeyName $ (getCollapsedList <$> parseJSON v) -- <?> Key key
  where
    addKeyName = (mappend ("failed to parse field " `mappend` T.unpack key `mappend`": "))
#else
        Just v    -> getCollapsedList <$> parseJSON v
#endif
#endif

            
src/Data/Aeson/Extra/Map.hs
import qualified Data.Text.Lazy      as LT
import qualified Data.Text.Read      as T

-- | A wrapper type to parse arbitrary maps
--
-- > λ > decode "{\"1\": 1, \"2\": 2}" :: Maybe (M (H.HashMap Int Int))
-- > Just (M {getMap = fromList [(1,1),(2,2)]})
newtype M a = M { getMap :: a }
  deriving (Eq, Ord, Show, Read, Functor, Foldable, Traversable, Typeable)

            
src/Data/Aeson/Extra/Map.hs
  parseJSONMap :: HM.HashMap Text Value -> Parser m

instance (Eq k, Hashable k, FromJSONKey k, FromJSON v) => FromJSONMap (HM.HashMap k v) k v where
  parseJSONMap = fmap HM.fromList . traverse f . HM.toList
    where f (k, v) = (,) <$> parseJSONKey k <*> parseJSON v

instance (Ord k, FromJSONKey k, FromJSON v) => FromJSONMap (Map.Map k v) k v where
  parseJSONMap = fmap Map.fromList . traverse f . HM.toList
    where f (k, v) = (,) <$> parseJSONKey k <*> parseJSON v

instance (FromJSONMap m k v) => FromJSON (M m) where
  parseJSON v = M <$> withObject "Map" parseJSONMap v


            
src/Data/Aeson/Extra/Map.hs
  toJSONMap :: m -> HM.HashMap Text Value

instance (ToJSONKey k, ToJSON v) => ToJSONMap (HM.HashMap k v) k v where
  toJSONMap = HM.fromList . fmap f . HM.toList
    where f (k, v) = (toJSONKey k, toJSON v)

instance (ToJSONKey k, ToJSON v) => ToJSONMap (Map.Map k v) k v where
  toJSONMap = HM.fromList . fmap f . Map.toList
    where f (k, v) = (toJSONKey k, toJSON v)

instance (ToJSONMap m k v) => ToJSON (M m) where
  toJSON (M m) = Object (toJSONMap m)

            
src/Data/Aeson/Extra/Recursive.hs
import qualified Data.Functor.Foldable as F
#endif

-- | A JSON \"object\" (key\/value map).
--
-- /Since: aeson-extra-0.3.1.0/
type ObjectF a = HashMap Text a

-- | A JSON \"array\" (sequence).

            
src/Data/Aeson/Extra/Time.hs

instance FromJSON U where
#if MIN_VERSION_aeson (0,10,0)
  parseJSON = fmap U . parseJSON
#else
  parseJSON = withText "UTCTime" (fmap U . run TimeParsers.utcTime)
#endif

-- | A type to parse 'ZonedTime'
--
-- /Since: aeson-extra-0.2.2.0/

            
src/Data/Aeson/Extra/Time.hs

instance FromJSON Z where
#if MIN_VERSION_aeson (0,10,0)
  parseJSON = fmap Z . parseJSON
#else
  parseJSON = withText "ZonedTime" (fmap Z . run TimeParsers.zonedTime)
#endif

#if !MIN_VERSION_aeson (0,10,0)
-- | Run a 'parsers' parser as an aeson parser.
run :: Parsec.Parsec Text () a -> Text -> Parser a