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
hguenther/gtl
lib/Language/GTL/Target/PromelaKCG.hs
bsd-3-clause
stateArgs :: String -> CInterface -> [String] stateArgs name iface = zipWith (\name' (_,_,indir) -> (if indir then "&" else "")++"now."++name') (stateVarNames name (cIFaceStateType iface)) (cIFaceStateType iface)
369
stateArgs :: String -> CInterface -> [String] stateArgs name iface = zipWith (\name' (_,_,indir) -> (if indir then "&" else "")++"now."++name') (stateVarNames name (cIFaceStateType iface)) (cIFaceStateType iface)
369
stateArgs name iface = zipWith (\name' (_,_,indir) -> (if indir then "&" else "")++"now."++name') (stateVarNames name (cIFaceStateType iface)) (cIFaceStateType iface)
323
false
true
0
11
183
92
50
42
null
null
kyren/hsgb
lib/Gameboy/Instructions.hs
unlicense
encodeInstruction (DEC_R ERegister) = [0x1d]
44
encodeInstruction (DEC_R ERegister) = [0x1d]
44
encodeInstruction (DEC_R ERegister) = [0x1d]
44
false
false
0
6
4
19
9
10
null
null
cchens/courseography
hs/Css/DrawCss.hs
gpl-3.0
colourButtonsCSS :: Css colourButtonsCSS = do ".colour" ? do width (pct 40) margin (px 5) (px 5) (px 5) (px 5) padding0 roundCorners alignCenter fontSize (em 0.75) border solid (px 2) "#008080" "-webkit-transition" -: "all 0.2s" "-moz-transition" -: "all 0.2s" "-ms-transition" -: "all 0.2s" "-o-transition" -: "all 0.2s" "transition" -: "all 0.2s" ":hover" & do "background-color" -: "black !important" "color" -: "#DCDCDC !important" cursor pointer "#red" ? do backgroundColor $ parse dRed "#green" ? do backgroundColor $ parse dGreen "#blue"? do backgroundColor $ parse dBlue "#purple"? do backgroundColor $ parse dPurple {- The input field. -}
840
colourButtonsCSS :: Css colourButtonsCSS = do ".colour" ? do width (pct 40) margin (px 5) (px 5) (px 5) (px 5) padding0 roundCorners alignCenter fontSize (em 0.75) border solid (px 2) "#008080" "-webkit-transition" -: "all 0.2s" "-moz-transition" -: "all 0.2s" "-ms-transition" -: "all 0.2s" "-o-transition" -: "all 0.2s" "transition" -: "all 0.2s" ":hover" & do "background-color" -: "black !important" "color" -: "#DCDCDC !important" cursor pointer "#red" ? do backgroundColor $ parse dRed "#green" ? do backgroundColor $ parse dGreen "#blue"? do backgroundColor $ parse dBlue "#purple"? do backgroundColor $ parse dPurple {- The input field. -}
840
colourButtonsCSS = do ".colour" ? do width (pct 40) margin (px 5) (px 5) (px 5) (px 5) padding0 roundCorners alignCenter fontSize (em 0.75) border solid (px 2) "#008080" "-webkit-transition" -: "all 0.2s" "-moz-transition" -: "all 0.2s" "-ms-transition" -: "all 0.2s" "-o-transition" -: "all 0.2s" "transition" -: "all 0.2s" ":hover" & do "background-color" -: "black !important" "color" -: "#DCDCDC !important" cursor pointer "#red" ? do backgroundColor $ parse dRed "#green" ? do backgroundColor $ parse dGreen "#blue"? do backgroundColor $ parse dBlue "#purple"? do backgroundColor $ parse dPurple {- The input field. -}
816
false
true
0
13
288
234
101
133
null
null
Saulzar/pong
src/Pong4.hs
bsd-3-clause
collidePaddle :: Float -> Float -> Point -> Maybe Vector collidePaddle bottom pos (x, y) | y <= bottom && overPaddle pos (x, y) = Just (0, -1) | otherwise = Nothing
170
collidePaddle :: Float -> Float -> Point -> Maybe Vector collidePaddle bottom pos (x, y) | y <= bottom && overPaddle pos (x, y) = Just (0, -1) | otherwise = Nothing
170
collidePaddle bottom pos (x, y) | y <= bottom && overPaddle pos (x, y) = Just (0, -1) | otherwise = Nothing
113
false
true
1
10
37
83
42
41
null
null
h8gi/Open-usp-Tukubai
COMMANDS.HS/getlast.hs
mit
{-- getlast(Open usp Tukubai) designed by Nobuaki Tounaka written by Ryuichi Ueda The MIT License Copyright (C) 2012 Universal Shell Programming Laboratory Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --} showUsage :: IO () showUsage = do System.IO.hPutStr stderr ("Usage : getlast <f1> <f2> <file>\n" ++ "Tue Aug 6 10:07:55 JST 2013\n" ++ "Open usp Tukubai (LINUX+FREEBSD), Haskell ver.\n")
1,411
showUsage :: IO () showUsage = do System.IO.hPutStr stderr ("Usage : getlast <f1> <f2> <file>\n" ++ "Tue Aug 6 10:07:55 JST 2013\n" ++ "Open usp Tukubai (LINUX+FREEBSD), Haskell ver.\n")
223
showUsage = do System.IO.hPutStr stderr ("Usage : getlast <f1> <f2> <file>\n" ++ "Tue Aug 6 10:07:55 JST 2013\n" ++ "Open usp Tukubai (LINUX+FREEBSD), Haskell ver.\n")
204
true
true
0
10
257
39
20
19
null
null
ur-crypto/sec-lib
library/Examples.hs
mit
--ueand [] [n1] = (Constant False):[] --ueand [n1] [] = (Constant False):[] ueand [] [] = []
92
ueand [] [] = []
16
ueand [] [] = []
16
true
false
1
6
16
24
10
14
null
null
llllllllll/h16cc
Assembler/Lexer.hs
gpl-2.0
resolveWhenUnless (e:es) = e : resolveWhenUnless es
51
resolveWhenUnless (e:es) = e : resolveWhenUnless es
51
resolveWhenUnless (e:es) = e : resolveWhenUnless es
51
false
false
2
6
6
25
11
14
null
null
nushio3/ghc
compiler/hsSyn/HsExpr.hs
bsd-3-clause
pprMatchContextNoun ThPatQuote = text "Template Haskell pattern quotation"
79
pprMatchContextNoun ThPatQuote = text "Template Haskell pattern quotation"
79
pprMatchContextNoun ThPatQuote = text "Template Haskell pattern quotation"
79
false
false
0
5
12
12
5
7
null
null
dysinger/amazonka
amazonka-ssm/gen/Network/AWS/SSM/ListDocuments.hs
mpl-2.0
-- | The maximum number of items to return for this call. The call also returns a -- token that you can specify in a subsequent call to get the next set of -- results. ldMaxResults :: Lens' ListDocuments (Maybe Natural) ldMaxResults = lens _ldMaxResults (\s a -> s { _ldMaxResults = a }) . mapping _Nat
302
ldMaxResults :: Lens' ListDocuments (Maybe Natural) ldMaxResults = lens _ldMaxResults (\s a -> s { _ldMaxResults = a }) . mapping _Nat
134
ldMaxResults = lens _ldMaxResults (\s a -> s { _ldMaxResults = a }) . mapping _Nat
82
true
true
1
10
56
60
30
30
null
null
lhoghu/yahoo-portfolio-manager
src/Data/YahooPortfolioManager/Plot.hs
mit
mydata :: (TS.TimePoint Double -> Bool) -> TS.TimeSeries Double -> Plot2D.T Int Double mydata filter ts = Plot2D.list Graph2D.listPoints . tsValues $ TS.filter filter ts
169
mydata :: (TS.TimePoint Double -> Bool) -> TS.TimeSeries Double -> Plot2D.T Int Double mydata filter ts = Plot2D.list Graph2D.listPoints . tsValues $ TS.filter filter ts
169
mydata filter ts = Plot2D.list Graph2D.listPoints . tsValues $ TS.filter filter ts
82
false
true
0
10
24
74
34
40
null
null
tomahawkins/mecha
Language/Mecha/Profile.hs
bsd-3-clause
-- | Extract the lines from an OpenSCAD DXF file. parseDXF :: String -> [Line] parseDXF = parse . lines where parse :: [String] -> [Line] parse a = case a of [] -> [] "LINE" : _ : _ : _ : x0 : _ : x1 : _ : y0 : _ : y1 : rest -> ((read x0, read y0), (read x1, read y1)) : parse rest _ : rest -> parse rest
322
parseDXF :: String -> [Line] parseDXF = parse . lines where parse :: [String] -> [Line] parse a = case a of [] -> [] "LINE" : _ : _ : _ : x0 : _ : x1 : _ : y0 : _ : y1 : rest -> ((read x0, read y0), (read x1, read y1)) : parse rest _ : rest -> parse rest
272
parseDXF = parse . lines where parse :: [String] -> [Line] parse a = case a of [] -> [] "LINE" : _ : _ : _ : x0 : _ : x1 : _ : y0 : _ : y1 : rest -> ((read x0, read y0), (read x1, read y1)) : parse rest _ : rest -> parse rest
243
true
true
0
18
93
163
84
79
null
null
centromere/cacophony
src/Crypto/Noise/DH/Curve448.hs
unlicense
pubEq :: PublicKey Curve448 -> PublicKey Curve448 -> Bool pubEq (PK448 a) (PK448 b) = a == b
104
pubEq :: PublicKey Curve448 -> PublicKey Curve448 -> Bool pubEq (PK448 a) (PK448 b) = a == b
104
pubEq (PK448 a) (PK448 b) = a == b
34
false
true
0
7
29
46
22
24
null
null
bitemyapp/ganeti
src/Ganeti/Objects/Disk.hs
bsd-2-clause
lidDiskType (LIDBlockDev {}) = DTBlock
38
lidDiskType (LIDBlockDev {}) = DTBlock
38
lidDiskType (LIDBlockDev {}) = DTBlock
38
false
false
0
6
4
17
8
9
null
null
jessica-taylor/quipp2
src/Quipp/Interpreter.hs
mit
varsToGraphValue' :: Map String AdtDefinition -> TypeExpr -> State [VarId] GraphValue varsToGraphValue' _ (ConstTExpr x) | elem x ["Bool", "Double"] = do (v:vs) <- get put vs return $ VarGraphValue v
205
varsToGraphValue' :: Map String AdtDefinition -> TypeExpr -> State [VarId] GraphValue varsToGraphValue' _ (ConstTExpr x) | elem x ["Bool", "Double"] = do (v:vs) <- get put vs return $ VarGraphValue v
205
varsToGraphValue' _ (ConstTExpr x) | elem x ["Bool", "Double"] = do (v:vs) <- get put vs return $ VarGraphValue v
119
false
true
0
10
36
90
42
48
null
null
oden-lang/oden
src/Oden/Infer.hs
mit
instantiate :: SourceInfo -> Scheme -> Infer Type instantiate si (Forall _ qs cs t) = do subst <- Substitution.fromList <$> mapM freshType qs let withConstraints = if Set.null cs then t else TConstrained (Set.map setConstraintSourceInfo cs) t return (apply subst withConstraints) where freshType (TVarBinding si' var) = (var,) <$> fresh si' setConstraintSourceInfo (ProtocolConstraint _ protocolName' type') = ProtocolConstraint (Metadata si) protocolName' type' -- | Given a typed expression, return a canonical expression with the free -- type variables (not present in the environment) declared as type quantifiers -- for the expression.
709
instantiate :: SourceInfo -> Scheme -> Infer Type instantiate si (Forall _ qs cs t) = do subst <- Substitution.fromList <$> mapM freshType qs let withConstraints = if Set.null cs then t else TConstrained (Set.map setConstraintSourceInfo cs) t return (apply subst withConstraints) where freshType (TVarBinding si' var) = (var,) <$> fresh si' setConstraintSourceInfo (ProtocolConstraint _ protocolName' type') = ProtocolConstraint (Metadata si) protocolName' type' -- | Given a typed expression, return a canonical expression with the free -- type variables (not present in the environment) declared as type quantifiers -- for the expression.
709
instantiate si (Forall _ qs cs t) = do subst <- Substitution.fromList <$> mapM freshType qs let withConstraints = if Set.null cs then t else TConstrained (Set.map setConstraintSourceInfo cs) t return (apply subst withConstraints) where freshType (TVarBinding si' var) = (var,) <$> fresh si' setConstraintSourceInfo (ProtocolConstraint _ protocolName' type') = ProtocolConstraint (Metadata si) protocolName' type' -- | Given a typed expression, return a canonical expression with the free -- type variables (not present in the environment) declared as type quantifiers -- for the expression.
659
false
true
0
14
160
172
84
88
null
null
jgoerzen/gopherbot
NetClient.hs
gpl-2.0
dlTo :: Socket -> Handle -> IO () dlTo s fh = recvBlocks s (\() buf -> hPutStr fh buf) ()
93
dlTo :: Socket -> Handle -> IO () dlTo s fh = recvBlocks s (\() buf -> hPutStr fh buf) ()
93
dlTo s fh = recvBlocks s (\() buf -> hPutStr fh buf) ()
59
false
true
0
8
24
55
27
28
null
null
ChristoSilvia/conform
src/ComplexShapes.hs
mit
unitCircle :: NPoints -> Polygon unitCircle = circle (0.0 :+ 0.0) 1.0
69
unitCircle :: NPoints -> Polygon unitCircle = circle (0.0 :+ 0.0) 1.0
69
unitCircle = circle (0.0 :+ 0.0) 1.0
36
false
true
0
7
11
27
14
13
null
null
tamarin-prover/tamarin-prover
lib/sapic/src/Sapic/ProgressFunction.hs
gpl-3.0
pfRange' :: (Show ann, Typeable ann, MonadCatch m) => AnProcess ann -> m (S.Set (ProcessPosition, ProcessPosition)) pfRange' proc = do froms <- pfFrom proc foldM mapFlat S.empty froms where mapFlat acc pos = do res <- flatten <$> pf proc pos return (acc `S.union` S.map (,pos) res)
404
pfRange' :: (Show ann, Typeable ann, MonadCatch m) => AnProcess ann -> m (S.Set (ProcessPosition, ProcessPosition)) pfRange' proc = do froms <- pfFrom proc foldM mapFlat S.empty froms where mapFlat acc pos = do res <- flatten <$> pf proc pos return (acc `S.union` S.map (,pos) res)
404
pfRange' proc = do froms <- pfFrom proc foldM mapFlat S.empty froms where mapFlat acc pos = do res <- flatten <$> pf proc pos return (acc `S.union` S.map (,pos) res)
288
false
true
0
13
169
137
67
70
null
null
diegospd/pol
src/StartApp.hs
gpl-3.0
cancelEdit' :: (Int, Zipper) -> Maybe (Int, Zipper) cancelEdit' (n,z) | T.null oldText = (,) n <$> parent (Z.delete z) | otherwise = return (n, z) where oldText = T.strip $ label z ^.itsText -- | Counts how many visible nodes are between the zipper and its parent. -- i.e. it counts how many visible nodes are in the subtrees of its previous siblings
364
cancelEdit' :: (Int, Zipper) -> Maybe (Int, Zipper) cancelEdit' (n,z) | T.null oldText = (,) n <$> parent (Z.delete z) | otherwise = return (n, z) where oldText = T.strip $ label z ^.itsText -- | Counts how many visible nodes are between the zipper and its parent. -- i.e. it counts how many visible nodes are in the subtrees of its previous siblings
364
cancelEdit' (n,z) | T.null oldText = (,) n <$> parent (Z.delete z) | otherwise = return (n, z) where oldText = T.strip $ label z ^.itsText -- | Counts how many visible nodes are between the zipper and its parent. -- i.e. it counts how many visible nodes are in the subtrees of its previous siblings
312
false
true
3
9
77
123
59
64
null
null
eelco/luisterpaal.fm
LastFm.hs
bsd-3-clause
getSession :: ClientConf -> Token -> IO (N.Result Session) getSession conf token = do result <- simpleHTTP $ Request (api_uri { uriQuery = sessionRequest conf token }) GET [] "" case result of (Left err) -> return $ Left err (Right response) -> do case rspCode response of -- (2,0,0) -> return $ Right (rspBody response) (2,0,0) -> return $ decode' (rspBody response) _ -> return $ Left (ErrorMisc $ "Getting session failed" ++ rspBody response)
542
getSession :: ClientConf -> Token -> IO (N.Result Session) getSession conf token = do result <- simpleHTTP $ Request (api_uri { uriQuery = sessionRequest conf token }) GET [] "" case result of (Left err) -> return $ Left err (Right response) -> do case rspCode response of -- (2,0,0) -> return $ Right (rspBody response) (2,0,0) -> return $ decode' (rspBody response) _ -> return $ Left (ErrorMisc $ "Getting session failed" ++ rspBody response)
542
getSession conf token = do result <- simpleHTTP $ Request (api_uri { uriQuery = sessionRequest conf token }) GET [] "" case result of (Left err) -> return $ Left err (Right response) -> do case rspCode response of -- (2,0,0) -> return $ Right (rspBody response) (2,0,0) -> return $ decode' (rspBody response) _ -> return $ Left (ErrorMisc $ "Getting session failed" ++ rspBody response)
483
false
true
0
19
172
177
87
90
null
null
kolmodin/cabal
Cabal/Distribution/Version.hs
bsd-3-clause
wildcardUpperBound :: Version -> Version wildcardUpperBound (Version lowerBound ts) = Version upperBound ts where upperBound = init lowerBound ++ [last lowerBound + 1]
173
wildcardUpperBound :: Version -> Version wildcardUpperBound (Version lowerBound ts) = Version upperBound ts where upperBound = init lowerBound ++ [last lowerBound + 1]
173
wildcardUpperBound (Version lowerBound ts) = Version upperBound ts where upperBound = init lowerBound ++ [last lowerBound + 1]
132
false
true
0
8
28
56
27
29
null
null
raventid/coursera_learning
haskell/chapter11/binary_tree_hw.hs
mit
foldTree f z (Node Leaf a right) = foldTree f (f a z) right
59
foldTree f z (Node Leaf a right) = foldTree f (f a z) right
59
foldTree f z (Node Leaf a right) = foldTree f (f a z) right
59
false
false
0
7
13
41
18
23
null
null
rfranek/duckling
Duckling/Time/SV/Rules.hs
bsd-3-clause
ruleHhmmss :: Rule ruleHhmmss = Rule { name = "hh:mm:ss" , pattern = [ regex "((?:[01]?\\d)|(?:2[0-3]))[:.]([0-5]\\d)[:.]([0-5]\\d)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (hh:mm:ss:_)):_) -> do h <- parseInt hh m <- parseInt mm s <- parseInt ss tt $ hourMinuteSecond False h m s _ -> Nothing }
382
ruleHhmmss :: Rule ruleHhmmss = Rule { name = "hh:mm:ss" , pattern = [ regex "((?:[01]?\\d)|(?:2[0-3]))[:.]([0-5]\\d)[:.]([0-5]\\d)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (hh:mm:ss:_)):_) -> do h <- parseInt hh m <- parseInt mm s <- parseInt ss tt $ hourMinuteSecond False h m s _ -> Nothing }
382
ruleHhmmss = Rule { name = "hh:mm:ss" , pattern = [ regex "((?:[01]?\\d)|(?:2[0-3]))[:.]([0-5]\\d)[:.]([0-5]\\d)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (hh:mm:ss:_)):_) -> do h <- parseInt hh m <- parseInt mm s <- parseInt ss tt $ hourMinuteSecond False h m s _ -> Nothing }
363
false
true
0
20
113
141
70
71
null
null
rueshyna/gogol
gogol-datastore/gen/Network/Google/Resource/Datastore/Projects/Lookup.hs
mpl-2.0
-- | OAuth bearer token. plBearerToken :: Lens' ProjectsLookup (Maybe Text) plBearerToken = lens _plBearerToken (\ s a -> s{_plBearerToken = a})
152
plBearerToken :: Lens' ProjectsLookup (Maybe Text) plBearerToken = lens _plBearerToken (\ s a -> s{_plBearerToken = a})
127
plBearerToken = lens _plBearerToken (\ s a -> s{_plBearerToken = a})
76
true
true
0
9
29
48
25
23
null
null
tyler-sommer/stormy-pond
test/Spec.hs
mit
testJSONEncodeWithDescAndReflections :: Test testJSONEncodeWithDescAndReflections = TestCase $ assertEqual "With description and reflections" (encode Ripple { summary = "A Summary" , description = Just "Description" , reflections = ["simple", "interesting"] }) "{\"summary\":\"A Summary\",\"description\":\"Description\",\"reflections\":[{\"name\":\"simple\",\"group\":null},{\"name\":\"interesting\",\"group\":null}]}"
603
testJSONEncodeWithDescAndReflections :: Test testJSONEncodeWithDescAndReflections = TestCase $ assertEqual "With description and reflections" (encode Ripple { summary = "A Summary" , description = Just "Description" , reflections = ["simple", "interesting"] }) "{\"summary\":\"A Summary\",\"description\":\"Description\",\"reflections\":[{\"name\":\"simple\",\"group\":null},{\"name\":\"interesting\",\"group\":null}]}"
603
testJSONEncodeWithDescAndReflections = TestCase $ assertEqual "With description and reflections" (encode Ripple { summary = "A Summary" , description = Just "Description" , reflections = ["simple", "interesting"] }) "{\"summary\":\"A Summary\",\"description\":\"Description\",\"reflections\":[{\"name\":\"simple\",\"group\":null},{\"name\":\"interesting\",\"group\":null}]}"
558
false
true
2
9
215
61
32
29
null
null
begriffs/postgrest
main/Main.hs
mit
{-| The purpose of this worker is to fill the refDbStructure created in 'main' with the 'DbStructure' returned from calling 'getDbStructure'. This method is meant to be called by multiple times by the same thread, but does nothing if the previous invocation has not terminated. In all cases this method does not halt the calling thread, the work is preformed in a separate thread. Note: 'atomicWriteIORef' is essentially a lazy semaphore that prevents two threads from running 'connectionWorker' at the same time. Background thread that does the following : 1. Tries to connect to pg server and will keep trying until success. 2. Checks if the pg version is supported and if it's not it kills the main program. 3. Obtains the dbStructure. 4. If 2 or 3 fail to give their result it means the connection is down so it goes back to 1, otherwise it finishes his work successfully. -} connectionWorker :: ThreadId -- ^ This thread is killed if pg version is unsupported -> P.Pool -- ^ The PostgreSQL connection pool -> Schema -- ^ Schema PostgREST is serving up -> IORef (Maybe DbStructure) -- ^ mutable reference to 'DbStructure' -> IORef Bool -- ^ Used as a binary Semaphore -> IO () connectionWorker mainTid pool schema refDbStructure refIsWorkerOn = do isWorkerOn <- readIORef refIsWorkerOn unless isWorkerOn $ do atomicWriteIORef refIsWorkerOn True void $ forkIO work where work = do atomicWriteIORef refDbStructure Nothing putStrLn ("Attempting to connect to the database..." :: Text) connected <- connectingSucceeded pool when connected $ do result <- P.use pool $ do actualPgVersion <- getPgVersion unless (actualPgVersion >= minimumPgVersion) $ liftIO $ do hPutStrLn stderr ("Cannot run in this PostgreSQL version, PostgREST needs at least " <> pgvName minimumPgVersion) killThread mainTid dbStructure <- HT.transaction HT.ReadCommitted HT.Read $ getDbStructure schema actualPgVersion liftIO $ atomicWriteIORef refDbStructure $ Just dbStructure case result of Left e -> do putStrLn ("Failed to query the database. Retrying." :: Text) hPutStrLn stderr (toS $ encodeError e) work Right _ -> do atomicWriteIORef refIsWorkerOn False putStrLn ("Connection successful" :: Text) {-| Used by 'connectionWorker' to check if the provided db-uri lets the application access the PostgreSQL database. This method is used the first time the connection is tested, but only to test before calling 'getDbStructure' inside the 'connectionWorker' method. The connection tries are capped, but if the connection times out no error is thrown, just 'False' is returned. -}
2,864
connectionWorker :: ThreadId -- ^ This thread is killed if pg version is unsupported -> P.Pool -- ^ The PostgreSQL connection pool -> Schema -- ^ Schema PostgREST is serving up -> IORef (Maybe DbStructure) -- ^ mutable reference to 'DbStructure' -> IORef Bool -- ^ Used as a binary Semaphore -> IO () connectionWorker mainTid pool schema refDbStructure refIsWorkerOn = do isWorkerOn <- readIORef refIsWorkerOn unless isWorkerOn $ do atomicWriteIORef refIsWorkerOn True void $ forkIO work where work = do atomicWriteIORef refDbStructure Nothing putStrLn ("Attempting to connect to the database..." :: Text) connected <- connectingSucceeded pool when connected $ do result <- P.use pool $ do actualPgVersion <- getPgVersion unless (actualPgVersion >= minimumPgVersion) $ liftIO $ do hPutStrLn stderr ("Cannot run in this PostgreSQL version, PostgREST needs at least " <> pgvName minimumPgVersion) killThread mainTid dbStructure <- HT.transaction HT.ReadCommitted HT.Read $ getDbStructure schema actualPgVersion liftIO $ atomicWriteIORef refDbStructure $ Just dbStructure case result of Left e -> do putStrLn ("Failed to query the database. Retrying." :: Text) hPutStrLn stderr (toS $ encodeError e) work Right _ -> do atomicWriteIORef refIsWorkerOn False putStrLn ("Connection successful" :: Text) {-| Used by 'connectionWorker' to check if the provided db-uri lets the application access the PostgreSQL database. This method is used the first time the connection is tested, but only to test before calling 'getDbStructure' inside the 'connectionWorker' method. The connection tries are capped, but if the connection times out no error is thrown, just 'False' is returned. -}
1,948
connectionWorker mainTid pool schema refDbStructure refIsWorkerOn = do isWorkerOn <- readIORef refIsWorkerOn unless isWorkerOn $ do atomicWriteIORef refIsWorkerOn True void $ forkIO work where work = do atomicWriteIORef refDbStructure Nothing putStrLn ("Attempting to connect to the database..." :: Text) connected <- connectingSucceeded pool when connected $ do result <- P.use pool $ do actualPgVersion <- getPgVersion unless (actualPgVersion >= minimumPgVersion) $ liftIO $ do hPutStrLn stderr ("Cannot run in this PostgreSQL version, PostgREST needs at least " <> pgvName minimumPgVersion) killThread mainTid dbStructure <- HT.transaction HT.ReadCommitted HT.Read $ getDbStructure schema actualPgVersion liftIO $ atomicWriteIORef refDbStructure $ Just dbStructure case result of Left e -> do putStrLn ("Failed to query the database. Retrying." :: Text) hPutStrLn stderr (toS $ encodeError e) work Right _ -> do atomicWriteIORef refIsWorkerOn False putStrLn ("Connection successful" :: Text) {-| Used by 'connectionWorker' to check if the provided db-uri lets the application access the PostgreSQL database. This method is used the first time the connection is tested, but only to test before calling 'getDbStructure' inside the 'connectionWorker' method. The connection tries are capped, but if the connection times out no error is thrown, just 'False' is returned. -}
1,616
true
true
0
21
708
350
157
193
null
null
frontrowed/stratosphere
library-gen/Stratosphere/ResourceProperties/ElasticBeanstalkConfigurationTemplateConfigurationOptionSetting.hs
mit
-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticbeanstalk-configurationtemplate-configurationoptionsetting.html#cfn-elasticbeanstalk-configurationtemplate-configurationoptionsetting-value ebctcosValue :: Lens' ElasticBeanstalkConfigurationTemplateConfigurationOptionSetting (Maybe (Val Text)) ebctcosValue = lens _elasticBeanstalkConfigurationTemplateConfigurationOptionSettingValue (\s a -> s { _elasticBeanstalkConfigurationTemplateConfigurationOptionSettingValue = a })
513
ebctcosValue :: Lens' ElasticBeanstalkConfigurationTemplateConfigurationOptionSetting (Maybe (Val Text)) ebctcosValue = lens _elasticBeanstalkConfigurationTemplateConfigurationOptionSettingValue (\s a -> s { _elasticBeanstalkConfigurationTemplateConfigurationOptionSettingValue = a })
284
ebctcosValue = lens _elasticBeanstalkConfigurationTemplateConfigurationOptionSettingValue (\s a -> s { _elasticBeanstalkConfigurationTemplateConfigurationOptionSettingValue = a })
179
true
true
0
9
22
52
28
24
null
null
TomMD/cryptol
cryptol/Main.hs
bsd-3-clause
-- | Set a batch script to be run. setBatchScript :: String -> OptParser Options setBatchScript path = modify $ \ opts -> opts { optBatch = Just path }
151
setBatchScript :: String -> OptParser Options setBatchScript path = modify $ \ opts -> opts { optBatch = Just path }
116
setBatchScript path = modify $ \ opts -> opts { optBatch = Just path }
70
true
true
0
9
29
42
22
20
null
null
heathweiss/Tricad
src/Stl/StlCornerPoints.hs
gpl-2.0
getTriangles (FacesBackBottomFront) c = concat [(getTriangles FaceBack c), (getTriangles FaceBottom c), (getTriangles FaceFront c) ]
138
getTriangles (FacesBackBottomFront) c = concat [(getTriangles FaceBack c), (getTriangles FaceBottom c), (getTriangles FaceFront c) ]
138
getTriangles (FacesBackBottomFront) c = concat [(getTriangles FaceBack c), (getTriangles FaceBottom c), (getTriangles FaceFront c) ]
138
false
false
1
8
20
54
26
28
null
null
nushio3/formura
src/Formura/MPICxx/Language.hs
mit
parensTuple :: Foldable t => t Src -> Src parensTuple = parens . intercalate ", " . toList
90
parensTuple :: Foldable t => t Src -> Src parensTuple = parens . intercalate ", " . toList
90
parensTuple = parens . intercalate ", " . toList
48
false
true
0
7
17
36
17
19
null
null
adizere/nifty-urb
src/Nifty/URB.hs
mit
getOutputFile :: Int -> String getOutputFile pId = "da_proc_" ++ (show pId) ++ ".out"
89
getOutputFile :: Int -> String getOutputFile pId = "da_proc_" ++ (show pId) ++ ".out"
89
getOutputFile pId = "da_proc_" ++ (show pId) ++ ".out"
58
false
true
2
7
17
39
17
22
null
null
KirillTim/raft-haskell
src/Handlers.hs
bsd-3-clause
handleVoteForCandidate _ = undefined
36
handleVoteForCandidate _ = undefined
36
handleVoteForCandidate _ = undefined
36
false
false
0
5
3
9
4
5
null
null
johan1a/haskell-go
src/Eval.hs
gpl-2.0
getName (IdDecl name) = name
28
getName (IdDecl name) = name
28
getName (IdDecl name) = name
28
false
false
0
6
4
16
7
9
null
null
azadbolour/boardgame
haskell-server/src/Bolour/Plane/Domain/LineSegment.hs
agpl-3.0
pointAt :: LineSegment val -> Int -> Point pointAt line offset = Point (row line offset) (column line offset)
109
pointAt :: LineSegment val -> Int -> Point pointAt line offset = Point (row line offset) (column line offset)
109
pointAt line offset = Point (row line offset) (column line offset)
66
false
true
0
7
18
48
23
25
null
null
DavidAlphaFox/ghc
libraries/Cabal/Cabal/Distribution/Simple/GHC/IPI642.hs
bsd-3-clause
mkInstalledPackageId :: Current.PackageIdentifier -> Current.InstalledPackageId mkInstalledPackageId = Current.InstalledPackageId . display
139
mkInstalledPackageId :: Current.PackageIdentifier -> Current.InstalledPackageId mkInstalledPackageId = Current.InstalledPackageId . display
139
mkInstalledPackageId = Current.InstalledPackageId . display
59
false
true
0
6
9
25
13
12
null
null
allonsy/mailServer
src/EncryptMail.hs
mit
keyToInteger :: ByteString -> Integer keyToInteger start = convert 0 0 $ unpack start where convert accum _ [] = accum convert accum counter (x:xs) = convert (accum + (shiftL (toInteger (ord x)) (counter * 8))) (counter + 1) xs --inverse of the above
260
keyToInteger :: ByteString -> Integer keyToInteger start = convert 0 0 $ unpack start where convert accum _ [] = accum convert accum counter (x:xs) = convert (accum + (shiftL (toInteger (ord x)) (counter * 8))) (counter + 1) xs --inverse of the above
260
keyToInteger start = convert 0 0 $ unpack start where convert accum _ [] = accum convert accum counter (x:xs) = convert (accum + (shiftL (toInteger (ord x)) (counter * 8))) (counter + 1) xs --inverse of the above
222
false
true
0
13
53
113
58
55
null
null
bitemyapp/ganeti
src/Ganeti/Constants.hs
bsd-2-clause
-- * RPC rpcEncodingNone :: Int rpcEncodingNone = 0
52
rpcEncodingNone :: Int rpcEncodingNone = 0
42
rpcEncodingNone = 0
19
true
true
0
6
9
19
8
11
null
null
Philonous/xml-picklers
tests/Tests.hs
bsd-3-clause
-- Provided a list of Nodes containing at least one Element, we verify that -- xpElemVerbatim always finds the first element. prop_xpElemVerbatimUnpickle :: [Node] -> Property prop_xpElemVerbatimUnpickle ns = let ne = find (\n -> case n of NodeElement _ -> True; _ -> False) ns in isJust ne ==> let NodeElement e = fromJust ne in case unpickle xpElemVerbatim ns of Right e_ -> e == e_ Left _ -> False -- Verify that xpElemVerbatim pickling an element returns only that element.
543
prop_xpElemVerbatimUnpickle :: [Node] -> Property prop_xpElemVerbatimUnpickle ns = let ne = find (\n -> case n of NodeElement _ -> True; _ -> False) ns in isJust ne ==> let NodeElement e = fromJust ne in case unpickle xpElemVerbatim ns of Right e_ -> e == e_ Left _ -> False -- Verify that xpElemVerbatim pickling an element returns only that element.
417
prop_xpElemVerbatimUnpickle ns = let ne = find (\n -> case n of NodeElement _ -> True; _ -> False) ns in isJust ne ==> let NodeElement e = fromJust ne in case unpickle xpElemVerbatim ns of Right e_ -> e == e_ Left _ -> False -- Verify that xpElemVerbatim pickling an element returns only that element.
367
true
true
1
15
148
128
61
67
null
null
jpbetz/protolang
haskell/Parser.hs
apache-2.0
parseExpr :: String -> Either ParseError Expr parseExpr s = parse (contents expr) "<stdin>" s
93
parseExpr :: String -> Either ParseError Expr parseExpr s = parse (contents expr) "<stdin>" s
93
parseExpr s = parse (contents expr) "<stdin>" s
47
false
true
0
7
14
36
17
19
null
null
jwbuurlage/category-theory-programmers
examples/folds/folds.hs
mit
lengthf :: Num b => [a] -> b lengthf = foldr (\_ c -> c + 1) 0
62
lengthf :: Num b => [a] -> b lengthf = foldr (\_ c -> c + 1) 0
62
lengthf = foldr (\_ c -> c + 1) 0
33
false
true
0
8
17
44
23
21
null
null
TomMD/cryptol
src/Cryptol/Parser/AST.hs
bsd-3-clause
asEApps :: Expr -> (Expr, [Expr]) asEApps expr = go expr [] where go e es = case isEApp e of Nothing -> (e, es) Just (e1, e2) -> go e1 (e2 : es)
198
asEApps :: Expr -> (Expr, [Expr]) asEApps expr = go expr [] where go e es = case isEApp e of Nothing -> (e, es) Just (e1, e2) -> go e1 (e2 : es)
198
asEApps expr = go expr [] where go e es = case isEApp e of Nothing -> (e, es) Just (e1, e2) -> go e1 (e2 : es)
164
false
true
0
10
87
96
49
47
null
null
rahulmutt/ghcvm
compiler/Eta/CodeGen/Closure.hs
bsd-3-clause
mkLFImported :: Id -> LambdaFormInfo mkLFImported id | Just con <- isDataConWorkId_maybe id , isNullaryRepDataCon con = LFCon { lfDataCon = con } | arity > 0 = LFReEntrant { lfTopLevelFlag = TopLevel, lfArity = arity, lfNoFreeVars = True, lfArgDescriptor = panic "mkLFImported: lfArgDescriptor" } | otherwise = mkLFArgument id where arity = idRepArity id
394
mkLFImported :: Id -> LambdaFormInfo mkLFImported id | Just con <- isDataConWorkId_maybe id , isNullaryRepDataCon con = LFCon { lfDataCon = con } | arity > 0 = LFReEntrant { lfTopLevelFlag = TopLevel, lfArity = arity, lfNoFreeVars = True, lfArgDescriptor = panic "mkLFImported: lfArgDescriptor" } | otherwise = mkLFArgument id where arity = idRepArity id
394
mkLFImported id | Just con <- isDataConWorkId_maybe id , isNullaryRepDataCon con = LFCon { lfDataCon = con } | arity > 0 = LFReEntrant { lfTopLevelFlag = TopLevel, lfArity = arity, lfNoFreeVars = True, lfArgDescriptor = panic "mkLFImported: lfArgDescriptor" } | otherwise = mkLFArgument id where arity = idRepArity id
357
false
true
1
9
94
116
58
58
null
null
olorin/amazonka
amazonka-cloudwatch-logs/gen/Network/AWS/CloudWatchLogs/Types/Product.hs
mpl-2.0
-- | Undocumented member. lgStoredBytes :: Lens' LogGroup (Maybe Natural) lgStoredBytes = lens _lgStoredBytes (\ s a -> s{_lgStoredBytes = a}) . mapping _Nat
157
lgStoredBytes :: Lens' LogGroup (Maybe Natural) lgStoredBytes = lens _lgStoredBytes (\ s a -> s{_lgStoredBytes = a}) . mapping _Nat
131
lgStoredBytes = lens _lgStoredBytes (\ s a -> s{_lgStoredBytes = a}) . mapping _Nat
83
true
true
0
10
23
53
28
25
null
null
olsner/ghc
compiler/nativeGen/NCGMonad.hs
bsd-3-clause
getNewRegNat :: Format -> NatM Reg getNewRegNat rep = do u <- getUniqueNat dflags <- getDynFlags return (RegVirtual $ targetMkVirtualReg (targetPlatform dflags) u rep)
180
getNewRegNat :: Format -> NatM Reg getNewRegNat rep = do u <- getUniqueNat dflags <- getDynFlags return (RegVirtual $ targetMkVirtualReg (targetPlatform dflags) u rep)
180
getNewRegNat rep = do u <- getUniqueNat dflags <- getDynFlags return (RegVirtual $ targetMkVirtualReg (targetPlatform dflags) u rep)
145
false
true
0
12
36
61
28
33
null
null
Lemmih/haskell-tc
src/Language/Haskell/TypeCheck/Monad.hs
mit
dropSkolem TcUniqueVar{} = return ()
36
dropSkolem TcUniqueVar{} = return ()
36
dropSkolem TcUniqueVar{} = return ()
36
false
false
0
6
4
18
8
10
null
null
JacquesCarette/literate-scientific-software
code/drasil-code/Language/Drasil/CodeSpec.hs
bsd-2-clause
matchSpaces :: [Space] -> [[CodeType]] -> SpaceMatch -> SpaceMatch matchSpaces (s:ss) (ct:cts) sm = matchSpaces ss cts $ matchSpace s ct sm
139
matchSpaces :: [Space] -> [[CodeType]] -> SpaceMatch -> SpaceMatch matchSpaces (s:ss) (ct:cts) sm = matchSpaces ss cts $ matchSpace s ct sm
139
matchSpaces (s:ss) (ct:cts) sm = matchSpaces ss cts $ matchSpace s ct sm
72
false
true
0
8
21
69
36
33
null
null
mdsteele/fallback
src/Fallback/State/Area.hs
gpl-3.0
------------------------------------------------------------------------------- decayFields :: Int -> Map.Map Position Field -> IO (Map.Map Position Field) decayFields frames fields = fmap (Map.mapMaybe id) $ for fields $ \field -> do let decay halflife = do let probKeep = 0.5 ** (fromIntegral frames / halflife) :: Double keep <- (probKeep >) <$> randomRIO (0, 1) return $ if keep then Just field else Nothing case field of BarrierWall duration -> do return $ if duration <= frames then Nothing else Just $ BarrierWall (duration - frames) FireWall _ -> decay 360 IceWall _ -> decay 480 PoisonCloud _ -> decay 300 SmokeScreen halflife -> decay halflife Webbing _ -> return (Just field) ------------------------------------------------------------------------------- -- | Effects that only impact the party and can be resolved in a -- non-mode-specific way.
933
decayFields :: Int -> Map.Map Position Field -> IO (Map.Map Position Field) decayFields frames fields = fmap (Map.mapMaybe id) $ for fields $ \field -> do let decay halflife = do let probKeep = 0.5 ** (fromIntegral frames / halflife) :: Double keep <- (probKeep >) <$> randomRIO (0, 1) return $ if keep then Just field else Nothing case field of BarrierWall duration -> do return $ if duration <= frames then Nothing else Just $ BarrierWall (duration - frames) FireWall _ -> decay 360 IceWall _ -> decay 480 PoisonCloud _ -> decay 300 SmokeScreen halflife -> decay halflife Webbing _ -> return (Just field) ------------------------------------------------------------------------------- -- | Effects that only impact the party and can be resolved in a -- non-mode-specific way.
852
decayFields frames fields = fmap (Map.mapMaybe id) $ for fields $ \field -> do let decay halflife = do let probKeep = 0.5 ** (fromIntegral frames / halflife) :: Double keep <- (probKeep >) <$> randomRIO (0, 1) return $ if keep then Just field else Nothing case field of BarrierWall duration -> do return $ if duration <= frames then Nothing else Just $ BarrierWall (duration - frames) FireWall _ -> decay 360 IceWall _ -> decay 480 PoisonCloud _ -> decay 300 SmokeScreen halflife -> decay halflife Webbing _ -> return (Just field) ------------------------------------------------------------------------------- -- | Effects that only impact the party and can be resolved in a -- non-mode-specific way.
776
true
true
0
20
201
270
130
140
null
null
jstolarek/ghc
libraries/base/Data/OldList.hs
bsd-3-clause
-- | The 'zip4' function takes four lists and returns a list of -- quadruples, analogous to 'zip'. zip4 :: [a] -> [b] -> [c] -> [d] -> [(a,b,c,d)] zip4 = zipWith4 (,,,)
207
zip4 :: [a] -> [b] -> [c] -> [d] -> [(a,b,c,d)] zip4 = zipWith4 (,,,)
108
zip4 = zipWith4 (,,,)
41
true
true
0
10
71
64
39
25
null
null
pfq/PFQ
user/lib/Haskell/Network/PFQ/Lang/Experimental.hs
gpl-2.0
-- | Evaluate to /Pass Qbuff/ if it is a broadcast frame, /Drop/ it otherwise. mac_broadcast = Function "mac_broadcast" () () () () () () () () :: NetFunction
158
mac_broadcast = Function "mac_broadcast" () () () () () () () () :: NetFunction
79
mac_broadcast = Function "mac_broadcast" () () () () () () () () :: NetFunction
79
true
false
0
6
28
45
23
22
null
null
pstiasny/mgr
Rays.hs
lgpl-3.0
normal :: Hit a -> Vec3 normal (Hit _ dg _) = dgNormal dg
57
normal :: Hit a -> Vec3 normal (Hit _ dg _) = dgNormal dg
57
normal (Hit _ dg _) = dgNormal dg
33
false
true
0
6
13
38
17
21
null
null
jsavatgy/hatupist
code/result-tables-03.hs
gpl-2.0
rColTitles = ["Päiväys", "Tulos", "Sija", "Virheitä" ]
66
rColTitles = ["Päiväys", "Tulos", "Sija", "Virheitä" ]
66
rColTitles = ["Päiväys", "Tulos", "Sija", "Virheitä" ]
66
false
false
0
5
18
18
11
7
null
null
dylanaraps/pywal
pywal/templates/colors.hs
mit
color10="{color10}"
19
color10="{color10}"
19
color10="{color10}"
19
false
false
1
5
0
11
3
8
null
null
lucasdicioccio/probecraft-hs
Network/Probecraft/Packet/Icmp.hs
bsd-3-clause
unparseKind EchoRequest = 8
27
unparseKind EchoRequest = 8
27
unparseKind EchoRequest = 8
27
false
false
0
5
3
9
4
5
null
null
christiaanb/clash-compiler
examples/Calculator.hs
bsd-2-clause
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d (f .: g) a b = f (g a b)
73
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d (f .: g) a b = f (g a b)
73
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d (f .: g) a b = f (g a b)
73
false
false
0
12
26
76
38
38
null
null
chrisbarrett/apidoc-checker
src/Apidoc/Check/Parsers.hs
bsd-3-clause
parseTypeRef :: Text -> Maybe DSL.TypeRef parseTypeRef s = case parseString parser mempty (Text.unpack s) of Success x -> pure x Failure _ -> empty where parser :: Parser DSL.TypeRef parser = choice [arrayType, mapType, nominalType] bracketed = between (char '[') (char ']') arrayType = bracketed parser mapType = string "map" *> bracketed parser nominalType = do ty <- concat <$> identifier `sepBy1` char '.' pure (DSL.TNominal (DSL.TypeName (Text.pack ty))) underscore = char '_' identifier = do c <- letter <|> underscore cs <- many (alphaNum <|> underscore) pure (c : cs)
665
parseTypeRef :: Text -> Maybe DSL.TypeRef parseTypeRef s = case parseString parser mempty (Text.unpack s) of Success x -> pure x Failure _ -> empty where parser :: Parser DSL.TypeRef parser = choice [arrayType, mapType, nominalType] bracketed = between (char '[') (char ']') arrayType = bracketed parser mapType = string "map" *> bracketed parser nominalType = do ty <- concat <$> identifier `sepBy1` char '.' pure (DSL.TNominal (DSL.TypeName (Text.pack ty))) underscore = char '_' identifier = do c <- letter <|> underscore cs <- many (alphaNum <|> underscore) pure (c : cs)
665
parseTypeRef s = case parseString parser mempty (Text.unpack s) of Success x -> pure x Failure _ -> empty where parser :: Parser DSL.TypeRef parser = choice [arrayType, mapType, nominalType] bracketed = between (char '[') (char ']') arrayType = bracketed parser mapType = string "map" *> bracketed parser nominalType = do ty <- concat <$> identifier `sepBy1` char '.' pure (DSL.TNominal (DSL.TypeName (Text.pack ty))) underscore = char '_' identifier = do c <- letter <|> underscore cs <- many (alphaNum <|> underscore) pure (c : cs)
623
false
true
7
16
181
249
120
129
null
null
litherum/cereal-conduit
Test/Main.hs
bsd-2-clause
sinktests = TestList [ sinktest1 , sinktest2 , sinktest3 , sinktest4 , sinktest5 , sinktest6 , sinktest7 , sinktest8 , sinktest9 ]
319
sinktests = TestList [ sinktest1 , sinktest2 , sinktest3 , sinktest4 , sinktest5 , sinktest6 , sinktest7 , sinktest8 , sinktest9 ]
319
sinktests = TestList [ sinktest1 , sinktest2 , sinktest3 , sinktest4 , sinktest5 , sinktest6 , sinktest7 , sinktest8 , sinktest9 ]
319
false
false
1
6
210
39
22
17
null
null
spechub/Hets
Propositional/Parse_AS_Basic.hs
gpl-2.0
-- | Parser for basic items parseBasicItems :: AParser st AS_BASIC.BASIC_ITEMS parseBasicItems = parsePredDecl <|> parseAxItems
127
parseBasicItems :: AParser st AS_BASIC.BASIC_ITEMS parseBasicItems = parsePredDecl <|> parseAxItems
99
parseBasicItems = parsePredDecl <|> parseAxItems
48
true
true
0
6
15
23
12
11
null
null
AndrewRademacher/hs-ebay-trading
src/Ebay/Types/Details.hs
mit
xpReturnsAcceptedOption :: PU Text ReturnsAcceptedOption xpReturnsAcceptedOption = PU { unpickleTree = return . ReturnsAcceptedOption , pickleTree = unReturnsAcceptedOption }
234
xpReturnsAcceptedOption :: PU Text ReturnsAcceptedOption xpReturnsAcceptedOption = PU { unpickleTree = return . ReturnsAcceptedOption , pickleTree = unReturnsAcceptedOption }
234
xpReturnsAcceptedOption = PU { unpickleTree = return . ReturnsAcceptedOption , pickleTree = unReturnsAcceptedOption }
177
false
true
1
8
78
38
19
19
null
null
seereason/process-extras
src/System/Process/ListLike.hs
mit
writeChunk :: ListLikeIO a c => Chunk a -> IO (Chunk a) writeChunk x = foldOutput (\_ -> return x) (\s -> hPutStr stdout s >> return x) (\s -> hPutStr stderr s >> return x) (\_ -> return x) (\_ -> return x) x
272
writeChunk :: ListLikeIO a c => Chunk a -> IO (Chunk a) writeChunk x = foldOutput (\_ -> return x) (\s -> hPutStr stdout s >> return x) (\s -> hPutStr stderr s >> return x) (\_ -> return x) (\_ -> return x) x
272
writeChunk x = foldOutput (\_ -> return x) (\s -> hPutStr stdout s >> return x) (\s -> hPutStr stderr s >> return x) (\_ -> return x) (\_ -> return x) x
216
false
true
0
9
108
125
62
63
null
null
hguenther/fac
Formula.hs
gpl-3.0
tseitin nxt (Or x y) = do (Formula cnf_x,l1) <- tseitin nxt x (Formula cnf_y,l2) <- tseitin nxt y vout <- nxt let Formula cnf_r = formulaOr (lp vout) [l1,l2] return (Formula $ Set.unions [cnf_x,cnf_y,cnf_r],lp vout)
225
tseitin nxt (Or x y) = do (Formula cnf_x,l1) <- tseitin nxt x (Formula cnf_y,l2) <- tseitin nxt y vout <- nxt let Formula cnf_r = formulaOr (lp vout) [l1,l2] return (Formula $ Set.unions [cnf_x,cnf_y,cnf_r],lp vout)
225
tseitin nxt (Or x y) = do (Formula cnf_x,l1) <- tseitin nxt x (Formula cnf_y,l2) <- tseitin nxt y vout <- nxt let Formula cnf_r = formulaOr (lp vout) [l1,l2] return (Formula $ Set.unions [cnf_x,cnf_y,cnf_r],lp vout)
225
false
false
0
12
45
133
63
70
null
null
sdiehl/ghc
compiler/prelude/THNames.hs
bsd-3-clause
-- data Exp = ... conE_RDR, litE_RDR, appE_RDR, infixApp_RDR :: RdrName conE_RDR = nameRdrName conEName
107
conE_RDR, litE_RDR, appE_RDR, infixApp_RDR :: RdrName conE_RDR = nameRdrName conEName
89
conE_RDR = nameRdrName conEName
35
true
true
0
5
18
21
14
7
null
null
fffej/HS-Poker
LookupPatternMatch.hs
bsd-3-clause
getValueFromProduct 3690 = 5800
31
getValueFromProduct 3690 = 5800
31
getValueFromProduct 3690 = 5800
31
false
false
0
5
3
9
4
5
null
null
PipocaQuemada/ermine
src/Ermine/Inference/Type.hs
bsd-2-clause
skolemize :: MonadMeta s m => Depth -> TypeM s -> m ([MetaK s], [MetaT s], [TypeM s], TypeM s) skolemize _ (Forall ks ts cs bd) = do sks <- for ks $ newMeta False sts <- for ts $ \(h,t) -> newMeta (instantiateVars sks t) h let inst = instantiateKindVars sks . instantiateVars sts (rs, tcs) <- unfurlConstraints $ inst cs unless (null rs) $ fail "invalid higher-rank row constraints" return (sks, sts, tcs, inst bd)
440
skolemize :: MonadMeta s m => Depth -> TypeM s -> m ([MetaK s], [MetaT s], [TypeM s], TypeM s) skolemize _ (Forall ks ts cs bd) = do sks <- for ks $ newMeta False sts <- for ts $ \(h,t) -> newMeta (instantiateVars sks t) h let inst = instantiateKindVars sks . instantiateVars sts (rs, tcs) <- unfurlConstraints $ inst cs unless (null rs) $ fail "invalid higher-rank row constraints" return (sks, sts, tcs, inst bd)
440
skolemize _ (Forall ks ts cs bd) = do sks <- for ks $ newMeta False sts <- for ts $ \(h,t) -> newMeta (instantiateVars sks t) h let inst = instantiateKindVars sks . instantiateVars sts (rs, tcs) <- unfurlConstraints $ inst cs unless (null rs) $ fail "invalid higher-rank row constraints" return (sks, sts, tcs, inst bd)
335
false
true
0
12
103
218
105
113
null
null
Baranowski/SourceGraph
Parsing/ParseModule.hs
gpl-3.0
getExp (EnumFromThen e1 e2) = liftM2 MS.union (getExp e1) (getExp e2)
69
getExp (EnumFromThen e1 e2) = liftM2 MS.union (getExp e1) (getExp e2)
69
getExp (EnumFromThen e1 e2) = liftM2 MS.union (getExp e1) (getExp e2)
69
false
false
0
7
10
39
18
21
null
null
acowley/ghc
compiler/basicTypes/Literal.hs
bsd-3-clause
{- Note [Printing of literals in Core] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function `add_par` is used to wrap parenthesis around negative integers (`LitInteger`) and labels (`MachLabel`), if they occur in a context requiring an atomic thing (for example function application). Although not all Core literals would be valid Haskell, we are trying to stay as close as possible to Haskell syntax in the printing of Core, to make it easier for a Haskell user to read Core. To that end: * We do print parenthesis around negative `LitInteger`, because we print `LitInteger` using plain number literals (no prefix or suffix), and plain number literals in Haskell require parenthesis in contexts like function application (i.e. `1 - -1` is not valid Haskell). * We don't print parenthesis around other (negative) literals, because they aren't needed in GHC/Haskell either (i.e. `1# -# -1#` is accepted by GHC's parser). Literal Output Output if context requires an atom (if different) ------- ------- ---------------------- MachChar 'a'# MachStr "aaa"# MachNullAddr "__NULL" MachInt -1# MachInt64 -1L# MachWord 1## MachWord64 1L## MachFloat -1.0# MachDouble -1.0## LitInteger -1 (-1) MachLabel "__label" ... ("__label" ...) -} {- ************************************************************************ * * \subsection{Hashing} * * ************************************************************************ Hash values should be zero or a positive integer. No negatives please. (They mess up the UniqFM for some reason.) -} hashLiteral :: Literal -> Int hashLiteral (MachChar c) = ord c + 1000
1,917
hashLiteral :: Literal -> Int hashLiteral (MachChar c) = ord c + 1000
76
hashLiteral (MachChar c) = ord c + 1000
46
true
true
0
6
554
37
18
19
null
null
m00nlight/99-problems
haskell/p-68.hs
bsd-3-clause
tree2Preorder (Branch e l r) = [e] ++ (tree2Preorder l) ++ (tree2Preorder r)
76
tree2Preorder (Branch e l r) = [e] ++ (tree2Preorder l) ++ (tree2Preorder r)
76
tree2Preorder (Branch e l r) = [e] ++ (tree2Preorder l) ++ (tree2Preorder r)
76
false
false
0
8
12
42
21
21
null
null
technogeeky/d-A
include/containers-0.5.0.0/Data/Map/Base.hs
gpl-3.0
hedgeInt :: Ord k => MaybeS k -> MaybeS k -> Map k a -> Map k b -> Map k a hedgeInt _ _ _ Tip = Tip
101
hedgeInt :: Ord k => MaybeS k -> MaybeS k -> Map k a -> Map k b -> Map k a hedgeInt _ _ _ Tip = Tip
101
hedgeInt _ _ _ Tip = Tip
26
false
true
0
11
30
69
30
39
null
null
abasko/linkedhashmap
src/Data/LinkedHashMap/IntMap.hs
bsd-3-clause
-- | /O(n)/ Transform this map by applying a function to every value. map :: (v1 -> v2) -> LinkedHashMap k v1 -> LinkedHashMap k v2 map f = mapWithKey (const f)
160
map :: (v1 -> v2) -> LinkedHashMap k v1 -> LinkedHashMap k v2 map f = mapWithKey (const f)
90
map f = mapWithKey (const f)
28
true
true
0
7
31
49
24
25
null
null
jml/hazard
lib/Hazard/Views.hs
apache-2.0
jsonExample :: ToJSON a => a -> H.Html jsonExample = H.pre . H.text . decodeUtf8 . toStrict . encode
100
jsonExample :: ToJSON a => a -> H.Html jsonExample = H.pre . H.text . decodeUtf8 . toStrict . encode
100
jsonExample = H.pre . H.text . decodeUtf8 . toStrict . encode
61
false
true
0
9
18
44
22
22
null
null
daniel-ziegler/provability
src/Modal/Code.hs
bsd-3-clause
codeToProgram :: MonadError CompileError m => CompileContext -> Code -> m CompiledAgent codeToProgram context code = do (prog, state) <- runStateT (compileCode code) context return $ Map.fromList [(a, prog a) | a <- actionList state] ------------------------------------------------------------------------------- -- Testing
331
codeToProgram :: MonadError CompileError m => CompileContext -> Code -> m CompiledAgent codeToProgram context code = do (prog, state) <- runStateT (compileCode code) context return $ Map.fromList [(a, prog a) | a <- actionList state] ------------------------------------------------------------------------------- -- Testing
331
codeToProgram context code = do (prog, state) <- runStateT (compileCode code) context return $ Map.fromList [(a, prog a) | a <- actionList state] ------------------------------------------------------------------------------- -- Testing
241
false
true
0
12
44
97
48
49
null
null
himura/ghc-mod
Types.hs
bsd-3-clause
addNewLine :: String -> String addNewLine = (++ "\n")
53
addNewLine :: String -> String addNewLine = (++ "\n")
53
addNewLine = (++ "\n")
22
false
true
0
7
8
26
12
14
null
null
massysett/penny
genPennyCabal/genPennyCabal.hs
bsd-3-clause
time :: Package time = atLeast "time" [1,4]
43
time :: Package time = atLeast "time" [1,4]
43
time = atLeast "time" [1,4]
27
false
true
0
6
7
29
13
16
null
null
HJvT/com
System/Win32/Com/Exception.hs
bsd-3-clause
dV_E_CLIPFORMAT :: HRESULT dV_E_CLIPFORMAT = word32ToInt32 (0x8004006A ::Word32)
80
dV_E_CLIPFORMAT :: HRESULT dV_E_CLIPFORMAT = word32ToInt32 (0x8004006A ::Word32)
80
dV_E_CLIPFORMAT = word32ToInt32 (0x8004006A ::Word32)
53
false
true
0
6
7
26
12
14
null
null
jeannekamikaze/Spear
Spear/GL.hs
mit
shaderSource :: GLSLShader -> CString -> IO () shaderSource shader str = let ptr = unsafeCoerce str in withArray [ptr] $ flip (glShaderSource (getShader shader) 1) nullPtr
183
shaderSource :: GLSLShader -> CString -> IO () shaderSource shader str = let ptr = unsafeCoerce str in withArray [ptr] $ flip (glShaderSource (getShader shader) 1) nullPtr
182
shaderSource shader str = let ptr = unsafeCoerce str in withArray [ptr] $ flip (glShaderSource (getShader shader) 1) nullPtr
135
false
true
0
12
38
72
34
38
null
null
mathologist/CTYCrypto
Ciphers.hs
gpl-3.0
stringToPairs pad (c1:c2:cs) | c1 == c2 = (c1, pad) : stringToPairs pad (c2:cs) | otherwise = (c1,c2) : stringToPairs pad cs
134
stringToPairs pad (c1:c2:cs) | c1 == c2 = (c1, pad) : stringToPairs pad (c2:cs) | otherwise = (c1,c2) : stringToPairs pad cs
134
stringToPairs pad (c1:c2:cs) | c1 == c2 = (c1, pad) : stringToPairs pad (c2:cs) | otherwise = (c1,c2) : stringToPairs pad cs
134
false
false
1
9
31
76
39
37
null
null
Saulzar/reflex-animation
src/Reflex/Animation.hs
bsd-3-clause
-- | Sample from a clip, returning Nothing outside the domain sampleClip :: (Ord time, Num time) => Clip time a -> time -> Maybe a sampleClip c t | t >= 0 && t <= period c = Just $ sampleAt (clipAnim c) t | otherwise = Nothing
246
sampleClip :: (Ord time, Num time) => Clip time a -> time -> Maybe a sampleClip c t | t >= 0 && t <= period c = Just $ sampleAt (clipAnim c) t | otherwise = Nothing
184
sampleClip c t | t >= 0 && t <= period c = Just $ sampleAt (clipAnim c) t | otherwise = Nothing
115
true
true
1
10
68
96
45
51
null
null
jkarni/polycephalous-instances
src/Language/Haskell/Polycephaly/TH.hs
bsd-3-clause
remakeInstances' :: Name -> RewriteRules -> Q [InstanceDec] remakeInstances' t rr = do ins <- getInstances t return $ map (addFlag rr . changeN t rr) ins
169
remakeInstances' :: Name -> RewriteRules -> Q [InstanceDec] remakeInstances' t rr = do ins <- getInstances t return $ map (addFlag rr . changeN t rr) ins
169
remakeInstances' t rr = do ins <- getInstances t return $ map (addFlag rr . changeN t rr) ins
109
false
true
0
11
42
67
31
36
null
null
fpco/inline-c
inline-c/src/Language/C/Inline/Context.hs
mit
baseCtx :: Context baseCtx = mempty { ctxTypesTable = baseTypesTable }
74
baseCtx :: Context baseCtx = mempty { ctxTypesTable = baseTypesTable }
74
baseCtx = mempty { ctxTypesTable = baseTypesTable }
55
false
true
0
6
14
22
12
10
null
null
GaloisInc/halvm-ghc
compiler/stgSyn/StgLint.hs
bsd-3-clause
checkInScope :: Id -> LintM () checkInScope id = LintM $ \loc scope errs -> if isLocalId id && not (id `elemVarSet` scope) then ((), addErr errs (hsep [ppr id, text "is out of scope"]) loc) else ((), errs)
226
checkInScope :: Id -> LintM () checkInScope id = LintM $ \loc scope errs -> if isLocalId id && not (id `elemVarSet` scope) then ((), addErr errs (hsep [ppr id, text "is out of scope"]) loc) else ((), errs)
226
checkInScope id = LintM $ \loc scope errs -> if isLocalId id && not (id `elemVarSet` scope) then ((), addErr errs (hsep [ppr id, text "is out of scope"]) loc) else ((), errs)
195
false
true
0
13
59
109
56
53
null
null
music-suite/music-pitch
src/Music/Pitch/Literal/Pitch.hs
bsd-3-clause
f'''' = fromPitch $ viaPitchL (3, 0, 4)
43
f'''' = fromPitch $ viaPitchL (3, 0, 4)
43
f'''' = fromPitch $ viaPitchL (3, 0, 4)
43
false
false
0
7
11
22
12
10
null
null
UU-ComputerScience/uulib
src/UU/PPrint.hs
bsd-3-clause
fold f [] = empty
23
fold f [] = empty
23
fold f [] = empty
23
false
false
0
6
10
13
6
7
null
null
Saulzar/reflex
src/Reflex/Class.hs
bsd-3-clause
-- | Experimental: Create a merge whose parents can change over time; changing the key of an Event is more efficient than with mergeIncremental mergeMapIncrementalWithMove :: (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Event t a)) -> Event t (Map k a) mergeMapIncrementalWithMove = fmap dmapToMap . mergeIncrementalWithMove . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWithMoveWith id)
412
mergeMapIncrementalWithMove :: (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Event t a)) -> Event t (Map k a) mergeMapIncrementalWithMove = fmap dmapToMap . mergeIncrementalWithMove . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWithMoveWith id)
268
mergeMapIncrementalWithMove = fmap dmapToMap . mergeIncrementalWithMove . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWithMoveWith id)
148
true
true
0
11
54
87
43
44
null
null
rueshyna/gogol
gogol-sheets/gen/Network/Google/Resource/Sheets/Spreadsheets/Values/Get.hs
mpl-2.0
-- | JSONP svgCallback :: Lens' SpreadsheetsValuesGet (Maybe Text) svgCallback = lens _svgCallback (\ s a -> s{_svgCallback = a})
131
svgCallback :: Lens' SpreadsheetsValuesGet (Maybe Text) svgCallback = lens _svgCallback (\ s a -> s{_svgCallback = a})
120
svgCallback = lens _svgCallback (\ s a -> s{_svgCallback = a})
64
true
true
0
9
21
48
25
23
null
null
39aldo39/klfc
src/Lookup/MacOS.hs
gpl-3.0
usedModifiers modifier = [modifier]
35
usedModifiers modifier = [modifier]
35
usedModifiers modifier = [modifier]
35
false
false
0
5
3
12
6
6
null
null
nushio3/ghc
compiler/typecheck/TcType.hs
bsd-3-clause
getDFunTyKey (TyConApp tc _) = getOccName tc
52
getDFunTyKey (TyConApp tc _) = getOccName tc
52
getDFunTyKey (TyConApp tc _) = getOccName tc
52
false
false
0
7
14
20
9
11
null
null
iteloo/tsuru-sample
iteratee-0.8.9.6/Examples/Tiff.hs
bsd-3-clause
-- An internal function to load the dictionary. It assumes that the stream -- is positioned to read the dictionary load_dict :: MonadIO m => Endian -> Iteratee [Word8] m (Maybe TIFFDict) load_dict e = do nentries <- endianRead2 e dict <- foldr (const read_entry) (return (Just IM.empty)) [1..nentries] next_dict <- endianRead4 e when (next_dict > 0) $ note ["The TIFF file contains several images, ", "only the first one will be considered"] return dict where read_entry dictM = dictM >>= maybe (return Nothing) (\dict -> do tag <- endianRead2 e typ' <- endianRead2 e typ <- convert_type (fromIntegral typ') count <- endianRead4 e -- we read the val-offset later. We need to check the size and the type -- of the datum, because val-offset may contain the value itself, -- in its lower-numbered bytes, regardless of the big/little endian -- order! note ["TIFFEntry: tag ",show . int_to_tag . fromIntegral $ tag, " type ", show typ, " count ", show count] enum_m <- maybe (return Nothing) (\t -> read_value t e (fromIntegral count)) typ case enum_m of Just enum -> return . Just $ IM.insert (fromIntegral tag) (TIFFDE (fromIntegral count) enum) dict _ -> return (Just dict) ) convert_type :: (Monad m, Nullable s) => Int -> Iteratee s m (Maybe TIFF_TYPE) convert_type typ | typ > 0 && typ <= fromEnum (maxBound::TIFF_TYPE) = return . Just . toEnum $ typ convert_type typ = do throwErr . iterStrExc $ "Bad type of entry: " ++ show typ return Nothing read_value :: MonadIO m => TIFF_TYPE -> Endian -> Int -> Iteratee [Word8] m (Maybe TIFFDE_ENUM) read_value typ e' 0 = do endianRead4 e' throwErr . iterStrExc $ "Zero count in the entry of type: " ++ show typ return Nothing -- Read an ascii string from the offset in the -- dictionary. The last byte of -- an ascii string is always zero, which is -- included in 'count' but we don't need to read it read_value TT_ascii e' count | count > 4 = do -- val-offset is offset offset <- endianRead4 e' return . Just . TEN_CHAR $ \iter_char -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . chr . fromIntegral) Iter.head) iter_char Iter.joinI $ Iter.joinI $ Iter.take (pred count) iter -- Read the string of 0 to 3 characters long -- The zero terminator is included in count, but -- we don't need to read it read_value TT_ascii _e count = do -- count is within 1..4 let len = pred count -- string length let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop ((chr . fromIntegral $ v):acc) (pred n)) str <- loop [] len Iter.drop (4-len) case str of Just str' -> return . Just . TEN_CHAR $ immed_value str' Nothing -> return Nothing -- Read the array of signed or unsigned bytes read_value typ e' count | count > 4 && typ == TT_byte || typ == TT_sbyte = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_byte typ) Iter.head) iter_int Iter.joinI $ Iter.joinI $ Iter.take count iter -- Read the array of 1 to 4 bytes read_value typ _e count | typ == TT_byte || typ == TT_sbyte = do let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop (conv_byte typ v:acc) (pred n)) str <- (loop [] count) Iter.drop (4-count) case str of Just str' -> return . Just . TEN_INT $ immed_value str' Nothing -> return Nothing -- Read the array of Word8 read_value TT_undefined e' count | count > 4 = do offset <- endianRead4 e' return . Just . TEN_BYTE $ \iter -> return $ do Iter.seek (fromIntegral offset) Iter.joinI $ Iter.take count iter -- Read the array of Word8 of 1..4 elements, -- packed in the offset field read_value TT_undefined _e count = do let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop (v:acc) (pred n)) str <- loop [] count Iter.drop (4-count) case str of Just str' -> return . Just . TEN_BYTE $ immed_value str' Nothing -> return Nothing --return . Just . TEN_BYTE $ immed_value str -- Read the array of short integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_short || typ == TT_sshort = do item <- endianRead2 e' Iter.drop 2 -- skip the padding return . Just . TEN_INT $ immed_value [conv_short typ item] -- of 2 elements: the offset field contains the value read_value typ e' 2 | typ == TT_short || typ == TT_sshort = do i1 <- endianRead2 e' i2 <- endianRead2 e' return . Just . TEN_INT $ immed_value [conv_short typ i1, conv_short typ i2] -- of n elements read_value typ e' count | typ == TT_short || typ == TT_sshort = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_short typ) (endianRead2 e')) iter_int Iter.joinI $ Iter.joinI $ Iter.take (2*count) iter -- Read the array of long integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_long || typ == TT_slong = do item <- endianRead4 e' return . Just . TEN_INT $ immed_value [conv_long typ item] -- of n elements read_value typ e' count | typ == TT_long || typ == TT_slong = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_long typ) (endianRead4 e')) iter_int Iter.joinI $ Iter.joinI $ Iter.take (4*count) iter read_value typ e' count = do -- stub _offset <- endianRead4 e' note ["unhandled type: ", show typ, " with count ", show count] return Nothing immed_value :: (Monad m) => [el] -> EnumeratorM [Word8] [el] m a immed_value item iter = --(Iter.enumPure1Chunk item >. enumEof) iter >>== Iter.joinI . return return . joinI . return . joinIM $ (enumPure1Chunk item >>> enumEof) iter conv_byte :: TIFF_TYPE -> Word8 -> Int conv_byte TT_byte = fromIntegral conv_byte TT_sbyte = fromIntegral . u8_to_s8 conv_byte _ = error "conv_byte called with non-byte type" conv_short :: TIFF_TYPE -> Word16 -> Int conv_short TT_short = fromIntegral conv_short TT_sshort = fromIntegral . u16_to_s16 conv_short _ = error "conv_short called with non-short type" conv_long :: TIFF_TYPE -> Word32 -> Int conv_long TT_long = fromIntegral conv_long TT_slong = fromIntegral . u32_to_s32 conv_long _ = error "conv_long called with non-long type" -- Reading the pixel matrix -- For simplicity, we assume no compression and 8-bit pixels
7,429
load_dict :: MonadIO m => Endian -> Iteratee [Word8] m (Maybe TIFFDict) load_dict e = do nentries <- endianRead2 e dict <- foldr (const read_entry) (return (Just IM.empty)) [1..nentries] next_dict <- endianRead4 e when (next_dict > 0) $ note ["The TIFF file contains several images, ", "only the first one will be considered"] return dict where read_entry dictM = dictM >>= maybe (return Nothing) (\dict -> do tag <- endianRead2 e typ' <- endianRead2 e typ <- convert_type (fromIntegral typ') count <- endianRead4 e -- we read the val-offset later. We need to check the size and the type -- of the datum, because val-offset may contain the value itself, -- in its lower-numbered bytes, regardless of the big/little endian -- order! note ["TIFFEntry: tag ",show . int_to_tag . fromIntegral $ tag, " type ", show typ, " count ", show count] enum_m <- maybe (return Nothing) (\t -> read_value t e (fromIntegral count)) typ case enum_m of Just enum -> return . Just $ IM.insert (fromIntegral tag) (TIFFDE (fromIntegral count) enum) dict _ -> return (Just dict) ) convert_type :: (Monad m, Nullable s) => Int -> Iteratee s m (Maybe TIFF_TYPE) convert_type typ | typ > 0 && typ <= fromEnum (maxBound::TIFF_TYPE) = return . Just . toEnum $ typ convert_type typ = do throwErr . iterStrExc $ "Bad type of entry: " ++ show typ return Nothing read_value :: MonadIO m => TIFF_TYPE -> Endian -> Int -> Iteratee [Word8] m (Maybe TIFFDE_ENUM) read_value typ e' 0 = do endianRead4 e' throwErr . iterStrExc $ "Zero count in the entry of type: " ++ show typ return Nothing -- Read an ascii string from the offset in the -- dictionary. The last byte of -- an ascii string is always zero, which is -- included in 'count' but we don't need to read it read_value TT_ascii e' count | count > 4 = do -- val-offset is offset offset <- endianRead4 e' return . Just . TEN_CHAR $ \iter_char -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . chr . fromIntegral) Iter.head) iter_char Iter.joinI $ Iter.joinI $ Iter.take (pred count) iter -- Read the string of 0 to 3 characters long -- The zero terminator is included in count, but -- we don't need to read it read_value TT_ascii _e count = do -- count is within 1..4 let len = pred count -- string length let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop ((chr . fromIntegral $ v):acc) (pred n)) str <- loop [] len Iter.drop (4-len) case str of Just str' -> return . Just . TEN_CHAR $ immed_value str' Nothing -> return Nothing -- Read the array of signed or unsigned bytes read_value typ e' count | count > 4 && typ == TT_byte || typ == TT_sbyte = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_byte typ) Iter.head) iter_int Iter.joinI $ Iter.joinI $ Iter.take count iter -- Read the array of 1 to 4 bytes read_value typ _e count | typ == TT_byte || typ == TT_sbyte = do let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop (conv_byte typ v:acc) (pred n)) str <- (loop [] count) Iter.drop (4-count) case str of Just str' -> return . Just . TEN_INT $ immed_value str' Nothing -> return Nothing -- Read the array of Word8 read_value TT_undefined e' count | count > 4 = do offset <- endianRead4 e' return . Just . TEN_BYTE $ \iter -> return $ do Iter.seek (fromIntegral offset) Iter.joinI $ Iter.take count iter -- Read the array of Word8 of 1..4 elements, -- packed in the offset field read_value TT_undefined _e count = do let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop (v:acc) (pred n)) str <- loop [] count Iter.drop (4-count) case str of Just str' -> return . Just . TEN_BYTE $ immed_value str' Nothing -> return Nothing --return . Just . TEN_BYTE $ immed_value str -- Read the array of short integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_short || typ == TT_sshort = do item <- endianRead2 e' Iter.drop 2 -- skip the padding return . Just . TEN_INT $ immed_value [conv_short typ item] -- of 2 elements: the offset field contains the value read_value typ e' 2 | typ == TT_short || typ == TT_sshort = do i1 <- endianRead2 e' i2 <- endianRead2 e' return . Just . TEN_INT $ immed_value [conv_short typ i1, conv_short typ i2] -- of n elements read_value typ e' count | typ == TT_short || typ == TT_sshort = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_short typ) (endianRead2 e')) iter_int Iter.joinI $ Iter.joinI $ Iter.take (2*count) iter -- Read the array of long integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_long || typ == TT_slong = do item <- endianRead4 e' return . Just . TEN_INT $ immed_value [conv_long typ item] -- of n elements read_value typ e' count | typ == TT_long || typ == TT_slong = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_long typ) (endianRead4 e')) iter_int Iter.joinI $ Iter.joinI $ Iter.take (4*count) iter read_value typ e' count = do -- stub _offset <- endianRead4 e' note ["unhandled type: ", show typ, " with count ", show count] return Nothing immed_value :: (Monad m) => [el] -> EnumeratorM [Word8] [el] m a immed_value item iter = --(Iter.enumPure1Chunk item >. enumEof) iter >>== Iter.joinI . return return . joinI . return . joinIM $ (enumPure1Chunk item >>> enumEof) iter conv_byte :: TIFF_TYPE -> Word8 -> Int conv_byte TT_byte = fromIntegral conv_byte TT_sbyte = fromIntegral . u8_to_s8 conv_byte _ = error "conv_byte called with non-byte type" conv_short :: TIFF_TYPE -> Word16 -> Int conv_short TT_short = fromIntegral conv_short TT_sshort = fromIntegral . u16_to_s16 conv_short _ = error "conv_short called with non-short type" conv_long :: TIFF_TYPE -> Word32 -> Int conv_long TT_long = fromIntegral conv_long TT_slong = fromIntegral . u32_to_s32 conv_long _ = error "conv_long called with non-long type" -- Reading the pixel matrix -- For simplicity, we assume no compression and 8-bit pixels
7,314
load_dict e = do nentries <- endianRead2 e dict <- foldr (const read_entry) (return (Just IM.empty)) [1..nentries] next_dict <- endianRead4 e when (next_dict > 0) $ note ["The TIFF file contains several images, ", "only the first one will be considered"] return dict where read_entry dictM = dictM >>= maybe (return Nothing) (\dict -> do tag <- endianRead2 e typ' <- endianRead2 e typ <- convert_type (fromIntegral typ') count <- endianRead4 e -- we read the val-offset later. We need to check the size and the type -- of the datum, because val-offset may contain the value itself, -- in its lower-numbered bytes, regardless of the big/little endian -- order! note ["TIFFEntry: tag ",show . int_to_tag . fromIntegral $ tag, " type ", show typ, " count ", show count] enum_m <- maybe (return Nothing) (\t -> read_value t e (fromIntegral count)) typ case enum_m of Just enum -> return . Just $ IM.insert (fromIntegral tag) (TIFFDE (fromIntegral count) enum) dict _ -> return (Just dict) ) convert_type :: (Monad m, Nullable s) => Int -> Iteratee s m (Maybe TIFF_TYPE) convert_type typ | typ > 0 && typ <= fromEnum (maxBound::TIFF_TYPE) = return . Just . toEnum $ typ convert_type typ = do throwErr . iterStrExc $ "Bad type of entry: " ++ show typ return Nothing read_value :: MonadIO m => TIFF_TYPE -> Endian -> Int -> Iteratee [Word8] m (Maybe TIFFDE_ENUM) read_value typ e' 0 = do endianRead4 e' throwErr . iterStrExc $ "Zero count in the entry of type: " ++ show typ return Nothing -- Read an ascii string from the offset in the -- dictionary. The last byte of -- an ascii string is always zero, which is -- included in 'count' but we don't need to read it read_value TT_ascii e' count | count > 4 = do -- val-offset is offset offset <- endianRead4 e' return . Just . TEN_CHAR $ \iter_char -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . chr . fromIntegral) Iter.head) iter_char Iter.joinI $ Iter.joinI $ Iter.take (pred count) iter -- Read the string of 0 to 3 characters long -- The zero terminator is included in count, but -- we don't need to read it read_value TT_ascii _e count = do -- count is within 1..4 let len = pred count -- string length let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop ((chr . fromIntegral $ v):acc) (pred n)) str <- loop [] len Iter.drop (4-len) case str of Just str' -> return . Just . TEN_CHAR $ immed_value str' Nothing -> return Nothing -- Read the array of signed or unsigned bytes read_value typ e' count | count > 4 && typ == TT_byte || typ == TT_sbyte = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_byte typ) Iter.head) iter_int Iter.joinI $ Iter.joinI $ Iter.take count iter -- Read the array of 1 to 4 bytes read_value typ _e count | typ == TT_byte || typ == TT_sbyte = do let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop (conv_byte typ v:acc) (pred n)) str <- (loop [] count) Iter.drop (4-count) case str of Just str' -> return . Just . TEN_INT $ immed_value str' Nothing -> return Nothing -- Read the array of Word8 read_value TT_undefined e' count | count > 4 = do offset <- endianRead4 e' return . Just . TEN_BYTE $ \iter -> return $ do Iter.seek (fromIntegral offset) Iter.joinI $ Iter.take count iter -- Read the array of Word8 of 1..4 elements, -- packed in the offset field read_value TT_undefined _e count = do let loop acc 0 = return . Just . reverse $ acc loop acc n = Iter.head >>= (\v -> loop (v:acc) (pred n)) str <- loop [] count Iter.drop (4-count) case str of Just str' -> return . Just . TEN_BYTE $ immed_value str' Nothing -> return Nothing --return . Just . TEN_BYTE $ immed_value str -- Read the array of short integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_short || typ == TT_sshort = do item <- endianRead2 e' Iter.drop 2 -- skip the padding return . Just . TEN_INT $ immed_value [conv_short typ item] -- of 2 elements: the offset field contains the value read_value typ e' 2 | typ == TT_short || typ == TT_sshort = do i1 <- endianRead2 e' i2 <- endianRead2 e' return . Just . TEN_INT $ immed_value [conv_short typ i1, conv_short typ i2] -- of n elements read_value typ e' count | typ == TT_short || typ == TT_sshort = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_short typ) (endianRead2 e')) iter_int Iter.joinI $ Iter.joinI $ Iter.take (2*count) iter -- Read the array of long integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_long || typ == TT_slong = do item <- endianRead4 e' return . Just . TEN_INT $ immed_value [conv_long typ item] -- of n elements read_value typ e' count | typ == TT_long || typ == TT_slong = do offset <- endianRead4 e' return . Just . TEN_INT $ \iter_int -> return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM ((:[]) . conv_long typ) (endianRead4 e')) iter_int Iter.joinI $ Iter.joinI $ Iter.take (4*count) iter read_value typ e' count = do -- stub _offset <- endianRead4 e' note ["unhandled type: ", show typ, " with count ", show count] return Nothing immed_value :: (Monad m) => [el] -> EnumeratorM [Word8] [el] m a immed_value item iter = --(Iter.enumPure1Chunk item >. enumEof) iter >>== Iter.joinI . return return . joinI . return . joinIM $ (enumPure1Chunk item >>> enumEof) iter conv_byte :: TIFF_TYPE -> Word8 -> Int conv_byte TT_byte = fromIntegral conv_byte TT_sbyte = fromIntegral . u8_to_s8 conv_byte _ = error "conv_byte called with non-byte type" conv_short :: TIFF_TYPE -> Word16 -> Int conv_short TT_short = fromIntegral conv_short TT_sshort = fromIntegral . u16_to_s16 conv_short _ = error "conv_short called with non-short type" conv_long :: TIFF_TYPE -> Word32 -> Int conv_long TT_long = fromIntegral conv_long TT_slong = fromIntegral . u32_to_s32 conv_long _ = error "conv_long called with non-long type" -- Reading the pixel matrix -- For simplicity, we assume no compression and 8-bit pixels
7,242
true
true
0
23
2,231
2,249
1,085
1,164
null
null
JacksonGariety/euler.hs
034.hs
bsd-3-clause
factorial :: Integer -> Integer factorial 0 = 1
47
factorial :: Integer -> Integer factorial 0 = 1
47
factorial 0 = 1
15
false
true
0
5
8
18
9
9
null
null
jclee/cartparse
parse.hs
bsd-2-clause
eol :: Parser String eol = (string "\r" >> ((string "\n" >> return "\r\n") <|> return "\r")) <|> string "\n" <?> "end of line"
138
eol :: Parser String eol = (string "\r" >> ((string "\n" >> return "\r\n") <|> return "\r")) <|> string "\n" <?> "end of line"
138
eol = (string "\r" >> ((string "\n" >> return "\r\n") <|> return "\r")) <|> string "\n" <?> "end of line"
117
false
true
6
11
35
66
30
36
null
null
christiaanb/DepCore
Test2.hs
bsd-2-clause
tcTerm env (Force t) Nothing = do (at,aty) <- inferType env t eval env aty >>= \case VLift ty' -> return (Force at,ty') _ -> throwError "tcTerm: Force: expected lift"
178
tcTerm env (Force t) Nothing = do (at,aty) <- inferType env t eval env aty >>= \case VLift ty' -> return (Force at,ty') _ -> throwError "tcTerm: Force: expected lift"
178
tcTerm env (Force t) Nothing = do (at,aty) <- inferType env t eval env aty >>= \case VLift ty' -> return (Force at,ty') _ -> throwError "tcTerm: Force: expected lift"
178
false
false
0
13
41
81
38
43
null
null
MasseR/xmonadcontrib
XMonad/Prompt.hs
bsd-3-clause
amberXPConfig, defaultXPConfig, greenXPConfig :: XPConfig defaultXPConfig = XPC { font = "-misc-fixed-*-*-*-*-12-*-*-*-*-*-*-*" , bgColor = "grey22" , fgColor = "grey80" , fgHLight = "black" , bgHLight = "grey" , borderColor = "white" , promptBorderWidth = 1 , promptKeymap = defaultXPKeymap , completionKey = xK_Tab , position = Bottom , height = 18 , historySize = 256 , historyFilter = id , defaultText = [] , autoComplete = Nothing , showCompletionOnTab = False , searchPredicate = isPrefixOf }
748
amberXPConfig, defaultXPConfig, greenXPConfig :: XPConfig defaultXPConfig = XPC { font = "-misc-fixed-*-*-*-*-12-*-*-*-*-*-*-*" , bgColor = "grey22" , fgColor = "grey80" , fgHLight = "black" , bgHLight = "grey" , borderColor = "white" , promptBorderWidth = 1 , promptKeymap = defaultXPKeymap , completionKey = xK_Tab , position = Bottom , height = 18 , historySize = 256 , historyFilter = id , defaultText = [] , autoComplete = Nothing , showCompletionOnTab = False , searchPredicate = isPrefixOf }
747
defaultXPConfig = XPC { font = "-misc-fixed-*-*-*-*-12-*-*-*-*-*-*-*" , bgColor = "grey22" , fgColor = "grey80" , fgHLight = "black" , bgHLight = "grey" , borderColor = "white" , promptBorderWidth = 1 , promptKeymap = defaultXPKeymap , completionKey = xK_Tab , position = Bottom , height = 18 , historySize = 256 , historyFilter = id , defaultText = [] , autoComplete = Nothing , showCompletionOnTab = False , searchPredicate = isPrefixOf }
689
false
true
4
8
326
136
81
55
null
null
davidpdrsn/keep
src/Main.hs
bsd-3-clause
showHelp :: IO () showHelp = putStrLn $ intercalate "\n" [ "Usage:" , " Show all lists: keep" , " Make a new list: keep <list name>" , " Get key in list: keep <list name> <key>" , " Add to list: keep <list name> <key> <value>" ]
427
showHelp :: IO () showHelp = putStrLn $ intercalate "\n" [ "Usage:" , " Show all lists: keep" , " Make a new list: keep <list name>" , " Get key in list: keep <list name> <key>" , " Add to list: keep <list name> <key> <value>" ]
427
showHelp = putStrLn $ intercalate "\n" [ "Usage:" , " Show all lists: keep" , " Make a new list: keep <list name>" , " Get key in list: keep <list name> <key>" , " Add to list: keep <list name> <key> <value>" ]
409
false
true
0
7
246
40
22
18
null
null
oswynb/weather
lib/Conversion.hs
bsd-3-clause
convertLoc :: LocationUOM -> LocationUOM -> Location -> Location convertLoc oldUOM newUOM (Location x y) = let f = convertLen oldUOM newUOM in Location (f x) (f y)
204
convertLoc :: LocationUOM -> LocationUOM -> Location -> Location convertLoc oldUOM newUOM (Location x y) = let f = convertLen oldUOM newUOM in Location (f x) (f y)
204
convertLoc oldUOM newUOM (Location x y) = let f = convertLen oldUOM newUOM in Location (f x) (f y)
106
false
true
0
9
68
71
34
37
null
null
graninas/Andromeda
test/Test/Simulator/SimulationSpec.hs
bsd-3-clause
spec = describe "Simulation tests" $ do it "Setting of value generator to unattached pipe should throw." $ do pipe <- createPipe :: IO SimulatorPipe sendRequest pipe (setGen1Act boostersNozzle1T) `shouldThrow` anyException it "Setting of value generator should be successfull." $ simulateSingleReq (setGen1Act boostersNozzle1T) `shouldReturn` Ok it "Continuous simulation of sensor should return values." $ do (pipe, simHandle) <- makeRunningSimulation networkDef r1 <- sendRequest pipe (setGen1Act boostersNozzle1T) r2 <- sendRequest pipe runNetworkAct OutValueSource vs <- sendRequest pipe (GetValueSource boostersNozzle1T) vals <- replicateM 10 $ threadDelay 1000 >> readValueSource vs stopSimulation simHandle nub [r1, r2] `shouldBe` [Ok] sort vals `shouldBe` vals length vals `shouldBe` 10 it "Continuous simulation of several sensors should return values." $ do (pipe, simHandle) <- makeRunningSimulation networkDef r1 <- sendRequest pipe (setGen1Act boostersNozzle1T) r2 <- sendRequest pipe (setGen2Act boostersNozzle2T) r3 <- sendRequest pipe runNetworkAct (OutValueSource vs1) <- sendRequest pipe (GetValueSource boostersNozzle1T) (OutValueSource vs2) <- sendRequest pipe (GetValueSource boostersNozzle2T) vals1 <- replicateM 10 $ threadDelay 1000 >> readValueSource vs1 vals2 <- replicateM 10 $ threadDelay 1000 >> readValueSource vs2 stopSimulation simHandle nub [r1, r2, r3] `shouldBe` [Ok] sort vals1 `shouldBe` vals1 length vals1 `shouldBe` 10 sort vals2 `shouldBe` reverse vals2 length vals2 `shouldBe` 10
1,635
spec = describe "Simulation tests" $ do it "Setting of value generator to unattached pipe should throw." $ do pipe <- createPipe :: IO SimulatorPipe sendRequest pipe (setGen1Act boostersNozzle1T) `shouldThrow` anyException it "Setting of value generator should be successfull." $ simulateSingleReq (setGen1Act boostersNozzle1T) `shouldReturn` Ok it "Continuous simulation of sensor should return values." $ do (pipe, simHandle) <- makeRunningSimulation networkDef r1 <- sendRequest pipe (setGen1Act boostersNozzle1T) r2 <- sendRequest pipe runNetworkAct OutValueSource vs <- sendRequest pipe (GetValueSource boostersNozzle1T) vals <- replicateM 10 $ threadDelay 1000 >> readValueSource vs stopSimulation simHandle nub [r1, r2] `shouldBe` [Ok] sort vals `shouldBe` vals length vals `shouldBe` 10 it "Continuous simulation of several sensors should return values." $ do (pipe, simHandle) <- makeRunningSimulation networkDef r1 <- sendRequest pipe (setGen1Act boostersNozzle1T) r2 <- sendRequest pipe (setGen2Act boostersNozzle2T) r3 <- sendRequest pipe runNetworkAct (OutValueSource vs1) <- sendRequest pipe (GetValueSource boostersNozzle1T) (OutValueSource vs2) <- sendRequest pipe (GetValueSource boostersNozzle2T) vals1 <- replicateM 10 $ threadDelay 1000 >> readValueSource vs1 vals2 <- replicateM 10 $ threadDelay 1000 >> readValueSource vs2 stopSimulation simHandle nub [r1, r2, r3] `shouldBe` [Ok] sort vals1 `shouldBe` vals1 length vals1 `shouldBe` 10 sort vals2 `shouldBe` reverse vals2 length vals2 `shouldBe` 10
1,635
spec = describe "Simulation tests" $ do it "Setting of value generator to unattached pipe should throw." $ do pipe <- createPipe :: IO SimulatorPipe sendRequest pipe (setGen1Act boostersNozzle1T) `shouldThrow` anyException it "Setting of value generator should be successfull." $ simulateSingleReq (setGen1Act boostersNozzle1T) `shouldReturn` Ok it "Continuous simulation of sensor should return values." $ do (pipe, simHandle) <- makeRunningSimulation networkDef r1 <- sendRequest pipe (setGen1Act boostersNozzle1T) r2 <- sendRequest pipe runNetworkAct OutValueSource vs <- sendRequest pipe (GetValueSource boostersNozzle1T) vals <- replicateM 10 $ threadDelay 1000 >> readValueSource vs stopSimulation simHandle nub [r1, r2] `shouldBe` [Ok] sort vals `shouldBe` vals length vals `shouldBe` 10 it "Continuous simulation of several sensors should return values." $ do (pipe, simHandle) <- makeRunningSimulation networkDef r1 <- sendRequest pipe (setGen1Act boostersNozzle1T) r2 <- sendRequest pipe (setGen2Act boostersNozzle2T) r3 <- sendRequest pipe runNetworkAct (OutValueSource vs1) <- sendRequest pipe (GetValueSource boostersNozzle1T) (OutValueSource vs2) <- sendRequest pipe (GetValueSource boostersNozzle2T) vals1 <- replicateM 10 $ threadDelay 1000 >> readValueSource vs1 vals2 <- replicateM 10 $ threadDelay 1000 >> readValueSource vs2 stopSimulation simHandle nub [r1, r2, r3] `shouldBe` [Ok] sort vals1 `shouldBe` vals1 length vals1 `shouldBe` 10 sort vals2 `shouldBe` reverse vals2 length vals2 `shouldBe` 10
1,635
false
false
0
14
309
484
224
260
null
null
facebookincubator/duckling
Duckling/Dimensions.hs
bsd-3-clause
langDimensions DE = DEDimensions.allDimensions
46
langDimensions DE = DEDimensions.allDimensions
46
langDimensions DE = DEDimensions.allDimensions
46
false
false
0
5
3
11
5
6
null
null
mathhun/stack
src/Stack/Types/Build.hs
bsd-3-clause
wantedLocalPackages :: [LocalPackage] -> Set PackageName wantedLocalPackages = Set.fromList . map (packageName . lpPackage) . filter lpWanted
141
wantedLocalPackages :: [LocalPackage] -> Set PackageName wantedLocalPackages = Set.fromList . map (packageName . lpPackage) . filter lpWanted
141
wantedLocalPackages = Set.fromList . map (packageName . lpPackage) . filter lpWanted
84
false
true
0
9
16
49
23
26
null
null
hvr/text
Data/Text.hs
bsd-2-clause
{- -- | /O(n)/ Portably breaks a 'Text' up into a list of 'Text's at line -- boundaries. -- -- A line boundary is considered to be either a line feed, a carriage -- return immediately followed by a line feed, or a carriage return. -- This accounts for both Unix and Windows line ending conventions, -- and for the old convention used on Mac OS 9 and earlier. lines' :: Text -> [Text] lines' ps | null ps = [] | otherwise = h : case uncons t of Nothing -> [] Just (c,t') | c == '\n' -> lines t' | c == '\r' -> case uncons t' of Just ('\n',t'') -> lines t'' _ -> lines t' where (h,t) = span notEOL ps notEOL c = c /= '\n' && c /= '\r' {-# INLINE lines' #-} -} -- | /O(n)/ Joins lines, after appending a terminating newline to -- each. unlines :: [Text] -> Text unlines = concat . L.map (`snoc` '\n')
1,071
unlines :: [Text] -> Text unlines = concat . L.map (`snoc` '\n')
64
unlines = concat . L.map (`snoc` '\n')
38
true
true
0
7
439
36
22
14
null
null
Lykos/Sara
src/lib/Sara/Z3/SymbolicStateSpace.hs
gpl-3.0
getOrCreateVar :: MonadState S.SymbolicState m => ResultTmpVar -> m A.Ast getOrCreateVar v = do state <- get runReaderT (S.getOrCreateVar v) state -- | Adds the given proof obligation to all states.
203
getOrCreateVar :: MonadState S.SymbolicState m => ResultTmpVar -> m A.Ast getOrCreateVar v = do state <- get runReaderT (S.getOrCreateVar v) state -- | Adds the given proof obligation to all states.
203
getOrCreateVar v = do state <- get runReaderT (S.getOrCreateVar v) state -- | Adds the given proof obligation to all states.
129
false
true
0
10
35
58
27
31
null
null
tolysz/yesod-websockets-extra
src/Yesod/WebSockets/Extra.hs
bsd-3-clause
wrapWS :: (MonadIO m, WS.WebSocketsData a) => (WS.Connection -> a -> IO ()) -> a -> WebSocketsT m () wrapWS ws x = ReaderT $ liftIO . flip ws x
143
wrapWS :: (MonadIO m, WS.WebSocketsData a) => (WS.Connection -> a -> IO ()) -> a -> WebSocketsT m () wrapWS ws x = ReaderT $ liftIO . flip ws x
143
wrapWS ws x = ReaderT $ liftIO . flip ws x
42
false
true
0
11
29
79
39
40
null
null
yangsiwei880813/CS644
src/CodeConstruct.hs
gpl-2.0
genExprAsm sd (Binary op exprL exprR nesting) | op == "&&" = ["; Binary op: " ++ op ++ " with shortcut"] ++ leftCode ++ ["cmp eax, 0", "je " ++ endLabel] ++ rightCode ++ [endLabel ++ ":"] | op == "||" = ["; Binary op: " ++ op ++ " with shortcut"] ++ leftCode ++ ["cmp eax, 1", "je " ++ endLabel] ++ rightCode ++ [endLabel ++ ":"] | otherwise = [";Binary op: " ++ op] ++ leftCode ++ ["push eax ; Push left value to stack"] ++ rightCode ++ ["mov ebx, eax", "pop eax ; Pop right value from stack"] ++ opCode where opname = if op == "&&" then "And" else "Or" endLabel = ".binary_End_" ++ opname ++ "_" ++ genLabel nesting rightCode = genExprAsm sd exprR opCode = genOpAsm op leftCode = case op of "=" -> genExprLhsAsm sd exprL _ -> genExprAsm sd exprL
958
genExprAsm sd (Binary op exprL exprR nesting) | op == "&&" = ["; Binary op: " ++ op ++ " with shortcut"] ++ leftCode ++ ["cmp eax, 0", "je " ++ endLabel] ++ rightCode ++ [endLabel ++ ":"] | op == "||" = ["; Binary op: " ++ op ++ " with shortcut"] ++ leftCode ++ ["cmp eax, 1", "je " ++ endLabel] ++ rightCode ++ [endLabel ++ ":"] | otherwise = [";Binary op: " ++ op] ++ leftCode ++ ["push eax ; Push left value to stack"] ++ rightCode ++ ["mov ebx, eax", "pop eax ; Pop right value from stack"] ++ opCode where opname = if op == "&&" then "And" else "Or" endLabel = ".binary_End_" ++ opname ++ "_" ++ genLabel nesting rightCode = genExprAsm sd exprR opCode = genOpAsm op leftCode = case op of "=" -> genExprLhsAsm sd exprL _ -> genExprAsm sd exprL
958
genExprAsm sd (Binary op exprL exprR nesting) | op == "&&" = ["; Binary op: " ++ op ++ " with shortcut"] ++ leftCode ++ ["cmp eax, 0", "je " ++ endLabel] ++ rightCode ++ [endLabel ++ ":"] | op == "||" = ["; Binary op: " ++ op ++ " with shortcut"] ++ leftCode ++ ["cmp eax, 1", "je " ++ endLabel] ++ rightCode ++ [endLabel ++ ":"] | otherwise = [";Binary op: " ++ op] ++ leftCode ++ ["push eax ; Push left value to stack"] ++ rightCode ++ ["mov ebx, eax", "pop eax ; Pop right value from stack"] ++ opCode where opname = if op == "&&" then "And" else "Or" endLabel = ".binary_End_" ++ opname ++ "_" ++ genLabel nesting rightCode = genExprAsm sd exprR opCode = genOpAsm op leftCode = case op of "=" -> genExprLhsAsm sd exprL _ -> genExprAsm sd exprL
958
false
false
6
12
359
269
138
131
null
null
kim/amazonka
amazonka-kinesis/gen/Network/AWS/Kinesis/ListStreams.hs
mpl-2.0
-- | If set to 'true', there are more streams available to list. lsrHasMoreStreams :: Lens' ListStreamsResponse Bool lsrHasMoreStreams = lens _lsrHasMoreStreams (\s a -> s { _lsrHasMoreStreams = a })
203
lsrHasMoreStreams :: Lens' ListStreamsResponse Bool lsrHasMoreStreams = lens _lsrHasMoreStreams (\s a -> s { _lsrHasMoreStreams = a })
138
lsrHasMoreStreams = lens _lsrHasMoreStreams (\s a -> s { _lsrHasMoreStreams = a })
86
true
true
0
9
34
40
22
18
null
null