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
JPMoresmau/leksah
src/IDE/Utils/ServerConnection.hs
gpl-2.0
doServerCommand' :: ServerCommand -> (ServerAnswer -> IDEM ()) -> IDEAction doServerCommand' command cont = do server' <- readIDE server case server' of Just handle -> do isOpen <- liftIO $ hIsOpen handle if isOpen then void (doCommand handle) else do modifyIDE_ (\ ide -> ide{server = Nothing}) doServerCommand command cont Nothing -> do prefs' <- readIDE prefs handle <- reifyIDE $ \ideR -> catch (connectTo (T.unpack $ serverIP prefs') (PortNumber (fromIntegral $ serverPort prefs'))) (\(exc :: SomeException) -> do catch (startServer (serverPort prefs')) (\(exc :: SomeException) -> throwIDE ("Can't start leksah-server" <> T.pack (show exc))) mbHandle <- waitForServer prefs' 100 case mbHandle of Just handle -> return handle Nothing -> throwIDE "Can't connect to leksah-server") modifyIDE_ (\ ide -> ide{server = Just handle}) doCommand handle return () where doCommand handle = do postAsyncIDE . void $ triggerEventIDE (StatusbarChanged [CompartmentCollect True]) resp <- liftIO $ do debugM "leksah" $ "Sending server command " ++ show command hPrint handle command hFlush handle debugM "leksah" $ "Waiting on server command " ++ show command hGetLine handle liftIO . debugM "leksah" $ "Server result " ++ resp postAsyncIDE $ do triggerEventIDE (StatusbarChanged [CompartmentCollect False]) cont (read resp)
1,864
doServerCommand' :: ServerCommand -> (ServerAnswer -> IDEM ()) -> IDEAction doServerCommand' command cont = do server' <- readIDE server case server' of Just handle -> do isOpen <- liftIO $ hIsOpen handle if isOpen then void (doCommand handle) else do modifyIDE_ (\ ide -> ide{server = Nothing}) doServerCommand command cont Nothing -> do prefs' <- readIDE prefs handle <- reifyIDE $ \ideR -> catch (connectTo (T.unpack $ serverIP prefs') (PortNumber (fromIntegral $ serverPort prefs'))) (\(exc :: SomeException) -> do catch (startServer (serverPort prefs')) (\(exc :: SomeException) -> throwIDE ("Can't start leksah-server" <> T.pack (show exc))) mbHandle <- waitForServer prefs' 100 case mbHandle of Just handle -> return handle Nothing -> throwIDE "Can't connect to leksah-server") modifyIDE_ (\ ide -> ide{server = Just handle}) doCommand handle return () where doCommand handle = do postAsyncIDE . void $ triggerEventIDE (StatusbarChanged [CompartmentCollect True]) resp <- liftIO $ do debugM "leksah" $ "Sending server command " ++ show command hPrint handle command hFlush handle debugM "leksah" $ "Waiting on server command " ++ show command hGetLine handle liftIO . debugM "leksah" $ "Server result " ++ resp postAsyncIDE $ do triggerEventIDE (StatusbarChanged [CompartmentCollect False]) cont (read resp)
1,864
doServerCommand' command cont = do server' <- readIDE server case server' of Just handle -> do isOpen <- liftIO $ hIsOpen handle if isOpen then void (doCommand handle) else do modifyIDE_ (\ ide -> ide{server = Nothing}) doServerCommand command cont Nothing -> do prefs' <- readIDE prefs handle <- reifyIDE $ \ideR -> catch (connectTo (T.unpack $ serverIP prefs') (PortNumber (fromIntegral $ serverPort prefs'))) (\(exc :: SomeException) -> do catch (startServer (serverPort prefs')) (\(exc :: SomeException) -> throwIDE ("Can't start leksah-server" <> T.pack (show exc))) mbHandle <- waitForServer prefs' 100 case mbHandle of Just handle -> return handle Nothing -> throwIDE "Can't connect to leksah-server") modifyIDE_ (\ ide -> ide{server = Just handle}) doCommand handle return () where doCommand handle = do postAsyncIDE . void $ triggerEventIDE (StatusbarChanged [CompartmentCollect True]) resp <- liftIO $ do debugM "leksah" $ "Sending server command " ++ show command hPrint handle command hFlush handle debugM "leksah" $ "Waiting on server command " ++ show command hGetLine handle liftIO . debugM "leksah" $ "Server result " ++ resp postAsyncIDE $ do triggerEventIDE (StatusbarChanged [CompartmentCollect False]) cont (read resp)
1,788
false
true
0
28
742
505
234
271
null
null
nomeata/ghc
compiler/codeGen/CgUtils.hs
bsd-3-clause
baseRegOffset (FloatReg 4) = oFFSET_StgRegTable_rF4
58
baseRegOffset (FloatReg 4) = oFFSET_StgRegTable_rF4
58
baseRegOffset (FloatReg 4) = oFFSET_StgRegTable_rF4
58
false
false
0
6
11
16
7
9
null
null
roman-smrz/rawe
src/FRP/Rawe/Prelude.hs
bsd-3-clause
-- take n, applied to a list xs, returns the prefix of xs of length n, -- or xs itself if n > length xs. drop n xs returns the suffix of xs -- after the first n elements, or [] if n > length xs. splitAt n xs -- is equivalent to (take n xs, drop n xs). take :: Bhv Int -> Bhv [a] -> Bhv [a] take = bfix $ \tk n xs -> ite (n <= 0) nil $ list nil (\x xs -> x ~: tk (n-1) xs) xs
377
take :: Bhv Int -> Bhv [a] -> Bhv [a] take = bfix $ \tk n xs -> ite (n <= 0) nil $ list nil (\x xs -> x ~: tk (n-1) xs) xs
122
take = bfix $ \tk n xs -> ite (n <= 0) nil $ list nil (\x xs -> x ~: tk (n-1) xs) xs
84
true
true
2
12
96
107
54
53
null
null
input-output-hk/cardano-sl
explorer/src/Pos/Explorer/TestUtil.hs
apache-2.0
---------------------------------------------------------------- -- Function mocks ---------------------------------------------------------------- -- | More predictable generation that doesn't violate the invariants. generateValidExplorerMockableMode :: BlockNumber -> SlotsPerEpoch -> IO ExplorerMockableMode generateValidExplorerMockableMode blocksNumber slotsPerEpoch = do slotStart <- liftIO $ generate $ arbitrary slotLeaders <- produceSlotLeaders blocksNumber secretKeys <- produceSecretKeys blocksNumber blocks <- withDefConfigurations $ \_ _ _ -> produceBlocksByBlockNumberAndSlots blocksNumber slotsPerEpoch slotLeaders secretKeys let tipBlock = Prelude.last blocks let pagedHHs = withDefConfigurations $ \_ _ _ -> createMapPageHHs blocks let hHsBlunds = withDefConfigurations $ \_ _ _ -> createMapHHsBlund blocks let epochPageHHs = withDefConfigurations $ \_ _ _ -> createMapEpochPageHHs blocks slotsPerEpoch let mapEpochMaxPages = withDefConfigurations $ \_ _ _ -> createMapEpochMaxPages (keys epochPageHHs) pure $ ExplorerMockableMode { emmGetTipBlock = pure tipBlock , emmGetPageBlocks = \page -> pure $ pagedHHs ^. at page , emmGetBlundFromHH = \hh -> pure $ hHsBlunds ^. at hh , emmGetSlotStart = \_ -> pure $ Just slotStart , emmGetLeadersFromEpoch = \_ -> pure $ Just slotLeaders , emmGetEpochBlocks = \epoch page -> pure $ epochPageHHs ^. at (epoch, page) , emmGetEpochPages = \epoch -> pure $ mapEpochMaxPages ^. at epoch } where createMapPageHHs :: [Block] -> Map Page [HeaderHash] createMapPageHHs blocks = fromListWith (++) [ (page, [hHash]) | (page, hHash) <- createPagedHeaderHashesPair blocks] createMapHHsBlund :: [Block] -> Map HeaderHash Blund createMapHHsBlund blocks = fromList $ map blockHH blocks where blockHH :: Block -> (HeaderHash, Blund) blockHH block = (headerHash block, (block, createEmptyUndo)) -- | TODO(ks): Need to add `getSlotIndex $ siSlot $ fst blund ^. mainBlockSlot`. createMapEpochPageHHs :: [Block] -> SlotsPerEpoch -> Map EpochPagedBlocksKey [HeaderHash] createMapEpochPageHHs blocks slotsPerEpoch' = unions $ map convertToPagedMap epochBlock where epochBlock :: [(EpochIndex, [HeaderHash])] epochBlock = zip [minBound..] epochHHs epochHHs :: [[HeaderHash]] epochHHs = headerHash <<$>> epochBlocks epochBlocks :: [[Block]] epochBlocks = splitEvery (fromIntegral slotsPerEpoch') blocks where splitEvery :: Int -> [a] -> [[a]] splitEvery _ [] = [] splitEvery n xs = as : splitEvery n bs where (as,bs) = splitAt n xs createMapEpochMaxPages :: [EpochPagedBlocksKey] -> Map Epoch Page createMapEpochMaxPages epochPages = do let groupedEpochPages :: [[(Epoch, Page)]] groupedEpochPages = groupBy ((==) `on` fst) epochPages fromList $ maximumBy (compare `on` fst) <$> groupedEpochPages -- | The first aproximation. Ideally, I wanted to have something to generate @Undo@ from -- @Block@. We could generate @Undo@ from _produceBlocksByBlockNumberAndSlots_, but we -- need to add quite a bit of logic to it. For now, it's good enough, since we are -- testing just the "sunny day" scenario, and we don't worry about rollbacks. There -- are already tests that cover a lot of rollback logic. -- For a more realistic @Undo@, check @Pos.Chain.Block.VAR.verifyBlocksPrefix@.
3,739
generateValidExplorerMockableMode :: BlockNumber -> SlotsPerEpoch -> IO ExplorerMockableMode generateValidExplorerMockableMode blocksNumber slotsPerEpoch = do slotStart <- liftIO $ generate $ arbitrary slotLeaders <- produceSlotLeaders blocksNumber secretKeys <- produceSecretKeys blocksNumber blocks <- withDefConfigurations $ \_ _ _ -> produceBlocksByBlockNumberAndSlots blocksNumber slotsPerEpoch slotLeaders secretKeys let tipBlock = Prelude.last blocks let pagedHHs = withDefConfigurations $ \_ _ _ -> createMapPageHHs blocks let hHsBlunds = withDefConfigurations $ \_ _ _ -> createMapHHsBlund blocks let epochPageHHs = withDefConfigurations $ \_ _ _ -> createMapEpochPageHHs blocks slotsPerEpoch let mapEpochMaxPages = withDefConfigurations $ \_ _ _ -> createMapEpochMaxPages (keys epochPageHHs) pure $ ExplorerMockableMode { emmGetTipBlock = pure tipBlock , emmGetPageBlocks = \page -> pure $ pagedHHs ^. at page , emmGetBlundFromHH = \hh -> pure $ hHsBlunds ^. at hh , emmGetSlotStart = \_ -> pure $ Just slotStart , emmGetLeadersFromEpoch = \_ -> pure $ Just slotLeaders , emmGetEpochBlocks = \epoch page -> pure $ epochPageHHs ^. at (epoch, page) , emmGetEpochPages = \epoch -> pure $ mapEpochMaxPages ^. at epoch } where createMapPageHHs :: [Block] -> Map Page [HeaderHash] createMapPageHHs blocks = fromListWith (++) [ (page, [hHash]) | (page, hHash) <- createPagedHeaderHashesPair blocks] createMapHHsBlund :: [Block] -> Map HeaderHash Blund createMapHHsBlund blocks = fromList $ map blockHH blocks where blockHH :: Block -> (HeaderHash, Blund) blockHH block = (headerHash block, (block, createEmptyUndo)) -- | TODO(ks): Need to add `getSlotIndex $ siSlot $ fst blund ^. mainBlockSlot`. createMapEpochPageHHs :: [Block] -> SlotsPerEpoch -> Map EpochPagedBlocksKey [HeaderHash] createMapEpochPageHHs blocks slotsPerEpoch' = unions $ map convertToPagedMap epochBlock where epochBlock :: [(EpochIndex, [HeaderHash])] epochBlock = zip [minBound..] epochHHs epochHHs :: [[HeaderHash]] epochHHs = headerHash <<$>> epochBlocks epochBlocks :: [[Block]] epochBlocks = splitEvery (fromIntegral slotsPerEpoch') blocks where splitEvery :: Int -> [a] -> [[a]] splitEvery _ [] = [] splitEvery n xs = as : splitEvery n bs where (as,bs) = splitAt n xs createMapEpochMaxPages :: [EpochPagedBlocksKey] -> Map Epoch Page createMapEpochMaxPages epochPages = do let groupedEpochPages :: [[(Epoch, Page)]] groupedEpochPages = groupBy ((==) `on` fst) epochPages fromList $ maximumBy (compare `on` fst) <$> groupedEpochPages -- | The first aproximation. Ideally, I wanted to have something to generate @Undo@ from -- @Block@. We could generate @Undo@ from _produceBlocksByBlockNumberAndSlots_, but we -- need to add quite a bit of logic to it. For now, it's good enough, since we are -- testing just the "sunny day" scenario, and we don't worry about rollbacks. There -- are already tests that cover a lot of rollback logic. -- For a more realistic @Undo@, check @Pos.Chain.Block.VAR.verifyBlocksPrefix@.
3,520
generateValidExplorerMockableMode blocksNumber slotsPerEpoch = do slotStart <- liftIO $ generate $ arbitrary slotLeaders <- produceSlotLeaders blocksNumber secretKeys <- produceSecretKeys blocksNumber blocks <- withDefConfigurations $ \_ _ _ -> produceBlocksByBlockNumberAndSlots blocksNumber slotsPerEpoch slotLeaders secretKeys let tipBlock = Prelude.last blocks let pagedHHs = withDefConfigurations $ \_ _ _ -> createMapPageHHs blocks let hHsBlunds = withDefConfigurations $ \_ _ _ -> createMapHHsBlund blocks let epochPageHHs = withDefConfigurations $ \_ _ _ -> createMapEpochPageHHs blocks slotsPerEpoch let mapEpochMaxPages = withDefConfigurations $ \_ _ _ -> createMapEpochMaxPages (keys epochPageHHs) pure $ ExplorerMockableMode { emmGetTipBlock = pure tipBlock , emmGetPageBlocks = \page -> pure $ pagedHHs ^. at page , emmGetBlundFromHH = \hh -> pure $ hHsBlunds ^. at hh , emmGetSlotStart = \_ -> pure $ Just slotStart , emmGetLeadersFromEpoch = \_ -> pure $ Just slotLeaders , emmGetEpochBlocks = \epoch page -> pure $ epochPageHHs ^. at (epoch, page) , emmGetEpochPages = \epoch -> pure $ mapEpochMaxPages ^. at epoch } where createMapPageHHs :: [Block] -> Map Page [HeaderHash] createMapPageHHs blocks = fromListWith (++) [ (page, [hHash]) | (page, hHash) <- createPagedHeaderHashesPair blocks] createMapHHsBlund :: [Block] -> Map HeaderHash Blund createMapHHsBlund blocks = fromList $ map blockHH blocks where blockHH :: Block -> (HeaderHash, Blund) blockHH block = (headerHash block, (block, createEmptyUndo)) -- | TODO(ks): Need to add `getSlotIndex $ siSlot $ fst blund ^. mainBlockSlot`. createMapEpochPageHHs :: [Block] -> SlotsPerEpoch -> Map EpochPagedBlocksKey [HeaderHash] createMapEpochPageHHs blocks slotsPerEpoch' = unions $ map convertToPagedMap epochBlock where epochBlock :: [(EpochIndex, [HeaderHash])] epochBlock = zip [minBound..] epochHHs epochHHs :: [[HeaderHash]] epochHHs = headerHash <<$>> epochBlocks epochBlocks :: [[Block]] epochBlocks = splitEvery (fromIntegral slotsPerEpoch') blocks where splitEvery :: Int -> [a] -> [[a]] splitEvery _ [] = [] splitEvery n xs = as : splitEvery n bs where (as,bs) = splitAt n xs createMapEpochMaxPages :: [EpochPagedBlocksKey] -> Map Epoch Page createMapEpochMaxPages epochPages = do let groupedEpochPages :: [[(Epoch, Page)]] groupedEpochPages = groupBy ((==) `on` fst) epochPages fromList $ maximumBy (compare `on` fst) <$> groupedEpochPages -- | The first aproximation. Ideally, I wanted to have something to generate @Undo@ from -- @Block@. We could generate @Undo@ from _produceBlocksByBlockNumberAndSlots_, but we -- need to add quite a bit of logic to it. For now, it's good enough, since we are -- testing just the "sunny day" scenario, and we don't worry about rollbacks. There -- are already tests that cover a lot of rollback logic. -- For a more realistic @Undo@, check @Pos.Chain.Block.VAR.verifyBlocksPrefix@.
3,415
true
true
0
14
953
808
429
379
null
null
nevrenato/Hets_Fork
CSL/quickchecks.hs
gpl-2.0
finsetC :: (Ord a) => Gen a -> Gen (SetOrInterval a) finsetC g = fmap (Set . Set.fromList) $ listOf1 g
102
finsetC :: (Ord a) => Gen a -> Gen (SetOrInterval a) finsetC g = fmap (Set . Set.fromList) $ listOf1 g
102
finsetC g = fmap (Set . Set.fromList) $ listOf1 g
49
false
true
0
10
20
62
29
33
null
null
ronwalf/ridemap
src/ridemap.hs
bsd-3-clause
gCirc :: Double gCirc = 20037508.34*2
37
gCirc :: Double gCirc = 20037508.34*2
37
gCirc = 20037508.34*2
21
false
true
0
5
5
15
8
7
null
null
shlevy/ghc
compiler/basicTypes/RdrName.hs
bsd-3-clause
extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv -- The Name should be a non-top-level thing extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name = WARN( isExternalName name, ppr name ) lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name }
326
extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name = WARN( isExternalName name, ppr name ) lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name }
282
extendLocalRdrEnv lre@(LRE { lre_env = env, lre_in_scope = ns }) name = WARN( isExternalName name, ppr name ) lre { lre_env = extendOccEnv env (nameOccName name) name , lre_in_scope = extendNameSet ns name }
226
true
true
1
10
67
103
53
50
null
null
Spawek/HCPParse
src/Data/Either/Unwrap.hs
mit
whenLeft _ _ = return ()
31
whenLeft _ _ = return ()
31
whenLeft _ _ = return ()
31
false
false
0
6
12
16
7
9
null
null
diku-dk/futhark
src/Language/Futhark/Prop.hs
isc
decImports ValDec {} = []
25
decImports ValDec {} = []
25
decImports ValDec {} = []
25
false
false
0
6
4
15
7
8
null
null
mightymoose/liquidhaskell
benchmarks/llrbtree-0.1.1/Data/Set/LLRBTree.hs
bsd-3-clause
---------------------------------------------------------------- turnR :: RBTree a -> RBTree a turnR Leaf = error "turnR"
134
turnR :: RBTree a -> RBTree a turnR Leaf = error "turnR"
68
turnR Leaf = error "turnR"
38
true
true
0
6
25
28
13
15
null
null
uwap/Idris-dev
src/Idris/Delaborate.hs
bsd-3-clause
pprintErr' i (LoadingFailed fn e) = text "Loading" <+> text fn <+> text "failed:" <+> pprintErr' i e
101
pprintErr' i (LoadingFailed fn e) = text "Loading" <+> text fn <+> text "failed:" <+> pprintErr' i e
101
pprintErr' i (LoadingFailed fn e) = text "Loading" <+> text fn <+> text "failed:" <+> pprintErr' i e
101
false
false
0
8
18
47
20
27
null
null
tonymorris/language-javascript
src/Language/JavaScript/Parser/AST.hs
bsd-3-clause
ss (NT node _ _) = showStrippedNode node
40
ss (NT node _ _) = showStrippedNode node
40
ss (NT node _ _) = showStrippedNode node
40
false
false
0
6
7
23
10
13
null
null
spockwangs/scheme.in.haskell
list7.hs
unlicense
-- | Implementing 'cdr'. -- Rules: -- (cdr (a b c)) = (b c) -- (cdr (a b)) = (b) -- (cdr (a)) = NIL -- (cdr (a b . c)) = (b . c) -- (cdr (a . b)) = b -- (cdr a) = error (not list) -- (cdr a b) = error (too many args) cdr :: [LispVal] -> ThrowsError LispVal cdr [List (x : xs)] = return $ List xs
309
cdr :: [LispVal] -> ThrowsError LispVal cdr [List (x : xs)] = return $ List xs
78
cdr [List (x : xs)] = return $ List xs
38
true
true
0
11
87
57
32
25
null
null
lovasko/swim
src/Command/Export/Perform.hs
bsd-2-clause
optionTimestamp :: Parser Bool -- ^ parser optionTimestamp = switch $ short 't' <> long "timestamp" <> help "Display time values as timestamps"
158
optionTimestamp :: Parser Bool optionTimestamp = switch $ short 't' <> long "timestamp" <> help "Display time values as timestamps"
146
optionTimestamp = switch $ short 't' <> long "timestamp" <> help "Display time values as timestamps"
115
true
true
6
5
37
39
17
22
null
null
dmjio/stripe
stripe-core/src/Web/Stripe/Charge.hs
mit
------------------------------------------------------------------------------ -- | Retrieve all `Charge`s getCharges :: StripeRequest GetCharges getCharges = request where request = mkStripeRequest GET url params url = "charges" params = []
268
getCharges :: StripeRequest GetCharges getCharges = request where request = mkStripeRequest GET url params url = "charges" params = []
161
getCharges = request where request = mkStripeRequest GET url params url = "charges" params = []
118
true
true
2
6
52
45
23
22
null
null
ygale/yesod
yesod-core/Yesod/Core/Handler.hs
mit
-- | Returns a function that runs 'HandlerT' actions inside @IO@. -- -- Sometimes you want to run an inner 'HandlerT' action outside -- the control flow of an HTTP request (on the outer 'HandlerT' -- action). For example, you may want to spawn a new thread: -- -- @ -- getFooR :: Handler RepHtml -- getFooR = do -- runInnerHandler <- handlerToIO -- liftIO $ forkIO $ runInnerHandler $ do -- /Code here runs inside GHandler but on a new thread./ -- /This is the inner GHandler./ -- ... -- /Code here runs inside the request's control flow./ -- /This is the outer GHandler./ -- ... -- @ -- -- Another use case for this function is creating a stream of -- server-sent events using 'GHandler' actions (see -- @yesod-eventsource@). -- -- Most of the environment from the outer 'GHandler' is preserved -- on the inner 'GHandler', however: -- -- * The request body is cleared (otherwise it would be very -- difficult to prevent huge memory leaks). -- -- * The cache is cleared (see 'CacheKey'). -- -- Changes to the response made inside the inner 'GHandler' are -- ignored (e.g., session variables, cookies, response headers). -- This allows the inner 'GHandler' to outlive the outer -- 'GHandler' (e.g., on the @forkIO@ example above, a response -- may be sent to the client without killing the new thread). handlerToIO :: (MonadIO m1, MonadIO m2) => HandlerT site m1 (HandlerT site IO a -> m2 a) handlerToIO = HandlerT $ \oldHandlerData -> do -- Take just the bits we need from oldHandlerData. let newReq = oldReq { reqWaiRequest = newWaiReq } where oldReq = handlerRequest oldHandlerData oldWaiReq = reqWaiRequest oldReq newWaiReq = oldWaiReq { W.requestBody = return mempty , W.requestBodyLength = W.KnownLength 0 } oldEnv = handlerEnv oldHandlerData newState <- liftIO $ do oldState <- I.readIORef (handlerState oldHandlerData) return $ oldState { ghsRBC = Nothing , ghsIdent = 1 , ghsCache = mempty , ghsCacheBy = mempty , ghsHeaders = mempty } -- xx From this point onwards, no references to oldHandlerData xx liftIO $ evaluate (newReq `seq` oldEnv `seq` newState `seq` ()) -- Return GHandler running function. return $ \(HandlerT f) -> liftIO $ runResourceT $ withInternalState $ \resState -> do -- The state IORef needs to be created here, otherwise it -- will be shared by different invocations of this function. newStateIORef <- liftIO (I.newIORef newState) let newHandlerData = HandlerData { handlerRequest = newReq , handlerEnv = oldEnv , handlerState = newStateIORef , handlerToParent = const () , handlerResource = resState } liftIO (f newHandlerData) -- | forkIO for a Handler (run an action in the background) -- -- Uses 'handlerToIO', liftResourceT, and resourceForkIO -- for correctness and efficiency -- -- Since 1.2.8
3,194
handlerToIO :: (MonadIO m1, MonadIO m2) => HandlerT site m1 (HandlerT site IO a -> m2 a) handlerToIO = HandlerT $ \oldHandlerData -> do -- Take just the bits we need from oldHandlerData. let newReq = oldReq { reqWaiRequest = newWaiReq } where oldReq = handlerRequest oldHandlerData oldWaiReq = reqWaiRequest oldReq newWaiReq = oldWaiReq { W.requestBody = return mempty , W.requestBodyLength = W.KnownLength 0 } oldEnv = handlerEnv oldHandlerData newState <- liftIO $ do oldState <- I.readIORef (handlerState oldHandlerData) return $ oldState { ghsRBC = Nothing , ghsIdent = 1 , ghsCache = mempty , ghsCacheBy = mempty , ghsHeaders = mempty } -- xx From this point onwards, no references to oldHandlerData xx liftIO $ evaluate (newReq `seq` oldEnv `seq` newState `seq` ()) -- Return GHandler running function. return $ \(HandlerT f) -> liftIO $ runResourceT $ withInternalState $ \resState -> do -- The state IORef needs to be created here, otherwise it -- will be shared by different invocations of this function. newStateIORef <- liftIO (I.newIORef newState) let newHandlerData = HandlerData { handlerRequest = newReq , handlerEnv = oldEnv , handlerState = newStateIORef , handlerToParent = const () , handlerResource = resState } liftIO (f newHandlerData) -- | forkIO for a Handler (run an action in the background) -- -- Uses 'handlerToIO', liftResourceT, and resourceForkIO -- for correctness and efficiency -- -- Since 1.2.8
1,866
handlerToIO = HandlerT $ \oldHandlerData -> do -- Take just the bits we need from oldHandlerData. let newReq = oldReq { reqWaiRequest = newWaiReq } where oldReq = handlerRequest oldHandlerData oldWaiReq = reqWaiRequest oldReq newWaiReq = oldWaiReq { W.requestBody = return mempty , W.requestBodyLength = W.KnownLength 0 } oldEnv = handlerEnv oldHandlerData newState <- liftIO $ do oldState <- I.readIORef (handlerState oldHandlerData) return $ oldState { ghsRBC = Nothing , ghsIdent = 1 , ghsCache = mempty , ghsCacheBy = mempty , ghsHeaders = mempty } -- xx From this point onwards, no references to oldHandlerData xx liftIO $ evaluate (newReq `seq` oldEnv `seq` newState `seq` ()) -- Return GHandler running function. return $ \(HandlerT f) -> liftIO $ runResourceT $ withInternalState $ \resState -> do -- The state IORef needs to be created here, otherwise it -- will be shared by different invocations of this function. newStateIORef <- liftIO (I.newIORef newState) let newHandlerData = HandlerData { handlerRequest = newReq , handlerEnv = oldEnv , handlerState = newStateIORef , handlerToParent = const () , handlerResource = resState } liftIO (f newHandlerData) -- | forkIO for a Handler (run an action in the background) -- -- Uses 'handlerToIO', liftResourceT, and resourceForkIO -- for correctness and efficiency -- -- Since 1.2.8
1,777
true
true
2
21
918
399
231
168
null
null
hinneburg/TopicExplorer
creator-server/common/src/TopicExplorer/Configuration/Date.hs
agpl-3.0
format :: Date -> String format d = printf "%04d-%02d-%02d %02d:%02d" (year d) (month d) (day d) (hour d) (minute d)
125
format :: Date -> String format d = printf "%04d-%02d-%02d %02d:%02d" (year d) (month d) (day d) (hour d) (minute d)
125
format d = printf "%04d-%02d-%02d %02d:%02d" (year d) (month d) (day d) (hour d) (minute d)
100
false
true
0
7
29
61
30
31
null
null
wavewave/lhc-analysis-collection
analysis/2013-08-05-XQLD-prospino_2sq.hs
gpl-3.0
snd3 (_,a,_) = a
16
snd3 (_,a,_) = a
16
snd3 (_,a,_) = a
16
false
false
0
5
3
19
10
9
null
null
mstksg/hledger
hledger-lib/Hledger/Read/CsvReader.hs
gpl-3.0
addDirective :: (DirectiveName, String) -> CsvRules -> CsvRules addDirective d r = r{rdirectives=d:rdirectives r}
113
addDirective :: (DirectiveName, String) -> CsvRules -> CsvRules addDirective d r = r{rdirectives=d:rdirectives r}
113
addDirective d r = r{rdirectives=d:rdirectives r}
49
false
true
0
9
13
55
26
29
null
null
ununsept/lambdaHTTP
Engine.hs
mit
loger :: Config -> SockAddr -> String -> IO () loger conf addr request = do time <- getClockTime case fileLog conf of Just file -> appendFile file $ (show addr) ++ " = " ++ (show time) ++ "\n" ++ request Nothing -> putStrLn $ (show addr) ++ " = " ++ (show time) ++ "\n" ++ request
328
loger :: Config -> SockAddr -> String -> IO () loger conf addr request = do time <- getClockTime case fileLog conf of Just file -> appendFile file $ (show addr) ++ " = " ++ (show time) ++ "\n" ++ request Nothing -> putStrLn $ (show addr) ++ " = " ++ (show time) ++ "\n" ++ request
328
loger conf addr request = do time <- getClockTime case fileLog conf of Just file -> appendFile file $ (show addr) ++ " = " ++ (show time) ++ "\n" ++ request Nothing -> putStrLn $ (show addr) ++ " = " ++ (show time) ++ "\n" ++ request
281
false
true
0
16
106
134
64
70
null
null
eugenkiss/mastermind
haskell/Strategies/Entropy.hs
bsd-3-clause
extractGuess' :: StrategyState -> Code extractGuess' = guess
60
extractGuess' :: StrategyState -> Code extractGuess' = guess
60
extractGuess' = guess
21
false
true
0
5
7
15
8
7
null
null
ku-fpg/kansas-amber
System/Hardware/Haskino/Compiler.hs
bsd-3-clause
compileExpr (ModI16 e1 e2) = compileTwoSubExpr "mod16" e1 e2
60
compileExpr (ModI16 e1 e2) = compileTwoSubExpr "mod16" e1 e2
60
compileExpr (ModI16 e1 e2) = compileTwoSubExpr "mod16" e1 e2
60
false
false
0
7
8
24
11
13
null
null
joelburget/haste-compiler
Tests/Read.hs
bsd-3-clause
strList = "[32,7,6,49,0,9,9]"
29
strList = "[32,7,6,49,0,9,9]"
29
strList = "[32,7,6,49,0,9,9]"
29
false
false
1
5
2
10
3
7
null
null
urbanslug/ghc
libraries/base/Data/Data.hs
bsd-3-clause
-- | Gets the fixity of a constructor constrFixity :: Constr -> Fixity constrFixity = confixity
95
constrFixity :: Constr -> Fixity constrFixity = confixity
57
constrFixity = confixity
24
true
true
0
7
15
23
10
13
null
null
kylc/torrent
src/BitTorrent/Bencode.hs
bsd-3-clause
bInt :: Parser Bencode bInt = BInt <$> (char 'i' *> signed decimal <* char 'e')
79
bInt :: Parser Bencode bInt = BInt <$> (char 'i' *> signed decimal <* char 'e')
79
bInt = BInt <$> (char 'i' *> signed decimal <* char 'e')
56
false
true
0
9
15
38
18
20
null
null
beni55/hspec-snap
src/Test/Hspec/Snap.hs
bsd-3-clause
setResult :: Result -> SnapHspecM b () setResult r = do (SnapHspecState r' s a i sess bef aft) <- S.get case r' of Success -> S.put (SnapHspecState r s a i sess bef aft) _ -> return () -- | Asserts that a given stateful action will produce a specific different result after -- an action has been run.
356
setResult :: Result -> SnapHspecM b () setResult r = do (SnapHspecState r' s a i sess bef aft) <- S.get case r' of Success -> S.put (SnapHspecState r s a i sess bef aft) _ -> return () -- | Asserts that a given stateful action will produce a specific different result after -- an action has been run.
356
setResult r = do (SnapHspecState r' s a i sess bef aft) <- S.get case r' of Success -> S.put (SnapHspecState r s a i sess bef aft) _ -> return () -- | Asserts that a given stateful action will produce a specific different result after -- an action has been run.
317
false
true
0
13
115
106
50
56
null
null
mfpi/hnars
src/FingerTree.hs
mit
(><) :: (Measured v a) => FingerTree v a -> FingerTree v a -> FingerTree v a xs >< ys = app3 xs [] ys
101
(><) :: (Measured v a) => FingerTree v a -> FingerTree v a -> FingerTree v a xs >< ys = app3 xs [] ys
101
xs >< ys = app3 xs [] ys
24
false
true
0
10
24
62
30
32
null
null
fpco/esqueleto
src/Database/Esqueleto/Internal/Sql.hs
bsd-3-clause
-- | Create a fresh 'Ident'. If possible, use the given -- 'DBName'. newIdentFor :: DBName -> SqlQuery Ident newIdentFor = Q . lift . try . unDBName where try orig = do s <- S.get let go (t:ts) | t `HS.member` inUse s = go ts | otherwise = use t go [] = error "Esqueleto/Sql/newIdentFor: never here" go (possibilities orig) possibilities t = t : map addNum [2..] where addNum :: Int -> T.Text addNum = T.append t . T.pack . show use t = do S.modify (\s -> s { inUse = HS.insert t (inUse s) }) return (I t) -- | Information needed to escape and use identifiers.
673
newIdentFor :: DBName -> SqlQuery Ident newIdentFor = Q . lift . try . unDBName where try orig = do s <- S.get let go (t:ts) | t `HS.member` inUse s = go ts | otherwise = use t go [] = error "Esqueleto/Sql/newIdentFor: never here" go (possibilities orig) possibilities t = t : map addNum [2..] where addNum :: Int -> T.Text addNum = T.append t . T.pack . show use t = do S.modify (\s -> s { inUse = HS.insert t (inUse s) }) return (I t) -- | Information needed to escape and use identifiers.
603
newIdentFor = Q . lift . try . unDBName where try orig = do s <- S.get let go (t:ts) | t `HS.member` inUse s = go ts | otherwise = use t go [] = error "Esqueleto/Sql/newIdentFor: never here" go (possibilities orig) possibilities t = t : map addNum [2..] where addNum :: Int -> T.Text addNum = T.append t . T.pack . show use t = do S.modify (\s -> s { inUse = HS.insert t (inUse s) }) return (I t) -- | Information needed to escape and use identifiers.
563
true
true
0
14
224
239
116
123
null
null
nevrenato/Hets_Fork
CASL/ToDoc.hs
gpl-2.0
mkJunctDoc :: FormExtension f => Bool -> FORMULA f -> Doc -> Doc mkJunctDoc b f = if isJunct f || b && isQuant f then parens else id
132
mkJunctDoc :: FormExtension f => Bool -> FORMULA f -> Doc -> Doc mkJunctDoc b f = if isJunct f || b && isQuant f then parens else id
132
mkJunctDoc b f = if isJunct f || b && isQuant f then parens else id
67
false
true
0
8
28
60
29
31
null
null
AndrewRademacher/hasql-postgres
library/Hasql/Postgres/ErrorCode.hs
mit
-- | Code \"2201F\". invalid_argument_for_power_function :: ErrorCode = "2201F"
96
invalid_argument_for_power_function :: ErrorCode = "2201F"
75
invalid_argument_for_power_function :: ErrorCode = "2201F"
75
true
false
0
5
25
12
6
6
null
null
vincenthz/hs-crypto-random
Crypto/Random/Entropy.hs
bsd-3-clause
createTestEntropyPool :: ByteString -> EntropyPool createTestEntropyPool bs | B.null bs = error "cannot create entropy pool from an empty bytestring" | otherwise = unsafePerformIO $ createEntropyPoolWith defaultPoolSize [EntropyBackend $ TestEntropySource bs]
267
createTestEntropyPool :: ByteString -> EntropyPool createTestEntropyPool bs | B.null bs = error "cannot create entropy pool from an empty bytestring" | otherwise = unsafePerformIO $ createEntropyPoolWith defaultPoolSize [EntropyBackend $ TestEntropySource bs]
267
createTestEntropyPool bs | B.null bs = error "cannot create entropy pool from an empty bytestring" | otherwise = unsafePerformIO $ createEntropyPoolWith defaultPoolSize [EntropyBackend $ TestEntropySource bs]
216
false
true
1
9
38
58
27
31
null
null
bacchanalia/KitchenSink
KitchenSink/Qualified.hs
gpl-3.0
-- |'VG.init' vg_init = VG.init
31
vg_init = VG.init
17
vg_init = VG.init
17
true
false
0
5
4
9
5
4
null
null
davidspies/regret-solver
game/src/Data/Dist.hs
gpl-3.0
withProbability :: Dist a -> Dist (Probability, a) withProbability (Bottom d) = Bottom (1, d)
93
withProbability :: Dist a -> Dist (Probability, a) withProbability (Bottom d) = Bottom (1, d)
93
withProbability (Bottom d) = Bottom (1, d)
42
false
true
0
9
14
49
24
25
null
null
utky/lycopene
src/Lycopene/Print.hs
apache-2.0
(<&>) :: Printer a -> Printer a -> Printer a (<&>) = pappend
60
(<&>) :: Printer a -> Printer a -> Printer a (<&>) = pappend
60
(<&>) = pappend
15
false
true
0
8
12
38
18
20
null
null
ezyang/ghc
compiler/prelude/THNames.hs
bsd-3-clause
staticEIdKey = mkPreludeMiscIdUnique 298
45
staticEIdKey = mkPreludeMiscIdUnique 298
45
staticEIdKey = mkPreludeMiscIdUnique 298
45
false
false
0
5
8
9
4
5
null
null
garetxe/cabal
cabal-install/tests/UnitTests/Distribution/Client/Dependency/Modular/Solver.hs
bsd-3-clause
-- | cabal must set enable-lib to false in order to avoid the unavailable -- dependency. Flags are true by default. The flag choice causes "pkg" to -- depend on "false-dep". testBuildable :: String -> ExampleDependency -> TestTree testBuildable testName unavailableDep = runTest $ mkTestExtLangPC (Just []) (Just []) [] db testName ["pkg"] expected where expected = Just [("false-dep", 1), ("pkg", 1)] db = [ Right $ exAv "pkg" 1 [ unavailableDep , ExFlag "enable-lib" (Buildable []) NotBuildable , ExTest "test" [exFlag "enable-lib" [ExAny "true-dep"] [ExAny "false-dep"]] ] , Right $ exAv "true-dep" 1 [] , Right $ exAv "false-dep" 1 [] ] -- | cabal must choose -flag1 +flag2 for "pkg", which requires packages -- "flag1-false" and "flag2-true".
934
testBuildable :: String -> ExampleDependency -> TestTree testBuildable testName unavailableDep = runTest $ mkTestExtLangPC (Just []) (Just []) [] db testName ["pkg"] expected where expected = Just [("false-dep", 1), ("pkg", 1)] db = [ Right $ exAv "pkg" 1 [ unavailableDep , ExFlag "enable-lib" (Buildable []) NotBuildable , ExTest "test" [exFlag "enable-lib" [ExAny "true-dep"] [ExAny "false-dep"]] ] , Right $ exAv "true-dep" 1 [] , Right $ exAv "false-dep" 1 [] ] -- | cabal must choose -flag1 +flag2 for "pkg", which requires packages -- "flag1-false" and "flag2-true".
760
testBuildable testName unavailableDep = runTest $ mkTestExtLangPC (Just []) (Just []) [] db testName ["pkg"] expected where expected = Just [("false-dep", 1), ("pkg", 1)] db = [ Right $ exAv "pkg" 1 [ unavailableDep , ExFlag "enable-lib" (Buildable []) NotBuildable , ExTest "test" [exFlag "enable-lib" [ExAny "true-dep"] [ExAny "false-dep"]] ] , Right $ exAv "true-dep" 1 [] , Right $ exAv "false-dep" 1 [] ] -- | cabal must choose -flag1 +flag2 for "pkg", which requires packages -- "flag1-false" and "flag2-true".
703
true
true
3
14
305
208
107
101
null
null
FranklinChen/stable-maps
System/Mem/StableName/Map.hs
bsd-3-clause
null :: Map f -> Bool null (Map m) = IntMap.null m
50
null :: Map f -> Bool null (Map m) = IntMap.null m
50
null (Map m) = IntMap.null m
28
false
true
0
7
11
32
15
17
null
null
adinapoli/Shelly.hs
test/src/Help.hs
bsd-3-clause
within_dir :: FilePath -> Sh a -> Sh a within_dir d action = with_dir d $ chdir d action
90
within_dir :: FilePath -> Sh a -> Sh a within_dir d action = with_dir d $ chdir d action
90
within_dir d action = with_dir d $ chdir d action
51
false
true
0
7
20
42
19
23
null
null
Noeda/dfterm3
src/Dfterm3/CP437ToUnicode.hs
isc
cp437ToUnicode 10 = '\x25d9'
28
cp437ToUnicode 10 = '\x25d9'
28
cp437ToUnicode 10 = '\x25d9'
28
false
false
0
5
3
9
4
5
null
null
parsonsmatt/lambda
src/Lambda/Core.hs
bsd-3-clause
(~>) :: String -> Lambda -> Lambda v ~> x = Wrap (Abs (Variable v) x)
69
(~>) :: String -> Lambda -> Lambda v ~> x = Wrap (Abs (Variable v) x)
69
v ~> x = Wrap (Abs (Variable v) x)
34
false
true
0
9
15
45
22
23
null
null
tabemann/amphibian
src_old/Network/IRC/Client/Amphibian/Commands.hs
bsd-3-clause
rpl_NONE :: MessageCommand rpl_NONE = "300"
43
rpl_NONE :: MessageCommand rpl_NONE = "300"
43
rpl_NONE = "300"
16
false
true
0
4
5
11
6
5
null
null
liamoc/composition-tree
Data/Compositions/Internal.hs
bsd-3-clause
-- | Convert a compositions list into a list of elements. The other direction -- is provided in the 'Data.Foldable.Foldable' instance. This will perform O(n log n) element compositions. -- -- __Isomorphism to lists__: -- -- prop> \(Compositions x) -> fromList (toList x) == x -- prop> \(x :: [Element]) -> toList (fromList x) == x -- -- __Is monoid morphism__: -- -- prop> fromList ([] :: [Element]) == mempty -- prop> \(a :: [Element]) b -> fromList (a ++ b) == fromList a <> fromList b fromList :: Monoid a => [a] -> Compositions a fromList = mconcat . map singleton
570
fromList :: Monoid a => [a] -> Compositions a fromList = mconcat . map singleton
80
fromList = mconcat . map singleton
34
true
true
0
7
103
47
29
18
null
null
juodaspaulius/clafer-old-customBNFC
src/Language/Clafer/Intermediate/Analysis.hs
mit
runListT_ :: Monad m => ListT m a -> m () runListT_ l = runListT l >> return ()
79
runListT_ :: Monad m => ListT m a -> m () runListT_ l = runListT l >> return ()
79
runListT_ l = runListT l >> return ()
37
false
true
0
8
18
47
21
26
null
null
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Haskell/basic_haskell/enumFromThenTo_1.hs
mit
primCmpInt (Neg x) (Neg y) = primCmpNat y x
43
primCmpInt (Neg x) (Neg y) = primCmpNat y x
43
primCmpInt (Neg x) (Neg y) = primCmpNat y x
43
false
false
0
7
8
28
13
15
null
null
beni55/cryptol
src/Cryptol/TypeCheck/Solver/Numeric/SimplifyExpr.hs
bsd-3-clause
crySimpExprStep :: Expr -> Maybe Expr crySimpExprStep e = case crySimpExprStep1 e of Just e1 -> Just e1 Nothing -> do let e1 = normSum e guard (e /= e1) return e1 -- | Make a simplification step, assuming the expression is well-formed.
282
crySimpExprStep :: Expr -> Maybe Expr crySimpExprStep e = case crySimpExprStep1 e of Just e1 -> Just e1 Nothing -> do let e1 = normSum e guard (e /= e1) return e1 -- | Make a simplification step, assuming the expression is well-formed.
282
crySimpExprStep e = case crySimpExprStep1 e of Just e1 -> Just e1 Nothing -> do let e1 = normSum e guard (e /= e1) return e1 -- | Make a simplification step, assuming the expression is well-formed.
244
false
true
0
13
89
78
35
43
null
null
kovach/web
res2/Unification.hs
gpl-2.0
freshTerm (Variable var) e@(Env{..}) = let f = Ref (R freshName) in (f, e{freshName = freshName + 1, context = M.insert var f context})
139
freshTerm (Variable var) e@(Env{..}) = let f = Ref (R freshName) in (f, e{freshName = freshName + 1, context = M.insert var f context})
139
freshTerm (Variable var) e@(Env{..}) = let f = Ref (R freshName) in (f, e{freshName = freshName + 1, context = M.insert var f context})
139
false
false
0
11
27
82
43
39
null
null
krakrjak/ImplicitCAD
Graphics/Implicit/ExtOpenScad/Eval/Expr.hs
agpl-3.0
patMatch Wild _ = Just []
25
patMatch Wild _ = Just []
25
patMatch Wild _ = Just []
25
false
false
0
6
5
16
7
9
null
null
chrisdotcode/hackage-server
Distribution/Server/Framework/BackupRestore.hs
bsd-3-clause
fromEntry :: Tar.Entry -> Import () fromEntry entry = case Tar.entryContent entry of Tar.NormalFile bytes _ -> fromFile (Tar.entryPath entry) bytes Tar.Directory {} -> return () -- ignore directory entries Tar.SymbolicLink target -> fromLink (Tar.entryPath entry) (Tar.fromLinkTarget target) _ -> throwError $ "Unexpected entry in backup tarball: " ++ Tar.entryPath entry
407
fromEntry :: Tar.Entry -> Import () fromEntry entry = case Tar.entryContent entry of Tar.NormalFile bytes _ -> fromFile (Tar.entryPath entry) bytes Tar.Directory {} -> return () -- ignore directory entries Tar.SymbolicLink target -> fromLink (Tar.entryPath entry) (Tar.fromLinkTarget target) _ -> throwError $ "Unexpected entry in backup tarball: " ++ Tar.entryPath entry
407
fromEntry entry = case Tar.entryContent entry of Tar.NormalFile bytes _ -> fromFile (Tar.entryPath entry) bytes Tar.Directory {} -> return () -- ignore directory entries Tar.SymbolicLink target -> fromLink (Tar.entryPath entry) (Tar.fromLinkTarget target) _ -> throwError $ "Unexpected entry in backup tarball: " ++ Tar.entryPath entry
371
false
true
0
11
86
129
61
68
null
null
thomasjm/ot.hs
test/Control/OperationalTransformation/Text0/Specs.hs
mit
apply :: T.Text -> Text0Operation -> T.Text apply input op = case C.apply op input of Left err -> error err Right x -> x
124
apply :: T.Text -> Text0Operation -> T.Text apply input op = case C.apply op input of Left err -> error err Right x -> x
124
apply input op = case C.apply op input of Left err -> error err Right x -> x
80
false
true
0
8
28
60
28
32
null
null
lorcanmcdonald/mars
src/Mars/Command/Ls.hs
bsd-3-clause
ansiColor Red = ansiWrap "31"
29
ansiColor Red = ansiWrap "31"
29
ansiColor Red = ansiWrap "31"
29
false
false
0
5
4
12
5
7
null
null
JacquesCarette/literate-scientific-software
code/drasil-example/Drasil/SSP/DataDefs.hs
bsd-2-clause
--Notes --FIXME: fill empty lists in lengthBQD :: QDefinition lengthBQD = mkQuantDef baseWthX lengthBEqn
105
lengthBQD :: QDefinition lengthBQD = mkQuantDef baseWthX lengthBEqn
67
lengthBQD = mkQuantDef baseWthX lengthBEqn
42
true
true
0
6
14
26
11
15
null
null
NerdGGuy/wai-middleware-session-stateless
src/Network/Wai/Middleware/Session/Stateless.hs
mit
clearSession :: [ByteString] -> (Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived) -> Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived clearSession x app req = foldr (\x' a -> setNullCookie x' a) app x req
307
clearSession :: [ByteString] -> (Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived) -> Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived clearSession x app req = foldr (\x' a -> setNullCookie x' a) app x req
307
clearSession x app req = foldr (\x' a -> setNullCookie x' a) app x req
70
false
true
0
12
101
98
49
49
null
null
denibertovic/haskell
kubernetes/lib/Kubernetes/OpenAPI/ModelLens.hs
bsd-3-clause
-- | 'v1ComponentStatusKind' Lens v1ComponentStatusKindL :: Lens_' V1ComponentStatus (Maybe Text) v1ComponentStatusKindL f V1ComponentStatus{..} = (\v1ComponentStatusKind -> V1ComponentStatus { v1ComponentStatusKind, ..} ) <$> f v1ComponentStatusKind
250
v1ComponentStatusKindL :: Lens_' V1ComponentStatus (Maybe Text) v1ComponentStatusKindL f V1ComponentStatus{..} = (\v1ComponentStatusKind -> V1ComponentStatus { v1ComponentStatusKind, ..} ) <$> f v1ComponentStatusKind
216
v1ComponentStatusKindL f V1ComponentStatus{..} = (\v1ComponentStatusKind -> V1ComponentStatus { v1ComponentStatusKind, ..} ) <$> f v1ComponentStatusKind
152
true
true
1
8
23
62
30
32
null
null
AlbinTheander/oden
test/Oden/Compiler/InstantiateSpec.hs
mit
recordPoly :: Core.Expr Poly.Type recordPoly = Core.RecordInitializer missing (Poly.TRecord missing (Poly.RExtension missing (Identifier "foo") tvarA (Poly.REmpty missing))) [Core.FieldInitializer missing (Identifier "foo") (Core.Symbol missing (Identifier "x") tvarA)]
283
recordPoly :: Core.Expr Poly.Type recordPoly = Core.RecordInitializer missing (Poly.TRecord missing (Poly.RExtension missing (Identifier "foo") tvarA (Poly.REmpty missing))) [Core.FieldInitializer missing (Identifier "foo") (Core.Symbol missing (Identifier "x") tvarA)]
283
recordPoly = Core.RecordInitializer missing (Poly.TRecord missing (Poly.RExtension missing (Identifier "foo") tvarA (Poly.REmpty missing))) [Core.FieldInitializer missing (Identifier "foo") (Core.Symbol missing (Identifier "x") tvarA)]
249
false
true
0
11
39
108
51
57
null
null
lukexi/cabal
Cabal/Distribution/PackageDescription/Configuration.hs
bsd-3-clause
libFillInDefaults :: Library -> Library libFillInDefaults lib@(Library { libBuildInfo = bi }) = lib { libBuildInfo = biFillInDefaults bi }
142
libFillInDefaults :: Library -> Library libFillInDefaults lib@(Library { libBuildInfo = bi }) = lib { libBuildInfo = biFillInDefaults bi }
142
libFillInDefaults lib@(Library { libBuildInfo = bi }) = lib { libBuildInfo = biFillInDefaults bi }
102
false
true
0
10
23
44
24
20
null
null
edom/ptt
src/Haskell/Interpret/Expression.hs
apache-2.0
substitute :: String -> Expr -> Expr -> Expr substitute name rep = go where go (Var n) | name == n = rep go (App a b) = App (go a) (go b) go (Lam n body) | name /= n = Lam n (go body) go x = x
228
substitute :: String -> Expr -> Expr -> Expr substitute name rep = go where go (Var n) | name == n = rep go (App a b) = App (go a) (go b) go (Lam n body) | name /= n = Lam n (go body) go x = x
228
substitute name rep = go where go (Var n) | name == n = rep go (App a b) = App (go a) (go b) go (Lam n body) | name /= n = Lam n (go body) go x = x
183
false
true
2
8
86
131
63
68
null
null
drmaruyama/Paraiso
Language/Paraiso/OM/Builder/Boolean.hs
bsd-3-clause
-- | Less than lt :: CompareOp lt = mkOp2B A.LT
47
lt :: CompareOp lt = mkOp2B A.LT
32
lt = mkOp2B A.LT
16
true
true
0
6
10
23
10
13
null
null
NICTA/validation
test/hunit_tests.hs
bsd-3-clause
main :: IO () main = do c <- runTestTT tests when (errors c > 0 || failures c > 0) exitFailure
98
main :: IO () main = do c <- runTestTT tests when (errors c > 0 || failures c > 0) exitFailure
98
main = do c <- runTestTT tests when (errors c > 0 || failures c > 0) exitFailure
84
false
true
0
13
25
61
26
35
null
null
bergmark/purescript
psc-make/Main.hs
mit
mkdirp :: FilePath -> IO () mkdirp = createDirectoryIfMissing True . takeDirectory
82
mkdirp :: FilePath -> IO () mkdirp = createDirectoryIfMissing True . takeDirectory
82
mkdirp = createDirectoryIfMissing True . takeDirectory
54
false
true
0
7
11
27
13
14
null
null
kmate/HaRe
old/testing/addCon/B1AST.hs
bsd-3-clause
addedC4 = error "added C4 Float to Data1"
41
addedC4 = error "added C4 Float to Data1"
41
addedC4 = error "added C4 Float to Data1"
41
false
false
0
5
7
9
4
5
null
null
keera-studios/hsQt
Qtc/Gui/QStyleOptionViewItem.hs
bsd-2-clause
setDecorationAlignment :: QStyleOptionViewItem a -> ((Alignment)) -> IO () setDecorationAlignment x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QStyleOptionViewItem_setDecorationAlignment cobj_x0 (toCLong $ qFlags_toInt x1)
228
setDecorationAlignment :: QStyleOptionViewItem a -> ((Alignment)) -> IO () setDecorationAlignment x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QStyleOptionViewItem_setDecorationAlignment cobj_x0 (toCLong $ qFlags_toInt x1)
228
setDecorationAlignment x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QStyleOptionViewItem_setDecorationAlignment cobj_x0 (toCLong $ qFlags_toInt x1)
153
false
true
2
9
29
74
35
39
null
null
luzhuomi/cpp-obs
Language/C/Obfuscate/SSA.hs
apache-2.0
{- The SSA Language ___ _ _ (Prog) p::= t x (t x) { d b } (Decl) d::= t x _ (Block) b::= l:{s} | l:{i,s} (Stmts) s::= x = e; s | goto l; | return e; | e; s | if e { s } else { s } _ (Phi) i::= x = phi(g) _ (Exp) e::= v | e(e) (Labelled args) g::= l:v (Labels) l::= l0 | l1 | ... (Values) v::= x | c (Types) t::= int | bool | t* | t[] | void (Loop Envs) \delta = (l_if, e, l_t, l_f) -} {- prettyLB :: LabeledBlock -> String prettyLB lb = "LB {" ++ "phis:" ++ (show (phis lb)) ++ ", stmts:" ++ (show (lb_stmts lb)) ++ "}" prettySSA :: SSA -> String prettySSA ssa = "scope_decls :" ++ (render $ pretty (scoped_decls ssa)) ++ "\n" ++ "labelled_blocks :" ++ (concatMap (\(label, lb) -> (render $ pretty label) ++ ":" ++ (prettyLB lb) ++ ",\n") (M.toList $ labelled_blocks ssa)) -} -- TODO : incorporating the formal args as allVars buildSSA :: CFG -> [Ident] -> SSA buildSSA cfg fargs = case buildDTree cfg of { Nothing -> error "failed to build dominance frontier table" ; Just (dtree, pcm, sdom) -> let dft = buildDF' (dtree, pcm, sdom, cfg) allVarsUsed = allVars cfg -- all vars used in this function, local declared, formal args and global allLocalVars = S.fromList (localDeclaredVars cfg) -- all locally declared vars in this function -- build a mapping from node label to a -- set of variables that need to be merged via phi func -- (note: variables are not yet renamed) phiLocMap :: M.Map Ident -- node label [Ident] -- variable idents phiLocMap = foldl (\m (label,v) -> case M.lookup label m of { Nothing -> M.insert label [v] m ; Just vs -> M.update (\_ -> Just $ vs ++ [v]) label m }) M.empty $ do { var <- allVarsUsed -- todo: shall we exclude global vars? ; let phiLocs = phiLoc var cfg dft ; phiLoc <- phiLocs ; return (phiLoc, var) } -- given a node's label (as the starting point of the search) -- a variable (which is not yet renamed), the dom tree -- to find the label of the node which contains preceding definition of the variable precDef :: Ident -> Ident -> DTree -> CFG -> Maybe Ident precDef currLbl var dt cfg = case M.lookup currLbl phiLocMap of { Just vs | var `elem` vs -> Just currLbl -- the var is reassigned through a phi function in the current block ; _ -> -- the var could be reassigned locally case M.lookup currLbl cfg of { Nothing -> error $ "Fatal: Label " ++ show currLbl ++ " is not found in the CFG" ; Just node | var `elem` (lVars node) -> Just currLbl ; Just _ | otherwise -> case parentOf currLbl dt of { Nothing | (var `S.member` formalArguments) || (var `S.member` allLocalVars) -> -- no parent: this is block 0 Just currLbl -- this could be due to a nested scope var in some inner block of if else or while. -- we will move it to block 0 (the init block) -- e.g. refer to the fibiter.c, the variable t -- this make sense for block 0, all local variables should be lifted and declared in block 0 | otherwise -> Nothing -- as this is to be decided later, it could be a global var ; Just parentLbl -> precDef parentLbl var dt cfg } } } formalArguments = S.fromList fargs -- renaming all the variables based on the individual labelled blocks -- and move all the declaration out. eachNode :: SSA -> (Ident, Node) -> SSA eachNode ssa (currLbl, node) = case node of { Node statements lvars rvars local_decls precLbls succLbls switchOrLoop -> let phis_ :: [( Ident -- ^ var being redefined (not yet renamed) , [(Ident, Maybe Ident)])] -- ^ (incoming block lbl, lbl of preceding blk in which var is redefined) phis_ = case M.lookup currLbl phiLocMap of { Nothing -> [] ; Just phiVars -> map (\v -> let lastDefs = map (\precLbl -> let mb_lblVarDefined = precDef precLbl v dtree cfg in (precLbl, mb_lblVarDefined)) precLbls in (v, lastDefs) -- find the preceding node and the renamed variable ) [ v | v <- phiVars, not (v `elem` local_decls) ] } -- build the renaming state from the rhs vars with the precDef -- or from phis_ rnState :: RenameState rnState = let -- todo, the local_decls should be filtered away from the rVars and local_decls should be appended with the current node label rnEnvLocal = M.fromList $ map (\var -> (var, var `app` currLbl)) local_decls rvarsNotLocal = filter (\var -> not (var `M.member` rnEnvLocal)) rvars rnEnv = case precLbls of { [] -> -- entry block -- todo: check, shouldn't be the formal arg? M.fromList (map (\var -> if (var `S.member` formalArguments) || (var `S.member` allLocalVars) then (var, var `app` currLbl) else (var, var) -- global ) rvarsNotLocal) ; [precLbl] -> -- non-phi block M.fromList (map (\var -> case precDef precLbl var dtree cfg of { Just def_lbl -> (var, var `app` def_lbl) ; Nothing -> -- it is a formal arg and should be redefined in block 0 if (var `S.member` formalArguments) || (var `S.member` allLocalVars) then (var, var `app` (iid (labPref ++ "0"))) else (var, var) -- global }) rvarsNotLocal) ; precLbls -> -- phi block M.fromList (map (\var -> case lookup var phis_ of { Just _ -> (var, var `app` currLbl) ; Nothing -> -- not in phi, it's a formal arg and should be redefined in block 0 -- (var, var `app` (iid (labPref ++ "0"))) -- updated: the above is not true, look at sort example, var j in node 7. (7 has preds 4 and 6, both do not redefine j, -- node 4 & 6 share a common ancestor 3 where j is redefined case filter isJust $ map (\precLbl -> precDef precLbl var dtree cfg) precLbls of { [] -> -- var is global (var, var) ; (def:defs) | all (\d -> d == def) defs -> let (Just def_lbl) = def in (var, var `app` def_lbl) | otherwise -> error $ "buildSSA: rnState variable " ++ (show var) ++ " has a conflicting preceding definition " ++ (show (def:defs)) ++ "\n current Label " ++ (show currLbl) ++ "\n CFG" ++ (show cfg) ++ "\n Phi loca Map" ++ (show phiLocMap) ++ "\n DFT" ++ (show dft) } }) rvarsNotLocal) } in RSt currLbl (rnEnvLocal `M.union` rnEnv) [] [] allLocalVars formalArguments renamedBlkItems_decls_containers :: ([AST.CCompoundBlockItem N.NodeInfo], [AST.CDeclaration N.NodeInfo], [Ident]) renamedBlkItems_decls_containers = renamePure rnState statements (renamedBlkItems, new_decls, containers) = renamedBlkItems_decls_containers -- scalar copy for container variables eg. say a[] then a[i] = a[j] --> a_2 = a_1; a_2[i_2] = a_1[j_2]; -- and insert them to the begining of the labeled block scalar_copy :: [Ident] -> [AST.CCompoundBlockItem N.NodeInfo] scalar_copy containers = concatMap (\container -> -- lookup the last def of container variable, similar to building rnState let containers' = case precLbls of { [] -> [] -- entry block ; [precLbl] -> case precDef precLbl container dtree cfg of { Just def_lbl -> [container `app` def_lbl] ; Nothing -> [container `app` (iid (labPref ++ "0"))] } ; precLbls -> case lookup container phis_ of -- phi block { Just _ -> [] -- should be covered by the phi translations ; Nothing -> case filter isJust $ map (\precLbl -> precDef precLbl container dtree cfg) precLbls of { [] -> error "impossible" ; (def:defs) | (all (\d -> d == def) defs) -> let (Just def_lbl) = def in [container `app` def_lbl] | otherwise -> error $ "buildSSA: scalar copy variable " ++ (show container) ++ " has a conflicting preceding definition" } } } in map (\container' -> AST.CBlockStmt (AST.CExpr (Just ((cvar (container `app` currLbl)) .=. (cvar container'))) N.undefNode)) containers' ) containers isLoop x = case x of { (IsLoop _ _) -> True ; _ -> False } labelled_block = LB phis_ ((scalar_copy containers) ++ renamedBlkItems) precLbls succLbls (lVars node) (rVars node) containers (isLoop switchOrLoop) in ssa{ labelled_blocks = M.insert currLbl labelled_block (labelled_blocks ssa) , scoped_decls = (scoped_decls ssa) ++ new_decls } } ssa = foldl eachNode (SSA [] M.empty sdom allLocalVars formalArguments) $ M.toList cfg io = unsafePerformIO $ print cfg >> print ssa >> print dft >> print pcm >> print dtree -- (map (\var -> (var, modLoc var cfg)) allVarsUsed) >> print dtree >> print dft >> print pcm >> print sdom in ssa -- the scoped_decls were not yet renamed which will be renamed in SSA to CPS convertion }
13,211
buildSSA :: CFG -> [Ident] -> SSA buildSSA cfg fargs = case buildDTree cfg of { Nothing -> error "failed to build dominance frontier table" ; Just (dtree, pcm, sdom) -> let dft = buildDF' (dtree, pcm, sdom, cfg) allVarsUsed = allVars cfg -- all vars used in this function, local declared, formal args and global allLocalVars = S.fromList (localDeclaredVars cfg) -- all locally declared vars in this function -- build a mapping from node label to a -- set of variables that need to be merged via phi func -- (note: variables are not yet renamed) phiLocMap :: M.Map Ident -- node label [Ident] -- variable idents phiLocMap = foldl (\m (label,v) -> case M.lookup label m of { Nothing -> M.insert label [v] m ; Just vs -> M.update (\_ -> Just $ vs ++ [v]) label m }) M.empty $ do { var <- allVarsUsed -- todo: shall we exclude global vars? ; let phiLocs = phiLoc var cfg dft ; phiLoc <- phiLocs ; return (phiLoc, var) } -- given a node's label (as the starting point of the search) -- a variable (which is not yet renamed), the dom tree -- to find the label of the node which contains preceding definition of the variable precDef :: Ident -> Ident -> DTree -> CFG -> Maybe Ident precDef currLbl var dt cfg = case M.lookup currLbl phiLocMap of { Just vs | var `elem` vs -> Just currLbl -- the var is reassigned through a phi function in the current block ; _ -> -- the var could be reassigned locally case M.lookup currLbl cfg of { Nothing -> error $ "Fatal: Label " ++ show currLbl ++ " is not found in the CFG" ; Just node | var `elem` (lVars node) -> Just currLbl ; Just _ | otherwise -> case parentOf currLbl dt of { Nothing | (var `S.member` formalArguments) || (var `S.member` allLocalVars) -> -- no parent: this is block 0 Just currLbl -- this could be due to a nested scope var in some inner block of if else or while. -- we will move it to block 0 (the init block) -- e.g. refer to the fibiter.c, the variable t -- this make sense for block 0, all local variables should be lifted and declared in block 0 | otherwise -> Nothing -- as this is to be decided later, it could be a global var ; Just parentLbl -> precDef parentLbl var dt cfg } } } formalArguments = S.fromList fargs -- renaming all the variables based on the individual labelled blocks -- and move all the declaration out. eachNode :: SSA -> (Ident, Node) -> SSA eachNode ssa (currLbl, node) = case node of { Node statements lvars rvars local_decls precLbls succLbls switchOrLoop -> let phis_ :: [( Ident -- ^ var being redefined (not yet renamed) , [(Ident, Maybe Ident)])] -- ^ (incoming block lbl, lbl of preceding blk in which var is redefined) phis_ = case M.lookup currLbl phiLocMap of { Nothing -> [] ; Just phiVars -> map (\v -> let lastDefs = map (\precLbl -> let mb_lblVarDefined = precDef precLbl v dtree cfg in (precLbl, mb_lblVarDefined)) precLbls in (v, lastDefs) -- find the preceding node and the renamed variable ) [ v | v <- phiVars, not (v `elem` local_decls) ] } -- build the renaming state from the rhs vars with the precDef -- or from phis_ rnState :: RenameState rnState = let -- todo, the local_decls should be filtered away from the rVars and local_decls should be appended with the current node label rnEnvLocal = M.fromList $ map (\var -> (var, var `app` currLbl)) local_decls rvarsNotLocal = filter (\var -> not (var `M.member` rnEnvLocal)) rvars rnEnv = case precLbls of { [] -> -- entry block -- todo: check, shouldn't be the formal arg? M.fromList (map (\var -> if (var `S.member` formalArguments) || (var `S.member` allLocalVars) then (var, var `app` currLbl) else (var, var) -- global ) rvarsNotLocal) ; [precLbl] -> -- non-phi block M.fromList (map (\var -> case precDef precLbl var dtree cfg of { Just def_lbl -> (var, var `app` def_lbl) ; Nothing -> -- it is a formal arg and should be redefined in block 0 if (var `S.member` formalArguments) || (var `S.member` allLocalVars) then (var, var `app` (iid (labPref ++ "0"))) else (var, var) -- global }) rvarsNotLocal) ; precLbls -> -- phi block M.fromList (map (\var -> case lookup var phis_ of { Just _ -> (var, var `app` currLbl) ; Nothing -> -- not in phi, it's a formal arg and should be redefined in block 0 -- (var, var `app` (iid (labPref ++ "0"))) -- updated: the above is not true, look at sort example, var j in node 7. (7 has preds 4 and 6, both do not redefine j, -- node 4 & 6 share a common ancestor 3 where j is redefined case filter isJust $ map (\precLbl -> precDef precLbl var dtree cfg) precLbls of { [] -> -- var is global (var, var) ; (def:defs) | all (\d -> d == def) defs -> let (Just def_lbl) = def in (var, var `app` def_lbl) | otherwise -> error $ "buildSSA: rnState variable " ++ (show var) ++ " has a conflicting preceding definition " ++ (show (def:defs)) ++ "\n current Label " ++ (show currLbl) ++ "\n CFG" ++ (show cfg) ++ "\n Phi loca Map" ++ (show phiLocMap) ++ "\n DFT" ++ (show dft) } }) rvarsNotLocal) } in RSt currLbl (rnEnvLocal `M.union` rnEnv) [] [] allLocalVars formalArguments renamedBlkItems_decls_containers :: ([AST.CCompoundBlockItem N.NodeInfo], [AST.CDeclaration N.NodeInfo], [Ident]) renamedBlkItems_decls_containers = renamePure rnState statements (renamedBlkItems, new_decls, containers) = renamedBlkItems_decls_containers -- scalar copy for container variables eg. say a[] then a[i] = a[j] --> a_2 = a_1; a_2[i_2] = a_1[j_2]; -- and insert them to the begining of the labeled block scalar_copy :: [Ident] -> [AST.CCompoundBlockItem N.NodeInfo] scalar_copy containers = concatMap (\container -> -- lookup the last def of container variable, similar to building rnState let containers' = case precLbls of { [] -> [] -- entry block ; [precLbl] -> case precDef precLbl container dtree cfg of { Just def_lbl -> [container `app` def_lbl] ; Nothing -> [container `app` (iid (labPref ++ "0"))] } ; precLbls -> case lookup container phis_ of -- phi block { Just _ -> [] -- should be covered by the phi translations ; Nothing -> case filter isJust $ map (\precLbl -> precDef precLbl container dtree cfg) precLbls of { [] -> error "impossible" ; (def:defs) | (all (\d -> d == def) defs) -> let (Just def_lbl) = def in [container `app` def_lbl] | otherwise -> error $ "buildSSA: scalar copy variable " ++ (show container) ++ " has a conflicting preceding definition" } } } in map (\container' -> AST.CBlockStmt (AST.CExpr (Just ((cvar (container `app` currLbl)) .=. (cvar container'))) N.undefNode)) containers' ) containers isLoop x = case x of { (IsLoop _ _) -> True ; _ -> False } labelled_block = LB phis_ ((scalar_copy containers) ++ renamedBlkItems) precLbls succLbls (lVars node) (rVars node) containers (isLoop switchOrLoop) in ssa{ labelled_blocks = M.insert currLbl labelled_block (labelled_blocks ssa) , scoped_decls = (scoped_decls ssa) ++ new_decls } } ssa = foldl eachNode (SSA [] M.empty sdom allLocalVars formalArguments) $ M.toList cfg io = unsafePerformIO $ print cfg >> print ssa >> print dft >> print pcm >> print dtree -- (map (\var -> (var, modLoc var cfg)) allVarsUsed) >> print dtree >> print dft >> print pcm >> print sdom in ssa -- the scoped_decls were not yet renamed which will be renamed in SSA to CPS convertion }
12,264
buildSSA cfg fargs = case buildDTree cfg of { Nothing -> error "failed to build dominance frontier table" ; Just (dtree, pcm, sdom) -> let dft = buildDF' (dtree, pcm, sdom, cfg) allVarsUsed = allVars cfg -- all vars used in this function, local declared, formal args and global allLocalVars = S.fromList (localDeclaredVars cfg) -- all locally declared vars in this function -- build a mapping from node label to a -- set of variables that need to be merged via phi func -- (note: variables are not yet renamed) phiLocMap :: M.Map Ident -- node label [Ident] -- variable idents phiLocMap = foldl (\m (label,v) -> case M.lookup label m of { Nothing -> M.insert label [v] m ; Just vs -> M.update (\_ -> Just $ vs ++ [v]) label m }) M.empty $ do { var <- allVarsUsed -- todo: shall we exclude global vars? ; let phiLocs = phiLoc var cfg dft ; phiLoc <- phiLocs ; return (phiLoc, var) } -- given a node's label (as the starting point of the search) -- a variable (which is not yet renamed), the dom tree -- to find the label of the node which contains preceding definition of the variable precDef :: Ident -> Ident -> DTree -> CFG -> Maybe Ident precDef currLbl var dt cfg = case M.lookup currLbl phiLocMap of { Just vs | var `elem` vs -> Just currLbl -- the var is reassigned through a phi function in the current block ; _ -> -- the var could be reassigned locally case M.lookup currLbl cfg of { Nothing -> error $ "Fatal: Label " ++ show currLbl ++ " is not found in the CFG" ; Just node | var `elem` (lVars node) -> Just currLbl ; Just _ | otherwise -> case parentOf currLbl dt of { Nothing | (var `S.member` formalArguments) || (var `S.member` allLocalVars) -> -- no parent: this is block 0 Just currLbl -- this could be due to a nested scope var in some inner block of if else or while. -- we will move it to block 0 (the init block) -- e.g. refer to the fibiter.c, the variable t -- this make sense for block 0, all local variables should be lifted and declared in block 0 | otherwise -> Nothing -- as this is to be decided later, it could be a global var ; Just parentLbl -> precDef parentLbl var dt cfg } } } formalArguments = S.fromList fargs -- renaming all the variables based on the individual labelled blocks -- and move all the declaration out. eachNode :: SSA -> (Ident, Node) -> SSA eachNode ssa (currLbl, node) = case node of { Node statements lvars rvars local_decls precLbls succLbls switchOrLoop -> let phis_ :: [( Ident -- ^ var being redefined (not yet renamed) , [(Ident, Maybe Ident)])] -- ^ (incoming block lbl, lbl of preceding blk in which var is redefined) phis_ = case M.lookup currLbl phiLocMap of { Nothing -> [] ; Just phiVars -> map (\v -> let lastDefs = map (\precLbl -> let mb_lblVarDefined = precDef precLbl v dtree cfg in (precLbl, mb_lblVarDefined)) precLbls in (v, lastDefs) -- find the preceding node and the renamed variable ) [ v | v <- phiVars, not (v `elem` local_decls) ] } -- build the renaming state from the rhs vars with the precDef -- or from phis_ rnState :: RenameState rnState = let -- todo, the local_decls should be filtered away from the rVars and local_decls should be appended with the current node label rnEnvLocal = M.fromList $ map (\var -> (var, var `app` currLbl)) local_decls rvarsNotLocal = filter (\var -> not (var `M.member` rnEnvLocal)) rvars rnEnv = case precLbls of { [] -> -- entry block -- todo: check, shouldn't be the formal arg? M.fromList (map (\var -> if (var `S.member` formalArguments) || (var `S.member` allLocalVars) then (var, var `app` currLbl) else (var, var) -- global ) rvarsNotLocal) ; [precLbl] -> -- non-phi block M.fromList (map (\var -> case precDef precLbl var dtree cfg of { Just def_lbl -> (var, var `app` def_lbl) ; Nothing -> -- it is a formal arg and should be redefined in block 0 if (var `S.member` formalArguments) || (var `S.member` allLocalVars) then (var, var `app` (iid (labPref ++ "0"))) else (var, var) -- global }) rvarsNotLocal) ; precLbls -> -- phi block M.fromList (map (\var -> case lookup var phis_ of { Just _ -> (var, var `app` currLbl) ; Nothing -> -- not in phi, it's a formal arg and should be redefined in block 0 -- (var, var `app` (iid (labPref ++ "0"))) -- updated: the above is not true, look at sort example, var j in node 7. (7 has preds 4 and 6, both do not redefine j, -- node 4 & 6 share a common ancestor 3 where j is redefined case filter isJust $ map (\precLbl -> precDef precLbl var dtree cfg) precLbls of { [] -> -- var is global (var, var) ; (def:defs) | all (\d -> d == def) defs -> let (Just def_lbl) = def in (var, var `app` def_lbl) | otherwise -> error $ "buildSSA: rnState variable " ++ (show var) ++ " has a conflicting preceding definition " ++ (show (def:defs)) ++ "\n current Label " ++ (show currLbl) ++ "\n CFG" ++ (show cfg) ++ "\n Phi loca Map" ++ (show phiLocMap) ++ "\n DFT" ++ (show dft) } }) rvarsNotLocal) } in RSt currLbl (rnEnvLocal `M.union` rnEnv) [] [] allLocalVars formalArguments renamedBlkItems_decls_containers :: ([AST.CCompoundBlockItem N.NodeInfo], [AST.CDeclaration N.NodeInfo], [Ident]) renamedBlkItems_decls_containers = renamePure rnState statements (renamedBlkItems, new_decls, containers) = renamedBlkItems_decls_containers -- scalar copy for container variables eg. say a[] then a[i] = a[j] --> a_2 = a_1; a_2[i_2] = a_1[j_2]; -- and insert them to the begining of the labeled block scalar_copy :: [Ident] -> [AST.CCompoundBlockItem N.NodeInfo] scalar_copy containers = concatMap (\container -> -- lookup the last def of container variable, similar to building rnState let containers' = case precLbls of { [] -> [] -- entry block ; [precLbl] -> case precDef precLbl container dtree cfg of { Just def_lbl -> [container `app` def_lbl] ; Nothing -> [container `app` (iid (labPref ++ "0"))] } ; precLbls -> case lookup container phis_ of -- phi block { Just _ -> [] -- should be covered by the phi translations ; Nothing -> case filter isJust $ map (\precLbl -> precDef precLbl container dtree cfg) precLbls of { [] -> error "impossible" ; (def:defs) | (all (\d -> d == def) defs) -> let (Just def_lbl) = def in [container `app` def_lbl] | otherwise -> error $ "buildSSA: scalar copy variable " ++ (show container) ++ " has a conflicting preceding definition" } } } in map (\container' -> AST.CBlockStmt (AST.CExpr (Just ((cvar (container `app` currLbl)) .=. (cvar container'))) N.undefNode)) containers' ) containers isLoop x = case x of { (IsLoop _ _) -> True ; _ -> False } labelled_block = LB phis_ ((scalar_copy containers) ++ renamedBlkItems) precLbls succLbls (lVars node) (rVars node) containers (isLoop switchOrLoop) in ssa{ labelled_blocks = M.insert currLbl labelled_block (labelled_blocks ssa) , scoped_decls = (scoped_decls ssa) ++ new_decls } } ssa = foldl eachNode (SSA [] M.empty sdom allLocalVars formalArguments) $ M.toList cfg io = unsafePerformIO $ print cfg >> print ssa >> print dft >> print pcm >> print dtree -- (map (\var -> (var, modLoc var cfg)) allVarsUsed) >> print dtree >> print dft >> print pcm >> print sdom in ssa -- the scoped_decls were not yet renamed which will be renamed in SSA to CPS convertion }
12,230
true
true
0
50
6,698
2,079
1,129
950
null
null
mightymoose/liquidhaskell
benchmarks/containers-0.5.0.0/Data/IntSet/Base.hs
bsd-3-clause
-- | /O(n)/. Convert the set to a descending list of elements. Subject to list -- fusion. toDescList :: IntSet -> [Int] toDescList = foldl (flip (:)) []
152
toDescList :: IntSet -> [Int] toDescList = foldl (flip (:)) []
62
toDescList = foldl (flip (:)) []
32
true
true
0
8
27
43
21
22
null
null
GaloisInc/halvm-ghc
compiler/utils/Outputable.hs
bsd-3-clause
neverQualify = QueryQualify neverQualifyNames neverQualifyModules neverQualifyPackages
145
neverQualify = QueryQualify neverQualifyNames neverQualifyModules neverQualifyPackages
145
neverQualify = QueryQualify neverQualifyNames neverQualifyModules neverQualifyPackages
145
false
false
0
5
64
13
6
7
null
null
nevrenato/Hets_Fork
Temporal/NuSmv.hs
gpl-2.0
modul :: Parser Module modul = do keyword "MODULE" name <- reserved keywords identifier << ws params <- option [] (between (token "(") (token ")") parameters) elements <- many element return (Module name params elements) where parameters = sepBy1 (reserved keywords identifier << ws) (token ",")
351
modul :: Parser Module modul = do keyword "MODULE" name <- reserved keywords identifier << ws params <- option [] (between (token "(") (token ")") parameters) elements <- many element return (Module name params elements) where parameters = sepBy1 (reserved keywords identifier << ws) (token ",")
351
modul = do keyword "MODULE" name <- reserved keywords identifier << ws params <- option [] (between (token "(") (token ")") parameters) elements <- many element return (Module name params elements) where parameters = sepBy1 (reserved keywords identifier << ws) (token ",")
328
false
true
1
12
101
137
60
77
null
null
iu-parfunc/containers
Data/Map/Base.hs
bsd-3-clause
-- According to benchmarks, this special case increases -- performance up to 30%. It does not help in difference or intersection. hedgeUnion blo bhi (Bin _ kx x l r) t2 = link kx x (hedgeUnion blo bmi l (trim blo bmi t2)) (hedgeUnion bmi bhi r (trim bmi bhi t2)) where bmi = JustS kx #if __GLASGOW_HASKELL__ >= 700
430
hedgeUnion blo bhi (Bin _ kx x l r) t2 = link kx x (hedgeUnion blo bmi l (trim blo bmi t2)) (hedgeUnion bmi bhi r (trim bmi bhi t2)) where bmi = JustS kx #if __GLASGOW_HASKELL__ >= 700
238
hedgeUnion blo bhi (Bin _ kx x l r) t2 = link kx x (hedgeUnion blo bmi l (trim blo bmi t2)) (hedgeUnion bmi bhi r (trim bmi bhi t2)) where bmi = JustS kx #if __GLASGOW_HASKELL__ >= 700
238
true
false
2
9
175
101
48
53
null
null
pauldoo/scratch
NBody/Main.hs
isc
reshape s@(Size w h) = do viewport $= (Position 0 0, s)
59
reshape s@(Size w h) = do viewport $= (Position 0 0, s)
59
reshape s@(Size w h) = do viewport $= (Position 0 0, s)
59
false
false
0
9
15
38
19
19
null
null
ocharles/hackage-server
Distribution/Server/Packages/Types.hs
bsd-3-clause
pkgLatestCabalFileText :: PkgInfo -> CabalFileText pkgLatestCabalFileText = fst . pkgLatestRevision
99
pkgLatestCabalFileText :: PkgInfo -> CabalFileText pkgLatestCabalFileText = fst . pkgLatestRevision
99
pkgLatestCabalFileText = fst . pkgLatestRevision
48
false
true
0
5
9
19
10
9
null
null
romac/mental
src/Mental/Infer.hs
bsd-3-clause
declToEnv (TyDecl name ty) = Map.singleton name (generalize mempty ty)
72
declToEnv (TyDecl name ty) = Map.singleton name (generalize mempty ty)
72
declToEnv (TyDecl name ty) = Map.singleton name (generalize mempty ty)
72
false
false
0
7
11
32
15
17
null
null
andorp/grin
grin/src/Grin/Grin.hs
bsd-3-clause
_VarNode _ rest = pure rest
27
_VarNode _ rest = pure rest
27
_VarNode _ rest = pure rest
27
false
false
0
5
5
14
6
8
null
null
ulikoehler/ProjectEuler
Euler28.hs
apache-2.0
main = do let diameter = 1001 -- First circle: 1 difference between diagonal numbers, second: 3, ... let differenceList = takeWhile(< diameter) [2,4..] -- Always 4 numbers per circle let allDifferences = concatMap (replicate 4) differenceList print $ sum $ scanl (+) 1 allDifferences
307
main = do let diameter = 1001 -- First circle: 1 difference between diagonal numbers, second: 3, ... let differenceList = takeWhile(< diameter) [2,4..] -- Always 4 numbers per circle let allDifferences = concatMap (replicate 4) differenceList print $ sum $ scanl (+) 1 allDifferences
307
main = do let diameter = 1001 -- First circle: 1 difference between diagonal numbers, second: 3, ... let differenceList = takeWhile(< diameter) [2,4..] -- Always 4 numbers per circle let allDifferences = concatMap (replicate 4) differenceList print $ sum $ scanl (+) 1 allDifferences
307
false
false
0
12
68
81
41
40
null
null
AlexanderPankiv/ghc
compiler/prelude/THNames.hs
bsd-3-clause
-- data Exp = ... varEIdKey, conEIdKey, litEIdKey, appEIdKey, infixEIdKey, infixAppIdKey, sectionLIdKey, sectionRIdKey, lamEIdKey, lamCaseEIdKey, tupEIdKey, unboxedTupEIdKey, condEIdKey, multiIfEIdKey, letEIdKey, caseEIdKey, doEIdKey, compEIdKey, fromEIdKey, fromThenEIdKey, fromToEIdKey, fromThenToEIdKey, listEIdKey, sigEIdKey, recConEIdKey, recUpdEIdKey, staticEIdKey, unboundVarEIdKey :: Unique varEIdKey = mkPreludeMiscIdUnique 270
468
varEIdKey, conEIdKey, litEIdKey, appEIdKey, infixEIdKey, infixAppIdKey, sectionLIdKey, sectionRIdKey, lamEIdKey, lamCaseEIdKey, tupEIdKey, unboxedTupEIdKey, condEIdKey, multiIfEIdKey, letEIdKey, caseEIdKey, doEIdKey, compEIdKey, fromEIdKey, fromThenEIdKey, fromToEIdKey, fromThenToEIdKey, listEIdKey, sigEIdKey, recConEIdKey, recUpdEIdKey, staticEIdKey, unboundVarEIdKey :: Unique varEIdKey = mkPreludeMiscIdUnique 270
450
varEIdKey = mkPreludeMiscIdUnique 270
45
true
true
5
5
70
80
62
18
null
null
BartMassey/anrand
anrand.hs
mit
testHelp :: IO () testHelp = do printf "Available Tests:\n" mapM_ (\t -> printf " %s\n" t) testSet exitSuccess
117
testHelp :: IO () testHelp = do printf "Available Tests:\n" mapM_ (\t -> printf " %s\n" t) testSet exitSuccess
117
testHelp = do printf "Available Tests:\n" mapM_ (\t -> printf " %s\n" t) testSet exitSuccess
99
false
true
0
10
25
46
21
25
null
null
kawu/partage
src/NLP/Partage/AStar/Chart.hs
bsd-2-clause
hasPassiveTrav :: (Ord t, Ord n) => Passive n t -> S.Set (Trav n t) -> Auto n t -> Chart n t -> Bool hasPassiveTrav p travSet auto chart = case passiveTrav p auto chart of Just ExtWeight{..} -> travSet `S.isSubsetOf` prioTrav Nothing -> False --------------------------------- -- Extraction of Processed Items --------------------------------- -- | Check whether the given passive item is final or not.
428
hasPassiveTrav :: (Ord t, Ord n) => Passive n t -> S.Set (Trav n t) -> Auto n t -> Chart n t -> Bool hasPassiveTrav p travSet auto chart = case passiveTrav p auto chart of Just ExtWeight{..} -> travSet `S.isSubsetOf` prioTrav Nothing -> False --------------------------------- -- Extraction of Processed Items --------------------------------- -- | Check whether the given passive item is final or not.
428
hasPassiveTrav p travSet auto chart = case passiveTrav p auto chart of Just ExtWeight{..} -> travSet `S.isSubsetOf` prioTrav Nothing -> False --------------------------------- -- Extraction of Processed Items --------------------------------- -- | Check whether the given passive item is final or not.
315
false
true
0
11
90
129
63
66
null
null
pharpend/comarkdown
tests/CompilerSpec.hs
gpl-3.0
spec :: Spec spec = parallel $ do describe "AST->Pandoc compiler" $ do describe "Outputting plain-text" $ do specify "given many Ignore blks, behave like text all in 1 ignore blk" $ property $ \(xs :: [String]) -> do result1 <- runDocument (mapM_ ignore xs) result2 <- runDocument (ignore (mconcat xs)) shouldBe (writePlain def result1) (writePlain def result2) specify "given many Comment blks, output is mempty" $ property $ \(xs :: [String]) -> do result <- runDocument (mapM_ comment xs) shouldBe result mempty specify "given many Comment blks interspersed in ignore blocks, same result as ignore blks standalone" $ property $ \(xs :: [String], ys :: [String]) -> do shuffledList <- generate (shuffle (mappend (fmap Ignore xs) (fmap Comment ys))) result1 <- runDocument (mapM_ insertPart shuffledList) result2 <- runDocument (forM_ shuffledList $ \case Ignore s -> ignore s _ -> return ()) shouldBe result1 result2 describe "Testing out Pandoc" $ do specify "Given two strings, pandoc a + pandoc b = pandoc (a + b)" $ do property $ \(x :: String, y :: String) -> let fromPandoc'' = runExceptional . fromEither . over _Left show in do readFirst <- fromPandoc'' $ readMarkdown def x readSecond <- fromPandoc'' $ readMarkdown def y let readXreadY = mappend readFirst readSecond readXY <- fromPandoc'' $ readMarkdown def (mappend x y) shouldBe readXreadY readXY
1,820
spec :: Spec spec = parallel $ do describe "AST->Pandoc compiler" $ do describe "Outputting plain-text" $ do specify "given many Ignore blks, behave like text all in 1 ignore blk" $ property $ \(xs :: [String]) -> do result1 <- runDocument (mapM_ ignore xs) result2 <- runDocument (ignore (mconcat xs)) shouldBe (writePlain def result1) (writePlain def result2) specify "given many Comment blks, output is mempty" $ property $ \(xs :: [String]) -> do result <- runDocument (mapM_ comment xs) shouldBe result mempty specify "given many Comment blks interspersed in ignore blocks, same result as ignore blks standalone" $ property $ \(xs :: [String], ys :: [String]) -> do shuffledList <- generate (shuffle (mappend (fmap Ignore xs) (fmap Comment ys))) result1 <- runDocument (mapM_ insertPart shuffledList) result2 <- runDocument (forM_ shuffledList $ \case Ignore s -> ignore s _ -> return ()) shouldBe result1 result2 describe "Testing out Pandoc" $ do specify "Given two strings, pandoc a + pandoc b = pandoc (a + b)" $ do property $ \(x :: String, y :: String) -> let fromPandoc'' = runExceptional . fromEither . over _Left show in do readFirst <- fromPandoc'' $ readMarkdown def x readSecond <- fromPandoc'' $ readMarkdown def y let readXreadY = mappend readFirst readSecond readXY <- fromPandoc'' $ readMarkdown def (mappend x y) shouldBe readXreadY readXY
1,820
spec = parallel $ do describe "AST->Pandoc compiler" $ do describe "Outputting plain-text" $ do specify "given many Ignore blks, behave like text all in 1 ignore blk" $ property $ \(xs :: [String]) -> do result1 <- runDocument (mapM_ ignore xs) result2 <- runDocument (ignore (mconcat xs)) shouldBe (writePlain def result1) (writePlain def result2) specify "given many Comment blks, output is mempty" $ property $ \(xs :: [String]) -> do result <- runDocument (mapM_ comment xs) shouldBe result mempty specify "given many Comment blks interspersed in ignore blocks, same result as ignore blks standalone" $ property $ \(xs :: [String], ys :: [String]) -> do shuffledList <- generate (shuffle (mappend (fmap Ignore xs) (fmap Comment ys))) result1 <- runDocument (mapM_ insertPart shuffledList) result2 <- runDocument (forM_ shuffledList $ \case Ignore s -> ignore s _ -> return ()) shouldBe result1 result2 describe "Testing out Pandoc" $ do specify "Given two strings, pandoc a + pandoc b = pandoc (a + b)" $ do property $ \(x :: String, y :: String) -> let fromPandoc'' = runExceptional . fromEither . over _Left show in do readFirst <- fromPandoc'' $ readMarkdown def x readSecond <- fromPandoc'' $ readMarkdown def y let readXreadY = mappend readFirst readSecond readXY <- fromPandoc'' $ readMarkdown def (mappend x y) shouldBe readXreadY readXY
1,807
false
true
0
26
678
481
224
257
null
null
ooz/Hafer
src/Hafer/Data/GenericGraph.hs
mit
vertices :: Graph v e -> [Vertex v] vertices g = case g of MathGraph vs es -> vs ElemSetGraph elems -> foldr (++) [] $ map (\e -> case e of GVertex v -> [v] _ -> []) elems
299
vertices :: Graph v e -> [Vertex v] vertices g = case g of MathGraph vs es -> vs ElemSetGraph elems -> foldr (++) [] $ map (\e -> case e of GVertex v -> [v] _ -> []) elems
299
vertices g = case g of MathGraph vs es -> vs ElemSetGraph elems -> foldr (++) [] $ map (\e -> case e of GVertex v -> [v] _ -> []) elems
263
false
true
0
15
167
108
52
56
null
null
hiteshjasani/nano-hmac
test/hmd5_qc.hs
bsd-3-clause
toString :: [Word8] -> String toString = unpack . pack
54
toString :: [Word8] -> String toString = unpack . pack
54
toString = unpack . pack
24
false
true
1
7
9
30
13
17
null
null
snoyberg/ghc
compiler/basicTypes/OccName.hs
bsd-3-clause
plusOccEnv (A x) (A y) = A $ plusUFM x y
42
plusOccEnv (A x) (A y) = A $ plusUFM x y
42
plusOccEnv (A x) (A y) = A $ plusUFM x y
42
false
false
0
7
12
32
15
17
null
null
cl04/advent2016
src/Day7.hs
bsd-3-clause
regularStr :: Monad m => ParsecT String u m (String, String) regularStr = str >>= \s -> return $! (s, mempty)
110
regularStr :: Monad m => ParsecT String u m (String, String) regularStr = str >>= \s -> return $! (s, mempty)
110
regularStr = str >>= \s -> return $! (s, mempty)
48
false
true
0
8
21
52
28
24
null
null
xmonad/xmonad-contrib
XMonad/Prompt/Directory.hs
bsd-3-clause
notboring _ = True
18
notboring _ = True
18
notboring _ = True
18
false
false
0
5
3
9
4
5
null
null
seckcoder/lang-learn
haskell/lambda-calculus/src/Main.hs
unlicense
eval3 :: Exp -> Eval3 Value eval3 (Lit i) = return (IntVal i)
61
eval3 :: Exp -> Eval3 Value eval3 (Lit i) = return (IntVal i)
61
eval3 (Lit i) = return (IntVal i)
33
false
true
0
9
12
40
18
22
null
null
mightybyte/reflex-dom-stubs
src/GHCJS/DOM/Node.hs
bsd-3-clause
nodeGetParentNode = undefined
29
nodeGetParentNode = undefined
29
nodeGetParentNode = undefined
29
false
false
0
4
2
6
3
3
null
null
acowley/language-c
src/Language/C/Analysis/TypeUtils.hs
bsd-3-clause
-- | Constructor for a simple floating-point type. floating :: FloatType -> Type floating ty = DirectType (TyFloating ty) noTypeQuals noAttributes
146
floating :: FloatType -> Type floating ty = DirectType (TyFloating ty) noTypeQuals noAttributes
95
floating ty = DirectType (TyFloating ty) noTypeQuals noAttributes
65
true
true
0
7
20
35
17
18
null
null
brendanhay/gogol
gogol-logging/gen/Network/Google/Resource/Logging/Projects/Locations/Buckets/Views/Patch.hs
mpl-2.0
-- | JSONP plbvpCallback :: Lens' ProjectsLocationsBucketsViewsPatch (Maybe Text) plbvpCallback = lens _plbvpCallback (\ s a -> s{_plbvpCallback = a})
158
plbvpCallback :: Lens' ProjectsLocationsBucketsViewsPatch (Maybe Text) plbvpCallback = lens _plbvpCallback (\ s a -> s{_plbvpCallback = a})
147
plbvpCallback = lens _plbvpCallback (\ s a -> s{_plbvpCallback = a})
76
true
true
0
8
27
49
25
24
null
null
narrative/stack
src/Stack/Init.hs
bsd-3-clause
getWorkingResolverPlan :: ( MonadBaseControl IO m, MonadIO m, MonadLogger m, MonadMask m , MonadReader env m, HasConfig env , HasGHCVariant env , HasHttpManager env , HasLogLevel env , HasReExec env , HasTerminal env) => Path Abs File -- ^ stack.yaml -> InitOpts -> Map PackageName (Path Abs File, C.GenericPackageDescription) -- ^ Src package name: cabal dir, cabal package description -> Resolver -> m ( Resolver , Map PackageName (Map FlagName Bool) , Map PackageName Version , Map PackageName (Path Abs File, C.GenericPackageDescription)) -- ^ ( Resolver -- , Flags for src packages and extra deps -- , Extra dependencies -- , Src packages actually considered) getWorkingResolverPlan stackYaml initOpts bundle resolver = do $logInfo $ "Selected resolver: " <> resolverName resolver go bundle where go info = do eres <- checkBundleResolver stackYaml initOpts info resolver -- if some packages failed try again using the rest case eres of Right (f, edeps)-> return (resolver, f, edeps, info) Left ignored | Map.null available -> do $logWarn "*** Could not find a working plan for any of \ \the user packages.\nProceeding to create a \ \config anyway." return (resolver, Map.empty, Map.empty, Map.empty) | otherwise -> do when ((Map.size available) == (Map.size info)) $ error "Bug: No packages to ignore" if length ignored > 1 then do $logWarn "*** Ignoring packages:" $logWarn $ indent $ showItems ignored else $logWarn $ "*** Ignoring package: " <> (T.pack $ packageNameString (head ignored)) go available where indent t = T.unlines $ fmap (" " <>) (T.lines t) isAvailable k _ = not (k `elem` ignored) available = Map.filterWithKey isAvailable info
2,343
getWorkingResolverPlan :: ( MonadBaseControl IO m, MonadIO m, MonadLogger m, MonadMask m , MonadReader env m, HasConfig env , HasGHCVariant env , HasHttpManager env , HasLogLevel env , HasReExec env , HasTerminal env) => Path Abs File -- ^ stack.yaml -> InitOpts -> Map PackageName (Path Abs File, C.GenericPackageDescription) -- ^ Src package name: cabal dir, cabal package description -> Resolver -> m ( Resolver , Map PackageName (Map FlagName Bool) , Map PackageName Version , Map PackageName (Path Abs File, C.GenericPackageDescription)) getWorkingResolverPlan stackYaml initOpts bundle resolver = do $logInfo $ "Selected resolver: " <> resolverName resolver go bundle where go info = do eres <- checkBundleResolver stackYaml initOpts info resolver -- if some packages failed try again using the rest case eres of Right (f, edeps)-> return (resolver, f, edeps, info) Left ignored | Map.null available -> do $logWarn "*** Could not find a working plan for any of \ \the user packages.\nProceeding to create a \ \config anyway." return (resolver, Map.empty, Map.empty, Map.empty) | otherwise -> do when ((Map.size available) == (Map.size info)) $ error "Bug: No packages to ignore" if length ignored > 1 then do $logWarn "*** Ignoring packages:" $logWarn $ indent $ showItems ignored else $logWarn $ "*** Ignoring package: " <> (T.pack $ packageNameString (head ignored)) go available where indent t = T.unlines $ fmap (" " <>) (T.lines t) isAvailable k _ = not (k `elem` ignored) available = Map.filterWithKey isAvailable info
2,187
getWorkingResolverPlan stackYaml initOpts bundle resolver = do $logInfo $ "Selected resolver: " <> resolverName resolver go bundle where go info = do eres <- checkBundleResolver stackYaml initOpts info resolver -- if some packages failed try again using the rest case eres of Right (f, edeps)-> return (resolver, f, edeps, info) Left ignored | Map.null available -> do $logWarn "*** Could not find a working plan for any of \ \the user packages.\nProceeding to create a \ \config anyway." return (resolver, Map.empty, Map.empty, Map.empty) | otherwise -> do when ((Map.size available) == (Map.size info)) $ error "Bug: No packages to ignore" if length ignored > 1 then do $logWarn "*** Ignoring packages:" $logWarn $ indent $ showItems ignored else $logWarn $ "*** Ignoring package: " <> (T.pack $ packageNameString (head ignored)) go available where indent t = T.unlines $ fmap (" " <>) (T.lines t) isAvailable k _ = not (k `elem` ignored) available = Map.filterWithKey isAvailable info
1,563
true
true
1
20
952
519
251
268
null
null
dimitri-xyz/public-bitcoin-type
Test/Test.hs
lgpl-2.1
showBitcoinTest :: Test showBitcoinTest = TestCase $ do assertEqual "0 looks like zero" "0.00000000" (show (0 :: Bitcoin)) assertEqual "Showing an integer" "7.00000000" (show (7 :: Bitcoin)) assertEqual "Showing a fraction" "0.50000000" (show (0.5 :: Bitcoin)) assertEqual "Showing a negative fraction" "-0.33333333" (show ((-0.33333333) :: Bitcoin)) assertEqual "Showing a negative number" "-9.90000000" (show ((-9.9) :: Bitcoin)) -------------------------------------------------------------------
571
showBitcoinTest :: Test showBitcoinTest = TestCase $ do assertEqual "0 looks like zero" "0.00000000" (show (0 :: Bitcoin)) assertEqual "Showing an integer" "7.00000000" (show (7 :: Bitcoin)) assertEqual "Showing a fraction" "0.50000000" (show (0.5 :: Bitcoin)) assertEqual "Showing a negative fraction" "-0.33333333" (show ((-0.33333333) :: Bitcoin)) assertEqual "Showing a negative number" "-9.90000000" (show ((-9.9) :: Bitcoin)) -------------------------------------------------------------------
571
showBitcoinTest = TestCase $ do assertEqual "0 looks like zero" "0.00000000" (show (0 :: Bitcoin)) assertEqual "Showing an integer" "7.00000000" (show (7 :: Bitcoin)) assertEqual "Showing a fraction" "0.50000000" (show (0.5 :: Bitcoin)) assertEqual "Showing a negative fraction" "-0.33333333" (show ((-0.33333333) :: Bitcoin)) assertEqual "Showing a negative number" "-9.90000000" (show ((-9.9) :: Bitcoin)) -------------------------------------------------------------------
547
false
true
0
14
128
143
71
72
null
null
urbanslug/ghc
compiler/hsSyn/HsDecls.hs
bsd-3-clause
docDeclDoc :: DocDecl -> HsDocString docDeclDoc (DocCommentNext d) = d
70
docDeclDoc :: DocDecl -> HsDocString docDeclDoc (DocCommentNext d) = d
70
docDeclDoc (DocCommentNext d) = d
33
false
true
0
7
9
24
12
12
null
null
YuichiroSato/GameOfSymbolGrounding
src/Data/Cell.hs
bsd-3-clause
randomCell :: (RandomGen g) => Int -> Int -> g -> (Cell, g) randomCell x0 y0 gen = (Cell ext int, newGen) where int = randomInternal t r2 r3 ext@(External t _ _) = randomExternal r1 (x0, y0) r4 ((r1, r2, r3, r4), newGen) = runState rand4 gen
255
randomCell :: (RandomGen g) => Int -> Int -> g -> (Cell, g) randomCell x0 y0 gen = (Cell ext int, newGen) where int = randomInternal t r2 r3 ext@(External t _ _) = randomExternal r1 (x0, y0) r4 ((r1, r2, r3, r4), newGen) = runState rand4 gen
255
randomCell x0 y0 gen = (Cell ext int, newGen) where int = randomInternal t r2 r3 ext@(External t _ _) = randomExternal r1 (x0, y0) r4 ((r1, r2, r3, r4), newGen) = runState rand4 gen
195
false
true
0
9
61
132
71
61
null
null
tibbe/ghc
compiler/codeGen/StgCmmPrim.hs
bsd-3-clause
translateOp dflags WordEqOp = Just (mo_wordEq dflags)
59
translateOp dflags WordEqOp = Just (mo_wordEq dflags)
59
translateOp dflags WordEqOp = Just (mo_wordEq dflags)
59
false
false
0
7
12
20
9
11
null
null
jvilar/hrows
lib/GUI/BuildMonad.hs
gpl-2.0
runBuild :: Builder -> GUIControl -> BuildMonad t -> IO t runBuild builder control action = runReaderT action (builder, control)
128
runBuild :: Builder -> GUIControl -> BuildMonad t -> IO t runBuild builder control action = runReaderT action (builder, control)
128
runBuild builder control action = runReaderT action (builder, control)
70
false
true
0
9
19
51
24
27
null
null
ryzhyk/cocoon
cocoon/SMT/SMTLib2.hs
apache-2.0
smtppExpr mf (EBinOp Neq e1 e2) = smtppExpr mf $ EUnOp Not $ EBinOp Eq e1 e2
76
smtppExpr mf (EBinOp Neq e1 e2) = smtppExpr mf $ EUnOp Not $ EBinOp Eq e1 e2
76
smtppExpr mf (EBinOp Neq e1 e2) = smtppExpr mf $ EUnOp Not $ EBinOp Eq e1 e2
76
false
false
0
7
16
42
19
23
null
null
ikirill/ComputationalMathematics
Cube/CubeGL.hs
gpl-3.0
whenM :: Monad m => m Bool -> m () -> m () whenM pred work = do x <- pred; unless x work
88
whenM :: Monad m => m Bool -> m () -> m () whenM pred work = do x <- pred; unless x work
88
whenM pred work = do x <- pred; unless x work
45
false
true
0
10
23
65
28
37
null
null
kmels/hledger
hledger/Hledger/Cli/Balance.hs
gpl-3.0
formatField :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> HledgerFormatField -> String formatField opts accountName depth total ljust min max field = case field of AccountField -> formatValue ljust min max $ maybe "" (maybeAccountNameDrop opts) accountName DepthSpacerField -> case min of Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' ' Nothing -> formatValue ljust Nothing max $ replicate depth ' ' TotalField -> formatValue ljust min max $ showAmountWithoutPrice total _ -> "" -- multi-column balance reports -- | Render a multi-column balance report as CSV.
747
formatField :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> HledgerFormatField -> String formatField opts accountName depth total ljust min max field = case field of AccountField -> formatValue ljust min max $ maybe "" (maybeAccountNameDrop opts) accountName DepthSpacerField -> case min of Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' ' Nothing -> formatValue ljust Nothing max $ replicate depth ' ' TotalField -> formatValue ljust min max $ showAmountWithoutPrice total _ -> "" -- multi-column balance reports -- | Render a multi-column balance report as CSV.
747
formatField opts accountName depth total ljust min max field = case field of AccountField -> formatValue ljust min max $ maybe "" (maybeAccountNameDrop opts) accountName DepthSpacerField -> case min of Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' ' Nothing -> formatValue ljust Nothing max $ replicate depth ' ' TotalField -> formatValue ljust min max $ showAmountWithoutPrice total _ -> "" -- multi-column balance reports -- | Render a multi-column balance report as CSV.
617
false
true
0
14
225
201
94
107
null
null
forked-upstream-packages-for-ghcjs/ghc
compiler/utils/Pretty.hs
bsd-3-clause
-- Worth a try! mkNest k p = nest_ k p
54
mkNest k p = nest_ k p
38
mkNest k p = nest_ k p
38
true
false
0
5
26
17
8
9
null
null
abramhindle/haskell-sand-game
Sand5.hs
lgpl-3.0
cursorLogic c@(Cursor { center = Eater, above = DustGenerator }) = eatAboveSendMessage c
88
cursorLogic c@(Cursor { center = Eater, above = DustGenerator }) = eatAboveSendMessage c
88
cursorLogic c@(Cursor { center = Eater, above = DustGenerator }) = eatAboveSendMessage c
88
false
false
0
10
12
33
18
15
null
null
NICTA/coordinate
src/Data/Geodetic/EllipsoidReaderT.hs
bsd-3-clause
wgs84'' :: EllipsoidReaderT f a -> f a wgs84'' r = (_Unwrapped # r) wgs84
79
wgs84'' :: EllipsoidReaderT f a -> f a wgs84'' r = (_Unwrapped # r) wgs84
79
wgs84'' r = (_Unwrapped # r) wgs84
36
false
true
0
7
20
37
17
20
null
null
rubik/stack
src/Stack/Setup/Installed.hs
bsd-3-clause
listInstalled :: (MonadIO m, MonadReader env m, HasConfig env, MonadThrow m) => Path Abs Dir -> m [Tool] listInstalled programsPath = do createTree programsPath (_, files) <- listDirectory programsPath return $ mapMaybe toTool files where toTool fp = do x <- T.stripSuffix ".installed" $ T.pack $ toFilePath $ filename fp parseToolText x
399
listInstalled :: (MonadIO m, MonadReader env m, HasConfig env, MonadThrow m) => Path Abs Dir -> m [Tool] listInstalled programsPath = do createTree programsPath (_, files) <- listDirectory programsPath return $ mapMaybe toTool files where toTool fp = do x <- T.stripSuffix ".installed" $ T.pack $ toFilePath $ filename fp parseToolText x
399
listInstalled programsPath = do createTree programsPath (_, files) <- listDirectory programsPath return $ mapMaybe toTool files where toTool fp = do x <- T.stripSuffix ".installed" $ T.pack $ toFilePath $ filename fp parseToolText x
266
false
true
1
13
113
146
65
81
null
null
bitemyapp/blpapi-hs
src/Finance/Blpapi/PrettyPrint.hs
mit
(<>) :: Builder -> Builder -> Builder (<>) = mappend
52
(<>) :: Builder -> Builder -> Builder (<>) = mappend
52
(<>) = mappend
14
false
true
0
6
9
23
14
9
null
null
stevely/hspirv
src/SpirV/Builder/Raw.hs
bsd-3-clause
typeVoid :: Builder Id typeVoid = addTypeDeclaration RepVoid OpTypeVoid
71
typeVoid :: Builder Id typeVoid = addTypeDeclaration RepVoid OpTypeVoid
71
typeVoid = addTypeDeclaration RepVoid OpTypeVoid
48
false
true
0
5
8
19
9
10
null
null
limaner2002/EPC-tools
USACScripts/src/Scripts/FCCForm471Types.hs
bsd-3-clause
checkLineItemCost :: LineItemCost -> Bool checkLineItemCost lineItem = checkCosts (lineItem ^. lineMonthly) (lineItem ^. lineOneTime)
133
checkLineItemCost :: LineItemCost -> Bool checkLineItemCost lineItem = checkCosts (lineItem ^. lineMonthly) (lineItem ^. lineOneTime)
133
checkLineItemCost lineItem = checkCosts (lineItem ^. lineMonthly) (lineItem ^. lineOneTime)
91
false
true
0
7
14
40
20
20
null
null