Search is not available for this dataset
repo_name string | path string | license string | full_code string | full_size int64 | uncommented_code string | uncommented_size int64 | function_only_code string | function_only_size int64 | is_commented bool | is_signatured bool | n_ast_errors int64 | ast_max_depth int64 | n_whitespaces int64 | n_ast_nodes int64 | n_ast_terminals int64 | n_ast_nonterminals int64 | loc int64 | cycloplexity int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ford-prefect/haskell-gi | lib/Data/GI/CodeGen/Code.hs | lgpl-2.1 | -- | Add a property-related export under the given section.
exportProperty :: HaddockSection -> SymbolName -> CodeGen ()
exportProperty s n = export (Export (ExportProperty s) n) | 178 | exportProperty :: HaddockSection -> SymbolName -> CodeGen ()
exportProperty s n = export (Export (ExportProperty s) n) | 118 | exportProperty s n = export (Export (ExportProperty s) n) | 57 | true | true | 0 | 9 | 26 | 47 | 23 | 24 | null | null |
ombocomp/repl-toolkit | System/REPL/Ask.hs | apache-2.0 | -- Example askers
-------------------------------------------------------------------------------
-- |Asks the user for a file or a directory.
--
-- Parsing checks for basic validity via 'System.FilePath.isValid'. Invalid paths are rejected.
--
-- After that, the asker determines whether the target exists and what type
-- it has. You can run a predicate on that information.
filepathAsker :: MonadIO m
=> PromptMsg
-> (FilePath -> TypeError)
-> Predicate m (PathExistenceType, FilePath) b
-> Asker m FilePath b
filepathAsker pr errT pred = Asker pr parse pred'
where
parse = (\fp -> if FP.isValid fp then Right fp else Left $ errT fp) . T.unpack
pred' fp = do
exType <- liftIO $ getExistenceType fp
pred (exType, fp)
--return $ if ok then Right (exType, fp)
-- else Left $ errP (exType, fp)
getExistenceType :: FilePath -> IO PathExistenceType
getExistenceType fp = do
isDir <- D.doesDirectoryExist fp
if isDir then return IsDirectory
else do isFile <- D.doesFileExist fp
return $ if isFile then IsFile
else DoesNotExist
-- |See 'filepathAsker'. This 'Asker' also ensures that the given path
-- is writeable in the following sense:
--
-- * at least some initial part of the path exists and
-- * the last existing part of the path is writeable.
--
-- 'PathRootDoesNotExist' and 'PathIsNotWritable' exceptions are thrown if the
-- first or second of these conditions is violated.
--
-- For relative paths, we only check that the current directory is writable.
--
-- Handled exceptions:
--
-- * 'System.IO.Error.isPermissionError'
-- * 'System.IO.Error.isDoesNotExistError' | 1,795 | filepathAsker :: MonadIO m
=> PromptMsg
-> (FilePath -> TypeError)
-> Predicate m (PathExistenceType, FilePath) b
-> Asker m FilePath b
filepathAsker pr errT pred = Asker pr parse pred'
where
parse = (\fp -> if FP.isValid fp then Right fp else Left $ errT fp) . T.unpack
pred' fp = do
exType <- liftIO $ getExistenceType fp
pred (exType, fp)
--return $ if ok then Right (exType, fp)
-- else Left $ errP (exType, fp)
getExistenceType :: FilePath -> IO PathExistenceType
getExistenceType fp = do
isDir <- D.doesDirectoryExist fp
if isDir then return IsDirectory
else do isFile <- D.doesFileExist fp
return $ if isFile then IsFile
else DoesNotExist
-- |See 'filepathAsker'. This 'Asker' also ensures that the given path
-- is writeable in the following sense:
--
-- * at least some initial part of the path exists and
-- * the last existing part of the path is writeable.
--
-- 'PathRootDoesNotExist' and 'PathIsNotWritable' exceptions are thrown if the
-- first or second of these conditions is violated.
--
-- For relative paths, we only check that the current directory is writable.
--
-- Handled exceptions:
--
-- * 'System.IO.Error.isPermissionError'
-- * 'System.IO.Error.isDoesNotExistError' | 1,414 | filepathAsker pr errT pred = Asker pr parse pred'
where
parse = (\fp -> if FP.isValid fp then Right fp else Left $ errT fp) . T.unpack
pred' fp = do
exType <- liftIO $ getExistenceType fp
pred (exType, fp)
--return $ if ok then Right (exType, fp)
-- else Left $ errP (exType, fp)
getExistenceType :: FilePath -> IO PathExistenceType
getExistenceType fp = do
isDir <- D.doesDirectoryExist fp
if isDir then return IsDirectory
else do isFile <- D.doesFileExist fp
return $ if isFile then IsFile
else DoesNotExist
-- |See 'filepathAsker'. This 'Asker' also ensures that the given path
-- is writeable in the following sense:
--
-- * at least some initial part of the path exists and
-- * the last existing part of the path is writeable.
--
-- 'PathRootDoesNotExist' and 'PathIsNotWritable' exceptions are thrown if the
-- first or second of these conditions is violated.
--
-- For relative paths, we only check that the current directory is writable.
--
-- Handled exceptions:
--
-- * 'System.IO.Error.isPermissionError'
-- * 'System.IO.Error.isDoesNotExistError' | 1,222 | true | true | 2 | 12 | 469 | 263 | 136 | 127 | null | null |
zer/BeginningHaskell | src/Chapter2/PatternMatching.hs | apache-2.0 | companyName :: Client -> Maybe String
companyName (Company name _ _ _) = Just name | 82 | companyName :: Client -> Maybe String
companyName (Company name _ _ _) = Just name | 82 | companyName (Company name _ _ _) = Just name | 44 | false | true | 0 | 7 | 14 | 36 | 17 | 19 | null | null |
nikki-and-the-robots/nikki | src/Base/Types/LevelMetaData.hs | lgpl-3.0 | loadMetaData :: FilePath -- ^ level file (.nl)
-> IO LevelMetaData
loadMetaData levelFile = do
exists <- doesFileExist (metaFile levelFile)
if not exists then do
logg Warning ("level meta data file does not exist: " ++ metaFile levelFile)
return $ LevelMetaData (guessName levelFile) Nothing Nothing Nothing Nothing
else do
metaDataJSON :: BSL.ByteString <- io $ BSL.readFile (metaFile levelFile)
BSL.length metaDataJSON `deepseq` return ()
let result :: Maybe LevelMetaData = decode' metaDataJSON
case result of
Nothing -> do
logg Warning ("meta data not parseable: " ++ levelFile)
return $ LevelMetaData (guessName levelFile) Nothing Nothing Nothing Nothing
Just x -> return x | 800 | loadMetaData :: FilePath -- ^ level file (.nl)
-> IO LevelMetaData
loadMetaData levelFile = do
exists <- doesFileExist (metaFile levelFile)
if not exists then do
logg Warning ("level meta data file does not exist: " ++ metaFile levelFile)
return $ LevelMetaData (guessName levelFile) Nothing Nothing Nothing Nothing
else do
metaDataJSON :: BSL.ByteString <- io $ BSL.readFile (metaFile levelFile)
BSL.length metaDataJSON `deepseq` return ()
let result :: Maybe LevelMetaData = decode' metaDataJSON
case result of
Nothing -> do
logg Warning ("meta data not parseable: " ++ levelFile)
return $ LevelMetaData (guessName levelFile) Nothing Nothing Nothing Nothing
Just x -> return x | 800 | loadMetaData levelFile = do
exists <- doesFileExist (metaFile levelFile)
if not exists then do
logg Warning ("level meta data file does not exist: " ++ metaFile levelFile)
return $ LevelMetaData (guessName levelFile) Nothing Nothing Nothing Nothing
else do
metaDataJSON :: BSL.ByteString <- io $ BSL.readFile (metaFile levelFile)
BSL.length metaDataJSON `deepseq` return ()
let result :: Maybe LevelMetaData = decode' metaDataJSON
case result of
Nothing -> do
logg Warning ("meta data not parseable: " ++ levelFile)
return $ LevelMetaData (guessName levelFile) Nothing Nothing Nothing Nothing
Just x -> return x | 729 | false | true | 0 | 18 | 221 | 225 | 103 | 122 | null | null |
outlikealambda/trustocracy | src/Zipper.hs | bsd-3-clause | zipper :: Keyed a => Zipper a -> Zipper a
zipper (t, parent:crumbs) = (createBranch t parent, crumbs) | 101 | zipper :: Keyed a => Zipper a -> Zipper a
zipper (t, parent:crumbs) = (createBranch t parent, crumbs) | 101 | zipper (t, parent:crumbs) = (createBranch t parent, crumbs) | 59 | false | true | 0 | 7 | 17 | 52 | 26 | 26 | null | null |
alexander-at-github/eta | compiler/ETA/TypeCheck/FunDeps.hs | bsd-3-clause | improveFromInstEnv :: InstEnvs
-> PredType
-> [Equation SrcSpan] -- Needs to be an Equation because
-- of quantified variables
-- Post: Equations oriented from the template (matching instance) to the workitem!
improveFromInstEnv _inst_env pred
| not (isClassPred pred)
= panic "improveFromInstEnv: not a class predicate" | 403 | improveFromInstEnv :: InstEnvs
-> PredType
-> [Equation SrcSpan]
improveFromInstEnv _inst_env pred
| not (isClassPred pred)
= panic "improveFromInstEnv: not a class predicate" | 217 | improveFromInstEnv _inst_env pred
| not (isClassPred pred)
= panic "improveFromInstEnv: not a class predicate" | 114 | true | true | 0 | 10 | 127 | 51 | 25 | 26 | null | null |
kim/amazonka | amazonka-swf/gen/Network/AWS/SWF/DescribeActivityType.hs | mpl-2.0 | -- | The activity type to get information about. Activity types are identified by
-- the 'name' and 'version' that were supplied when the activity was registered.
datActivityType :: Lens' DescribeActivityType ActivityType
datActivityType = lens _datActivityType (\s a -> s { _datActivityType = a }) | 298 | datActivityType :: Lens' DescribeActivityType ActivityType
datActivityType = lens _datActivityType (\s a -> s { _datActivityType = a }) | 135 | datActivityType = lens _datActivityType (\s a -> s { _datActivityType = a }) | 76 | true | true | 0 | 9 | 44 | 41 | 23 | 18 | null | null |
copland/cmdargs | Data/Generics/Any/Prelude.hs | bsd-3-clause | isTuple x = isJust $ readTupleType $ typeShell x | 48 | isTuple x = isJust $ readTupleType $ typeShell x | 48 | isTuple x = isJust $ readTupleType $ typeShell x | 48 | false | false | 5 | 5 | 8 | 25 | 9 | 16 | null | null |
spyked/slides | ht-revisited/examples/ref-examples.hs | cc0-1.0 | vnil :: Vector Z a
vnil = Vector Empty | 38 | vnil :: Vector Z a
vnil = Vector Empty | 38 | vnil = Vector Empty | 19 | false | true | 0 | 5 | 8 | 19 | 9 | 10 | null | null |
juhp/leksah | src/IDE/Pane/PackageEditor.hs | gpl-2.0 | hasUnknownBenchmarkTypes :: PackageDescription -> Bool
hasUnknownBenchmarkTypes pd =
not . null . filter unknown $ benchmarks pd
where
unknown (Benchmark _ (BenchmarkExeV10 _ _) _ _) = False
unknown _ = True | 221 | hasUnknownBenchmarkTypes :: PackageDescription -> Bool
hasUnknownBenchmarkTypes pd =
not . null . filter unknown $ benchmarks pd
where
unknown (Benchmark _ (BenchmarkExeV10 _ _) _ _) = False
unknown _ = True | 221 | hasUnknownBenchmarkTypes pd =
not . null . filter unknown $ benchmarks pd
where
unknown (Benchmark _ (BenchmarkExeV10 _ _) _ _) = False
unknown _ = True | 166 | false | true | 0 | 9 | 45 | 75 | 36 | 39 | null | null |
smaccm/capDL-tool | CapDL/PrintIsabelle.hs | bsd-2-clause | printIrqMappings :: ObjMap Word -> IRQMap -> [Doc]
printIrqMappings ms irqNode =
let irqs = Map.map printID irqNode
irqs' = Map.toList $ Map.mapKeys fromIntegral irqs
ids = completeMap irqs' (zip [0..255] (map num [Map.size ms'..])) --FIXME: factor out 255?
in map printIrqMapping ids
where ms' = Map.filterWithKey (\id _ -> not (mapElem id irqNode)) ms | 381 | printIrqMappings :: ObjMap Word -> IRQMap -> [Doc]
printIrqMappings ms irqNode =
let irqs = Map.map printID irqNode
irqs' = Map.toList $ Map.mapKeys fromIntegral irqs
ids = completeMap irqs' (zip [0..255] (map num [Map.size ms'..])) --FIXME: factor out 255?
in map printIrqMapping ids
where ms' = Map.filterWithKey (\id _ -> not (mapElem id irqNode)) ms | 381 | printIrqMappings ms irqNode =
let irqs = Map.map printID irqNode
irqs' = Map.toList $ Map.mapKeys fromIntegral irqs
ids = completeMap irqs' (zip [0..255] (map num [Map.size ms'..])) --FIXME: factor out 255?
in map printIrqMapping ids
where ms' = Map.filterWithKey (\id _ -> not (mapElem id irqNode)) ms | 330 | false | true | 0 | 16 | 82 | 147 | 73 | 74 | null | null |
alphaHeavy/cabal | cabal-install/Distribution/Client/Targets.hs | bsd-3-clause | readPToMaybe :: Parse.ReadP a a -> String -> Maybe a
readPToMaybe p str = listToMaybe [ r | (r,s) <- Parse.readP_to_S p str
, all isSpace s ] | 178 | readPToMaybe :: Parse.ReadP a a -> String -> Maybe a
readPToMaybe p str = listToMaybe [ r | (r,s) <- Parse.readP_to_S p str
, all isSpace s ] | 178 | readPToMaybe p str = listToMaybe [ r | (r,s) <- Parse.readP_to_S p str
, all isSpace s ] | 125 | false | true | 0 | 10 | 64 | 70 | 34 | 36 | null | null |
OpenXT/manager | upgrade-db/Migrations/M_40.hs | gpl-2.0 | updateConfigV4VToArgo = xformVmJSON xform where
xform tree = jsMv "/config/v4v" "/config/argo" tree | 101 | updateConfigV4VToArgo = xformVmJSON xform where
xform tree = jsMv "/config/v4v" "/config/argo" tree | 101 | updateConfigV4VToArgo = xformVmJSON xform where
xform tree = jsMv "/config/v4v" "/config/argo" tree | 101 | false | false | 1 | 5 | 13 | 28 | 12 | 16 | null | null |
kbiscanic/hash | src/Parsing/HashParser.hs | gpl-2.0 | nonEscapeNoQ :: Parser Char
nonEscapeNoQ = noneOf "\\\"\0\n\r\v\t\b\f " | 71 | nonEscapeNoQ :: Parser Char
nonEscapeNoQ = noneOf "\\\"\0\n\r\v\t\b\f " | 71 | nonEscapeNoQ = noneOf "\\\"\0\n\r\v\t\b\f " | 43 | false | true | 0 | 6 | 8 | 23 | 9 | 14 | null | null |
sdiehl/ghc | compiler/nativeGen/RegAlloc/Graph/SpillClean.hs | bsd-3-clause | accBlockReloadsSlot :: BlockId -> Slot -> CleanM ()
accBlockReloadsSlot blockId slot
= modify $ \s -> s {
sReloadedBy = addToUFM_C (++)
(sReloadedBy s)
(SSlot slot)
[blockId] } | 281 | accBlockReloadsSlot :: BlockId -> Slot -> CleanM ()
accBlockReloadsSlot blockId slot
= modify $ \s -> s {
sReloadedBy = addToUFM_C (++)
(sReloadedBy s)
(SSlot slot)
[blockId] } | 281 | accBlockReloadsSlot blockId slot
= modify $ \s -> s {
sReloadedBy = addToUFM_C (++)
(sReloadedBy s)
(SSlot slot)
[blockId] } | 229 | false | true | 0 | 11 | 132 | 72 | 38 | 34 | null | null |
ygale/yesod | yesod-test/Yesod/Test.hs | mit | postBody :: (Yesod site, RedirectUrl site url)
=> url
-> BSL8.ByteString
-> YesodExample site ()
postBody url body = request $ do
setMethod "POST"
setUrl url
setRequestBody body
-- | Perform a GET request to @url@.
--
-- ==== __Examples__
--
-- > get HomeR
--
-- > get ("http://google.com" :: Text) | 332 | postBody :: (Yesod site, RedirectUrl site url)
=> url
-> BSL8.ByteString
-> YesodExample site ()
postBody url body = request $ do
setMethod "POST"
setUrl url
setRequestBody body
-- | Perform a GET request to @url@.
--
-- ==== __Examples__
--
-- > get HomeR
--
-- > get ("http://google.com" :: Text) | 332 | postBody url body = request $ do
setMethod "POST"
setUrl url
setRequestBody body
-- | Perform a GET request to @url@.
--
-- ==== __Examples__
--
-- > get HomeR
--
-- > get ("http://google.com" :: Text) | 208 | false | true | 2 | 10 | 85 | 85 | 41 | 44 | null | null |
forked-upstream-packages-for-ghcjs/ghc | compiler/utils/Util.hs | bsd-3-clause | readRational :: String -> Rational -- NB: *does* handle a leading "-"
readRational top_s
= case top_s of
'-' : xs -> - (read_me xs)
xs -> read_me xs
where
read_me s
= case (do { (x,"") <- readRational__ s ; return x }) of
[x] -> x
[] -> error ("readRational: no parse:" ++ top_s)
_ -> error ("readRational: ambiguous parse:" ++ top_s)
-----------------------------------------------------------------------------
-- read helpers | 502 | readRational :: String -> Rational
readRational top_s
= case top_s of
'-' : xs -> - (read_me xs)
xs -> read_me xs
where
read_me s
= case (do { (x,"") <- readRational__ s ; return x }) of
[x] -> x
[] -> error ("readRational: no parse:" ++ top_s)
_ -> error ("readRational: ambiguous parse:" ++ top_s)
-----------------------------------------------------------------------------
-- read helpers | 467 | readRational top_s
= case top_s of
'-' : xs -> - (read_me xs)
xs -> read_me xs
where
read_me s
= case (do { (x,"") <- readRational__ s ; return x }) of
[x] -> x
[] -> error ("readRational: no parse:" ++ top_s)
_ -> error ("readRational: ambiguous parse:" ++ top_s)
-----------------------------------------------------------------------------
-- read helpers | 432 | true | true | 1 | 10 | 141 | 146 | 72 | 74 | null | null |
brendanhay/gogol | gogol-shopping-content/gen/Network/Google/ShoppingContent/Types/Product.hs | mpl-2.0 | -- | Creates a value of 'OrderTrackingSignal' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'otsDeliveryPostalCode'
--
-- * 'otsMerchantId'
--
-- * 'otsOrderTrackingSignalId'
--
-- * 'otsLineItems'
--
-- * 'otsOrderCreatedTime'
--
-- * 'otsDeliveryRegionCode'
--
-- * 'otsShippingInfo'
--
-- * 'otsShipmentLineItemMApping'
--
-- * 'otsCustomerShippingFee'
--
-- * 'otsOrderId'
orderTrackingSignal
:: OrderTrackingSignal
orderTrackingSignal =
OrderTrackingSignal'
{ _otsDeliveryPostalCode = Nothing
, _otsMerchantId = Nothing
, _otsOrderTrackingSignalId = Nothing
, _otsLineItems = Nothing
, _otsOrderCreatedTime = Nothing
, _otsDeliveryRegionCode = Nothing
, _otsShippingInfo = Nothing
, _otsShipmentLineItemMApping = Nothing
, _otsCustomerShippingFee = Nothing
, _otsOrderId = Nothing
} | 924 | orderTrackingSignal
:: OrderTrackingSignal
orderTrackingSignal =
OrderTrackingSignal'
{ _otsDeliveryPostalCode = Nothing
, _otsMerchantId = Nothing
, _otsOrderTrackingSignalId = Nothing
, _otsLineItems = Nothing
, _otsOrderCreatedTime = Nothing
, _otsDeliveryRegionCode = Nothing
, _otsShippingInfo = Nothing
, _otsShipmentLineItemMApping = Nothing
, _otsCustomerShippingFee = Nothing
, _otsOrderId = Nothing
} | 460 | orderTrackingSignal =
OrderTrackingSignal'
{ _otsDeliveryPostalCode = Nothing
, _otsMerchantId = Nothing
, _otsOrderTrackingSignalId = Nothing
, _otsLineItems = Nothing
, _otsOrderCreatedTime = Nothing
, _otsDeliveryRegionCode = Nothing
, _otsShippingInfo = Nothing
, _otsShipmentLineItemMApping = Nothing
, _otsCustomerShippingFee = Nothing
, _otsOrderId = Nothing
} | 413 | true | true | 1 | 7 | 166 | 103 | 71 | 32 | null | null |
pgj/bead | src/Bead/View/TemplateAndComponentNames.hs | bsd-3-clause | userTimeZoneField = UserField "usertimezone" | 44 | userTimeZoneField = UserField "usertimezone" | 44 | userTimeZoneField = UserField "usertimezone" | 44 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
gittywithexcitement/hindent | src/HIndent/Pretty.hs | bsd-3-clause | decl (TypeDecl _ typehead typ) =
depend (write "type ")
(depend (pretty typehead)
(depend (write " = ")
(pretty typ))) | 171 | decl (TypeDecl _ typehead typ) =
depend (write "type ")
(depend (pretty typehead)
(depend (write " = ")
(pretty typ))) | 171 | decl (TypeDecl _ typehead typ) =
depend (write "type ")
(depend (pretty typehead)
(depend (write " = ")
(pretty typ))) | 171 | false | false | 0 | 11 | 72 | 64 | 31 | 33 | null | null |
fmapfmapfmap/amazonka | amazonka-swf/gen/Network/AWS/SWF/Types/Product.hs | mpl-2.0 | -- | The ID of the 'DecisionTaskCompleted' event corresponding to the
-- decision task that resulted in the 'SignalExternalWorkflowExecution'
-- decision for this signal. This information can be useful for diagnosing
-- problems by tracing back the chain of events leading up to this event.
seweieaDecisionTaskCompletedEventId :: Lens' SignalExternalWorkflowExecutionInitiatedEventAttributes Integer
seweieaDecisionTaskCompletedEventId = lens _seweieaDecisionTaskCompletedEventId (\ s a -> s{_seweieaDecisionTaskCompletedEventId = a}) | 534 | seweieaDecisionTaskCompletedEventId :: Lens' SignalExternalWorkflowExecutionInitiatedEventAttributes Integer
seweieaDecisionTaskCompletedEventId = lens _seweieaDecisionTaskCompletedEventId (\ s a -> s{_seweieaDecisionTaskCompletedEventId = a}) | 243 | seweieaDecisionTaskCompletedEventId = lens _seweieaDecisionTaskCompletedEventId (\ s a -> s{_seweieaDecisionTaskCompletedEventId = a}) | 134 | true | true | 0 | 9 | 60 | 43 | 25 | 18 | null | null |
Airtnp/Freshman_Simple_Haskell_Lib | Idioms/Collaborative-filtering.hs | mit | mergeAdd xs [] = xs | 19 | mergeAdd xs [] = xs | 19 | mergeAdd xs [] = xs | 19 | false | false | 1 | 5 | 4 | 18 | 6 | 12 | null | null |
koterpillar/equations | src/Control/Equation/Solve.hs | mit | solveAgainst _ [] = return MultipleSolutions | 44 | solveAgainst _ [] = return MultipleSolutions | 44 | solveAgainst _ [] = return MultipleSolutions | 44 | false | false | 0 | 6 | 5 | 16 | 7 | 9 | null | null |
ghc-android/ghc | compiler/typecheck/TcRnTypes.hs | bsd-3-clause | pprSkolInfo FamInstSkol = ptext (sLit "a family instance declaration") | 76 | pprSkolInfo FamInstSkol = ptext (sLit "a family instance declaration") | 76 | pprSkolInfo FamInstSkol = ptext (sLit "a family instance declaration") | 76 | false | false | 1 | 7 | 14 | 22 | 8 | 14 | null | null |
javgh/bitcoin-rpc | Network/BitcoinRPC.hs | bsd-3-clause | errorCodeInvalidAddress :: Integer
errorCodeInvalidAddress = -5 | 63 | errorCodeInvalidAddress :: Integer
errorCodeInvalidAddress = -5 | 63 | errorCodeInvalidAddress = -5 | 28 | false | true | 0 | 5 | 5 | 13 | 7 | 6 | null | null |
8l/barrelfish | hake/Tools.hs | mit | -- ARM-GCC 2015q2 (GCC 4.9)
arm_netos_arm_2015q2
= ToolDetails {
toolPath = "/home/netos/tools/gcc-arm-embedded" </>
"gcc-arm-none-eabi-4_9-2015q2" </>
"bin",
toolPrefix = "arm-none-eabi-"
} | 254 | arm_netos_arm_2015q2
= ToolDetails {
toolPath = "/home/netos/tools/gcc-arm-embedded" </>
"gcc-arm-none-eabi-4_9-2015q2" </>
"bin",
toolPrefix = "arm-none-eabi-"
} | 226 | arm_netos_arm_2015q2
= ToolDetails {
toolPath = "/home/netos/tools/gcc-arm-embedded" </>
"gcc-arm-none-eabi-4_9-2015q2" </>
"bin",
toolPrefix = "arm-none-eabi-"
} | 226 | true | false | 1 | 9 | 83 | 36 | 18 | 18 | null | null |
Raveline/FQuoter | lib/FQuoter/Serialize/Queries.hs | gpl-3.0 | queryFor (QDissociate DBQuote DBAuthor) = "DELETE FROM Quote_Authors WHERE related_quote = ? AND related_author = ?" | 116 | queryFor (QDissociate DBQuote DBAuthor) = "DELETE FROM Quote_Authors WHERE related_quote = ? AND related_author = ?" | 116 | queryFor (QDissociate DBQuote DBAuthor) = "DELETE FROM Quote_Authors WHERE related_quote = ? AND related_author = ?" | 116 | false | false | 0 | 7 | 15 | 17 | 8 | 9 | null | null |
eryx67/haskell-libtorrent | src/Network/Libtorrent/Types/ArrayLike.hs | bsd-3-clause | fromList :: VectorLike a => [ElemType a] -> IO a
fromList as = do
v <- newVector
forM_ as $ addElem v
return v | 116 | fromList :: VectorLike a => [ElemType a] -> IO a
fromList as = do
v <- newVector
forM_ as $ addElem v
return v | 116 | fromList as = do
v <- newVector
forM_ as $ addElem v
return v | 67 | false | true | 0 | 8 | 29 | 60 | 26 | 34 | null | null |
JeanJoskin/JsLib | src/Language/JsLib/Parser/Parser.hs | bsd-3-clause | -- AssignmentExpression (11.13) (modified)
-- Fixme: Lefthand-side should not be a conditional, infix, unary or postfix
assignOps = anyOp [(AEquals,"="),(AMultiply,"*="),(ADivide,"/="),(AModulus,"%="),
(AAdd,"+="),(ASubtract,"-="),(ASignedShiftLeft,"<<="),
(ASignedShiftRight,">>="),(AUnsignedShiftRight,">>>="),
(ABitAND,"&="),(ABitXOR,"^="),(ABitOR,"|=")] | 397 | assignOps = anyOp [(AEquals,"="),(AMultiply,"*="),(ADivide,"/="),(AModulus,"%="),
(AAdd,"+="),(ASubtract,"-="),(ASignedShiftLeft,"<<="),
(ASignedShiftRight,">>="),(AUnsignedShiftRight,">>>="),
(ABitAND,"&="),(ABitXOR,"^="),(ABitOR,"|=")] | 276 | assignOps = anyOp [(AEquals,"="),(AMultiply,"*="),(ADivide,"/="),(AModulus,"%="),
(AAdd,"+="),(ASubtract,"-="),(ASignedShiftLeft,"<<="),
(ASignedShiftRight,">>="),(AUnsignedShiftRight,">>>="),
(ABitAND,"&="),(ABitXOR,"^="),(ABitOR,"|=")] | 276 | true | false | 0 | 7 | 62 | 119 | 78 | 41 | null | null |
snoyberg/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | -- The 'inline' function
inlineIdName :: Name
inlineIdName = varQual gHC_MAGIC (fsLit "inline") inlineIdKey | 118 | inlineIdName :: Name
inlineIdName = varQual gHC_MAGIC (fsLit "inline") inlineIdKey | 93 | inlineIdName = varQual gHC_MAGIC (fsLit "inline") inlineIdKey | 72 | true | true | 0 | 7 | 24 | 25 | 13 | 12 | null | null |
meiersi/blaze-binary | src/Data/Blaze/Binary/Encoding.hs | bsd-3-clause | int16 :: Encoding Int16
int16 = VStream . VInt16 | 48 | int16 :: Encoding Int16
int16 = VStream . VInt16 | 48 | int16 = VStream . VInt16 | 24 | false | true | 1 | 6 | 8 | 25 | 10 | 15 | null | null |
seereason/wl-pprint-text | Text/PrettyPrint/Leijen/Text/Monadic.hs | bsd-3-clause | -- | The document @(bool b)@ shows the literal boolean @b@ using
-- 'text'.
bool :: (Monad m) => Bool -> m Doc
bool = return . PP.bool | 136 | bool :: (Monad m) => Bool -> m Doc
bool = return . PP.bool | 58 | bool = return . PP.bool | 23 | true | true | 1 | 8 | 29 | 42 | 20 | 22 | null | null |
plow-technologies/cassava | Data/Csv/Parser.hs | bsd-3-clause | header :: Word8 -- ^ Field delimiter
-> AL.Parser Header
header !delim = V.fromList <$!> name delim `sepByDelim1'` delim <* endOfLine | 141 | header :: Word8 -- ^ Field delimiter
-> AL.Parser Header
header !delim = V.fromList <$!> name delim `sepByDelim1'` delim <* endOfLine | 141 | header !delim = V.fromList <$!> name delim `sepByDelim1'` delim <* endOfLine | 76 | false | true | 0 | 8 | 28 | 44 | 22 | 22 | null | null |
tolysz/prepare-ghcjs | spec-lts8/base/Data/Data.hs | bsd-3-clause | integerType :: DataType
integerType = mkIntType "Prelude.Integer" | 65 | integerType :: DataType
integerType = mkIntType "Prelude.Integer" | 65 | integerType = mkIntType "Prelude.Integer" | 41 | false | true | 0 | 6 | 6 | 20 | 8 | 12 | null | null |
rahulmutt/ghcvm | compiler/Eta/Types/TyCon.hs | bsd-3-clause | -- | Create a lifted primitive 'TyCon' such as @RealWorld@
mkLiftedPrimTyCon :: Name -> Kind -> [Role] -> PrimRep -> TyCon
mkLiftedPrimTyCon name kind roles rep
= mkPrimTyCon' name kind roles rep False | 204 | mkLiftedPrimTyCon :: Name -> Kind -> [Role] -> PrimRep -> TyCon
mkLiftedPrimTyCon name kind roles rep
= mkPrimTyCon' name kind roles rep False | 145 | mkLiftedPrimTyCon name kind roles rep
= mkPrimTyCon' name kind roles rep False | 80 | true | true | 0 | 8 | 35 | 58 | 27 | 31 | null | null |
TravisWhitaker/discern | src/Discern/GHC/Expectation.hs | mit | classMethRep :: [G.Id] -> ExClassMeth -> ClassMethRep
classMethRep gis (ExClassMeth n t) =
let gms = map unMeth gis
mmt = find (\(gn, _) -> gn == n) gms
in case mmt
of Nothing -> ClassMethAbsent n
(Just (_, (Left e))) -> ClassMethWrongType n t (Left e)
(Just (_, (Right gt))) -> if t == gt
then ClassMethOK n
else ClassMethWrongType n t (Right gt) | 504 | classMethRep :: [G.Id] -> ExClassMeth -> ClassMethRep
classMethRep gis (ExClassMeth n t) =
let gms = map unMeth gis
mmt = find (\(gn, _) -> gn == n) gms
in case mmt
of Nothing -> ClassMethAbsent n
(Just (_, (Left e))) -> ClassMethWrongType n t (Left e)
(Just (_, (Right gt))) -> if t == gt
then ClassMethOK n
else ClassMethWrongType n t (Right gt) | 504 | classMethRep gis (ExClassMeth n t) =
let gms = map unMeth gis
mmt = find (\(gn, _) -> gn == n) gms
in case mmt
of Nothing -> ClassMethAbsent n
(Just (_, (Left e))) -> ClassMethWrongType n t (Left e)
(Just (_, (Right gt))) -> if t == gt
then ClassMethOK n
else ClassMethWrongType n t (Right gt) | 450 | false | true | 0 | 14 | 221 | 183 | 94 | 89 | null | null |
elieux/ghc | compiler/deSugar/Coverage.hs | bsd-3-clause | {-
************************************************************************
* *
* The main function: addTicksToBinds
* *
************************************************************************
-}
addTicksToBinds
:: DynFlags
-> Module
-> ModLocation -- ... off the current module
-> NameSet -- Exported Ids. When we call addTicksToBinds,
-- isExportedId doesn't work yet (the desugarer
-- hasn't set it), so we have to work from this set.
-> [TyCon] -- Type constructor in this module
-> LHsBinds Id
-> IO (LHsBinds Id, HpcInfo, ModBreaks)
addTicksToBinds dflags mod mod_loc exports tyCons binds
| let passes = coveragePasses dflags, not (null passes),
Just orig_file <- ml_hs_file mod_loc = do
if "boot" `isSuffixOf` orig_file
then return (binds, emptyHpcInfo False, emptyModBreaks)
else do
us <- mkSplitUniqSupply 'C' -- for cost centres
let orig_file2 = guessSourceFile binds orig_file
tickPass tickish (binds,st) =
let env = TTE
{ fileName = mkFastString orig_file2
, declPath = []
, tte_dflags = dflags
, exports = exports
, inlines = emptyVarSet
, inScope = emptyVarSet
, blackList = Map.fromList
[ (getSrcSpan (tyConName tyCon),())
| tyCon <- tyCons ]
, density = mkDensity tickish dflags
, this_mod = mod
, tickishType = tickish
}
(binds',_,st') = unTM (addTickLHsBinds binds) env st
in (binds', st')
initState = TT { tickBoxCount = 0
, mixEntries = []
, breakCount = 0
, breaks = []
, uniqSupply = us
}
(binds1,st) = foldr tickPass (binds, initState) passes
let tickCount = tickBoxCount st
hashNo <- writeMixEntries dflags mod tickCount (reverse $ mixEntries st)
orig_file2
modBreaks <- mkModBreaks dflags (breakCount st) (reverse $ breaks st)
when (dopt Opt_D_dump_ticked dflags) $
log_action dflags dflags SevDump noSrcSpan defaultDumpStyle
(pprLHsBinds binds1)
return (binds1, HpcInfo tickCount hashNo, modBreaks)
| otherwise = return (binds, emptyHpcInfo False, emptyModBreaks) | 2,899 | addTicksToBinds
:: DynFlags
-> Module
-> ModLocation -- ... off the current module
-> NameSet -- Exported Ids. When we call addTicksToBinds,
-- isExportedId doesn't work yet (the desugarer
-- hasn't set it), so we have to work from this set.
-> [TyCon] -- Type constructor in this module
-> LHsBinds Id
-> IO (LHsBinds Id, HpcInfo, ModBreaks)
addTicksToBinds dflags mod mod_loc exports tyCons binds
| let passes = coveragePasses dflags, not (null passes),
Just orig_file <- ml_hs_file mod_loc = do
if "boot" `isSuffixOf` orig_file
then return (binds, emptyHpcInfo False, emptyModBreaks)
else do
us <- mkSplitUniqSupply 'C' -- for cost centres
let orig_file2 = guessSourceFile binds orig_file
tickPass tickish (binds,st) =
let env = TTE
{ fileName = mkFastString orig_file2
, declPath = []
, tte_dflags = dflags
, exports = exports
, inlines = emptyVarSet
, inScope = emptyVarSet
, blackList = Map.fromList
[ (getSrcSpan (tyConName tyCon),())
| tyCon <- tyCons ]
, density = mkDensity tickish dflags
, this_mod = mod
, tickishType = tickish
}
(binds',_,st') = unTM (addTickLHsBinds binds) env st
in (binds', st')
initState = TT { tickBoxCount = 0
, mixEntries = []
, breakCount = 0
, breaks = []
, uniqSupply = us
}
(binds1,st) = foldr tickPass (binds, initState) passes
let tickCount = tickBoxCount st
hashNo <- writeMixEntries dflags mod tickCount (reverse $ mixEntries st)
orig_file2
modBreaks <- mkModBreaks dflags (breakCount st) (reverse $ breaks st)
when (dopt Opt_D_dump_ticked dflags) $
log_action dflags dflags SevDump noSrcSpan defaultDumpStyle
(pprLHsBinds binds1)
return (binds1, HpcInfo tickCount hashNo, modBreaks)
| otherwise = return (binds, emptyHpcInfo False, emptyModBreaks) | 2,549 | addTicksToBinds dflags mod mod_loc exports tyCons binds
| let passes = coveragePasses dflags, not (null passes),
Just orig_file <- ml_hs_file mod_loc = do
if "boot" `isSuffixOf` orig_file
then return (binds, emptyHpcInfo False, emptyModBreaks)
else do
us <- mkSplitUniqSupply 'C' -- for cost centres
let orig_file2 = guessSourceFile binds orig_file
tickPass tickish (binds,st) =
let env = TTE
{ fileName = mkFastString orig_file2
, declPath = []
, tte_dflags = dflags
, exports = exports
, inlines = emptyVarSet
, inScope = emptyVarSet
, blackList = Map.fromList
[ (getSrcSpan (tyConName tyCon),())
| tyCon <- tyCons ]
, density = mkDensity tickish dflags
, this_mod = mod
, tickishType = tickish
}
(binds',_,st') = unTM (addTickLHsBinds binds) env st
in (binds', st')
initState = TT { tickBoxCount = 0
, mixEntries = []
, breakCount = 0
, breaks = []
, uniqSupply = us
}
(binds1,st) = foldr tickPass (binds, initState) passes
let tickCount = tickBoxCount st
hashNo <- writeMixEntries dflags mod tickCount (reverse $ mixEntries st)
orig_file2
modBreaks <- mkModBreaks dflags (breakCount st) (reverse $ breaks st)
when (dopt Opt_D_dump_ticked dflags) $
log_action dflags dflags SevDump noSrcSpan defaultDumpStyle
(pprLHsBinds binds1)
return (binds1, HpcInfo tickCount hashNo, modBreaks)
| otherwise = return (binds, emptyHpcInfo False, emptyModBreaks) | 2,050 | true | true | 1 | 27 | 1,283 | 561 | 295 | 266 | null | null |
dahlia/nirum | src/Nirum/Targets/Python.hs | gpl-3.0 | compileTypeDeclaration src
d@TypeDeclaration { typename = typename'
, type' = union@UnionType {}
, typeAnnotations = annotations
} = do
tagCodes <- mapM (compileUnionTag src typename') tags'
insertStandardImport "typing"
insertStandardImport "enum"
insertThirdPartyImports [("nirum.deserialize", ["deserialize_meta"])]
insertThirdPartyImportsA
[ ("nirum.constructs", [("name_dict_type", "NameDict")])
, ("nirum.datastructures", [("map_type", "Map")])
]
pyVer <- getPythonVersion
return $ toStrict $ renderMarkup $ [compileText|
class #{className}(#{T.intercalate "," $ compileExtendClasses annotations}):
#{compileDocstring " " d}
__nirum_type__ = 'union'
__nirum_union_behind_name__ = '#{toBehindSnakeCaseText typename'}'
__nirum_field_names__ = name_dict_type([
%{ forall (Tag (Name f b) _ _) <- tags' }
('#{toAttributeName f}', '#{I.toSnakeCaseText b}'),
%{ endforall }
])
class Tag(enum.Enum):
%{ forall (Tag tn _ _) <- tags' }
#{toEnumMemberName tn} = '#{toBehindSnakeCaseText tn}'
%{ endforall }
%{ case pyVer }
%{ of Python2 }
def __init__(self, *args, **kwargs):
%{ of Python3 }
def __init__(self, *args, **kwargs) -> None:
%{ endcase }
raise NotImplementedError(
"{0} cannot be instantiated "
"since it is an abstract class. Instantiate a concrete subtype "
"of it instead.".format(typing._type_repr(self))
)
%{ case pyVer }
%{ of Python2 }
def __nirum_serialize__(self):
%{ of Python3 }
def __nirum_serialize__(self) -> typing.Mapping[str, object]:
%{ endcase }
raise NotImplementedError(
"{0} cannot be instantiated "
"since it is an abstract class. Instantiate a concrete subtype "
"of it instead.".format(typing._type_repr(self))
)
@classmethod
%{ case pyVer }
%{ of Python2 }
def __nirum_deserialize__(cls, value):
%{ of Python3 }
def __nirum_deserialize__(cls: '#{className}', value) -> '#{className}':
%{ endcase }
%{ case defaultTag union }
%{ of Just dt }
if isinstance(value, dict) and '_tag' not in value:
value = dict(value)
value['_tag'] = '#{toBehindSnakeCaseText $ tagName dt}'
%{ of Nothing }
%{ endcase }
if '_type' not in value:
raise ValueError('"_type" field is missing.')
if '_tag' not in value:
raise ValueError('"_tag" field is missing.')
if not hasattr(cls, '__nirum_tag__'):
for sub_cls in cls.__subclasses__():
if sub_cls.__nirum_tag__.value == value['_tag']:
cls = sub_cls
break
else:
raise ValueError(
'%r is not deserialzable tag of `%s`' % (
value, typing._type_repr(cls)
)
)
if not cls.__nirum_union_behind_name__ == value['_type']:
raise ValueError(
'%s expect "_type" equal to "%s", but found %s' % (
typing._type_repr(cls),
cls.__nirum_union_behind_name__,
value['_type']
)
)
if not cls.__nirum_tag__.value == value['_tag']:
raise ValueError(
'%s expect "_tag" equal to "%s", but found %s' % (
typing._type_repr(cls),
cls.__nirum_tag__.value,
cls
)
)
args = dict()
behind_names = cls.__nirum_tag_names__.behind_names
errors = set()
for attribute_name, item in value.items():
if attribute_name in ('_type', '_tag'):
continue
if attribute_name in behind_names:
name = behind_names[attribute_name]
else:
name = attribute_name
tag_types = dict(cls.__nirum_tag_types__())
try:
field_type = tag_types[name]
except KeyError:
continue
try:
args[name] = deserialize_meta(field_type, item)
except ValueError as e:
errors.add('%s: %s' % (attribute_name, str(e)))
if errors:
raise ValueError('\n'.join(sorted(errors)))
return cls(**args)
%{ forall tagCode <- tagCodes }
#{tagCode}
%{ endforall }
#{className}.__nirum_tag_classes__ = map_type({
%{ forall (Tag tn _ _) <- tags' }
#{className}.Tag.#{toEnumMemberName tn}: #{toClassName' tn},
%{ endforall }
})
|]
where
tags' :: [Tag]
tags' = DS.toList $ tags union
className :: T.Text
className = toClassName' typename'
compileExtendClasses :: A.AnnotationSet -> [Code]
compileExtendClasses annotations' =
if null extendClasses
then ["object"]
else extendClasses
where
extendsClassMap :: M.Map I.Identifier Code
extendsClassMap = [("error", "Exception")]
extendClasses :: [Code]
extendClasses = catMaybes
[ M.lookup annotationName extendsClassMap
| (A.Annotation annotationName _) <- A.toList annotations'
]
toBehindSnakeCaseText :: Name -> T.Text
toBehindSnakeCaseText = I.toSnakeCaseText . N.behindName | 5,477 | compileTypeDeclaration src
d@TypeDeclaration { typename = typename'
, type' = union@UnionType {}
, typeAnnotations = annotations
} = do
tagCodes <- mapM (compileUnionTag src typename') tags'
insertStandardImport "typing"
insertStandardImport "enum"
insertThirdPartyImports [("nirum.deserialize", ["deserialize_meta"])]
insertThirdPartyImportsA
[ ("nirum.constructs", [("name_dict_type", "NameDict")])
, ("nirum.datastructures", [("map_type", "Map")])
]
pyVer <- getPythonVersion
return $ toStrict $ renderMarkup $ [compileText|
class #{className}(#{T.intercalate "," $ compileExtendClasses annotations}):
#{compileDocstring " " d}
__nirum_type__ = 'union'
__nirum_union_behind_name__ = '#{toBehindSnakeCaseText typename'}'
__nirum_field_names__ = name_dict_type([
%{ forall (Tag (Name f b) _ _) <- tags' }
('#{toAttributeName f}', '#{I.toSnakeCaseText b}'),
%{ endforall }
])
class Tag(enum.Enum):
%{ forall (Tag tn _ _) <- tags' }
#{toEnumMemberName tn} = '#{toBehindSnakeCaseText tn}'
%{ endforall }
%{ case pyVer }
%{ of Python2 }
def __init__(self, *args, **kwargs):
%{ of Python3 }
def __init__(self, *args, **kwargs) -> None:
%{ endcase }
raise NotImplementedError(
"{0} cannot be instantiated "
"since it is an abstract class. Instantiate a concrete subtype "
"of it instead.".format(typing._type_repr(self))
)
%{ case pyVer }
%{ of Python2 }
def __nirum_serialize__(self):
%{ of Python3 }
def __nirum_serialize__(self) -> typing.Mapping[str, object]:
%{ endcase }
raise NotImplementedError(
"{0} cannot be instantiated "
"since it is an abstract class. Instantiate a concrete subtype "
"of it instead.".format(typing._type_repr(self))
)
@classmethod
%{ case pyVer }
%{ of Python2 }
def __nirum_deserialize__(cls, value):
%{ of Python3 }
def __nirum_deserialize__(cls: '#{className}', value) -> '#{className}':
%{ endcase }
%{ case defaultTag union }
%{ of Just dt }
if isinstance(value, dict) and '_tag' not in value:
value = dict(value)
value['_tag'] = '#{toBehindSnakeCaseText $ tagName dt}'
%{ of Nothing }
%{ endcase }
if '_type' not in value:
raise ValueError('"_type" field is missing.')
if '_tag' not in value:
raise ValueError('"_tag" field is missing.')
if not hasattr(cls, '__nirum_tag__'):
for sub_cls in cls.__subclasses__():
if sub_cls.__nirum_tag__.value == value['_tag']:
cls = sub_cls
break
else:
raise ValueError(
'%r is not deserialzable tag of `%s`' % (
value, typing._type_repr(cls)
)
)
if not cls.__nirum_union_behind_name__ == value['_type']:
raise ValueError(
'%s expect "_type" equal to "%s", but found %s' % (
typing._type_repr(cls),
cls.__nirum_union_behind_name__,
value['_type']
)
)
if not cls.__nirum_tag__.value == value['_tag']:
raise ValueError(
'%s expect "_tag" equal to "%s", but found %s' % (
typing._type_repr(cls),
cls.__nirum_tag__.value,
cls
)
)
args = dict()
behind_names = cls.__nirum_tag_names__.behind_names
errors = set()
for attribute_name, item in value.items():
if attribute_name in ('_type', '_tag'):
continue
if attribute_name in behind_names:
name = behind_names[attribute_name]
else:
name = attribute_name
tag_types = dict(cls.__nirum_tag_types__())
try:
field_type = tag_types[name]
except KeyError:
continue
try:
args[name] = deserialize_meta(field_type, item)
except ValueError as e:
errors.add('%s: %s' % (attribute_name, str(e)))
if errors:
raise ValueError('\n'.join(sorted(errors)))
return cls(**args)
%{ forall tagCode <- tagCodes }
#{tagCode}
%{ endforall }
#{className}.__nirum_tag_classes__ = map_type({
%{ forall (Tag tn _ _) <- tags' }
#{className}.Tag.#{toEnumMemberName tn}: #{toClassName' tn},
%{ endforall }
})
|]
where
tags' :: [Tag]
tags' = DS.toList $ tags union
className :: T.Text
className = toClassName' typename'
compileExtendClasses :: A.AnnotationSet -> [Code]
compileExtendClasses annotations' =
if null extendClasses
then ["object"]
else extendClasses
where
extendsClassMap :: M.Map I.Identifier Code
extendsClassMap = [("error", "Exception")]
extendClasses :: [Code]
extendClasses = catMaybes
[ M.lookup annotationName extendsClassMap
| (A.Annotation annotationName _) <- A.toList annotations'
]
toBehindSnakeCaseText :: Name -> T.Text
toBehindSnakeCaseText = I.toSnakeCaseText . N.behindName | 5,477 | compileTypeDeclaration src
d@TypeDeclaration { typename = typename'
, type' = union@UnionType {}
, typeAnnotations = annotations
} = do
tagCodes <- mapM (compileUnionTag src typename') tags'
insertStandardImport "typing"
insertStandardImport "enum"
insertThirdPartyImports [("nirum.deserialize", ["deserialize_meta"])]
insertThirdPartyImportsA
[ ("nirum.constructs", [("name_dict_type", "NameDict")])
, ("nirum.datastructures", [("map_type", "Map")])
]
pyVer <- getPythonVersion
return $ toStrict $ renderMarkup $ [compileText|
class #{className}(#{T.intercalate "," $ compileExtendClasses annotations}):
#{compileDocstring " " d}
__nirum_type__ = 'union'
__nirum_union_behind_name__ = '#{toBehindSnakeCaseText typename'}'
__nirum_field_names__ = name_dict_type([
%{ forall (Tag (Name f b) _ _) <- tags' }
('#{toAttributeName f}', '#{I.toSnakeCaseText b}'),
%{ endforall }
])
class Tag(enum.Enum):
%{ forall (Tag tn _ _) <- tags' }
#{toEnumMemberName tn} = '#{toBehindSnakeCaseText tn}'
%{ endforall }
%{ case pyVer }
%{ of Python2 }
def __init__(self, *args, **kwargs):
%{ of Python3 }
def __init__(self, *args, **kwargs) -> None:
%{ endcase }
raise NotImplementedError(
"{0} cannot be instantiated "
"since it is an abstract class. Instantiate a concrete subtype "
"of it instead.".format(typing._type_repr(self))
)
%{ case pyVer }
%{ of Python2 }
def __nirum_serialize__(self):
%{ of Python3 }
def __nirum_serialize__(self) -> typing.Mapping[str, object]:
%{ endcase }
raise NotImplementedError(
"{0} cannot be instantiated "
"since it is an abstract class. Instantiate a concrete subtype "
"of it instead.".format(typing._type_repr(self))
)
@classmethod
%{ case pyVer }
%{ of Python2 }
def __nirum_deserialize__(cls, value):
%{ of Python3 }
def __nirum_deserialize__(cls: '#{className}', value) -> '#{className}':
%{ endcase }
%{ case defaultTag union }
%{ of Just dt }
if isinstance(value, dict) and '_tag' not in value:
value = dict(value)
value['_tag'] = '#{toBehindSnakeCaseText $ tagName dt}'
%{ of Nothing }
%{ endcase }
if '_type' not in value:
raise ValueError('"_type" field is missing.')
if '_tag' not in value:
raise ValueError('"_tag" field is missing.')
if not hasattr(cls, '__nirum_tag__'):
for sub_cls in cls.__subclasses__():
if sub_cls.__nirum_tag__.value == value['_tag']:
cls = sub_cls
break
else:
raise ValueError(
'%r is not deserialzable tag of `%s`' % (
value, typing._type_repr(cls)
)
)
if not cls.__nirum_union_behind_name__ == value['_type']:
raise ValueError(
'%s expect "_type" equal to "%s", but found %s' % (
typing._type_repr(cls),
cls.__nirum_union_behind_name__,
value['_type']
)
)
if not cls.__nirum_tag__.value == value['_tag']:
raise ValueError(
'%s expect "_tag" equal to "%s", but found %s' % (
typing._type_repr(cls),
cls.__nirum_tag__.value,
cls
)
)
args = dict()
behind_names = cls.__nirum_tag_names__.behind_names
errors = set()
for attribute_name, item in value.items():
if attribute_name in ('_type', '_tag'):
continue
if attribute_name in behind_names:
name = behind_names[attribute_name]
else:
name = attribute_name
tag_types = dict(cls.__nirum_tag_types__())
try:
field_type = tag_types[name]
except KeyError:
continue
try:
args[name] = deserialize_meta(field_type, item)
except ValueError as e:
errors.add('%s: %s' % (attribute_name, str(e)))
if errors:
raise ValueError('\n'.join(sorted(errors)))
return cls(**args)
%{ forall tagCode <- tagCodes }
#{tagCode}
%{ endforall }
#{className}.__nirum_tag_classes__ = map_type({
%{ forall (Tag tn _ _) <- tags' }
#{className}.Tag.#{toEnumMemberName tn}: #{toClassName' tn},
%{ endforall }
})
|]
where
tags' :: [Tag]
tags' = DS.toList $ tags union
className :: T.Text
className = toClassName' typename'
compileExtendClasses :: A.AnnotationSet -> [Code]
compileExtendClasses annotations' =
if null extendClasses
then ["object"]
else extendClasses
where
extendsClassMap :: M.Map I.Identifier Code
extendsClassMap = [("error", "Exception")]
extendClasses :: [Code]
extendClasses = catMaybes
[ M.lookup annotationName extendsClassMap
| (A.Annotation annotationName _) <- A.toList annotations'
]
toBehindSnakeCaseText :: Name -> T.Text
toBehindSnakeCaseText = I.toSnakeCaseText . N.behindName | 5,477 | false | false | 0 | 13 | 1,815 | 339 | 183 | 156 | null | null |
eelcoh/cryptochallenge | test/Set1/Challenge01Spec.hs | bsd-3-clause | hexString =
"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" | 112 | hexString =
"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" | 112 | hexString =
"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" | 112 | false | false | 1 | 5 | 4 | 10 | 3 | 7 | null | null |
Rathcke/uni | ap/advanced programming/exam/src/subs/InterpreterTest.hs | gpl-3.0 | typeErrorLt :: Either Error Env
typeErrorLt =
Left (Error "<: type mismatch") | 81 | typeErrorLt :: Either Error Env
typeErrorLt =
Left (Error "<: type mismatch") | 81 | typeErrorLt =
Left (Error "<: type mismatch") | 49 | false | true | 0 | 6 | 15 | 30 | 13 | 17 | null | null |
ScrambledEggsOnToast/Kachushi | Kachushi/HandAnalyse.hs | mit | compareHand = flip (compare `on` rating) | 40 | compareHand = flip (compare `on` rating) | 40 | compareHand = flip (compare `on` rating) | 40 | false | false | 1 | 7 | 5 | 22 | 10 | 12 | null | null |
timtylin/scholdoc | src/Text/Pandoc/Writers/Markdown.hs | gpl-2.0 | inlineToMarkdown opts (Code attr str) = do
let tickGroups = filter (\s -> '`' `elem` s) $ group str
let longest = if null tickGroups
then 0
else maximum $ map length tickGroups
let marker = replicate (longest + 1) '`'
let spacer = if (longest == 0) then "" else " "
let attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr
then attrsToMarkdown attr
else empty
plain <- gets stPlain
if plain
then return $ text str
else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs | 633 | inlineToMarkdown opts (Code attr str) = do
let tickGroups = filter (\s -> '`' `elem` s) $ group str
let longest = if null tickGroups
then 0
else maximum $ map length tickGroups
let marker = replicate (longest + 1) '`'
let spacer = if (longest == 0) then "" else " "
let attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr
then attrsToMarkdown attr
else empty
plain <- gets stPlain
if plain
then return $ text str
else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs | 633 | inlineToMarkdown opts (Code attr str) = do
let tickGroups = filter (\s -> '`' `elem` s) $ group str
let longest = if null tickGroups
then 0
else maximum $ map length tickGroups
let marker = replicate (longest + 1) '`'
let spacer = if (longest == 0) then "" else " "
let attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr
then attrsToMarkdown attr
else empty
plain <- gets stPlain
if plain
then return $ text str
else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs | 633 | false | false | 0 | 15 | 220 | 217 | 107 | 110 | null | null |
krisajenkins/esqueleto | src/Database/Esqueleto/Internal/Sql.hs | bsd-3-clause | materializeExpr :: IdentInfo -> SqlExpr (Value a) -> (TLB.Builder, [PersistValue])
materializeExpr info (ERaw p f) =
let (b, vals) = f info
in (parensM p b, vals) | 166 | materializeExpr :: IdentInfo -> SqlExpr (Value a) -> (TLB.Builder, [PersistValue])
materializeExpr info (ERaw p f) =
let (b, vals) = f info
in (parensM p b, vals) | 166 | materializeExpr info (ERaw p f) =
let (b, vals) = f info
in (parensM p b, vals) | 83 | false | true | 0 | 9 | 30 | 84 | 43 | 41 | null | null |
apyrgio/ganeti | src/Ganeti/JQScheduler.hs | bsd-2-clause | jobWatcher :: JQStatus -> JobWithStat -> Event -> IO ()
jobWatcher state jWS e = do
let jid = qjId $ jJob jWS
jids = show $ fromJobId jid
logInfo $ "Scheduler notified of change of job " ++ jids
logDebug $ "Scheduler notify event for " ++ jids ++ ": " ++ show e
let inotify = jINotify jWS
when (e == Ignored && isJust inotify) $ do
qdir <- queueDir
let fpath = liveJobFile qdir jid
_ <- addWatch (fromJust inotify) [Modify, Delete] fpath
(jobWatcher state jWS)
return ()
updateJob state jWS
-- | Attach the job watcher to a running job. | 583 | jobWatcher :: JQStatus -> JobWithStat -> Event -> IO ()
jobWatcher state jWS e = do
let jid = qjId $ jJob jWS
jids = show $ fromJobId jid
logInfo $ "Scheduler notified of change of job " ++ jids
logDebug $ "Scheduler notify event for " ++ jids ++ ": " ++ show e
let inotify = jINotify jWS
when (e == Ignored && isJust inotify) $ do
qdir <- queueDir
let fpath = liveJobFile qdir jid
_ <- addWatch (fromJust inotify) [Modify, Delete] fpath
(jobWatcher state jWS)
return ()
updateJob state jWS
-- | Attach the job watcher to a running job. | 583 | jobWatcher state jWS e = do
let jid = qjId $ jJob jWS
jids = show $ fromJobId jid
logInfo $ "Scheduler notified of change of job " ++ jids
logDebug $ "Scheduler notify event for " ++ jids ++ ": " ++ show e
let inotify = jINotify jWS
when (e == Ignored && isJust inotify) $ do
qdir <- queueDir
let fpath = liveJobFile qdir jid
_ <- addWatch (fromJust inotify) [Modify, Delete] fpath
(jobWatcher state jWS)
return ()
updateJob state jWS
-- | Attach the job watcher to a running job. | 527 | false | true | 0 | 13 | 150 | 206 | 95 | 111 | null | null |
brendanhay/gogol | gogol-shopping-content/gen/Network/Google/Resource/Content/Orders/Updateshipment.hs | mpl-2.0 | -- | OAuth access token.
ouAccessToken :: Lens' OrdersUpdateshipment (Maybe Text)
ouAccessToken
= lens _ouAccessToken
(\ s a -> s{_ouAccessToken = a}) | 158 | ouAccessToken :: Lens' OrdersUpdateshipment (Maybe Text)
ouAccessToken
= lens _ouAccessToken
(\ s a -> s{_ouAccessToken = a}) | 133 | ouAccessToken
= lens _ouAccessToken
(\ s a -> s{_ouAccessToken = a}) | 76 | true | true | 0 | 9 | 29 | 48 | 25 | 23 | null | null |
pyuk/euler2 | src/P13.hs | bsd-3-clause | sepDigits x = x `mod` 10 : sepDigits (x `div` 10) | 49 | sepDigits x = x `mod` 10 : sepDigits (x `div` 10) | 49 | sepDigits x = x `mod` 10 : sepDigits (x `div` 10) | 49 | false | false | 0 | 8 | 10 | 31 | 17 | 14 | null | null |
phischu/fragnix | builtins/ghc-prim/GHC.Prim.hs | bsd-3-clause | -- | Read a vector from specified index of mutable array of scalars; offset is in scalar elements.
readWord32ArrayAsWord32X16# :: MutableByteArray# s -> Int# -> State# s -> (# State# s,Word32X16# #)
readWord32ArrayAsWord32X16# = readWord32ArrayAsWord32X16# | 258 | readWord32ArrayAsWord32X16# :: MutableByteArray# s -> Int# -> State# s -> (# State# s,Word32X16# #)
readWord32ArrayAsWord32X16# = readWord32ArrayAsWord32X16# | 157 | readWord32ArrayAsWord32X16# = readWord32ArrayAsWord32X16# | 57 | true | true | 0 | 9 | 36 | 38 | 19 | 19 | null | null |
andrewthad/vinyl-vectors | src/Data/List/TypeLevel/Witness/OrdList.hs | bsd-3-clause | lemma1 (SublistSuper SublistNil) o@(OrdListCons OrdListSingle) = BoundedListNil | 79 | lemma1 (SublistSuper SublistNil) o@(OrdListCons OrdListSingle) = BoundedListNil | 79 | lemma1 (SublistSuper SublistNil) o@(OrdListCons OrdListSingle) = BoundedListNil | 79 | false | false | 0 | 8 | 6 | 26 | 13 | 13 | null | null |
mfpi/OpenGLRaw | src/Graphics/Rendering/OpenGL/Raw/ARB/Compatibility/Tokens.hs | bsd-3-clause | gl_3D :: GLenum
gl_3D = 0x0601 | 30 | gl_3D :: GLenum
gl_3D = 0x0601 | 30 | gl_3D = 0x0601 | 14 | false | true | 0 | 4 | 5 | 11 | 6 | 5 | null | null |
rumblesan/improviz | src/Gfx/Context.hs | bsd-3-clause | wrapNoArg :: TVar GfxEngine -> GraphicsEngine () -> IO ()
wrapNoArg gfx func = do
ge <- readTVarIO gfx
newGe <- execStateT func ge
atomically $ writeTVar gfx $! force newGe | 181 | wrapNoArg :: TVar GfxEngine -> GraphicsEngine () -> IO ()
wrapNoArg gfx func = do
ge <- readTVarIO gfx
newGe <- execStateT func ge
atomically $ writeTVar gfx $! force newGe | 181 | wrapNoArg gfx func = do
ge <- readTVarIO gfx
newGe <- execStateT func ge
atomically $ writeTVar gfx $! force newGe | 123 | false | true | 0 | 10 | 39 | 81 | 34 | 47 | null | null |
msakai/icfpc2014 | ULambdaCompiler.hs | bsd-3-clause | -- try it with <http://icfpcontest.org/lman.html>
test_fact :: [Inst]
test_fact = compile [] $
ELetRec
[ ("fact", ELambda ["n"] $ EIf ("n" .==. 0) 1 ("n" * (ECall "fact" ["n" - 1]))) ]
(ECall "fact" [4]) | 213 | test_fact :: [Inst]
test_fact = compile [] $
ELetRec
[ ("fact", ELambda ["n"] $ EIf ("n" .==. 0) 1 ("n" * (ECall "fact" ["n" - 1]))) ]
(ECall "fact" [4]) | 163 | test_fact = compile [] $
ELetRec
[ ("fact", ELambda ["n"] $ EIf ("n" .==. 0) 1 ("n" * (ECall "fact" ["n" - 1]))) ]
(ECall "fact" [4]) | 143 | true | true | 2 | 14 | 44 | 103 | 52 | 51 | null | null |
tdidriksen/copatterns | src/findus/TerminationChecker.hs | mit | -- General functions
-- | Finds the sublist starting from the first element for which the predicate holds.
subListFrom :: (a -> Bool) -> [a] -> [a]
subListFrom f [] = [] | 174 | subListFrom :: (a -> Bool) -> [a] -> [a]
subListFrom f [] = [] | 66 | subListFrom f [] = [] | 25 | true | true | 0 | 9 | 36 | 49 | 25 | 24 | null | null |
JoeLoser/CS4450-Principles-of-Programming | homeworks/hw5/hw5_sdk/ImpParser.hs | mit | p = T.makeTokenParser lang | 26 | p = T.makeTokenParser lang | 26 | p = T.makeTokenParser lang | 26 | false | false | 1 | 6 | 3 | 14 | 5 | 9 | null | null |
jamessanders/easy-http | src/Network/EasyHttp/Server.hs | bsd-3-clause | debugServer s = do
tn <- getZonedTime
putStrLn $ printf "[%s] %s" (show tn) (C.unpack s) | 95 | debugServer s = do
tn <- getZonedTime
putStrLn $ printf "[%s] %s" (show tn) (C.unpack s) | 95 | debugServer s = do
tn <- getZonedTime
putStrLn $ printf "[%s] %s" (show tn) (C.unpack s) | 95 | false | false | 0 | 11 | 22 | 44 | 20 | 24 | null | null |
toonn/wyah | src/STLCLexer.hs | bsd-2-clause | natural :: Parser Integer
natural = Tok.natural lexer | 53 | natural :: Parser Integer
natural = Tok.natural lexer | 53 | natural = Tok.natural lexer | 27 | false | true | 0 | 6 | 7 | 24 | 10 | 14 | null | null |
tpsinnem/Idris-dev | src/Idris/Primitives.hs | bsd-3-clause | floatToInt _ _ = Nothing | 24 | floatToInt _ _ = Nothing | 24 | floatToInt _ _ = Nothing | 24 | false | false | 1 | 5 | 4 | 12 | 5 | 7 | null | null |
BartAdv/Idris-dev | src/Idris/Core/TT.hs | bsd-3-clause | showCG (NS n s) = showSep "." (map T.unpack (reverse s)) ++ "." ++ showCG n | 75 | showCG (NS n s) = showSep "." (map T.unpack (reverse s)) ++ "." ++ showCG n | 75 | showCG (NS n s) = showSep "." (map T.unpack (reverse s)) ++ "." ++ showCG n | 75 | false | false | 0 | 11 | 15 | 50 | 23 | 27 | null | null |
apollo-lang/apollo | src/Eval.hs | mit | oVPitch _ = error "Expected VInt or VPitch"
| 53 | toVPitch _ = error "Expected VInt or VPitch" | 53 | toVPitch _ = error "Expected VInt or VPitch" | 53 | false | false | 0 | 5 | 17 | 13 | 5 | 8 | null | null |
marcellussiegburg/autotool | collection/src/Flow/State.hs | gpl-2.0 | all_states :: Set Identifier -> Set State
all_states s = S.fromList $ map state $
forM ( S.toList s ) $ \ v -> [ (v,False), (v,True) ] | 139 | all_states :: Set Identifier -> Set State
all_states s = S.fromList $ map state $
forM ( S.toList s ) $ \ v -> [ (v,False), (v,True) ] | 138 | all_states s = S.fromList $ map state $
forM ( S.toList s ) $ \ v -> [ (v,False), (v,True) ] | 96 | false | true | 0 | 10 | 32 | 75 | 39 | 36 | null | null |
glaebhoerl/stageless | src/LLVM.hs | mit | translateBlock :: LLVM m => IR.Block -> m (Terminator, [CallsBlockWith])
translateBlock IR.Block { IR.arguments, IR.body, IR.transfer } = do
translateArguments arguments
mapM_ translateStatement body
translateTransfer transfer | 238 | translateBlock :: LLVM m => IR.Block -> m (Terminator, [CallsBlockWith])
translateBlock IR.Block { IR.arguments, IR.body, IR.transfer } = do
translateArguments arguments
mapM_ translateStatement body
translateTransfer transfer | 238 | translateBlock IR.Block { IR.arguments, IR.body, IR.transfer } = do
translateArguments arguments
mapM_ translateStatement body
translateTransfer transfer | 165 | false | true | 0 | 9 | 37 | 79 | 38 | 41 | null | null |
sdiehl/ghc | compiler/simplCore/OccurAnal.hs | bsd-3-clause | occurAnalyseExpr :: CoreExpr -> CoreExpr
-- Do occurrence analysis, and discard occurrence info returned
occurAnalyseExpr = occurAnalyseExpr' True | 154 | occurAnalyseExpr :: CoreExpr -> CoreExpr
occurAnalyseExpr = occurAnalyseExpr' True | 82 | occurAnalyseExpr = occurAnalyseExpr' True | 41 | true | true | 0 | 5 | 25 | 19 | 10 | 9 | null | null |
balangs/eTeak | src/Chan.hs | bsd-3-clause | isChan :: [Context Decl] -> Decl -> Bool
isChan _ (ChanDecl {}) = True | 74 | isChan :: [Context Decl] -> Decl -> Bool
isChan _ (ChanDecl {}) = True | 70 | isChan _ (ChanDecl {}) = True | 29 | false | true | 1 | 9 | 17 | 42 | 20 | 22 | null | null |
spechub/Hets | OWL2/XML.hs | gpl-2.0 | isSmth :: String -> Text.XML.Light.QName -> Bool
isSmth s = (s ==) . qName | 74 | isSmth :: String -> Text.XML.Light.QName -> Bool
isSmth s = (s ==) . qName | 74 | isSmth s = (s ==) . qName | 25 | false | true | 0 | 7 | 13 | 34 | 19 | 15 | null | null |
jwiegley/ghc-release | libraries/terminfo/System/Console/Terminfo/Base.hs | gpl-3.0 | -- | Write the terminal output to the standard output device.
runTermOutput :: Terminal -> TermOutput -> IO ()
runTermOutput = hRunTermOutput stdout | 148 | runTermOutput :: Terminal -> TermOutput -> IO ()
runTermOutput = hRunTermOutput stdout | 86 | runTermOutput = hRunTermOutput stdout | 37 | true | true | 0 | 8 | 22 | 28 | 14 | 14 | null | null |
orome/crypto-enigma-hs | Crypto/Enigma.hs | bsd-3-clause | {-|
Convert a 'String' to valid Enigma machine input: replace any symbols for which there are standard Kriegsmarine
substitutions, remove any remaining non-letter characters, and convert to uppercase. This function is applied
automatically to 'String's suppied as 'Message' arguments to functions in this package.
-}
-- REV: Awkward pack/unpack patch to remove dependency on MissingH (#29)
message :: String -> Message
message s = filter (`elem` letters) $ foldl1 fmap (uncurry replace' <$> subs) $ toUpper <$> s
where
subs = [(" ",""),(".","X"),(",","Y"),("'","J"),(">","J"),("<","J"),("!","X"),
("?","UD"),("-","YY"),(":","XX"),("(","KK"),(")","KK"),
("1","YQ"),("2","YW"),("3","YE"),("4","YR"),("5","YT"),
("6","YZ"),("7","YU"),("8","YI"),("9","YO"),("0","YP")]
replace' a b c = unpack $ replace (pack a) (pack b) (pack c)
-- REV: Rejected (#12) alternate version in which 'Message' is at class (and caller is responsible for making Message).
-- data Message = Message String deriving Show
--
-- message :: String -> Message
-- message s = Message (filter (`elem` letters) $ foldl1 fmap (uncurry replace <$> subs) $ toUpper <$> s)
-- where
-- subs = [(" ",""),(".","X"),(",","Y"),("'","J"),(">","J"),("<","J"),("!","X"),
-- ("?","UD"),("-","YY"),(":","XX"),("(","KK"),(")","KK"),
-- ("1","YQ"),("2","YW"),("3","YE"),("4","YR"),("5","YT"),
-- ("6","YZ"),("7","YU"),("8","YI"),("9","YO"),("0","YP")] | 1,529 | message :: String -> Message
message s = filter (`elem` letters) $ foldl1 fmap (uncurry replace' <$> subs) $ toUpper <$> s
where
subs = [(" ",""),(".","X"),(",","Y"),("'","J"),(">","J"),("<","J"),("!","X"),
("?","UD"),("-","YY"),(":","XX"),("(","KK"),(")","KK"),
("1","YQ"),("2","YW"),("3","YE"),("4","YR"),("5","YT"),
("6","YZ"),("7","YU"),("8","YI"),("9","YO"),("0","YP")]
replace' a b c = unpack $ replace (pack a) (pack b) (pack c)
-- REV: Rejected (#12) alternate version in which 'Message' is at class (and caller is responsible for making Message).
-- data Message = Message String deriving Show
--
-- message :: String -> Message
-- message s = Message (filter (`elem` letters) $ foldl1 fmap (uncurry replace <$> subs) $ toUpper <$> s)
-- where
-- subs = [(" ",""),(".","X"),(",","Y"),("'","J"),(">","J"),("<","J"),("!","X"),
-- ("?","UD"),("-","YY"),(":","XX"),("(","KK"),(")","KK"),
-- ("1","YQ"),("2","YW"),("3","YE"),("4","YR"),("5","YT"),
-- ("6","YZ"),("7","YU"),("8","YI"),("9","YO"),("0","YP")] | 1,139 | message s = filter (`elem` letters) $ foldl1 fmap (uncurry replace' <$> subs) $ toUpper <$> s
where
subs = [(" ",""),(".","X"),(",","Y"),("'","J"),(">","J"),("<","J"),("!","X"),
("?","UD"),("-","YY"),(":","XX"),("(","KK"),(")","KK"),
("1","YQ"),("2","YW"),("3","YE"),("4","YR"),("5","YT"),
("6","YZ"),("7","YU"),("8","YI"),("9","YO"),("0","YP")]
replace' a b c = unpack $ replace (pack a) (pack b) (pack c)
-- REV: Rejected (#12) alternate version in which 'Message' is at class (and caller is responsible for making Message).
-- data Message = Message String deriving Show
--
-- message :: String -> Message
-- message s = Message (filter (`elem` letters) $ foldl1 fmap (uncurry replace <$> subs) $ toUpper <$> s)
-- where
-- subs = [(" ",""),(".","X"),(",","Y"),("'","J"),(">","J"),("<","J"),("!","X"),
-- ("?","UD"),("-","YY"),(":","XX"),("(","KK"),(")","KK"),
-- ("1","YQ"),("2","YW"),("3","YE"),("4","YR"),("5","YT"),
-- ("6","YZ"),("7","YU"),("8","YI"),("9","YO"),("0","YP")] | 1,110 | true | true | 1 | 11 | 294 | 322 | 197 | 125 | null | null |
olsner/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | integralClassKey = mkPreludeClassUnique 7 | 48 | integralClassKey = mkPreludeClassUnique 7 | 48 | integralClassKey = mkPreludeClassUnique 7 | 48 | false | false | 0 | 5 | 10 | 9 | 4 | 5 | null | null |
akc/gfscript | HOPS/GF/Const.hs | bsd-3-clause | --------------------------------------------------------------------------------
-- Parse
--------------------------------------------------------------------------------
-- | Parser for an `Expr`.
expr :: Parser Expr
expr = expr0 | 231 | expr :: Parser Expr
expr = expr0 | 32 | expr = expr0 | 12 | true | true | 1 | 5 | 17 | 22 | 11 | 11 | null | null |
pascalpoizat/veca-haskell | test/TimedAutomatonTests.hs | apache-2.0 | c' :: Clock
c' = Clock "c'" | 27 | c' :: Clock
c' = Clock "c'" | 27 | c' = Clock "c'" | 15 | false | true | 0 | 6 | 6 | 20 | 8 | 12 | null | null |
ComputationWithBoundedResources/tct-core | src/Tct/Core/Common/SemiRing.hs | bsd-3-clause | -- | Foldable version of 'mul'.
bigMul :: (F.Foldable t, Multiplicative a) => t a -> a
bigMul = F.foldl mul one | 111 | bigMul :: (F.Foldable t, Multiplicative a) => t a -> a
bigMul = F.foldl mul one | 79 | bigMul = F.foldl mul one | 24 | true | true | 0 | 8 | 21 | 49 | 23 | 26 | null | null |
christiaanb/ghc | compiler/main/DriverMkDepend.hs | bsd-3-clause | insertSuffixes
:: FilePath -- Original filename; e.g. "foo.o"
-> [String] -- Suffix prefixes e.g. ["x_", "y_"]
-> [FilePath] -- Zapped filenames e.g. ["foo.x_o", "foo.y_o"]
-- Note that that the extra bit gets inserted *before* the old suffix
-- We assume the old suffix contains no dots, so we know where to
-- split it
insertSuffixes file_name extras
= [ basename <.> (extra ++ suffix) | extra <- extras ]
where
(basename, suffix) = case splitExtension file_name of
-- Drop the "." from the extension
(b, s) -> (b, drop 1 s)
-----------------------------------------------------------------
--
-- endMkDependHs
-- Complete the makefile, close the tmp file etc
--
----------------------------------------------------------------- | 877 | insertSuffixes
:: FilePath -- Original filename; e.g. "foo.o"
-> [String] -- Suffix prefixes e.g. ["x_", "y_"]
-> [FilePath]
insertSuffixes file_name extras
= [ basename <.> (extra ++ suffix) | extra <- extras ]
where
(basename, suffix) = case splitExtension file_name of
-- Drop the "." from the extension
(b, s) -> (b, drop 1 s)
-----------------------------------------------------------------
--
-- endMkDependHs
-- Complete the makefile, close the tmp file etc
--
----------------------------------------------------------------- | 651 | insertSuffixes file_name extras
= [ basename <.> (extra ++ suffix) | extra <- extras ]
where
(basename, suffix) = case splitExtension file_name of
-- Drop the "." from the extension
(b, s) -> (b, drop 1 s)
-----------------------------------------------------------------
--
-- endMkDependHs
-- Complete the makefile, close the tmp file etc
--
----------------------------------------------------------------- | 487 | true | true | 0 | 9 | 252 | 109 | 65 | 44 | null | null |
brendanhay/gogol | gogol-docs/gen/Network/Google/Docs/Types/Product.hs | mpl-2.0 | -- | An inline object paragraph element.
peInlineObjectElement :: Lens' ParagraphElement (Maybe InlineObjectElement)
peInlineObjectElement
= lens _peInlineObjectElement
(\ s a -> s{_peInlineObjectElement = a}) | 217 | peInlineObjectElement :: Lens' ParagraphElement (Maybe InlineObjectElement)
peInlineObjectElement
= lens _peInlineObjectElement
(\ s a -> s{_peInlineObjectElement = a}) | 176 | peInlineObjectElement
= lens _peInlineObjectElement
(\ s a -> s{_peInlineObjectElement = a}) | 100 | true | true | 0 | 9 | 31 | 48 | 25 | 23 | null | null |
ocean0yohsuke/deepcontrol | DeepControl/Monad.hs | bsd-3-clause | (->->=) :: (Monad m1, Monad m2, Traversable m2, Monad m3, Traversable m3, Monad m4, Traversable m4) => m2 (m4 a) -> (a -> m1 (m2 (m3 (m4 b)))) -> m1 (m2 (m3 (m4 b)))
m ->->= k = (*-*) m >>>>= k | 193 | (->->=) :: (Monad m1, Monad m2, Traversable m2, Monad m3, Traversable m3, Monad m4, Traversable m4) => m2 (m4 a) -> (a -> m1 (m2 (m3 (m4 b)))) -> m1 (m2 (m3 (m4 b)))
m ->->= k = (*-*) m >>>>= k | 193 | m ->->= k = (*-*) m >>>>= k | 27 | false | true | 0 | 17 | 41 | 143 | 71 | 72 | null | null |
brendanhay/gogol | gogol-sourcerepo/gen/Network/Google/SourceRepo/Types/Product.hs | mpl-2.0 | -- | Creates a value of 'SyncRepoRequest' with the minimum fields required to make a request.
--
syncRepoRequest
:: SyncRepoRequest
syncRepoRequest = SyncRepoRequest' | 170 | syncRepoRequest
:: SyncRepoRequest
syncRepoRequest = SyncRepoRequest' | 73 | syncRepoRequest = SyncRepoRequest' | 34 | true | true | 1 | 5 | 26 | 17 | 8 | 9 | null | null |
uduki/hsQt | Qtc/Core/QMatrix.hs | bsd-2-clause | mapToPolygon :: QMatrix a -> ((Rect)) -> IO (QPolygon ())
mapToPolygon x0 (x1)
= withQPolygonResult $
withObjectPtr x0 $ \cobj_x0 ->
withCRect x1 $ \crect_x1_x crect_x1_y crect_x1_w crect_x1_h ->
qtc_QMatrix_mapToPolygon_qth cobj_x0 crect_x1_x crect_x1_y crect_x1_w crect_x1_h | 292 | mapToPolygon :: QMatrix a -> ((Rect)) -> IO (QPolygon ())
mapToPolygon x0 (x1)
= withQPolygonResult $
withObjectPtr x0 $ \cobj_x0 ->
withCRect x1 $ \crect_x1_x crect_x1_y crect_x1_w crect_x1_h ->
qtc_QMatrix_mapToPolygon_qth cobj_x0 crect_x1_x crect_x1_y crect_x1_w crect_x1_h | 292 | mapToPolygon x0 (x1)
= withQPolygonResult $
withObjectPtr x0 $ \cobj_x0 ->
withCRect x1 $ \crect_x1_x crect_x1_y crect_x1_w crect_x1_h ->
qtc_QMatrix_mapToPolygon_qth cobj_x0 crect_x1_x crect_x1_y crect_x1_w crect_x1_h | 234 | false | true | 0 | 10 | 50 | 92 | 46 | 46 | null | null |
christiaanb/ghc | compiler/stranal/DmdAnal.hs | bsd-3-clause | dmdAnal' env dmd (App fun arg)
= -- This case handles value arguments (type args handled above)
-- Crucially, coercions /are/ handled here, because they are
-- value arguments (Trac #10288)
let
call_dmd = mkCallDmd dmd
(fun_ty, fun') = dmdAnal env call_dmd fun
(arg_dmd, res_ty) = splitDmdTy fun_ty
(arg_ty, arg') = dmdAnalStar env (dmdTransformThunkDmd arg arg_dmd) arg
in
-- pprTrace "dmdAnal:app" (vcat
-- [ text "dmd =" <+> ppr dmd
-- , text "expr =" <+> ppr (App fun arg)
-- , text "fun dmd_ty =" <+> ppr fun_ty
-- , text "arg dmd =" <+> ppr arg_dmd
-- , text "arg dmd_ty =" <+> ppr arg_ty
-- , text "res dmd_ty =" <+> ppr res_ty
-- , text "overall res dmd_ty =" <+> ppr (res_ty `bothDmdType` arg_ty) ])
(res_ty `bothDmdType` arg_ty, App fun' arg') | 881 | dmdAnal' env dmd (App fun arg)
= -- This case handles value arguments (type args handled above)
-- Crucially, coercions /are/ handled here, because they are
-- value arguments (Trac #10288)
let
call_dmd = mkCallDmd dmd
(fun_ty, fun') = dmdAnal env call_dmd fun
(arg_dmd, res_ty) = splitDmdTy fun_ty
(arg_ty, arg') = dmdAnalStar env (dmdTransformThunkDmd arg arg_dmd) arg
in
-- pprTrace "dmdAnal:app" (vcat
-- [ text "dmd =" <+> ppr dmd
-- , text "expr =" <+> ppr (App fun arg)
-- , text "fun dmd_ty =" <+> ppr fun_ty
-- , text "arg dmd =" <+> ppr arg_dmd
-- , text "arg dmd_ty =" <+> ppr arg_ty
-- , text "res dmd_ty =" <+> ppr res_ty
-- , text "overall res dmd_ty =" <+> ppr (res_ty `bothDmdType` arg_ty) ])
(res_ty `bothDmdType` arg_ty, App fun' arg') | 881 | dmdAnal' env dmd (App fun arg)
= -- This case handles value arguments (type args handled above)
-- Crucially, coercions /are/ handled here, because they are
-- value arguments (Trac #10288)
let
call_dmd = mkCallDmd dmd
(fun_ty, fun') = dmdAnal env call_dmd fun
(arg_dmd, res_ty) = splitDmdTy fun_ty
(arg_ty, arg') = dmdAnalStar env (dmdTransformThunkDmd arg arg_dmd) arg
in
-- pprTrace "dmdAnal:app" (vcat
-- [ text "dmd =" <+> ppr dmd
-- , text "expr =" <+> ppr (App fun arg)
-- , text "fun dmd_ty =" <+> ppr fun_ty
-- , text "arg dmd =" <+> ppr arg_dmd
-- , text "arg dmd_ty =" <+> ppr arg_ty
-- , text "res dmd_ty =" <+> ppr res_ty
-- , text "overall res dmd_ty =" <+> ppr (res_ty `bothDmdType` arg_ty) ])
(res_ty `bothDmdType` arg_ty, App fun' arg') | 881 | false | false | 0 | 11 | 262 | 124 | 69 | 55 | null | null |
rueshyna/gogol | gogol-sheets/gen/Network/Google/Resource/Sheets/Spreadsheets/Values/BatchGet.hs | mpl-2.0 | -- | How values should be represented in the output. The default render
-- option is ValueRenderOption.FORMATTED_VALUE.
svbgValueRenderOption :: Lens' SpreadsheetsValuesBatchGet (Maybe Text)
svbgValueRenderOption
= lens _svbgValueRenderOption
(\ s a -> s{_svbgValueRenderOption = a}) | 291 | svbgValueRenderOption :: Lens' SpreadsheetsValuesBatchGet (Maybe Text)
svbgValueRenderOption
= lens _svbgValueRenderOption
(\ s a -> s{_svbgValueRenderOption = a}) | 171 | svbgValueRenderOption
= lens _svbgValueRenderOption
(\ s a -> s{_svbgValueRenderOption = a}) | 100 | true | true | 0 | 9 | 41 | 49 | 26 | 23 | null | null |
EarlGray/omit | Main.hs | mit | makeTreeFromIndex :: FilePath -> M.Map FilePath IndexEntry -> IO GitTree
makeTreeFromIndex root indexByPath = go root $ fsTreeFromList root $ map (PF.splitPath . indFName . snd) $ M.toAscList indexByPath
where
go workdir (FSDir dir entries) = do
leaves <- forM entries $ \entry -> do
case entry of
FSFile fname -> do
let ie = indexByPath M.! path
path' = PF.makeRelative root workdir </> fname
path = if "./" `L.isPrefixOf` path' then drop 2 path' else path'
case indmodeToBlobMode (indMode ie) of
Nothing -> error $ concat ["unknown mode ", show (indMode ie), " in index ", showSHA (indSHA ie)]
Just mod -> return $ GitBlob mod (indSHA ie) fname
FSDir subdir _ -> go (workdir </> subdir) entry
let treeentrify (GitBlob mod sha fname) = (show mod, fname, sha)
treeentrify (GitTree sha dir _) = ("40000", dir, sha)
-- mapM (\(mod, name, sha) -> putStrLn $ mod++" "++showSHA sha++": " ++name) $ map treeentrify leaves
let sha = hashobj $ blobify "tree" $ dumpTreeObject $ map treeentrify leaves
return $ GitTree sha dir leaves | 1,185 | makeTreeFromIndex :: FilePath -> M.Map FilePath IndexEntry -> IO GitTree
makeTreeFromIndex root indexByPath = go root $ fsTreeFromList root $ map (PF.splitPath . indFName . snd) $ M.toAscList indexByPath
where
go workdir (FSDir dir entries) = do
leaves <- forM entries $ \entry -> do
case entry of
FSFile fname -> do
let ie = indexByPath M.! path
path' = PF.makeRelative root workdir </> fname
path = if "./" `L.isPrefixOf` path' then drop 2 path' else path'
case indmodeToBlobMode (indMode ie) of
Nothing -> error $ concat ["unknown mode ", show (indMode ie), " in index ", showSHA (indSHA ie)]
Just mod -> return $ GitBlob mod (indSHA ie) fname
FSDir subdir _ -> go (workdir </> subdir) entry
let treeentrify (GitBlob mod sha fname) = (show mod, fname, sha)
treeentrify (GitTree sha dir _) = ("40000", dir, sha)
-- mapM (\(mod, name, sha) -> putStrLn $ mod++" "++showSHA sha++": " ++name) $ map treeentrify leaves
let sha = hashobj $ blobify "tree" $ dumpTreeObject $ map treeentrify leaves
return $ GitTree sha dir leaves | 1,185 | makeTreeFromIndex root indexByPath = go root $ fsTreeFromList root $ map (PF.splitPath . indFName . snd) $ M.toAscList indexByPath
where
go workdir (FSDir dir entries) = do
leaves <- forM entries $ \entry -> do
case entry of
FSFile fname -> do
let ie = indexByPath M.! path
path' = PF.makeRelative root workdir </> fname
path = if "./" `L.isPrefixOf` path' then drop 2 path' else path'
case indmodeToBlobMode (indMode ie) of
Nothing -> error $ concat ["unknown mode ", show (indMode ie), " in index ", showSHA (indSHA ie)]
Just mod -> return $ GitBlob mod (indSHA ie) fname
FSDir subdir _ -> go (workdir </> subdir) entry
let treeentrify (GitBlob mod sha fname) = (show mod, fname, sha)
treeentrify (GitTree sha dir _) = ("40000", dir, sha)
-- mapM (\(mod, name, sha) -> putStrLn $ mod++" "++showSHA sha++": " ++name) $ map treeentrify leaves
let sha = hashobj $ blobify "tree" $ dumpTreeObject $ map treeentrify leaves
return $ GitTree sha dir leaves | 1,112 | false | true | 0 | 26 | 335 | 406 | 195 | 211 | null | null |
zalora/Angel | src/Angel/Config.hs | bsd-3-clause | reflatten :: Name -> HM.HashMap Name Value -> HM.HashMap Name Value
reflatten prog pcfg = HM.fromList asList
where asList = map prependKey $ filter notCount $ HM.toList pcfg
prependKey (k, v) = (prog <> "." <> k, v)
notCount = not . (== "count") . fst
-- |given a new SpecKey just parsed from the file, update the
-- |shared state TVar | 374 | reflatten :: Name -> HM.HashMap Name Value -> HM.HashMap Name Value
reflatten prog pcfg = HM.fromList asList
where asList = map prependKey $ filter notCount $ HM.toList pcfg
prependKey (k, v) = (prog <> "." <> k, v)
notCount = not . (== "count") . fst
-- |given a new SpecKey just parsed from the file, update the
-- |shared state TVar | 374 | reflatten prog pcfg = HM.fromList asList
where asList = map prependKey $ filter notCount $ HM.toList pcfg
prependKey (k, v) = (prog <> "." <> k, v)
notCount = not . (== "count") . fst
-- |given a new SpecKey just parsed from the file, update the
-- |shared state TVar | 306 | false | true | 2 | 11 | 100 | 118 | 60 | 58 | null | null |
kig/tomtegebra | Tomtegebra/Algebra.hs | gpl-3.0 | updateBinding _ B _ = Invalid | 29 | updateBinding _ B _ = Invalid | 29 | updateBinding _ B _ = Invalid | 29 | false | false | 0 | 5 | 5 | 13 | 6 | 7 | null | null |
begriffs/hscope | t/Build.hs | bsd-3-clause | main :: IO ()
main = withTemporaryDirectory "/tmp/hscope_test_XXXXXX" $ \td -> testSimpleMain $ do
plan 48
hpath <- liftIO $ canonicalizePath "./dist/build/hscope/hscope"
tfile <- liftIO $ canonicalizePath "./t/files/Simple.hs"
ec1 <- liftIO $ system $ "cd " ++ td ++ " && " ++ hpath ++ " -b " ++ tfile
res1 <- liftIO $ readProcess "cdb" [ "-l", td ++ "/hscope.out" ] ""
is ec1 ExitSuccess
like res1 "main"
res2 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "main" ] ""
like res2 "main = "
res3 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "findInfo" ] ""
like res3 "-> findInfo "
res4 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "options" ] ""
like res4 "Permute options"
res5 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "runLines" ] ""
like res5 ">>= runLines"
(ec2, l1) <- liftIO $ hscopeInteract hpath td [ "1main", "1findInfo" ]
is ec2 ExitSuccess
like l1 ">> "
like l1 tfile
like l1 "main ="
like l1 "findInfo ity cdb str ="
(ec3, l2) <- liftIO $ hscopeInteract hpath td [ "3findInfo", "1Build", "1Config" ]
is ec3 ExitSuccess
like l2 "-> findInfo "
like l2 "2 lines"
like l2 "Build Bool"
like l2 " Config {"
(ec4, l3) <- liftIO $ hscopeInteract hpath td [ "1Flag", "1Unused", "1cBuild" ]
is ec4 ExitSuccess
like l3 "data Flag"
like l3 "type Unused"
like l3 "cBuild :: Bool"
(ec5, l4) <- liftIO $ hscopeInteract hpath td [ "3cBuild", "3Flag", "3==" ]
is ec5 ExitSuccess
like l4 "cBuild cfg"
like l4 "parseFlags ::"
like l4 "groupBy (==)"
res6 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out", "t/files/a.c" ] ""
like res6 "Parse error: 0"
like res6 "a.c"
dfoo <- liftIO $ doesFileExist $ td ++ "/foo.out"
is dfoo True
res7 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "t/files/Arrow.hs", "t/files/CPP.hs" ] ""
is res7 ""
res8 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "doSth" ] ""
like res8 "doSth ="
res9 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "foo" ] ""
like res9 "foo 6 bar = id"
unlike res9 "warning"
res9_1 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-7", "Ar" ] ""
is res9_1 "cscope: 1 lines\nt/files/Arrow.hs <unknown> 1 <unknown>\n"
res10 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-3", "groupBy" ] ""
like res10 "groupBy (==)"
res10_1 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-3", "Build" ] ""
like res10_1 "NoArg $ Build False"
like res10_1 "Build b) ="
res11 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-4", "= do" ] ""
like res11 "files/Simple.hs <unknown> 115 main = do"
res12 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "-I", "t/files/a", "-I", "t/files/b"
, "t/files/CPP2.hs" ] ""
is res12 ""
res13 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "bar" ] ""
like res13 "bar 7 bar = id"
res14 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "t/files/garrs.hs" ] ""
is res14 ""
res15 <- liftIO $ readProcess hpath [ "--help" ] ""
like res15 $ "Usage: hscope [OPTION...] files..."
like res15 "-b"
res16 <- liftIO $ readProcess hpath [] ""
is res16 res15
res17 <- liftIO $ readProcess hpath [ "--build" ] ""
like res17 $ "Please provide files to build the hscope database"
res18 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "t/files/Fixity.hs" ] ""
is res18 $ ""
res19 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-3", "==>" ] ""
like res19 "0 ==>"
res20 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "-X", "MagicHash", "t/files/Unbox.hs" ] ""
is res20 $ ""
res21 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "t/files/Setup.lhs" ] ""
is res21 $ ""
res22 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "-I", "t/files/a", "-I", "t/files/b"
, "t/files/CPP3.hs" ] ""
is res22 ""
return () | 4,916 | main :: IO ()
main = withTemporaryDirectory "/tmp/hscope_test_XXXXXX" $ \td -> testSimpleMain $ do
plan 48
hpath <- liftIO $ canonicalizePath "./dist/build/hscope/hscope"
tfile <- liftIO $ canonicalizePath "./t/files/Simple.hs"
ec1 <- liftIO $ system $ "cd " ++ td ++ " && " ++ hpath ++ " -b " ++ tfile
res1 <- liftIO $ readProcess "cdb" [ "-l", td ++ "/hscope.out" ] ""
is ec1 ExitSuccess
like res1 "main"
res2 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "main" ] ""
like res2 "main = "
res3 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "findInfo" ] ""
like res3 "-> findInfo "
res4 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "options" ] ""
like res4 "Permute options"
res5 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "runLines" ] ""
like res5 ">>= runLines"
(ec2, l1) <- liftIO $ hscopeInteract hpath td [ "1main", "1findInfo" ]
is ec2 ExitSuccess
like l1 ">> "
like l1 tfile
like l1 "main ="
like l1 "findInfo ity cdb str ="
(ec3, l2) <- liftIO $ hscopeInteract hpath td [ "3findInfo", "1Build", "1Config" ]
is ec3 ExitSuccess
like l2 "-> findInfo "
like l2 "2 lines"
like l2 "Build Bool"
like l2 " Config {"
(ec4, l3) <- liftIO $ hscopeInteract hpath td [ "1Flag", "1Unused", "1cBuild" ]
is ec4 ExitSuccess
like l3 "data Flag"
like l3 "type Unused"
like l3 "cBuild :: Bool"
(ec5, l4) <- liftIO $ hscopeInteract hpath td [ "3cBuild", "3Flag", "3==" ]
is ec5 ExitSuccess
like l4 "cBuild cfg"
like l4 "parseFlags ::"
like l4 "groupBy (==)"
res6 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out", "t/files/a.c" ] ""
like res6 "Parse error: 0"
like res6 "a.c"
dfoo <- liftIO $ doesFileExist $ td ++ "/foo.out"
is dfoo True
res7 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "t/files/Arrow.hs", "t/files/CPP.hs" ] ""
is res7 ""
res8 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "doSth" ] ""
like res8 "doSth ="
res9 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "foo" ] ""
like res9 "foo 6 bar = id"
unlike res9 "warning"
res9_1 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-7", "Ar" ] ""
is res9_1 "cscope: 1 lines\nt/files/Arrow.hs <unknown> 1 <unknown>\n"
res10 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-3", "groupBy" ] ""
like res10 "groupBy (==)"
res10_1 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-3", "Build" ] ""
like res10_1 "NoArg $ Build False"
like res10_1 "Build b) ="
res11 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-4", "= do" ] ""
like res11 "files/Simple.hs <unknown> 115 main = do"
res12 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "-I", "t/files/a", "-I", "t/files/b"
, "t/files/CPP2.hs" ] ""
is res12 ""
res13 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "bar" ] ""
like res13 "bar 7 bar = id"
res14 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "t/files/garrs.hs" ] ""
is res14 ""
res15 <- liftIO $ readProcess hpath [ "--help" ] ""
like res15 $ "Usage: hscope [OPTION...] files..."
like res15 "-b"
res16 <- liftIO $ readProcess hpath [] ""
is res16 res15
res17 <- liftIO $ readProcess hpath [ "--build" ] ""
like res17 $ "Please provide files to build the hscope database"
res18 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "t/files/Fixity.hs" ] ""
is res18 $ ""
res19 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-3", "==>" ] ""
like res19 "0 ==>"
res20 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "-X", "MagicHash", "t/files/Unbox.hs" ] ""
is res20 $ ""
res21 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "t/files/Setup.lhs" ] ""
is res21 $ ""
res22 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "-I", "t/files/a", "-I", "t/files/b"
, "t/files/CPP3.hs" ] ""
is res22 ""
return () | 4,916 | main = withTemporaryDirectory "/tmp/hscope_test_XXXXXX" $ \td -> testSimpleMain $ do
plan 48
hpath <- liftIO $ canonicalizePath "./dist/build/hscope/hscope"
tfile <- liftIO $ canonicalizePath "./t/files/Simple.hs"
ec1 <- liftIO $ system $ "cd " ++ td ++ " && " ++ hpath ++ " -b " ++ tfile
res1 <- liftIO $ readProcess "cdb" [ "-l", td ++ "/hscope.out" ] ""
is ec1 ExitSuccess
like res1 "main"
res2 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "main" ] ""
like res2 "main = "
res3 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "findInfo" ] ""
like res3 "-> findInfo "
res4 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "options" ] ""
like res4 "Permute options"
res5 <- liftIO $ readProcess "cdb" [ "-q", td ++ "/hscope.out", "runLines" ] ""
like res5 ">>= runLines"
(ec2, l1) <- liftIO $ hscopeInteract hpath td [ "1main", "1findInfo" ]
is ec2 ExitSuccess
like l1 ">> "
like l1 tfile
like l1 "main ="
like l1 "findInfo ity cdb str ="
(ec3, l2) <- liftIO $ hscopeInteract hpath td [ "3findInfo", "1Build", "1Config" ]
is ec3 ExitSuccess
like l2 "-> findInfo "
like l2 "2 lines"
like l2 "Build Bool"
like l2 " Config {"
(ec4, l3) <- liftIO $ hscopeInteract hpath td [ "1Flag", "1Unused", "1cBuild" ]
is ec4 ExitSuccess
like l3 "data Flag"
like l3 "type Unused"
like l3 "cBuild :: Bool"
(ec5, l4) <- liftIO $ hscopeInteract hpath td [ "3cBuild", "3Flag", "3==" ]
is ec5 ExitSuccess
like l4 "cBuild cfg"
like l4 "parseFlags ::"
like l4 "groupBy (==)"
res6 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out", "t/files/a.c" ] ""
like res6 "Parse error: 0"
like res6 "a.c"
dfoo <- liftIO $ doesFileExist $ td ++ "/foo.out"
is dfoo True
res7 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "t/files/Arrow.hs", "t/files/CPP.hs" ] ""
is res7 ""
res8 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "doSth" ] ""
like res8 "doSth ="
res9 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "foo" ] ""
like res9 "foo 6 bar = id"
unlike res9 "warning"
res9_1 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-7", "Ar" ] ""
is res9_1 "cscope: 1 lines\nt/files/Arrow.hs <unknown> 1 <unknown>\n"
res10 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-3", "groupBy" ] ""
like res10 "groupBy (==)"
res10_1 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-3", "Build" ] ""
like res10_1 "NoArg $ Build False"
like res10_1 "Build b) ="
res11 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/hscope.out"
, "-4", "= do" ] ""
like res11 "files/Simple.hs <unknown> 115 main = do"
res12 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "-I", "t/files/a", "-I", "t/files/b"
, "t/files/CPP2.hs" ] ""
is res12 ""
res13 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-1", "bar" ] ""
like res13 "bar 7 bar = id"
res14 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "t/files/garrs.hs" ] ""
is res14 ""
res15 <- liftIO $ readProcess hpath [ "--help" ] ""
like res15 $ "Usage: hscope [OPTION...] files..."
like res15 "-b"
res16 <- liftIO $ readProcess hpath [] ""
is res16 res15
res17 <- liftIO $ readProcess hpath [ "--build" ] ""
like res17 $ "Please provide files to build the hscope database"
res18 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "t/files/Fixity.hs" ] ""
is res18 $ ""
res19 <- liftIO $ readProcess hpath [ "-d", "-f", td ++ "/foo.out"
, "-3", "==>" ] ""
like res19 "0 ==>"
res20 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "-X", "MagicHash", "t/files/Unbox.hs" ] ""
is res20 $ ""
res21 <- liftIO $ readProcess hpath [ "--build", "-f", td ++ "/foo.out"
, "t/files/Setup.lhs" ] ""
is res21 $ ""
res22 <- liftIO $ readProcess hpath [ "-b", "-f", td ++ "/foo.out"
, "-I", "t/files/a", "-I", "t/files/b"
, "t/files/CPP3.hs" ] ""
is res22 ""
return () | 4,902 | false | true | 0 | 17 | 1,717 | 1,466 | 711 | 755 | null | null |
psibi/incredible | logic/Types.hs | mit | isPortTypeIn :: PortType -> Bool
isPortTypeIn PTConclusion = False | 66 | isPortTypeIn :: PortType -> Bool
isPortTypeIn PTConclusion = False | 66 | isPortTypeIn PTConclusion = False | 33 | false | true | 0 | 5 | 8 | 18 | 9 | 9 | null | null |
jtobin/flat-mcmc | test/Rosenbrock.hs | mit | main :: IO ()
main = withSystemRandom . asGenIO $ mcmc 100 origin rosenbrock | 76 | main :: IO ()
main = withSystemRandom . asGenIO $ mcmc 100 origin rosenbrock | 76 | main = withSystemRandom . asGenIO $ mcmc 100 origin rosenbrock | 62 | false | true | 0 | 6 | 13 | 31 | 15 | 16 | null | null |
ndmitchell/hogle-dead | src/Input/Type.hs | bsd-3-clause | prettyItem x = showItem x | 25 | prettyItem x = showItem x | 25 | prettyItem x = showItem x | 25 | false | false | 0 | 5 | 4 | 12 | 5 | 7 | null | null |
norm2782/uuagc | src/Parser.hs | bsd-3-clause | pINST = pCostReserved 5 "inst" <?> "inst" | 52 | pINST = pCostReserved 5 "inst" <?> "inst" | 52 | pINST = pCostReserved 5 "inst" <?> "inst" | 52 | false | false | 0 | 6 | 17 | 15 | 7 | 8 | null | null |
jstolarek/ghc | compiler/cmm/PprC.hs | bsd-3-clause | te_Stmt :: CmmNode e x -> TE ()
te_Stmt (CmmAssign r e) = te_Reg r >> te_Expr e | 87 | te_Stmt :: CmmNode e x -> TE ()
te_Stmt (CmmAssign r e) = te_Reg r >> te_Expr e | 87 | te_Stmt (CmmAssign r e) = te_Reg r >> te_Expr e | 55 | false | true | 0 | 9 | 25 | 50 | 22 | 28 | null | null |
ulricha/dsh-sql | src/Database/DSH/Backend/Sql/Opt/Properties/Const.hs | bsd-3-clause | inferConstSelect (BinAppE Eq (ConstE v) (ColE c)) = [(c, v)] | 60 | inferConstSelect (BinAppE Eq (ConstE v) (ColE c)) = [(c, v)] | 60 | inferConstSelect (BinAppE Eq (ConstE v) (ColE c)) = [(c, v)] | 60 | false | false | 0 | 9 | 9 | 40 | 21 | 19 | null | null |
lukexi/cabal | cabal-install/Distribution/Client/IndexUtils.hs | bsd-3-clause | typeCodeFromRefType SnapshotRef = Tar.buildTreeSnapshotTypeCode | 63 | typeCodeFromRefType SnapshotRef = Tar.buildTreeSnapshotTypeCode | 63 | typeCodeFromRefType SnapshotRef = Tar.buildTreeSnapshotTypeCode | 63 | false | false | 1 | 6 | 3 | 15 | 5 | 10 | null | null |
jamshidh/ethereum-vm | src/Blockchain/BlockSynchronizer.hs | bsd-3-clause | handleNewBlockHashes::[SHA]->EthCryptM ContextM ()
--handleNewBlockHashes _ list | trace ("########### handleNewBlockHashes: " ++ show list) $ False = undefined
handleNewBlockHashes [] = return () | 196 | handleNewBlockHashes::[SHA]->EthCryptM ContextM ()
handleNewBlockHashes [] = return () | 86 | handleNewBlockHashes [] = return () | 35 | true | true | 0 | 7 | 22 | 36 | 18 | 18 | null | null |
awto/poly-dyn | src/Data/Dynamic/Poly.hs | bsd-3-clause | dynApply :: Dynamic -> Dynamic -> Maybe Dynamic
dynApply (Dynamic ft@(UTerm (Arr _ _)) fv) (Dynamic a av)
= either (const Nothing) Just $ runUniM
$ do
(UTerm (Arr fd fc)) <- freshen ft
at <- freshen a
_ <- unifyOccurs fd at
fc' <- applyBindings fc
return $ Dynamic fc' (unsafeCoerce fv $ av) | 343 | dynApply :: Dynamic -> Dynamic -> Maybe Dynamic
dynApply (Dynamic ft@(UTerm (Arr _ _)) fv) (Dynamic a av)
= either (const Nothing) Just $ runUniM
$ do
(UTerm (Arr fd fc)) <- freshen ft
at <- freshen a
_ <- unifyOccurs fd at
fc' <- applyBindings fc
return $ Dynamic fc' (unsafeCoerce fv $ av) | 343 | dynApply (Dynamic ft@(UTerm (Arr _ _)) fv) (Dynamic a av)
= either (const Nothing) Just $ runUniM
$ do
(UTerm (Arr fd fc)) <- freshen ft
at <- freshen a
_ <- unifyOccurs fd at
fc' <- applyBindings fc
return $ Dynamic fc' (unsafeCoerce fv $ av) | 295 | false | true | 14 | 9 | 106 | 147 | 74 | 73 | null | null |
TomMD/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | noMethodBindingErrorIdKey = mkPreludeMiscIdUnique 11 | 56 | noMethodBindingErrorIdKey = mkPreludeMiscIdUnique 11 | 56 | noMethodBindingErrorIdKey = mkPreludeMiscIdUnique 11 | 56 | false | false | 0 | 5 | 7 | 9 | 4 | 5 | null | null |
PipocaQuemada/ermine | opt/ekg/Ermine/Monitor.hs | bsd-2-clause | label :: (MonadIO m, HasMonitor t) => Text -> t -> m Label
label = runReaderT . labelM | 86 | label :: (MonadIO m, HasMonitor t) => Text -> t -> m Label
label = runReaderT . labelM | 86 | label = runReaderT . labelM | 27 | false | true | 0 | 8 | 17 | 41 | 21 | 20 | null | null |
Rydgel/haskellSDL2Examples | src/lesson17.hs | gpl-2.0 | drawWorld :: SDL.Renderer -> [Asset] -> World -> IO ()
drawWorld renderer assets world = withBlankScreen renderer $ mapM render' (quadrants world)
where (texture, w, h) = head assets
render' entity = with2 (maskFor entity) (positionFor entity) (SDL.renderCopy renderer texture)
sprite = toRect 0 0 (w `div` 2) (h `div` 2)
maskFor entity = maskFromState sprite (mouseState entity)
positionFor entity = sprite `moveTo` positionToPoint (position entity) | 494 | drawWorld :: SDL.Renderer -> [Asset] -> World -> IO ()
drawWorld renderer assets world = withBlankScreen renderer $ mapM render' (quadrants world)
where (texture, w, h) = head assets
render' entity = with2 (maskFor entity) (positionFor entity) (SDL.renderCopy renderer texture)
sprite = toRect 0 0 (w `div` 2) (h `div` 2)
maskFor entity = maskFromState sprite (mouseState entity)
positionFor entity = sprite `moveTo` positionToPoint (position entity) | 494 | drawWorld renderer assets world = withBlankScreen renderer $ mapM render' (quadrants world)
where (texture, w, h) = head assets
render' entity = with2 (maskFor entity) (positionFor entity) (SDL.renderCopy renderer texture)
sprite = toRect 0 0 (w `div` 2) (h `div` 2)
maskFor entity = maskFromState sprite (mouseState entity)
positionFor entity = sprite `moveTo` positionToPoint (position entity) | 439 | false | true | 0 | 10 | 109 | 189 | 97 | 92 | null | null |
ekmett/text | tests/Tests/Properties.hs | bsd-2-clause | sf_intersperse p c= (L.intersperse c . L.filter p) `eqP`
(unpackS . S.intersperse c . S.filter p) | 116 | sf_intersperse p c= (L.intersperse c . L.filter p) `eqP`
(unpackS . S.intersperse c . S.filter p) | 116 | sf_intersperse p c= (L.intersperse c . L.filter p) `eqP`
(unpackS . S.intersperse c . S.filter p) | 116 | false | false | 0 | 10 | 34 | 55 | 27 | 28 | null | null |
termite2/synthesis | Synthesis/Interface.hs | bsd-3-clause | withTmp' :: Ops s u -> (DDNode s u -> StateT (DB s u sp lp) (ST s) a) -> StateT (DB s u sp lp) (ST s) a
withTmp' Ops{..} func = do
ind <- allocIdx
var <- lift $ ithVar ind
res <- func var
freeIdx ind
lift $ deref var
return res | 251 | withTmp' :: Ops s u -> (DDNode s u -> StateT (DB s u sp lp) (ST s) a) -> StateT (DB s u sp lp) (ST s) a
withTmp' Ops{..} func = do
ind <- allocIdx
var <- lift $ ithVar ind
res <- func var
freeIdx ind
lift $ deref var
return res | 251 | withTmp' Ops{..} func = do
ind <- allocIdx
var <- lift $ ithVar ind
res <- func var
freeIdx ind
lift $ deref var
return res | 147 | false | true | 10 | 9 | 78 | 138 | 69 | 69 | null | null |
oldmanmike/ghc | compiler/hsSyn/HsExpr.hs | bsd-3-clause | ppr_expr (HsBinTick tickIdTrue tickIdFalse exp)
= pprTicks (ppr exp) $
hcat [text "bintick<",
ppr tickIdTrue,
text ",",
ppr tickIdFalse,
text ">(",
ppr exp, text ")"] | 222 | ppr_expr (HsBinTick tickIdTrue tickIdFalse exp)
= pprTicks (ppr exp) $
hcat [text "bintick<",
ppr tickIdTrue,
text ",",
ppr tickIdFalse,
text ">(",
ppr exp, text ")"] | 222 | ppr_expr (HsBinTick tickIdTrue tickIdFalse exp)
= pprTicks (ppr exp) $
hcat [text "bintick<",
ppr tickIdTrue,
text ",",
ppr tickIdFalse,
text ">(",
ppr exp, text ")"] | 222 | false | false | 0 | 8 | 80 | 77 | 37 | 40 | null | null |
jwalsh/mal | haskell/Core.hs | mpl-2.0 | run_2 :: (MalVal -> MalVal -> MalVal) -> [MalVal] -> IOThrows MalVal
run_2 f (x:y:[]) = return $ f x y | 102 | run_2 :: (MalVal -> MalVal -> MalVal) -> [MalVal] -> IOThrows MalVal
run_2 f (x:y:[]) = return $ f x y | 102 | run_2 f (x:y:[]) = return $ f x y | 33 | false | true | 2 | 8 | 20 | 69 | 33 | 36 | null | null |
Peaker/Algorithm-W-Step-By-Step | test/TestVals.hs | gpl-3.0 | unsafeCoerceTypePair :: (T.NominalId, Nominal)
unsafeCoerceTypePair =
( "UnsafeCoerce"
, Nominal
{ _nomParams = Map.empty
, _nomType =
Scheme (TV.singleton tvA <> TV.singleton tvB) mempty (ta ~> tb)
}
) | 250 | unsafeCoerceTypePair :: (T.NominalId, Nominal)
unsafeCoerceTypePair =
( "UnsafeCoerce"
, Nominal
{ _nomParams = Map.empty
, _nomType =
Scheme (TV.singleton tvA <> TV.singleton tvB) mempty (ta ~> tb)
}
) | 250 | unsafeCoerceTypePair =
( "UnsafeCoerce"
, Nominal
{ _nomParams = Map.empty
, _nomType =
Scheme (TV.singleton tvA <> TV.singleton tvB) mempty (ta ~> tb)
}
) | 203 | false | true | 0 | 13 | 76 | 79 | 41 | 38 | null | null |
DanGrayson/cubicaltt | CTT.hs | mit | def :: [Decl] -> Env -> Env
def ds (rho,vs,fs) = (Def ds rho,vs,fs) | 67 | def :: [Decl] -> Env -> Env
def ds (rho,vs,fs) = (Def ds rho,vs,fs) | 67 | def ds (rho,vs,fs) = (Def ds rho,vs,fs) | 39 | false | true | 0 | 6 | 13 | 50 | 28 | 22 | null | null |
sdiehl/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | typeNatLeqTyFamNameKey = mkPreludeTyConUnique 169 | 52 | typeNatLeqTyFamNameKey = mkPreludeTyConUnique 169 | 52 | typeNatLeqTyFamNameKey = mkPreludeTyConUnique 169 | 52 | false | false | 0 | 5 | 6 | 9 | 4 | 5 | null | null |
locaweb/leela | src/warpdrive/src/Leela/Data/Timeout.hs | apache-2.0 | creat :: TimeoutManager -> TimeoutInUs -> Finalizer -> IO ()
creat _ timeout fin = do
tm <- getSystemTimerManager
void $ registerTimeout tm timeout fin | 155 | creat :: TimeoutManager -> TimeoutInUs -> Finalizer -> IO ()
creat _ timeout fin = do
tm <- getSystemTimerManager
void $ registerTimeout tm timeout fin | 155 | creat _ timeout fin = do
tm <- getSystemTimerManager
void $ registerTimeout tm timeout fin | 94 | false | true | 0 | 9 | 28 | 56 | 26 | 30 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.