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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CanvasHS/Canvas.hs | canvashs-module/CanvasHs/Protocol/Input.hs | lgpl-2.1 | -- | a helper function to make a modifierlist from the incoming JSON
makeModifiers :: Bool -> Bool -> Bool -> [Modifier]
makeModifiers ctrl alt shift =
(if ctrl then [Ctrl] else []) ++
(if alt then [Alt] else []) ++
(if shift then [Shift] else []) | 261 | makeModifiers :: Bool -> Bool -> Bool -> [Modifier]
makeModifiers ctrl alt shift =
(if ctrl then [Ctrl] else []) ++
(if alt then [Alt] else []) ++
(if shift then [Shift] else []) | 192 | makeModifiers ctrl alt shift =
(if ctrl then [Ctrl] else []) ++
(if alt then [Alt] else []) ++
(if shift then [Shift] else []) | 140 | true | true | 0 | 9 | 60 | 96 | 53 | 43 | null | null |
rzil/honours | DeepLearning/PNN/PNN-Haskell/src/PNN.hs | mit | fromVectors vs = fromLists (map V.toList vs) | 44 | fromVectors vs = fromLists (map V.toList vs) | 44 | fromVectors vs = fromLists (map V.toList vs) | 44 | false | false | 0 | 8 | 6 | 22 | 10 | 12 | null | null |
dambaev/hproxy | src/TCPServer.hs | gpl-2.0 | startTCPServerBasePort:: PortID
-> Int
-> (Int-> HEP ())
-> (Pid-> Handle-> HEP ())
-> HEP ()
-> HEP (Pid, PortID)
startTCPServerBasePort base
connectionsCount
receiveAction
onOpen
onClose = do
!input <- liftIO newMBox
sv <- spawn $! procWithBracket (serverSupInit base connectionsCount input receiveAction onOpen)
(serverSupShutdown >> onClose >> procFinished) $! proc $! serverSupervisor receiveAction onOpen
ServerStarted !port <- liftIO $! receiveMBox input
return (sv, port) | 711 | startTCPServerBasePort:: PortID
-> Int
-> (Int-> HEP ())
-> (Pid-> Handle-> HEP ())
-> HEP ()
-> HEP (Pid, PortID)
startTCPServerBasePort base
connectionsCount
receiveAction
onOpen
onClose = do
!input <- liftIO newMBox
sv <- spawn $! procWithBracket (serverSupInit base connectionsCount input receiveAction onOpen)
(serverSupShutdown >> onClose >> procFinished) $! proc $! serverSupervisor receiveAction onOpen
ServerStarted !port <- liftIO $! receiveMBox input
return (sv, port) | 711 | startTCPServerBasePort base
connectionsCount
receiveAction
onOpen
onClose = do
!input <- liftIO newMBox
sv <- spawn $! procWithBracket (serverSupInit base connectionsCount input receiveAction onOpen)
(serverSupShutdown >> onClose >> procFinished) $! proc $! serverSupervisor receiveAction onOpen
ServerStarted !port <- liftIO $! receiveMBox input
return (sv, port) | 484 | false | true | 0 | 14 | 295 | 179 | 85 | 94 | null | null |
PipocaQuemada/ermine | src/Ermine/Pattern/Matrix.hs | bsd-2-clause | hoistClaused tr (Localized ds g) =
Localized (hoistScope tr' <$> ds) (hoistScope tr' <$> g)
where
tr' = hoistScope tr
-- * Pattern Matrix
-- | Pattern matrices for compilation. The matrix is represented as a list
-- of columns. There is also an extra column representing the guards. | 288 | hoistClaused tr (Localized ds g) =
Localized (hoistScope tr' <$> ds) (hoistScope tr' <$> g)
where
tr' = hoistScope tr
-- * Pattern Matrix
-- | Pattern matrices for compilation. The matrix is represented as a list
-- of columns. There is also an extra column representing the guards. | 288 | hoistClaused tr (Localized ds g) =
Localized (hoistScope tr' <$> ds) (hoistScope tr' <$> g)
where
tr' = hoistScope tr
-- * Pattern Matrix
-- | Pattern matrices for compilation. The matrix is represented as a list
-- of columns. There is also an extra column representing the guards. | 288 | false | false | 0 | 8 | 54 | 58 | 29 | 29 | null | null |
kindohm/Tidal | Sound/Tidal/Dirt.hs | gpl-3.0 | stut :: Integer -> Double -> Rational -> OscPattern -> OscPattern
stut steps feedback time p = stack (p:(map (\x -> (((x%steps)*time) ~> (p |*| gain (pure $ scale (fromIntegral x))))) [1..(steps-1)]))
where scale x
= ((+feedback) . (*(1-feedback)) . (/(fromIntegral steps)) . ((fromIntegral steps)-)) x | 316 | stut :: Integer -> Double -> Rational -> OscPattern -> OscPattern
stut steps feedback time p = stack (p:(map (\x -> (((x%steps)*time) ~> (p |*| gain (pure $ scale (fromIntegral x))))) [1..(steps-1)]))
where scale x
= ((+feedback) . (*(1-feedback)) . (/(fromIntegral steps)) . ((fromIntegral steps)-)) x | 316 | stut steps feedback time p = stack (p:(map (\x -> (((x%steps)*time) ~> (p |*| gain (pure $ scale (fromIntegral x))))) [1..(steps-1)]))
where scale x
= ((+feedback) . (*(1-feedback)) . (/(fromIntegral steps)) . ((fromIntegral steps)-)) x | 250 | false | true | 0 | 21 | 59 | 184 | 100 | 84 | null | null |
yoo-e/weixin-mp-sdk | WeiXin/PublicPlatform/Conversation/Message.hs | mit | talkerMessageDir :: HasWxppOutMsgDir a => a -> NonEmpty FilePath
talkerMessageDir env = fmap (</> "talk") $ getWxppOutMsgDir env | 128 | talkerMessageDir :: HasWxppOutMsgDir a => a -> NonEmpty FilePath
talkerMessageDir env = fmap (</> "talk") $ getWxppOutMsgDir env | 128 | talkerMessageDir env = fmap (</> "talk") $ getWxppOutMsgDir env | 63 | false | true | 0 | 7 | 17 | 42 | 20 | 22 | null | null |
jeannekamikaze/Spear | Spear/Game.hs | mit | runSubGame :: Game s a -> s -> Game t (a,s)
runSubGame game state = gameIO (runGame game state) >>= \result -> case result of
Left err -> gameError err
Right x -> return x
-- | Like 'runSubGame', but discarding the result. | 251 | runSubGame :: Game s a -> s -> Game t (a,s)
runSubGame game state = gameIO (runGame game state) >>= \result -> case result of
Left err -> gameError err
Right x -> return x
-- | Like 'runSubGame', but discarding the result. | 250 | runSubGame game state = gameIO (runGame game state) >>= \result -> case result of
Left err -> gameError err
Right x -> return x
-- | Like 'runSubGame', but discarding the result. | 206 | false | true | 0 | 10 | 71 | 93 | 44 | 49 | null | null |
Motions/motions | src/Bio/Motions/Format/DumpSerialisation.hs | apache-2.0 | getKeyframe :: Dump -> Callbacks -> StepCounter -> ProtoKeyframe.Keyframe
getKeyframe Dump{..} cbs counter = ProtoKeyframe.Keyframe
{ binders = S.fromList $ serialiseBinders dumpBinders
, chains = S.fromList $ map keyframeSerialiseChain dumpChains
, callbacks = S.fromList $ serialiseCallbacks cbs
, step_counter = Just counter
} | 349 | getKeyframe :: Dump -> Callbacks -> StepCounter -> ProtoKeyframe.Keyframe
getKeyframe Dump{..} cbs counter = ProtoKeyframe.Keyframe
{ binders = S.fromList $ serialiseBinders dumpBinders
, chains = S.fromList $ map keyframeSerialiseChain dumpChains
, callbacks = S.fromList $ serialiseCallbacks cbs
, step_counter = Just counter
} | 349 | getKeyframe Dump{..} cbs counter = ProtoKeyframe.Keyframe
{ binders = S.fromList $ serialiseBinders dumpBinders
, chains = S.fromList $ map keyframeSerialiseChain dumpChains
, callbacks = S.fromList $ serialiseCallbacks cbs
, step_counter = Just counter
} | 275 | false | true | 0 | 8 | 62 | 98 | 51 | 47 | null | null |
clinoge/primer-semestre-udone | src/07-arreglos/arreglos.hs | mit | mapear f (x:xs) = f x : (mapear f xs) | 37 | mapear f (x:xs) = f x : (mapear f xs) | 37 | mapear f (x:xs) = f x : (mapear f xs) | 37 | false | false | 2 | 7 | 9 | 37 | 16 | 21 | null | null |
jtdubs/Light | src/Light/Geometry/Normal.hs | mit | (!+!), (!-!) :: Normal -> Normal -> Normal
(Normal x y z) !+! (Normal a b c) = Normal (x+a) (y+b) (z+c) | 103 | (!+!), (!-!) :: Normal -> Normal -> Normal
(Normal x y z) !+! (Normal a b c) = Normal (x+a) (y+b) (z+c) | 103 | (Normal x y z) !+! (Normal a b c) = Normal (x+a) (y+b) (z+c) | 60 | false | true | 0 | 7 | 21 | 79 | 43 | 36 | null | null |
zaxtax/hakaru | haskell/Language/Hakaru/Sample.hs | bsd-3-clause | evaluateSCon (MeasureOp_ m) es env = evaluateMeasureOp m es env | 64 | evaluateSCon (MeasureOp_ m) es env = evaluateMeasureOp m es env | 64 | evaluateSCon (MeasureOp_ m) es env = evaluateMeasureOp m es env | 64 | false | false | 0 | 7 | 10 | 26 | 12 | 14 | null | null |
cmc-haskell-2016/asteroids | src/ServerSide.hs | bsd-3-clause | saveGame :: ServantResponse GameId
saveGame = return 0 | 54 | saveGame :: ServantResponse GameId
saveGame = return 0 | 54 | saveGame = return 0 | 19 | false | true | 0 | 5 | 7 | 17 | 8 | 9 | null | null |
jvictor0/JoSQL | Server/Parser.hs | mit | lex_ TopLevel res [] = Just (Node TopLevel $ reverse res,[]) | 60 | lex_ TopLevel res [] = Just (Node TopLevel $ reverse res,[]) | 60 | lex_ TopLevel res [] = Just (Node TopLevel $ reverse res,[]) | 60 | false | false | 0 | 8 | 10 | 36 | 17 | 19 | null | null |
k0001/opaleye-sot | src/lib/Tisch/Internal/Compat.hs | bsd-3-clause | pgFixed
:: forall e s
. ( KnownNat s
, Fixed.HasResolution e, GHC.CmpNat s (PGNumericScale e + 1) ~ 'LT)
=> Fixed e -> O.Column (PGNumeric s)
pgFixed = case GHC.natVal (Proxy :: Proxy s) of
0 -> \(MkFixed x) -> OI.literalColumn (HDB.IntegerLit x)
_ -> OI.literalColumn . HDB.OtherLit . Fixed.showFixed False
| 324 | pgFixed
:: forall e s
. ( KnownNat s
, Fixed.HasResolution e, GHC.CmpNat s (PGNumericScale e + 1) ~ 'LT)
=> Fixed e -> O.Column (PGNumeric s)
pgFixed = case GHC.natVal (Proxy :: Proxy s) of
0 -> \(MkFixed x) -> OI.literalColumn (HDB.IntegerLit x)
_ -> OI.literalColumn . HDB.OtherLit . Fixed.showFixed False
| 324 | pgFixed = case GHC.natVal (Proxy :: Proxy s) of
0 -> \(MkFixed x) -> OI.literalColumn (HDB.IntegerLit x)
_ -> OI.literalColumn . HDB.OtherLit . Fixed.showFixed False
| 170 | false | true | 0 | 12 | 68 | 153 | 76 | 77 | null | null |
utdemir/wai | wai-extra/Network/Wai/Middleware/RequestLogger.hs | mit | apacheMiddleware :: ApacheLoggerActions -> Middleware
apacheMiddleware ala app req sendResponse = app req $ \res -> do
let msize = contentLength (responseHeaders res)
apacheLogger ala req (responseStatus res) msize
sendResponse res | 243 | apacheMiddleware :: ApacheLoggerActions -> Middleware
apacheMiddleware ala app req sendResponse = app req $ \res -> do
let msize = contentLength (responseHeaders res)
apacheLogger ala req (responseStatus res) msize
sendResponse res | 243 | apacheMiddleware ala app req sendResponse = app req $ \res -> do
let msize = contentLength (responseHeaders res)
apacheLogger ala req (responseStatus res) msize
sendResponse res | 189 | false | true | 0 | 15 | 42 | 85 | 37 | 48 | null | null |
lukexi/ghc-7.8-arm64 | compiler/codeGen/StgCmmPrim.hs | bsd-3-clause | translateOp _ DoubleGeOp = Just (MO_F_Ge W64) | 54 | translateOp _ DoubleGeOp = Just (MO_F_Ge W64) | 54 | translateOp _ DoubleGeOp = Just (MO_F_Ge W64) | 54 | false | false | 1 | 7 | 15 | 21 | 9 | 12 | null | null |
tolysz/prepare-ghcjs | spec-lts8/base-pure/GHC/Event/Manager.hs | bsd-3-clause | unless :: Monad m => Bool -> m () -> m ()
unless p = when (not p) | 65 | unless :: Monad m => Bool -> m () -> m ()
unless p = when (not p) | 65 | unless p = when (not p) | 23 | false | true | 0 | 10 | 17 | 53 | 23 | 30 | null | null |
castaway/pandoc | src/Text/Pandoc/Writers/Docx.hs | gpl-2.0 | inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst | 61 | inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst | 61 | inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst | 61 | false | false | 0 | 6 | 8 | 26 | 11 | 15 | null | null |
jac3km4/haskit | src/LuaJIT/ByteCode.hs | mit | uget a d = Instruction 43 $ TwoArgs a d | 39 | uget a d = Instruction 43 $ TwoArgs a d | 39 | uget a d = Instruction 43 $ TwoArgs a d | 39 | false | false | 3 | 5 | 9 | 28 | 10 | 18 | null | null |
sol/doctest | test/integration/template-haskell-bugfix/Main.hs | mit | -- The splice operator $ takes the Haskell source code
-- generated at compile time by "pr" and splices it into
-- the argument of "putStrLn".
main = putStrLn ( $(pr "Hello") ) | 176 | main = putStrLn ( $(pr "Hello") ) | 33 | main = putStrLn ( $(pr "Hello") ) | 33 | true | false | 0 | 9 | 32 | 22 | 12 | 10 | null | null |
Ertruby/PPFinalProject | src/Sprockell/Components.hs | gpl-2.0 | initRng :: Seed -> RngState
initRng seed = RngState (mkStdGen seed) | 67 | initRng :: Seed -> RngState
initRng seed = RngState (mkStdGen seed) | 67 | initRng seed = RngState (mkStdGen seed) | 39 | false | true | 0 | 7 | 10 | 30 | 14 | 16 | null | null |
mi-na/scotland_yard | src/CharacterD.hs | bsd-3-clause | getPlayerStatus :: Player -> (Int, Char, Node, [String])
getPlayerStatus targetP = (myNumber targetP, myOccupation targetP, myNode targetP, specialMethod targetP) | 162 | getPlayerStatus :: Player -> (Int, Char, Node, [String])
getPlayerStatus targetP = (myNumber targetP, myOccupation targetP, myNode targetP, specialMethod targetP) | 162 | getPlayerStatus targetP = (myNumber targetP, myOccupation targetP, myNode targetP, specialMethod targetP) | 105 | false | true | 0 | 9 | 18 | 63 | 32 | 31 | null | null |
XertroV/blocvoting | src/BlocVoting/Tally.hs | mit | getEmpowerment :: GrandTally -> Voter -> Int
getEmpowerment gt v = uj $ Map.lookup v (gtVoters gt)
where uj (Just i) = i
uj Nothing = 0 | 146 | getEmpowerment :: GrandTally -> Voter -> Int
getEmpowerment gt v = uj $ Map.lookup v (gtVoters gt)
where uj (Just i) = i
uj Nothing = 0 | 146 | getEmpowerment gt v = uj $ Map.lookup v (gtVoters gt)
where uj (Just i) = i
uj Nothing = 0 | 101 | false | true | 3 | 8 | 37 | 77 | 33 | 44 | null | null |
isomorphism/hackage2 | Distribution/Server/Util/NameIndex.hs | bsd-3-clause | lookupName :: String -> NameIndex -> Set String
lookupName caseName (NameIndex index _ _ _) =
Map.findWithDefault Set.empty (map toLower caseName) index | 156 | lookupName :: String -> NameIndex -> Set String
lookupName caseName (NameIndex index _ _ _) =
Map.findWithDefault Set.empty (map toLower caseName) index | 156 | lookupName caseName (NameIndex index _ _ _) =
Map.findWithDefault Set.empty (map toLower caseName) index | 108 | false | true | 0 | 7 | 25 | 62 | 29 | 33 | null | null |
jparyani/capnproto-boostpython | compiler/src/CxxGenerator.hs | bsd-2-clause | cxxFieldSizeString (SizeInlineComposite _ _) = "INLINE_COMPOSITE" | 65 | cxxFieldSizeString (SizeInlineComposite _ _) = "INLINE_COMPOSITE" | 65 | cxxFieldSizeString (SizeInlineComposite _ _) = "INLINE_COMPOSITE" | 65 | false | false | 0 | 6 | 5 | 18 | 8 | 10 | null | null |
ndmitchell/cmdargs | Data/Generics/Any/Prelude.hs | bsd-3-clause | fromTuple w = children (compose0 w $ typeShell w) | 49 | fromTuple w = children (compose0 w $ typeShell w) | 49 | fromTuple w = children (compose0 w $ typeShell w) | 49 | false | false | 1 | 8 | 8 | 29 | 11 | 18 | null | null |
sapek/pandoc | src/Text/Pandoc/Readers/Org.hs | gpl-2.0 | inlineNote :: OrgParser (F Inlines)
inlineNote = try $ do
string "[fn:"
ref <- many alphaNum
char ':'
note <- fmap B.para . trimInlinesF . mconcat <$> many1Till inline (char ']')
when (not $ null ref) $
addToNotesTable ("fn:" ++ ref, note)
return $ B.note <$> note | 283 | inlineNote :: OrgParser (F Inlines)
inlineNote = try $ do
string "[fn:"
ref <- many alphaNum
char ':'
note <- fmap B.para . trimInlinesF . mconcat <$> many1Till inline (char ']')
when (not $ null ref) $
addToNotesTable ("fn:" ++ ref, note)
return $ B.note <$> note | 283 | inlineNote = try $ do
string "[fn:"
ref <- many alphaNum
char ':'
note <- fmap B.para . trimInlinesF . mconcat <$> many1Till inline (char ']')
when (not $ null ref) $
addToNotesTable ("fn:" ++ ref, note)
return $ B.note <$> note | 247 | false | true | 0 | 13 | 65 | 127 | 58 | 69 | null | null |
sukhmel/algorithms.intro | part_1/chapter_2/MergeSort.hs | mit | inversions :: MonadWriter [(t, t)] m => t -> [t] -> m ()
inversions i js = writer ((), [(i, j) | j <- js]) | 107 | inversions :: MonadWriter [(t, t)] m => t -> [t] -> m ()
inversions i js = writer ((), [(i, j) | j <- js]) | 107 | inversions i js = writer ((), [(i, j) | j <- js]) | 49 | false | true | 0 | 9 | 25 | 78 | 42 | 36 | null | null |
ivanperez-keera/Yampa | yampa/tests/TestsLaws.hs | bsd-3-clause | laws_t1_lhs :: [Double]
laws_t1_lhs = testSF1 (integral >>> arr id) | 67 | laws_t1_lhs :: [Double]
laws_t1_lhs = testSF1 (integral >>> arr id) | 67 | laws_t1_lhs = testSF1 (integral >>> arr id) | 43 | false | true | 0 | 8 | 9 | 34 | 15 | 19 | null | null |
mukeshtiwari/formalized-voting | paper-code-with-ballot/Main.hs | mit | haskCoq (h : hs) = Cons h (haskCoq hs) | 38 | haskCoq (h : hs) = Cons h (haskCoq hs) | 38 | haskCoq (h : hs) = Cons h (haskCoq hs) | 38 | false | false | 0 | 6 | 8 | 29 | 13 | 16 | null | null |
siddhanathan/ghc | testsuite/tests/simplCore/should_compile/T5458.hs | bsd-3-clause | f :: T a -> Bool -> [Int]
f x b = case b of
True -> f x b
False -> x : f x (x > 19) | 114 | f :: T a -> Bool -> [Int]
f x b = case b of
True -> f x b
False -> x : f x (x > 19) | 114 | f x b = case b of
True -> f x b
False -> x : f x (x > 19) | 88 | false | true | 0 | 11 | 59 | 71 | 34 | 37 | null | null |
karamellpelle/grid | source/OpenGL/ES2/Values.hs | gpl-3.0 | gl_ELEMENT_ARRAY_BUFFER :: GLenum
gl_ELEMENT_ARRAY_BUFFER = 0x8893 | 74 | gl_ELEMENT_ARRAY_BUFFER :: GLenum
gl_ELEMENT_ARRAY_BUFFER = 0x8893 | 74 | gl_ELEMENT_ARRAY_BUFFER = 0x8893 | 40 | false | true | 0 | 4 | 13 | 11 | 6 | 5 | null | null |
olsner/ghc | compiler/cmm/CmmExpr.hs | bsd-3-clause | globalRegType dflags Hp = gcWord dflags | 54 | globalRegType dflags Hp = gcWord dflags | 54 | globalRegType dflags Hp = gcWord dflags | 54 | false | false | 0 | 5 | 20 | 14 | 6 | 8 | null | null |
urbanslug/ghc | testsuite/tests/perf/should_run/T4474b.hs | bsd-3-clause | fullTree 0 = Leaf 1 | 19 | fullTree 0 = Leaf 1 | 19 | fullTree 0 = Leaf 1 | 19 | false | false | 0 | 5 | 4 | 12 | 5 | 7 | null | null |
cchalmers/lens | src/Control/Lens/Plated.hs | bsd-3-clause | -- | Rewrite by applying a monadic rule everywhere you can. Ensures that the rule cannot
-- be applied anywhere in the result.
rewriteM :: (Monad m, Plated a) => (a -> m (Maybe a)) -> a -> m a
rewriteM = rewriteMOf plate | 220 | rewriteM :: (Monad m, Plated a) => (a -> m (Maybe a)) -> a -> m a
rewriteM = rewriteMOf plate | 93 | rewriteM = rewriteMOf plate | 27 | true | true | 0 | 11 | 43 | 58 | 30 | 28 | null | null |
bergmark/http2 | Network/HPACK/Table/DoubleHashMap.hs | bsd-3-clause | fromList :: Ord a => [(a,Header)] -> DoubleHashMap a
fromList alist = hashinner
where
ins !hp (!a,!dhm) = insert dhm a hp
!hashinner = foldl' ins empty alist | 167 | fromList :: Ord a => [(a,Header)] -> DoubleHashMap a
fromList alist = hashinner
where
ins !hp (!a,!dhm) = insert dhm a hp
!hashinner = foldl' ins empty alist | 167 | fromList alist = hashinner
where
ins !hp (!a,!dhm) = insert dhm a hp
!hashinner = foldl' ins empty alist | 114 | false | true | 0 | 8 | 37 | 80 | 38 | 42 | null | null |
GaloisInc/halvm-ghc | compiler/basicTypes/OccName.hs | bsd-3-clause | isValOcc _ = False | 37 | isValOcc _ = False | 37 | isValOcc _ = False | 37 | false | false | 0 | 5 | 22 | 9 | 4 | 5 | null | null |
shlevy/Idris-dev | src/Idris/CaseSplit.hs | bsd-3-clause | replaceSplits :: String -> [[(Name, PTerm)]] -> Idris [String]
replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
where
rep str [] = str ++ "\n"
rep str ((n, tm) : ups) = rep (updatePat False (show n) (nshow tm) str) ups
updateRHSs i [] = return []
updateRHSs i (x : xs) = do (x', i') <- updateRHS (null xs) i x
xs' <- updateRHSs i' xs
return (x' : xs')
updateRHS last i ('?':'=':xs) = do (xs', i') <- updateRHS last i xs
return ("?=" ++ xs', i')
updateRHS last i ('?':xs)
= do let (nm, rest_in) = span (not . (\x -> isSpace x || x == ')'
|| x == '(')) xs
let rest = if last then rest_in else
case span (not . (=='\n')) rest_in of
(_, restnl) -> restnl
(nm', i') <- getUniq nm i
return ('?':nm' ++ rest, i')
updateRHS last i (x : xs) = do (xs', i') <- updateRHS last i xs
return (x : xs', i')
updateRHS last i [] = return ("", i)
-- TMP HACK: If there are Nats, we don't want to show as numerals since
-- this isn't supported in a pattern, so special case here
nshow (PRef _ _ (UN z)) | z == txt "Z" = "Z"
nshow (PApp _ (PRef _ _ (UN s)) [x]) | s == txt "S" =
"(S " ++ addBrackets (nshow (getTm x)) ++ ")"
nshow t = show t
-- if there's any {n} replace with {n=n}
-- but don't replace it in comments
expandBraces ('{' : '-' : xs) = '{' : '-' : xs
expandBraces ('{' : xs)
= let (brace, (_:rest)) = span (/= '}') xs in
if (not ('=' `elem` brace))
then ('{' : brace ++ " = " ++ brace ++ "}") ++
expandBraces rest
else ('{' : brace ++ "}") ++ expandBraces rest
expandBraces (x : xs) = x : expandBraces xs
expandBraces [] = []
updatePat start n tm [] = []
updatePat start n tm ('{':rest) =
let (space, rest') = span isSpace rest in
'{' : space ++ updatePat False n tm rest'
updatePat start n tm done@('?':rest) = done
updatePat True n tm xs@(c:rest) | length xs > length n
= let (before, after@(next:_)) = splitAt (length n) xs in
if (before == n && not (isAlphaNum next))
then addBrackets tm ++ updatePat False n tm after
else c : updatePat (not (isAlphaNum c)) n tm rest
updatePat start n tm (c:rest) = c : updatePat (not ((isAlphaNum c) || c == '_')) n tm rest
addBrackets tm | ' ' `elem` tm
, not (isPrefixOf "(" tm)
, not (isSuffixOf ")" tm) = "(" ++ tm ++ ")"
| otherwise = tm | 2,837 | replaceSplits :: String -> [[(Name, PTerm)]] -> Idris [String]
replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
where
rep str [] = str ++ "\n"
rep str ((n, tm) : ups) = rep (updatePat False (show n) (nshow tm) str) ups
updateRHSs i [] = return []
updateRHSs i (x : xs) = do (x', i') <- updateRHS (null xs) i x
xs' <- updateRHSs i' xs
return (x' : xs')
updateRHS last i ('?':'=':xs) = do (xs', i') <- updateRHS last i xs
return ("?=" ++ xs', i')
updateRHS last i ('?':xs)
= do let (nm, rest_in) = span (not . (\x -> isSpace x || x == ')'
|| x == '(')) xs
let rest = if last then rest_in else
case span (not . (=='\n')) rest_in of
(_, restnl) -> restnl
(nm', i') <- getUniq nm i
return ('?':nm' ++ rest, i')
updateRHS last i (x : xs) = do (xs', i') <- updateRHS last i xs
return (x : xs', i')
updateRHS last i [] = return ("", i)
-- TMP HACK: If there are Nats, we don't want to show as numerals since
-- this isn't supported in a pattern, so special case here
nshow (PRef _ _ (UN z)) | z == txt "Z" = "Z"
nshow (PApp _ (PRef _ _ (UN s)) [x]) | s == txt "S" =
"(S " ++ addBrackets (nshow (getTm x)) ++ ")"
nshow t = show t
-- if there's any {n} replace with {n=n}
-- but don't replace it in comments
expandBraces ('{' : '-' : xs) = '{' : '-' : xs
expandBraces ('{' : xs)
= let (brace, (_:rest)) = span (/= '}') xs in
if (not ('=' `elem` brace))
then ('{' : brace ++ " = " ++ brace ++ "}") ++
expandBraces rest
else ('{' : brace ++ "}") ++ expandBraces rest
expandBraces (x : xs) = x : expandBraces xs
expandBraces [] = []
updatePat start n tm [] = []
updatePat start n tm ('{':rest) =
let (space, rest') = span isSpace rest in
'{' : space ++ updatePat False n tm rest'
updatePat start n tm done@('?':rest) = done
updatePat True n tm xs@(c:rest) | length xs > length n
= let (before, after@(next:_)) = splitAt (length n) xs in
if (before == n && not (isAlphaNum next))
then addBrackets tm ++ updatePat False n tm after
else c : updatePat (not (isAlphaNum c)) n tm rest
updatePat start n tm (c:rest) = c : updatePat (not ((isAlphaNum c) || c == '_')) n tm rest
addBrackets tm | ' ' `elem` tm
, not (isPrefixOf "(" tm)
, not (isSuffixOf ")" tm) = "(" ++ tm ++ ")"
| otherwise = tm | 2,837 | replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
where
rep str [] = str ++ "\n"
rep str ((n, tm) : ups) = rep (updatePat False (show n) (nshow tm) str) ups
updateRHSs i [] = return []
updateRHSs i (x : xs) = do (x', i') <- updateRHS (null xs) i x
xs' <- updateRHSs i' xs
return (x' : xs')
updateRHS last i ('?':'=':xs) = do (xs', i') <- updateRHS last i xs
return ("?=" ++ xs', i')
updateRHS last i ('?':xs)
= do let (nm, rest_in) = span (not . (\x -> isSpace x || x == ')'
|| x == '(')) xs
let rest = if last then rest_in else
case span (not . (=='\n')) rest_in of
(_, restnl) -> restnl
(nm', i') <- getUniq nm i
return ('?':nm' ++ rest, i')
updateRHS last i (x : xs) = do (xs', i') <- updateRHS last i xs
return (x : xs', i')
updateRHS last i [] = return ("", i)
-- TMP HACK: If there are Nats, we don't want to show as numerals since
-- this isn't supported in a pattern, so special case here
nshow (PRef _ _ (UN z)) | z == txt "Z" = "Z"
nshow (PApp _ (PRef _ _ (UN s)) [x]) | s == txt "S" =
"(S " ++ addBrackets (nshow (getTm x)) ++ ")"
nshow t = show t
-- if there's any {n} replace with {n=n}
-- but don't replace it in comments
expandBraces ('{' : '-' : xs) = '{' : '-' : xs
expandBraces ('{' : xs)
= let (brace, (_:rest)) = span (/= '}') xs in
if (not ('=' `elem` brace))
then ('{' : brace ++ " = " ++ brace ++ "}") ++
expandBraces rest
else ('{' : brace ++ "}") ++ expandBraces rest
expandBraces (x : xs) = x : expandBraces xs
expandBraces [] = []
updatePat start n tm [] = []
updatePat start n tm ('{':rest) =
let (space, rest') = span isSpace rest in
'{' : space ++ updatePat False n tm rest'
updatePat start n tm done@('?':rest) = done
updatePat True n tm xs@(c:rest) | length xs > length n
= let (before, after@(next:_)) = splitAt (length n) xs in
if (before == n && not (isAlphaNum next))
then addBrackets tm ++ updatePat False n tm after
else c : updatePat (not (isAlphaNum c)) n tm rest
updatePat start n tm (c:rest) = c : updatePat (not ((isAlphaNum c) || c == '_')) n tm rest
addBrackets tm | ' ' `elem` tm
, not (isPrefixOf "(" tm)
, not (isSuffixOf ")" tm) = "(" ++ tm ++ ")"
| otherwise = tm | 2,774 | false | true | 30 | 30 | 1,100 | 1,188 | 606 | 582 | null | null |
sweirich/tal | src/K.hs | mit | z :: Name Tm
(x,y,z) = (string2Name "x", string2Name "y", string2Name "z") | 74 | z :: Name Tm
(x,y,z) = (string2Name "x", string2Name "y", string2Name "z") | 74 | (x,y,z) = (string2Name "x", string2Name "y", string2Name "z") | 61 | false | true | 1 | 6 | 11 | 45 | 22 | 23 | null | null |
sdiehl/print | src/Print.hs | mit | appPrec1 = 11 | 13 | appPrec1 = 11 | 13 | appPrec1 = 11 | 13 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
nakamuray/mangekyo | src/Mangekyo/Interpreter.hs | bsd-2-clause | match (PVariable v (Just p)) o = do
vos <- match p o
return $ (v, o) : vos | 82 | match (PVariable v (Just p)) o = do
vos <- match p o
return $ (v, o) : vos | 82 | match (PVariable v (Just p)) o = do
vos <- match p o
return $ (v, o) : vos | 82 | false | false | 1 | 9 | 26 | 59 | 26 | 33 | null | null |
urbanslug/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | rec1TyConName = tcQual gHC_GENERICS (fsLit "Rec1") rec1TyConKey | 64 | rec1TyConName = tcQual gHC_GENERICS (fsLit "Rec1") rec1TyConKey | 64 | rec1TyConName = tcQual gHC_GENERICS (fsLit "Rec1") rec1TyConKey | 64 | false | false | 0 | 7 | 7 | 19 | 9 | 10 | null | null |
arianvp/crdt | src/CRDT/PNCounter.hs | bsd-3-clause | -- | Decrements the counter
decrement :: Ord a => a -> PNCounter a -> PNCounter a
decrement i (PNCounter p n) = PNCounter p (GCounter.increment i n) | 149 | decrement :: Ord a => a -> PNCounter a -> PNCounter a
decrement i (PNCounter p n) = PNCounter p (GCounter.increment i n) | 121 | decrement i (PNCounter p n) = PNCounter p (GCounter.increment i n) | 66 | true | true | 0 | 8 | 28 | 61 | 29 | 32 | null | null |
batkot/haskell-bf | src/Parser.hs | bsd-3-clause | optimizeStep acc ((Move 0):cs) = optimizeStep acc cs | 52 | optimizeStep acc ((Move 0):cs) = optimizeStep acc cs | 52 | optimizeStep acc ((Move 0):cs) = optimizeStep acc cs | 52 | false | false | 0 | 9 | 7 | 29 | 14 | 15 | null | null |
rueshyna/gogol | gogol-cloudmonitoring/gen/Network/Google/CloudMonitoring/Types/Product.hs | mpl-2.0 | -- | The label\'s name.
wtrCommonLabels :: Lens' WriteTimeseriesRequest (Maybe WriteTimeseriesRequestCommonLabels)
wtrCommonLabels
= lens _wtrCommonLabels
(\ s a -> s{_wtrCommonLabels = a}) | 197 | wtrCommonLabels :: Lens' WriteTimeseriesRequest (Maybe WriteTimeseriesRequestCommonLabels)
wtrCommonLabels
= lens _wtrCommonLabels
(\ s a -> s{_wtrCommonLabels = a}) | 173 | wtrCommonLabels
= lens _wtrCommonLabels
(\ s a -> s{_wtrCommonLabels = a}) | 82 | true | true | 0 | 9 | 29 | 48 | 25 | 23 | null | null |
emwap/feldspar-compiler | src/Feldspar/Compiler/Frontend/CommandLine/Main.hs | bsd-3-clause | mergeModules (x:xs) = Module {
entities = nub $ entities x ++ entities (mergeModules xs) -- nub is in fact a "global plugin" here
} | 135 | mergeModules (x:xs) = Module {
entities = nub $ entities x ++ entities (mergeModules xs) -- nub is in fact a "global plugin" here
} | 135 | mergeModules (x:xs) = Module {
entities = nub $ entities x ++ entities (mergeModules xs) -- nub is in fact a "global plugin" here
} | 135 | false | false | 0 | 10 | 28 | 45 | 23 | 22 | null | null |
Ming-Tang/FP15 | src/FP15/Evaluator/Number.hs | mit | getTower (IntN _) = IntT | 24 | getTower (IntN _) = IntT | 24 | getTower (IntN _) = IntT | 24 | false | false | 0 | 7 | 4 | 15 | 7 | 8 | null | null |
mitsuji/bingo | app/Main.hs | bsd-3-clause | lookupParams :: BS.ByteString -> [(BS.ByteString,BS.ByteString)] -> Maybe String
lookupParams key params = do
b <- Map.lookup key $ Map.fromList params
return $ T.unpack $ decodeUtf8 b | 188 | lookupParams :: BS.ByteString -> [(BS.ByteString,BS.ByteString)] -> Maybe String
lookupParams key params = do
b <- Map.lookup key $ Map.fromList params
return $ T.unpack $ decodeUtf8 b | 188 | lookupParams key params = do
b <- Map.lookup key $ Map.fromList params
return $ T.unpack $ decodeUtf8 b | 107 | false | true | 0 | 10 | 29 | 79 | 38 | 41 | null | null |
fjarri/haskell-random123 | test/TestTypeclasses.hs | bsd-3-clause | test_li1x64_bijection initial = initial == mapped initial where
types = initial :: Word64
mapped = liFromInteger . liToInteger | 134 | test_li1x64_bijection initial = initial == mapped initial where
types = initial :: Word64
mapped = liFromInteger . liToInteger | 134 | test_li1x64_bijection initial = initial == mapped initial where
types = initial :: Word64
mapped = liFromInteger . liToInteger | 134 | false | false | 0 | 7 | 25 | 35 | 18 | 17 | null | null |
nevrenato/Hets_Fork | Common/MathLink.hs | gpl-2.0 | dfSYNTAXPKT = 10 | 16 | dfSYNTAXPKT = 10 | 16 | dfSYNTAXPKT = 10 | 16 | false | false | 1 | 5 | 2 | 10 | 3 | 7 | null | null |
AlexanderPankiv/ghc | compiler/deSugar/DsForeign.hs | bsd-3-clause | -- This function returns the primitive type associated with the boxed
-- type argument to a foreign export (eg. Int ==> Int#).
getPrimTyOf :: Type -> UnaryType
getPrimTyOf ty
| isBoolTy rep_ty = intPrimTy
-- Except for Bool, the types we are interested in have a single constructor
-- with a single primitive-typed argument (see TcType.legalFEArgTyCon).
| otherwise =
case splitDataProductType_maybe rep_ty of
Just (_, _, data_con, [prim_ty]) ->
ASSERT(dataConSourceArity data_con == 1)
ASSERT2(isUnLiftedType prim_ty, ppr prim_ty)
prim_ty
_other -> pprPanic "DsForeign.getPrimTyOf" (ppr ty)
where
UnaryRep rep_ty = repType ty
-- represent a primitive type as a Char, for building a string that
-- described the foreign function type. The types are size-dependent,
-- e.g. 'W' is a signed 32-bit integer. | 860 | getPrimTyOf :: Type -> UnaryType
getPrimTyOf ty
| isBoolTy rep_ty = intPrimTy
-- Except for Bool, the types we are interested in have a single constructor
-- with a single primitive-typed argument (see TcType.legalFEArgTyCon).
| otherwise =
case splitDataProductType_maybe rep_ty of
Just (_, _, data_con, [prim_ty]) ->
ASSERT(dataConSourceArity data_con == 1)
ASSERT2(isUnLiftedType prim_ty, ppr prim_ty)
prim_ty
_other -> pprPanic "DsForeign.getPrimTyOf" (ppr ty)
where
UnaryRep rep_ty = repType ty
-- represent a primitive type as a Char, for building a string that
-- described the foreign function type. The types are size-dependent,
-- e.g. 'W' is a signed 32-bit integer. | 733 | getPrimTyOf ty
| isBoolTy rep_ty = intPrimTy
-- Except for Bool, the types we are interested in have a single constructor
-- with a single primitive-typed argument (see TcType.legalFEArgTyCon).
| otherwise =
case splitDataProductType_maybe rep_ty of
Just (_, _, data_con, [prim_ty]) ->
ASSERT(dataConSourceArity data_con == 1)
ASSERT2(isUnLiftedType prim_ty, ppr prim_ty)
prim_ty
_other -> pprPanic "DsForeign.getPrimTyOf" (ppr ty)
where
UnaryRep rep_ty = repType ty
-- represent a primitive type as a Char, for building a string that
-- described the foreign function type. The types are size-dependent,
-- e.g. 'W' is a signed 32-bit integer. | 700 | true | true | 1 | 11 | 176 | 133 | 69 | 64 | null | null |
fmthoma/ghc | compiler/hsSyn/HsExpr.hs | bsd-3-clause | ppr_expr (HsOverLit lit) = ppr lit | 34 | ppr_expr (HsOverLit lit) = ppr lit | 34 | ppr_expr (HsOverLit lit) = ppr lit | 34 | false | false | 0 | 7 | 5 | 18 | 8 | 10 | null | null |
paulbarbu/ePseudocode | src/EPseudocode/Builtins.hs | bsd-3-clause | fread :: [[Expr]] -> ErrorWithIO Expr
fread [[File f]] = do
i <- liftIO $ try $ hGetLine f
case i of
Left err -> if isEOFError err then return (Bool False) else throwError "Unexpected error"
Right val -> return $ String val | 247 | fread :: [[Expr]] -> ErrorWithIO Expr
fread [[File f]] = do
i <- liftIO $ try $ hGetLine f
case i of
Left err -> if isEOFError err then return (Bool False) else throwError "Unexpected error"
Right val -> return $ String val | 247 | fread [[File f]] = do
i <- liftIO $ try $ hGetLine f
case i of
Left err -> if isEOFError err then return (Bool False) else throwError "Unexpected error"
Right val -> return $ String val | 209 | false | true | 0 | 13 | 66 | 109 | 52 | 57 | null | null |
hsyl20/ViperVM | haskus-system/src/lib/Haskus/Arch/X86_64/Linux/SyscallTable.hs | bsd-3-clause | syscalls :: QuasiQuoter
syscalls = QuasiQuoter
{ quoteDec = makeSyscalls
, quoteExp = undefined
, quotePat = undefined
, quoteType = undefined
} | 162 | syscalls :: QuasiQuoter
syscalls = QuasiQuoter
{ quoteDec = makeSyscalls
, quoteExp = undefined
, quotePat = undefined
, quoteType = undefined
} | 162 | syscalls = QuasiQuoter
{ quoteDec = makeSyscalls
, quoteExp = undefined
, quotePat = undefined
, quoteType = undefined
} | 138 | false | true | 0 | 7 | 40 | 41 | 24 | 17 | null | null |
39aldo39/klfc | src/Xkb/XCompose.hs | gpl-3.0 | printCustomDeadKeys ∷ Layout → [String]
printCustomDeadKeys = concatMap (concatMap printCustomDeadKey ∘ view _letters) ∘ view _keys | 131 | printCustomDeadKeys ∷ Layout → [String]
printCustomDeadKeys = concatMap (concatMap printCustomDeadKey ∘ view _letters) ∘ view _keys | 131 | printCustomDeadKeys = concatMap (concatMap printCustomDeadKey ∘ view _letters) ∘ view _keys | 91 | false | true | 0 | 9 | 15 | 41 | 20 | 21 | null | null |
siddhanathan/ghc | testsuite/tests/rename/should_compile/timing001.hs | bsd-3-clause | a056 = a057 | 11 | a056 = a057 | 11 | a056 = a057 | 11 | false | false | 1 | 5 | 2 | 10 | 3 | 7 | null | null |
shlevy/ghc | compiler/typecheck/TcRnTypes.hs | bsd-3-clause | -- | No signature or a partial signature
hasCompleteSig :: TcSigFun -> Name -> Bool
hasCompleteSig sig_fn name
= case sig_fn name of
Just (TcIdSig (CompleteSig {})) -> True
_ -> False
{-
************************************************************************
* *
* Canonical constraints *
* *
* These are the constraints the low-level simplifier works with *
* *
************************************************************************
-}
-- The syntax of xi (ξ) types:
-- xi ::= a | T xis | xis -> xis | ... | forall a. tau
-- Two important notes:
-- (i) No type families, unless we are under a ForAll
-- (ii) Note that xi types can contain unexpanded type synonyms;
-- however, the (transitive) expansions of those type synonyms
-- will not contain any type functions, unless we are under a ForAll.
-- We enforce the structure of Xi types when we flatten (TcCanonical) | 1,209 | hasCompleteSig :: TcSigFun -> Name -> Bool
hasCompleteSig sig_fn name
= case sig_fn name of
Just (TcIdSig (CompleteSig {})) -> True
_ -> False
{-
************************************************************************
* *
* Canonical constraints *
* *
* These are the constraints the low-level simplifier works with *
* *
************************************************************************
-}
-- The syntax of xi (ξ) types:
-- xi ::= a | T xis | xis -> xis | ... | forall a. tau
-- Two important notes:
-- (i) No type families, unless we are under a ForAll
-- (ii) Note that xi types can contain unexpanded type synonyms;
-- however, the (transitive) expansions of those type synonyms
-- will not contain any type functions, unless we are under a ForAll.
-- We enforce the structure of Xi types when we flatten (TcCanonical) | 1,168 | hasCompleteSig sig_fn name
= case sig_fn name of
Just (TcIdSig (CompleteSig {})) -> True
_ -> False
{-
************************************************************************
* *
* Canonical constraints *
* *
* These are the constraints the low-level simplifier works with *
* *
************************************************************************
-}
-- The syntax of xi (ξ) types:
-- xi ::= a | T xis | xis -> xis | ... | forall a. tau
-- Two important notes:
-- (i) No type families, unless we are under a ForAll
-- (ii) Note that xi types can contain unexpanded type synonyms;
-- however, the (transitive) expansions of those type synonyms
-- will not contain any type functions, unless we are under a ForAll.
-- We enforce the structure of Xi types when we flatten (TcCanonical) | 1,125 | true | true | 0 | 12 | 478 | 75 | 40 | 35 | null | null |
brendanhay/gogol | gogol-appengine/gen/Network/Google/Resource/AppEngine/Apps/AuthorizedCertificates/List.hs | mpl-2.0 | -- | Continuation token for fetching the next page of results.
aaclPageToken :: Lens' AppsAuthorizedCertificatesList (Maybe Text)
aaclPageToken
= lens _aaclPageToken
(\ s a -> s{_aaclPageToken = a}) | 206 | aaclPageToken :: Lens' AppsAuthorizedCertificatesList (Maybe Text)
aaclPageToken
= lens _aaclPageToken
(\ s a -> s{_aaclPageToken = a}) | 143 | aaclPageToken
= lens _aaclPageToken
(\ s a -> s{_aaclPageToken = a}) | 76 | true | true | 1 | 9 | 35 | 51 | 25 | 26 | null | null |
icyfork/shellcheck | ShellCheck/Analytics.hs | gpl-3.0 | checkValidCondOps _ _ = return () | 33 | checkValidCondOps _ _ = return () | 33 | checkValidCondOps _ _ = return () | 33 | false | false | 1 | 6 | 5 | 16 | 7 | 9 | null | null |
sebmathguy/chatex | src/Main.hs | gpl-3.0 | main :: IO ()
main = do
userBuffers <- atomically $ (newTVar (empty :: Map User (TChan Text)))
scotty 9987 $ multiUser userBuffers | 134 | main :: IO ()
main = do
userBuffers <- atomically $ (newTVar (empty :: Map User (TChan Text)))
scotty 9987 $ multiUser userBuffers | 134 | main = do
userBuffers <- atomically $ (newTVar (empty :: Map User (TChan Text)))
scotty 9987 $ multiUser userBuffers | 120 | false | true | 0 | 14 | 26 | 63 | 30 | 33 | null | null |
petertseng/adventofcode-hs | bin/12_json_numbers.hs | apache-2.0 | parseC :: Char -> ParseState -> Either String ParseState
-- in string
parseC c ps@ParseState { inString = True } = case (c, ps) of
('r', _) | redStart ps + 1 == idx ps -> incRedGood ps
('e', _) | redStart ps + 2 == idx ps -> incRedGood ps
('d', _) | redStart ps + 3 == idx ps -> incRedGood ps
-- "red"
('"', ParseState { nest = Object _:ns, redGood = 3 }) | redStart ps + 4 == idx ps ->
-- assumes that there is never a key "red"
Right (ps { nest = Object True:ns, inString = False })
-- any other close quote
('"', _) -> Right (ps { inString = False })
_ -> Right ps
-- not in string | 608 | parseC :: Char -> ParseState -> Either String ParseState
parseC c ps@ParseState { inString = True } = case (c, ps) of
('r', _) | redStart ps + 1 == idx ps -> incRedGood ps
('e', _) | redStart ps + 2 == idx ps -> incRedGood ps
('d', _) | redStart ps + 3 == idx ps -> incRedGood ps
-- "red"
('"', ParseState { nest = Object _:ns, redGood = 3 }) | redStart ps + 4 == idx ps ->
-- assumes that there is never a key "red"
Right (ps { nest = Object True:ns, inString = False })
-- any other close quote
('"', _) -> Right (ps { inString = False })
_ -> Right ps
-- not in string | 595 | parseC c ps@ParseState { inString = True } = case (c, ps) of
('r', _) | redStart ps + 1 == idx ps -> incRedGood ps
('e', _) | redStart ps + 2 == idx ps -> incRedGood ps
('d', _) | redStart ps + 3 == idx ps -> incRedGood ps
-- "red"
('"', ParseState { nest = Object _:ns, redGood = 3 }) | redStart ps + 4 == idx ps ->
-- assumes that there is never a key "red"
Right (ps { nest = Object True:ns, inString = False })
-- any other close quote
('"', _) -> Right (ps { inString = False })
_ -> Right ps
-- not in string | 538 | true | true | 0 | 14 | 152 | 277 | 141 | 136 | null | null |
taktoa/TSLogAnalyzer | library/Utility/TSLogAnalyzer/Parse.hs | gpl-3.0 | -- | Parse a connection
parseConn :: LogEntry -> Maybe (Time, Connection)
parseConn (LogEntry t INFO VirtualServerBase m) = (t,) <$> connParse (m <> ";") | 153 | parseConn :: LogEntry -> Maybe (Time, Connection)
parseConn (LogEntry t INFO VirtualServerBase m) = (t,) <$> connParse (m <> ";") | 129 | parseConn (LogEntry t INFO VirtualServerBase m) = (t,) <$> connParse (m <> ";") | 79 | true | true | 0 | 8 | 24 | 58 | 31 | 27 | null | null |
bjornbm/astro | test/Astro/Coords/TNRSpec.hs | bsd-3-clause | spec_trivialSV = describe "A trivial state vector" $ do
it "gives a correct orbital (TNR) frame" $
orbitalFrame pv == _Y |: _Z |:. _X
it "gives a correct attiude (RPY) frame" $
attitudeCoordSys pv ~== _Y |: negateVec _Z |:. negateVec _X
where
r = scaleVec ((1::Double) *~ meter) _X :: Car DLength Double
v = scaleVec (1 *~ (meter / second)) _Y
pv = C' r v | 384 | spec_trivialSV = describe "A trivial state vector" $ do
it "gives a correct orbital (TNR) frame" $
orbitalFrame pv == _Y |: _Z |:. _X
it "gives a correct attiude (RPY) frame" $
attitudeCoordSys pv ~== _Y |: negateVec _Z |:. negateVec _X
where
r = scaleVec ((1::Double) *~ meter) _X :: Car DLength Double
v = scaleVec (1 *~ (meter / second)) _Y
pv = C' r v | 384 | spec_trivialSV = describe "A trivial state vector" $ do
it "gives a correct orbital (TNR) frame" $
orbitalFrame pv == _Y |: _Z |:. _X
it "gives a correct attiude (RPY) frame" $
attitudeCoordSys pv ~== _Y |: negateVec _Z |:. negateVec _X
where
r = scaleVec ((1::Double) *~ meter) _X :: Car DLength Double
v = scaleVec (1 *~ (meter / second)) _Y
pv = C' r v | 384 | false | false | 5 | 12 | 97 | 145 | 64 | 81 | null | null |
rahulmutt/codec-jvm | src/Codec/JVM/Opcode.hs | apache-2.0 | dload_3 = Opcode 0x29 | 21 | dload_3 = Opcode 0x29 | 21 | dload_3 = Opcode 0x29 | 21 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
brendanhay/gogol | gogol-spanner/gen/Network/Google/Spanner/Types/Product.hs | mpl-2.0 | -- | The desired end state of the update.
uimInstance :: Lens' UpdateInstanceMetadata (Maybe Instance)
uimInstance
= lens _uimInstance (\ s a -> s{_uimInstance = a}) | 167 | uimInstance :: Lens' UpdateInstanceMetadata (Maybe Instance)
uimInstance
= lens _uimInstance (\ s a -> s{_uimInstance = a}) | 125 | uimInstance
= lens _uimInstance (\ s a -> s{_uimInstance = a}) | 64 | true | true | 1 | 9 | 27 | 52 | 25 | 27 | null | null |
SavinaRoja/challenges | Rosalind/String_Algorithms/dna.hs | unlicense | main :: IO ()
main = do
args <- getArgs
contents <- BL.readFile (head args)
let counts = countMap contents
let lookupHelper k = show (M.findWithDefault 0 k counts)
-- This prints out the results in problem answer format: #A, #C, #G, #T
-- In ASCII: A = 65, C = 67, G = 71, T = 84
putStr $ intercalate " " $ map lookupHelper [65, 67, 71, 84] | 354 | main :: IO ()
main = do
args <- getArgs
contents <- BL.readFile (head args)
let counts = countMap contents
let lookupHelper k = show (M.findWithDefault 0 k counts)
-- This prints out the results in problem answer format: #A, #C, #G, #T
-- In ASCII: A = 65, C = 67, G = 71, T = 84
putStr $ intercalate " " $ map lookupHelper [65, 67, 71, 84] | 354 | main = do
args <- getArgs
contents <- BL.readFile (head args)
let counts = countMap contents
let lookupHelper k = show (M.findWithDefault 0 k counts)
-- This prints out the results in problem answer format: #A, #C, #G, #T
-- In ASCII: A = 65, C = 67, G = 71, T = 84
putStr $ intercalate " " $ map lookupHelper [65, 67, 71, 84] | 340 | false | true | 0 | 14 | 83 | 119 | 55 | 64 | null | null |
nevrenato/Hets_Fork | Temporal/NuSmv.hs | gpl-2.0 | typeSpec :: Parser Type
typeSpec = boolSpec
<|> wordSpec
<|> enumSpec
<|> rangeSpec
<|> arraySpec
where
boolSpec = do keyword "boolean"
return BoolType
wordSpec = do keyword "word"
token "["
width <- integer
token "]"
return (WordType width)
enumSpec = do token "{"
values <- sepBy1 (liftM Symbol identifier <|> liftM Number integer) (ws >> token ",")
token "}"
return (EnumType values)
rangeSpec = do from <- integer
token ".."
to <- integer
return (RangeType from to)
arraySpec = do keyword "array"
from <- integer
token ".."
to <- integer
keyword "of"
ty <- typeSpec
return (ArrayType from to ty)
{------------------------------------------------------------------------------} | 1,078 | typeSpec :: Parser Type
typeSpec = boolSpec
<|> wordSpec
<|> enumSpec
<|> rangeSpec
<|> arraySpec
where
boolSpec = do keyword "boolean"
return BoolType
wordSpec = do keyword "word"
token "["
width <- integer
token "]"
return (WordType width)
enumSpec = do token "{"
values <- sepBy1 (liftM Symbol identifier <|> liftM Number integer) (ws >> token ",")
token "}"
return (EnumType values)
rangeSpec = do from <- integer
token ".."
to <- integer
return (RangeType from to)
arraySpec = do keyword "array"
from <- integer
token ".."
to <- integer
keyword "of"
ty <- typeSpec
return (ArrayType from to ty)
{------------------------------------------------------------------------------} | 1,078 | typeSpec = boolSpec
<|> wordSpec
<|> enumSpec
<|> rangeSpec
<|> arraySpec
where
boolSpec = do keyword "boolean"
return BoolType
wordSpec = do keyword "word"
token "["
width <- integer
token "]"
return (WordType width)
enumSpec = do token "{"
values <- sepBy1 (liftM Symbol identifier <|> liftM Number integer) (ws >> token ",")
token "}"
return (EnumType values)
rangeSpec = do from <- integer
token ".."
to <- integer
return (RangeType from to)
arraySpec = do keyword "array"
from <- integer
token ".."
to <- integer
keyword "of"
ty <- typeSpec
return (ArrayType from to ty)
{------------------------------------------------------------------------------} | 1,054 | false | true | 17 | 11 | 498 | 293 | 122 | 171 | null | null |
gitfoxi/vcd-haskell | app/hus-x1-hub.hs | agpl-3.0 | parseOpts :: OptionsParser Opts
parseOpts = Opts
<$> argument str
( metavar "HUSFILE.hus"
<> value ""
<> help "A Horizontal-Uncompressed State file (or use stdin)") | 185 | parseOpts :: OptionsParser Opts
parseOpts = Opts
<$> argument str
( metavar "HUSFILE.hus"
<> value ""
<> help "A Horizontal-Uncompressed State file (or use stdin)") | 185 | parseOpts = Opts
<$> argument str
( metavar "HUSFILE.hus"
<> value ""
<> help "A Horizontal-Uncompressed State file (or use stdin)") | 153 | false | true | 2 | 9 | 45 | 46 | 20 | 26 | null | null |
li-zhirui/EoplLangs | test/MutablePairs/EvaluatorSuite.hs | bsd-3-clause | testPair :: Test
testPair = TestList
[ testEq "Eval left of a pair should be the first value"
(ExprNum 1)
"let x = 1 y = 2 in left(pair(x, y))"
, testEq "Eval right of a pair should be the second value"
(ExprNum 2)
"let x = 1 y = 2 in right(pair(x, y))"
, testEq "Test set left"
(ExprNum 3)
$ unlines
[ "let p = pair(1, 2)"
, "in begin"
, " setleft(p, 3);"
, " left(p) "
, " end"
]
, testEq "Test set right"
(ExprNum 4)
$ unlines
[ "let p = pair(1, 2)"
, "in begin"
, " setright(p, 4);"
, " right(p) "
, " end"
]
] | 789 | testPair :: Test
testPair = TestList
[ testEq "Eval left of a pair should be the first value"
(ExprNum 1)
"let x = 1 y = 2 in left(pair(x, y))"
, testEq "Eval right of a pair should be the second value"
(ExprNum 2)
"let x = 1 y = 2 in right(pair(x, y))"
, testEq "Test set left"
(ExprNum 3)
$ unlines
[ "let p = pair(1, 2)"
, "in begin"
, " setleft(p, 3);"
, " left(p) "
, " end"
]
, testEq "Test set right"
(ExprNum 4)
$ unlines
[ "let p = pair(1, 2)"
, "in begin"
, " setright(p, 4);"
, " right(p) "
, " end"
]
] | 789 | testPair = TestList
[ testEq "Eval left of a pair should be the first value"
(ExprNum 1)
"let x = 1 y = 2 in left(pair(x, y))"
, testEq "Eval right of a pair should be the second value"
(ExprNum 2)
"let x = 1 y = 2 in right(pair(x, y))"
, testEq "Test set left"
(ExprNum 3)
$ unlines
[ "let p = pair(1, 2)"
, "in begin"
, " setleft(p, 3);"
, " left(p) "
, " end"
]
, testEq "Test set right"
(ExprNum 4)
$ unlines
[ "let p = pair(1, 2)"
, "in begin"
, " setright(p, 4);"
, " right(p) "
, " end"
]
] | 772 | false | true | 0 | 10 | 389 | 125 | 64 | 61 | null | null |
fpco/schoolofhaskell.com | src/Handler/User.hs | mit | sidebarHelper :: Html -- ^ tutorial sidebar
-> Maybe TutorialContent -> Handler Widget
sidebarHelper tutSidebar msidebarContent =
withPadding . snd <$> sidebarContent
where
sidebarContent = maybe (return mempty) displayTutorial msidebarContent
--TODO: tidier
withPadding body =
[whamlet|
$newline never
<div style=padding-top:20px; itemprop=desc>
^{body}
\#{tutSidebar}
|] | 456 | sidebarHelper :: Html -- ^ tutorial sidebar
-> Maybe TutorialContent -> Handler Widget
sidebarHelper tutSidebar msidebarContent =
withPadding . snd <$> sidebarContent
where
sidebarContent = maybe (return mempty) displayTutorial msidebarContent
--TODO: tidier
withPadding body =
[whamlet|
$newline never
<div style=padding-top:20px; itemprop=desc>
^{body}
\#{tutSidebar}
|] | 456 | sidebarHelper tutSidebar msidebarContent =
withPadding . snd <$> sidebarContent
where
sidebarContent = maybe (return mempty) displayTutorial msidebarContent
--TODO: tidier
withPadding body =
[whamlet|
$newline never
<div style=padding-top:20px; itemprop=desc>
^{body}
\#{tutSidebar}
|] | 355 | false | true | 0 | 7 | 127 | 73 | 38 | 35 | null | null |
agrafix/legoDSL | NXT/Types.hs | bsd-3-clause | toCName NXTFloat = "float" | 26 | toCName NXTFloat = "float" | 26 | toCName NXTFloat = "float" | 26 | false | false | 0 | 4 | 3 | 10 | 4 | 6 | null | null |
mwu-tow/language-c-quote | Language/C/Pretty.hs | bsd-3-clause | angleList :: [Doc] -> Doc
angleList = enclosesep langle rangle comma | 68 | angleList :: [Doc] -> Doc
angleList = enclosesep langle rangle comma | 68 | angleList = enclosesep langle rangle comma | 42 | false | true | 0 | 7 | 10 | 32 | 14 | 18 | null | null |
limaner2002/EPC-tools | USACScripts/src/Scripts/Execute.hs | bsd-3-clause | setTimeout :: ResponseTimeout -> ManagerSettings -> ManagerSettings
setTimeout timeout settings = settings { managerResponseTimeout = timeout } | 143 | setTimeout :: ResponseTimeout -> ManagerSettings -> ManagerSettings
setTimeout timeout settings = settings { managerResponseTimeout = timeout } | 143 | setTimeout timeout settings = settings { managerResponseTimeout = timeout } | 75 | false | true | 0 | 6 | 16 | 32 | 17 | 15 | null | null |
ambiata/mafia | src/Mafia/Cache.hs | bsd-3-clause | -- the package cache path includes a version number in case the contents or
-- layout of the cache changes in subsequent mafia versions.
cacheVersion :: Int
cacheVersion =
3 | 175 | cacheVersion :: Int
cacheVersion =
3 | 38 | cacheVersion =
3 | 18 | true | true | 0 | 6 | 31 | 20 | 9 | 11 | null | null |
sol/hspec-experimental | test/Test/Hspec/ExperimentalSpec.hs | mit | spec :: Spec
spec = do
describe "Expectation as an example" $ do
it "is executed only once" $ do
ref <- newIORef (23 :: Int)
let testSpec = H.it "some behavior" (modifyIORef ref succ)
H.hspec testSpec
readIORef ref `shouldReturn` 24
it "can be quantified" $ do
ref <- newIORef (23 :: Int)
let testSpec =
H.it "some behavior" $ \xs -> do
modifyIORef ref succ
(reverse . reverse) xs `shouldBe` (xs :: [Int])
H.hspec testSpec
readIORef ref `shouldReturn` 123
describe "pending" $ do
it "specifies a pending example" $ do
r <- runSpec $ do
H.it "foo" H.pending
r `shouldSatisfy` any (== " # PENDING: No reason given")
where
runSpec :: H.Spec -> IO [String]
runSpec = fmap lines . capture_ . H.hspecWith H.defaultConfig | 854 | spec :: Spec
spec = do
describe "Expectation as an example" $ do
it "is executed only once" $ do
ref <- newIORef (23 :: Int)
let testSpec = H.it "some behavior" (modifyIORef ref succ)
H.hspec testSpec
readIORef ref `shouldReturn` 24
it "can be quantified" $ do
ref <- newIORef (23 :: Int)
let testSpec =
H.it "some behavior" $ \xs -> do
modifyIORef ref succ
(reverse . reverse) xs `shouldBe` (xs :: [Int])
H.hspec testSpec
readIORef ref `shouldReturn` 123
describe "pending" $ do
it "specifies a pending example" $ do
r <- runSpec $ do
H.it "foo" H.pending
r `shouldSatisfy` any (== " # PENDING: No reason given")
where
runSpec :: H.Spec -> IO [String]
runSpec = fmap lines . capture_ . H.hspecWith H.defaultConfig | 854 | spec = do
describe "Expectation as an example" $ do
it "is executed only once" $ do
ref <- newIORef (23 :: Int)
let testSpec = H.it "some behavior" (modifyIORef ref succ)
H.hspec testSpec
readIORef ref `shouldReturn` 24
it "can be quantified" $ do
ref <- newIORef (23 :: Int)
let testSpec =
H.it "some behavior" $ \xs -> do
modifyIORef ref succ
(reverse . reverse) xs `shouldBe` (xs :: [Int])
H.hspec testSpec
readIORef ref `shouldReturn` 123
describe "pending" $ do
it "specifies a pending example" $ do
r <- runSpec $ do
H.it "foo" H.pending
r `shouldSatisfy` any (== " # PENDING: No reason given")
where
runSpec :: H.Spec -> IO [String]
runSpec = fmap lines . capture_ . H.hspecWith H.defaultConfig | 841 | false | true | 0 | 26 | 264 | 299 | 141 | 158 | null | null |
sebschrader/programmierung-ss2015 | E02/A3.hs | mit | leafsToList (Branch left right) = leafsToList left ++ leafsToList right | 71 | leafsToList (Branch left right) = leafsToList left ++ leafsToList right | 71 | leafsToList (Branch left right) = leafsToList left ++ leafsToList right | 71 | false | false | 0 | 7 | 9 | 27 | 12 | 15 | null | null |
daleooo/barrelfish | tools/flounder/CAbsSyntax.hs | mit | pp_typespec (Array 0 t) n = pp_typespec t (n++"[]") | 51 | pp_typespec (Array 0 t) n = pp_typespec t (n++"[]") | 51 | pp_typespec (Array 0 t) n = pp_typespec t (n++"[]") | 51 | false | false | 0 | 7 | 8 | 31 | 15 | 16 | null | null |
nushio3/ghc | compiler/simplStg/UnariseStg.hs | bsd-3-clause | unariseAlts us rho (UbxTupAlt n) bndr [(DataAlt _, ys, uses, e)]
= [(DataAlt (tupleDataCon Unboxed n), ys', uses', unariseExpr us2' rho'' e)]
where
(us2', rho', ys', uses') = unariseUsedIdBinders us rho ys uses
rho'' = extendVarEnv rho' bndr ys' | 257 | unariseAlts us rho (UbxTupAlt n) bndr [(DataAlt _, ys, uses, e)]
= [(DataAlt (tupleDataCon Unboxed n), ys', uses', unariseExpr us2' rho'' e)]
where
(us2', rho', ys', uses') = unariseUsedIdBinders us rho ys uses
rho'' = extendVarEnv rho' bndr ys' | 257 | unariseAlts us rho (UbxTupAlt n) bndr [(DataAlt _, ys, uses, e)]
= [(DataAlt (tupleDataCon Unboxed n), ys', uses', unariseExpr us2' rho'' e)]
where
(us2', rho', ys', uses') = unariseUsedIdBinders us rho ys uses
rho'' = extendVarEnv rho' bndr ys' | 257 | false | false | 1 | 9 | 50 | 127 | 62 | 65 | null | null |
GaloisInc/halvm-ghc | compiler/utils/Outputable.hs | bsd-3-clause | brackets d = SDoc $ Pretty.brackets . runSDoc d | 52 | brackets d = SDoc $ Pretty.brackets . runSDoc d | 52 | brackets d = SDoc $ Pretty.brackets . runSDoc d | 52 | false | false | 0 | 7 | 13 | 22 | 10 | 12 | null | null |
dorchard/camfort | src/Camfort/Helpers/Vec.hs | apache-2.0 | zipWith :: (a -> b -> c) -> Vec n a -> Vec n b -> Vec n c
zipWith _ Nil Nil = Nil | 81 | zipWith :: (a -> b -> c) -> Vec n a -> Vec n b -> Vec n c
zipWith _ Nil Nil = Nil | 81 | zipWith _ Nil Nil = Nil | 23 | false | true | 0 | 8 | 24 | 56 | 27 | 29 | null | null |
sjakobi/heist | src/Heist/Compiled/Internal.hs | bsd-3-clause | ------------------------------------------------------------------------------
-- | Converts a pure HTML Node splice function to a pure Builder splice
-- function.
htmlNodeSplice :: (a -> [X.Node]) -> a -> Builder
htmlNodeSplice f = X.renderHtmlFragment X.UTF8 . f | 264 | htmlNodeSplice :: (a -> [X.Node]) -> a -> Builder
htmlNodeSplice f = X.renderHtmlFragment X.UTF8 . f | 100 | htmlNodeSplice f = X.renderHtmlFragment X.UTF8 . f | 50 | true | true | 0 | 10 | 32 | 54 | 27 | 27 | null | null |
ecaustin/haskhol-math | src/HaskHOL/Lib/Lists.hs | bsd-2-clause | thmMONO_ALL2 :: ListsCtxt thry => HOL cls thry HOLThm
thmMONO_ALL2 = Base.thmMONO_ALL2 | 86 | thmMONO_ALL2 :: ListsCtxt thry => HOL cls thry HOLThm
thmMONO_ALL2 = Base.thmMONO_ALL2 | 86 | thmMONO_ALL2 = Base.thmMONO_ALL2 | 32 | false | true | 0 | 7 | 11 | 33 | 14 | 19 | null | null |
tanishiking/hscc | src/Parser.hs | mit | {- =========
- Parser
========-}
parseProgram :: String -> Either String Program
parseProgram input = case parse program "Parse" input of
Left err -> Left $ show err
Right val -> Right val | 237 | parseProgram :: String -> Either String Program
parseProgram input = case parse program "Parse" input of
Left err -> Left $ show err
Right val -> Right val | 198 | parseProgram input = case parse program "Parse" input of
Left err -> Left $ show err
Right val -> Right val | 150 | true | true | 0 | 9 | 81 | 67 | 30 | 37 | null | null |
meiersi/blaze-builder | benchmarks/FastPut.hs | bsd-3-clause | toLazyByteStringWith
:: Int -- ^ Buffer size (upper-bounds the resulting chunk size).
-> Int -- ^ Minimal free buffer space for continuing filling
-- the same buffer after a 'flush' or a direct bytestring
-- insertion. This corresponds to the minimal desired
-- chunk size.
-> Int -- ^ Size of the first buffer to be used and copied for
-- larger resulting sequences
-> Put a -- ^ Builder to run.
-> L.ByteString -- ^ Lazy bytestring to output after the builder is
-- finished.
-> L.ByteString -- ^ Resulting lazy bytestring
toLazyByteStringWith bufSize minBufSize firstBufSize (Put b) k =
inlinePerformIO $ fillFirstBuffer (b finalStep)
where
finalStep _ (BufRange pf _) = return $ Done pf undefined
-- fill a first very small buffer, if we need more space then copy it
-- to the new buffer of size 'minBufSize'. This way we don't pay the
-- allocation cost of the big 'bufSize' buffer, when outputting only
-- small sequences.
fillFirstBuffer !step0
| minBufSize <= firstBufSize = fillNewBuffer firstBufSize step0
| otherwise = do
fpbuf <- S.mallocByteString firstBufSize
withForeignPtr fpbuf $ \pf -> do
let !br = BufRange pf (pf `plusPtr` firstBufSize)
mkbs pf' = S.PS fpbuf 0 (pf' `minusPtr` pf)
{-# INLINE mkbs #-}
next <- step0 br
case next of
Done pf' _
| pf' == pf -> return k
| otherwise -> return $ L.Chunk (mkbs pf') k
BufferFull newSize pf' nextStep -> do
let !l = pf' `minusPtr` pf
fillNewBuffer (max (l + newSize) minBufSize) $
\(BufRange pfNew peNew) -> do
copyBytes pfNew pf l
let !brNew = BufRange (pfNew `plusPtr` l) peNew
nextStep brNew
InsertByteString _ _ _ -> error "not yet implemented"
{-
ModifyChunks pf' bsk nextStep(
| pf' == pf ->
return $ bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep)
| otherwise ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep))
-}
-- allocate and fill a new buffer
fillNewBuffer !size !step0 = do
fpbuf <- S.mallocByteString size
withForeignPtr fpbuf $ fillBuffer fpbuf
where
fillBuffer fpbuf !pbuf = fill pbuf step0
where
!pe = pbuf `plusPtr` size
fill !pf !step = do
let !br = BufRange pf pe
next <- step br
let mkbs pf' = S.PS fpbuf (pf `minusPtr` pbuf) (pf' `minusPtr` pf)
{-# INLINE mkbs #-}
case next of
Done pf' _
| pf' == pf -> return k
| otherwise -> return $ L.Chunk (mkbs pf') k
BufferFull newSize pf' nextStep ->
return $ L.Chunk (mkbs pf')
(inlinePerformIO $
fillNewBuffer (max newSize bufSize) nextStep)
InsertByteString _ _ _ -> error "not yet implemented2"
{-
ModifyChunks pf' bsk nextStep
| pf' == pf ->
return $ bsk (inlinePerformIO $ fill pf' nextStep)
| minBufSize < pe `minusPtr` pf' ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fill pf' nextStep))
| otherwise ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep))
-}
-- | Extract the lazy 'L.ByteString' from the builder by running it with default
-- buffer sizes. Use this function, if you do not have any special
-- considerations with respect to buffer sizes.
--
-- @ 'toLazyByteString' b = 'toLazyByteStringWith' 'defaultBufferSize' 'defaultMinimalBufferSize' 'defaultFirstBufferSize' b L.empty@
--
-- Note that @'toLazyByteString'@ is a 'Monoid' homomorphism.
--
-- > toLazyByteString mempty == mempty
-- > toLazyByteString (x `mappend` y) == toLazyByteString x `mappend` toLazyByteString y
--
-- However, in the second equation, the left-hand-side is generally faster to
-- execute.
-- | 4,905 | toLazyByteStringWith
:: Int -- ^ Buffer size (upper-bounds the resulting chunk size).
-> Int -- ^ Minimal free buffer space for continuing filling
-- the same buffer after a 'flush' or a direct bytestring
-- insertion. This corresponds to the minimal desired
-- chunk size.
-> Int -- ^ Size of the first buffer to be used and copied for
-- larger resulting sequences
-> Put a -- ^ Builder to run.
-> L.ByteString -- ^ Lazy bytestring to output after the builder is
-- finished.
-> L.ByteString
toLazyByteStringWith bufSize minBufSize firstBufSize (Put b) k =
inlinePerformIO $ fillFirstBuffer (b finalStep)
where
finalStep _ (BufRange pf _) = return $ Done pf undefined
-- fill a first very small buffer, if we need more space then copy it
-- to the new buffer of size 'minBufSize'. This way we don't pay the
-- allocation cost of the big 'bufSize' buffer, when outputting only
-- small sequences.
fillFirstBuffer !step0
| minBufSize <= firstBufSize = fillNewBuffer firstBufSize step0
| otherwise = do
fpbuf <- S.mallocByteString firstBufSize
withForeignPtr fpbuf $ \pf -> do
let !br = BufRange pf (pf `plusPtr` firstBufSize)
mkbs pf' = S.PS fpbuf 0 (pf' `minusPtr` pf)
{-# INLINE mkbs #-}
next <- step0 br
case next of
Done pf' _
| pf' == pf -> return k
| otherwise -> return $ L.Chunk (mkbs pf') k
BufferFull newSize pf' nextStep -> do
let !l = pf' `minusPtr` pf
fillNewBuffer (max (l + newSize) minBufSize) $
\(BufRange pfNew peNew) -> do
copyBytes pfNew pf l
let !brNew = BufRange (pfNew `plusPtr` l) peNew
nextStep brNew
InsertByteString _ _ _ -> error "not yet implemented"
{-
ModifyChunks pf' bsk nextStep(
| pf' == pf ->
return $ bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep)
| otherwise ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep))
-}
-- allocate and fill a new buffer
fillNewBuffer !size !step0 = do
fpbuf <- S.mallocByteString size
withForeignPtr fpbuf $ fillBuffer fpbuf
where
fillBuffer fpbuf !pbuf = fill pbuf step0
where
!pe = pbuf `plusPtr` size
fill !pf !step = do
let !br = BufRange pf pe
next <- step br
let mkbs pf' = S.PS fpbuf (pf `minusPtr` pbuf) (pf' `minusPtr` pf)
{-# INLINE mkbs #-}
case next of
Done pf' _
| pf' == pf -> return k
| otherwise -> return $ L.Chunk (mkbs pf') k
BufferFull newSize pf' nextStep ->
return $ L.Chunk (mkbs pf')
(inlinePerformIO $
fillNewBuffer (max newSize bufSize) nextStep)
InsertByteString _ _ _ -> error "not yet implemented2"
{-
ModifyChunks pf' bsk nextStep
| pf' == pf ->
return $ bsk (inlinePerformIO $ fill pf' nextStep)
| minBufSize < pe `minusPtr` pf' ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fill pf' nextStep))
| otherwise ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep))
-}
-- | Extract the lazy 'L.ByteString' from the builder by running it with default
-- buffer sizes. Use this function, if you do not have any special
-- considerations with respect to buffer sizes.
--
-- @ 'toLazyByteString' b = 'toLazyByteStringWith' 'defaultBufferSize' 'defaultMinimalBufferSize' 'defaultFirstBufferSize' b L.empty@
--
-- Note that @'toLazyByteString'@ is a 'Monoid' homomorphism.
--
-- > toLazyByteString mempty == mempty
-- > toLazyByteString (x `mappend` y) == toLazyByteString x `mappend` toLazyByteString y
--
-- However, in the second equation, the left-hand-side is generally faster to
-- execute.
-- | 4,873 | toLazyByteStringWith bufSize minBufSize firstBufSize (Put b) k =
inlinePerformIO $ fillFirstBuffer (b finalStep)
where
finalStep _ (BufRange pf _) = return $ Done pf undefined
-- fill a first very small buffer, if we need more space then copy it
-- to the new buffer of size 'minBufSize'. This way we don't pay the
-- allocation cost of the big 'bufSize' buffer, when outputting only
-- small sequences.
fillFirstBuffer !step0
| minBufSize <= firstBufSize = fillNewBuffer firstBufSize step0
| otherwise = do
fpbuf <- S.mallocByteString firstBufSize
withForeignPtr fpbuf $ \pf -> do
let !br = BufRange pf (pf `plusPtr` firstBufSize)
mkbs pf' = S.PS fpbuf 0 (pf' `minusPtr` pf)
{-# INLINE mkbs #-}
next <- step0 br
case next of
Done pf' _
| pf' == pf -> return k
| otherwise -> return $ L.Chunk (mkbs pf') k
BufferFull newSize pf' nextStep -> do
let !l = pf' `minusPtr` pf
fillNewBuffer (max (l + newSize) minBufSize) $
\(BufRange pfNew peNew) -> do
copyBytes pfNew pf l
let !brNew = BufRange (pfNew `plusPtr` l) peNew
nextStep brNew
InsertByteString _ _ _ -> error "not yet implemented"
{-
ModifyChunks pf' bsk nextStep(
| pf' == pf ->
return $ bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep)
| otherwise ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep))
-}
-- allocate and fill a new buffer
fillNewBuffer !size !step0 = do
fpbuf <- S.mallocByteString size
withForeignPtr fpbuf $ fillBuffer fpbuf
where
fillBuffer fpbuf !pbuf = fill pbuf step0
where
!pe = pbuf `plusPtr` size
fill !pf !step = do
let !br = BufRange pf pe
next <- step br
let mkbs pf' = S.PS fpbuf (pf `minusPtr` pbuf) (pf' `minusPtr` pf)
{-# INLINE mkbs #-}
case next of
Done pf' _
| pf' == pf -> return k
| otherwise -> return $ L.Chunk (mkbs pf') k
BufferFull newSize pf' nextStep ->
return $ L.Chunk (mkbs pf')
(inlinePerformIO $
fillNewBuffer (max newSize bufSize) nextStep)
InsertByteString _ _ _ -> error "not yet implemented2"
{-
ModifyChunks pf' bsk nextStep
| pf' == pf ->
return $ bsk (inlinePerformIO $ fill pf' nextStep)
| minBufSize < pe `minusPtr` pf' ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fill pf' nextStep))
| otherwise ->
return $ L.Chunk (mkbs pf')
(bsk (inlinePerformIO $ fillNewBuffer bufSize nextStep))
-}
-- | Extract the lazy 'L.ByteString' from the builder by running it with default
-- buffer sizes. Use this function, if you do not have any special
-- considerations with respect to buffer sizes.
--
-- @ 'toLazyByteString' b = 'toLazyByteStringWith' 'defaultBufferSize' 'defaultMinimalBufferSize' 'defaultFirstBufferSize' b L.empty@
--
-- Note that @'toLazyByteString'@ is a 'Monoid' homomorphism.
--
-- > toLazyByteString mempty == mempty
-- > toLazyByteString (x `mappend` y) == toLazyByteString x `mappend` toLazyByteString y
--
-- However, in the second equation, the left-hand-side is generally faster to
-- execute.
-- | 4,212 | true | true | 0 | 26 | 2,068 | 711 | 344 | 367 | null | null |
nevrenato/Hets_Fork | CSL/TreePO.hs | gpl-2.0 | cmpSoIsEx i1@(IntVal _ _) s2@(Set s) =
case cmpClosedInts (setToClosedInt i1) $ setToClosedInt s2 of
Comparable EQ -> Comparable GT
Comparable LT -> if any (flip membSoI i1) $ Set.toList s
then Incomparable Overlap
else Incomparable Disjoint
so -> so | 318 | cmpSoIsEx i1@(IntVal _ _) s2@(Set s) =
case cmpClosedInts (setToClosedInt i1) $ setToClosedInt s2 of
Comparable EQ -> Comparable GT
Comparable LT -> if any (flip membSoI i1) $ Set.toList s
then Incomparable Overlap
else Incomparable Disjoint
so -> so | 318 | cmpSoIsEx i1@(IntVal _ _) s2@(Set s) =
case cmpClosedInts (setToClosedInt i1) $ setToClosedInt s2 of
Comparable EQ -> Comparable GT
Comparable LT -> if any (flip membSoI i1) $ Set.toList s
then Incomparable Overlap
else Incomparable Disjoint
so -> so | 318 | false | false | 0 | 12 | 107 | 112 | 53 | 59 | null | null |
alexander-at-github/eta | compiler/ETA/Prelude/PrimOp.hs | bsd-3-clause | tagOf_PrimOp IntRemOp = _ILIT(13) | 33 | tagOf_PrimOp IntRemOp = _ILIT(13) | 33 | tagOf_PrimOp IntRemOp = _ILIT(13) | 33 | false | false | 0 | 6 | 3 | 15 | 7 | 8 | null | null |
glguy/irc-core | hookup/src/Hookup.hs | isc | openSocket' ::
HostName {- ^ destination -} ->
PortNumber {- ^ destination port -} ->
Maybe HostName {- ^ source -} ->
IO Socket {- ^ connected socket -}
openSocket' h p mbBind =
do mbSrc <- traverse (resolve Nothing) mbBind
dst <- resolve (Just p) h
let pairs = interleaveAddressFamilies (matchBindAddrs mbSrc dst)
when (null pairs)
(throwIO (HostnameResolutionFailure h "No source/destination address family match"))
res <- concurrentAttempts connAttemptDelay Socket.close (uncurry connectToAddrInfo <$> pairs)
case res of
Left es -> throwIO (ConnectionFailure (mapMaybe fromException es))
Right s -> pure s | 697 | openSocket' ::
HostName {- ^ destination -} ->
PortNumber {- ^ destination port -} ->
Maybe HostName {- ^ source -} ->
IO Socket
openSocket' h p mbBind =
do mbSrc <- traverse (resolve Nothing) mbBind
dst <- resolve (Just p) h
let pairs = interleaveAddressFamilies (matchBindAddrs mbSrc dst)
when (null pairs)
(throwIO (HostnameResolutionFailure h "No source/destination address family match"))
res <- concurrentAttempts connAttemptDelay Socket.close (uncurry connectToAddrInfo <$> pairs)
case res of
Left es -> throwIO (ConnectionFailure (mapMaybe fromException es))
Right s -> pure s | 667 | openSocket' h p mbBind =
do mbSrc <- traverse (resolve Nothing) mbBind
dst <- resolve (Just p) h
let pairs = interleaveAddressFamilies (matchBindAddrs mbSrc dst)
when (null pairs)
(throwIO (HostnameResolutionFailure h "No source/destination address family match"))
res <- concurrentAttempts connAttemptDelay Socket.close (uncurry connectToAddrInfo <$> pairs)
case res of
Left es -> throwIO (ConnectionFailure (mapMaybe fromException es))
Right s -> pure s | 505 | true | true | 0 | 14 | 177 | 195 | 91 | 104 | null | null |
rueshyna/gogol | gogol-play-moviespartner/gen/Network/Google/PlayMoviesPartner/Types/Product.hs | mpl-2.0 | -- | Type of pricing that should be applied to this Avail based on how the
-- partner classify them. Example: \"Tier\", \"WSP\", \"SRP\", or
-- \"Category\".
aPriceType :: Lens' Avail (Maybe Text)
aPriceType
= lens _aPriceType (\ s a -> s{_aPriceType = a}) | 258 | aPriceType :: Lens' Avail (Maybe Text)
aPriceType
= lens _aPriceType (\ s a -> s{_aPriceType = a}) | 100 | aPriceType
= lens _aPriceType (\ s a -> s{_aPriceType = a}) | 61 | true | true | 0 | 9 | 45 | 50 | 27 | 23 | null | null |
seL4/capDL-tool | CapDL/DumpParser.hs | bsd-2-clause | all_decls :: Arch -> MapParser [Decl]
all_decls arch = do
objs <- obj_decls arch
cov <- cov_decls
caps <- cap_decls
cdt <- cdt_decls
irq <- make_irq_decl
return $ objs ++ cov ++ caps ++ cdt ++ irq | 220 | all_decls :: Arch -> MapParser [Decl]
all_decls arch = do
objs <- obj_decls arch
cov <- cov_decls
caps <- cap_decls
cdt <- cdt_decls
irq <- make_irq_decl
return $ objs ++ cov ++ caps ++ cdt ++ irq | 220 | all_decls arch = do
objs <- obj_decls arch
cov <- cov_decls
caps <- cap_decls
cdt <- cdt_decls
irq <- make_irq_decl
return $ objs ++ cov ++ caps ++ cdt ++ irq | 182 | false | true | 0 | 11 | 60 | 85 | 39 | 46 | null | null |
llllllllll/snipper | src/snipper.hs | gpl-3.0 | io_temp_hi :: IO FilePath
io_temp_hi = do
h <- getHomeDirectory
return $ h ++ "/.snipper/#.snips.hi"
-- |Temp c source file for eval c/c++ | 147 | io_temp_hi :: IO FilePath
io_temp_hi = do
h <- getHomeDirectory
return $ h ++ "/.snipper/#.snips.hi"
-- |Temp c source file for eval c/c++ | 147 | io_temp_hi = do
h <- getHomeDirectory
return $ h ++ "/.snipper/#.snips.hi"
-- |Temp c source file for eval c/c++ | 121 | false | true | 0 | 8 | 31 | 39 | 17 | 22 | null | null |
mstksg/hledger | hledger-ui/Hledger/UI/UIUtils.hs | gpl-3.0 | runInfo = runCommand "hledger-ui --info" >>= waitForProcess | 59 | runInfo = runCommand "hledger-ui --info" >>= waitForProcess | 59 | runInfo = runCommand "hledger-ui --info" >>= waitForProcess | 59 | false | false | 1 | 6 | 6 | 17 | 6 | 11 | null | null |
tolysz/prepare-ghcjs | spec-lts8/base/GHC/Enum.hs | bsd-3-clause | -- Don't inline this until RULE "enumDeltaToInteger" has had a chance to fire
enumDeltaToIntegerFB :: (Integer -> a -> a) -> a
-> Integer -> Integer -> Integer -> a
enumDeltaToIntegerFB c n x delta lim
| delta >= 0 = up_fb c n x delta lim
| otherwise = dn_fb c n x delta lim | 300 | enumDeltaToIntegerFB :: (Integer -> a -> a) -> a
-> Integer -> Integer -> Integer -> a
enumDeltaToIntegerFB c n x delta lim
| delta >= 0 = up_fb c n x delta lim
| otherwise = dn_fb c n x delta lim | 222 | enumDeltaToIntegerFB c n x delta lim
| delta >= 0 = up_fb c n x delta lim
| otherwise = dn_fb c n x delta lim | 114 | true | true | 1 | 9 | 81 | 93 | 46 | 47 | null | null |
ulricha/dsh | src/Database/DSH/VSL/Builtins.hs | bsd-3-clause | shredLiteral _ _ = $impossible | 30 | shredLiteral _ _ = $impossible | 30 | shredLiteral _ _ = $impossible | 30 | false | false | 1 | 6 | 4 | 13 | 5 | 8 | null | null |
jb55/cabal2nix | src/Cabal2Nix/Name.hs | bsd-3-clause | -- in glibc
libNixName "ruby1.8" = return "ruby" | 75 | libNixName "ruby1.8" = return "ruby" | 63 | libNixName "ruby1.8" = return "ruby" | 63 | true | false | 0 | 5 | 34 | 14 | 6 | 8 | null | null |
mettekou/ghc | compiler/basicTypes/BasicTypes.hs | bsd-3-clause | -- Loop-breaker that breaks a non-rule cycle
isStrongLoopBreaker _ = False | 96 | isStrongLoopBreaker _ = False | 51 | isStrongLoopBreaker _ = False | 51 | true | false | 0 | 5 | 32 | 10 | 5 | 5 | null | null |
ryanfan/courseography | dependencies/HaXml-1.25.3/src/Text/XML/HaXml/DtdToHaskell/Convert.hs | gpl-3.0 | -- mkData [[String]] [] False (name n)
mkAttrDef (N e) (AttDef (N n) (EnumeratedType (NotationType nt)) _) =
[EnumDef (name_a e n) (map (name_ac e n) nt)] | 158 | mkAttrDef (N e) (AttDef (N n) (EnumeratedType (NotationType nt)) _) =
[EnumDef (name_a e n) (map (name_ac e n) nt)] | 119 | mkAttrDef (N e) (AttDef (N n) (EnumeratedType (NotationType nt)) _) =
[EnumDef (name_a e n) (map (name_ac e n) nt)] | 119 | true | false | 0 | 10 | 30 | 80 | 39 | 41 | null | null |
ModernSteward/blog | Handler/Plugin.hs | bsd-2-clause | getRemovePermissionR :: PermissionId -> Handler RepHtml
getRemovePermissionR perId = do
uid <- requireAuthId
(msgType, msg) <- runDB $ do
mentity <- get perId
case mentity of
Just entity ->
if uid == permissionUser entity then do
delete perId
return (Success, "Plugin uninstalled.")
else return (Error, "This permission does not belong to you.")
Nothing -> return (Error, "Permission id not found")
case msgType of
Success -> do
setMessage $ successMessage msg
_ -> setMessage $ failureMessage msg
redirect PermissionsR | 675 | getRemovePermissionR :: PermissionId -> Handler RepHtml
getRemovePermissionR perId = do
uid <- requireAuthId
(msgType, msg) <- runDB $ do
mentity <- get perId
case mentity of
Just entity ->
if uid == permissionUser entity then do
delete perId
return (Success, "Plugin uninstalled.")
else return (Error, "This permission does not belong to you.")
Nothing -> return (Error, "Permission id not found")
case msgType of
Success -> do
setMessage $ successMessage msg
_ -> setMessage $ failureMessage msg
redirect PermissionsR | 675 | getRemovePermissionR perId = do
uid <- requireAuthId
(msgType, msg) <- runDB $ do
mentity <- get perId
case mentity of
Just entity ->
if uid == permissionUser entity then do
delete perId
return (Success, "Plugin uninstalled.")
else return (Error, "This permission does not belong to you.")
Nothing -> return (Error, "Permission id not found")
case msgType of
Success -> do
setMessage $ successMessage msg
_ -> setMessage $ failureMessage msg
redirect PermissionsR | 619 | false | true | 0 | 18 | 233 | 170 | 80 | 90 | null | null |
TomMD/ghc | compiler/codeGen/StgCmmPrim.hs | bsd-3-clause | translateOp dflags SameSmallMutableArrayOp= Just (mo_wordEq dflags) | 67 | translateOp dflags SameSmallMutableArrayOp= Just (mo_wordEq dflags) | 67 | translateOp dflags SameSmallMutableArrayOp= Just (mo_wordEq dflags) | 67 | false | false | 0 | 7 | 5 | 22 | 9 | 13 | null | null |
jkachmar/servant-persistent-realworld | src/Foundation.hs | mit | getConnStr _ = do
maybePool <- runMaybeT $ do
let keys = [ "host="
, " port="
, " user="
, " password="
, " dbname="
]
envs = [ "PGHOST"
, "PGPORT"
, "PGUSER"
, "PGPASS"
, "PGDATABASE"
]
envVars <- traverse (MaybeT . lookupEnv) envs
pure $ mconcat . zipWith (<>) keys $ BS8.pack <$> envVars
case maybePool of
Nothing ->
throwIO $ userError $ "Database configuration not present in environment!"
Just pool -> pure pool | 606 | getConnStr _ = do
maybePool <- runMaybeT $ do
let keys = [ "host="
, " port="
, " user="
, " password="
, " dbname="
]
envs = [ "PGHOST"
, "PGPORT"
, "PGUSER"
, "PGPASS"
, "PGDATABASE"
]
envVars <- traverse (MaybeT . lookupEnv) envs
pure $ mconcat . zipWith (<>) keys $ BS8.pack <$> envVars
case maybePool of
Nothing ->
throwIO $ userError $ "Database configuration not present in environment!"
Just pool -> pure pool | 606 | getConnStr _ = do
maybePool <- runMaybeT $ do
let keys = [ "host="
, " port="
, " user="
, " password="
, " dbname="
]
envs = [ "PGHOST"
, "PGPORT"
, "PGUSER"
, "PGPASS"
, "PGDATABASE"
]
envVars <- traverse (MaybeT . lookupEnv) envs
pure $ mconcat . zipWith (<>) keys $ BS8.pack <$> envVars
case maybePool of
Nothing ->
throwIO $ userError $ "Database configuration not present in environment!"
Just pool -> pure pool | 606 | false | false | 0 | 15 | 266 | 145 | 74 | 71 | null | null |
MateVM/hs-java | JVM/Assembler.hs | lgpl-3.0 | byte2atype 10 = return T_INT | 28 | byte2atype 10 = return T_INT | 28 | byte2atype 10 = return T_INT | 28 | false | false | 1 | 5 | 4 | 15 | 5 | 10 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.