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
zachsully/hakaru
haskell/Tests/Disintegrate.hs
bsd-3-clause
testPerform0b = runPerform norm0b
33
testPerform0b = runPerform norm0b
33
testPerform0b = runPerform norm0b
33
false
false
1
5
3
13
4
9
null
null
VictorDenisov/cluedo
src/Test/AllTests.hs
gpl-2.0
testParseCard_notCard :: Assertion testParseCard_notCard = Model.parseCard "NotCard" @=? Nothing
96
testParseCard_notCard :: Assertion testParseCard_notCard = Model.parseCard "NotCard" @=? Nothing
96
testParseCard_notCard = Model.parseCard "NotCard" @=? Nothing
61
false
true
0
7
8
27
11
16
null
null
anttisalonen/economics
src/TestMarket.hs
mit
dem n = E.lookup n demands
26
dem n = E.lookup n demands
26
dem n = E.lookup n demands
26
false
false
0
6
5
16
7
9
null
null
adarqui/github
Github/GitData/References.hs
bsd-3-clause
-- | A single reference by the ref name. -- -- > reference "mike-burns" "github" "heads/master" reference :: String -> String -> String -> IO (Either Error GitReference) reference = reference' Nothing
200
reference :: String -> String -> String -> IO (Either Error GitReference) reference = reference' Nothing
104
reference = reference' Nothing
30
true
true
0
11
31
46
22
24
null
null
facebookincubator/duckling
Duckling/Time/DE/Rules.hs
bsd-3-clause
ruleHhmmMilitary :: Rule ruleHhmmMilitary = Rule { name = "hhmm (military)" , pattern = [ regex "((?:[01]?\\d)|(?:2[0-3]))([0-5]\\d)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (h:m:_)):_) -> do hh <- parseInt h mm <- parseInt m tt . mkLatent $ hourMinute False hh mm _ -> Nothing }
358
ruleHhmmMilitary :: Rule ruleHhmmMilitary = Rule { name = "hhmm (military)" , pattern = [ regex "((?:[01]?\\d)|(?:2[0-3]))([0-5]\\d)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (h:m:_)):_) -> do hh <- parseInt h mm <- parseInt m tt . mkLatent $ hourMinute False hh mm _ -> Nothing }
358
ruleHhmmMilitary = Rule { name = "hhmm (military)" , pattern = [ regex "((?:[01]?\\d)|(?:2[0-3]))([0-5]\\d)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (h:m:_)):_) -> do hh <- parseInt h mm <- parseInt m tt . mkLatent $ hourMinute False hh mm _ -> Nothing }
333
false
true
0
19
103
135
66
69
null
null
brendanhay/gogol
gogol-identity-toolkit/gen/Network/Google/IdentityToolkit/Types/Product.hs
mpl-2.0
-- | The new email the user attempts to change to. sairNewEmail :: Lens' SetAccountInfoResponse (Maybe Text) sairNewEmail = lens _sairNewEmail (\ s a -> s{_sairNewEmail = a})
176
sairNewEmail :: Lens' SetAccountInfoResponse (Maybe Text) sairNewEmail = lens _sairNewEmail (\ s a -> s{_sairNewEmail = a})
125
sairNewEmail = lens _sairNewEmail (\ s a -> s{_sairNewEmail = a})
67
true
true
0
9
29
48
25
23
null
null
facebookincubator/duckling
Duckling/Numeral/RU/Rules.hs
bsd-3-clause
ruleInteger :: Rule ruleInteger = Rule { name = "integer 0" , pattern = [ regex "(ноль|нуля|нисколько)" ] , prod = \_ -> integer 0 }
148
ruleInteger :: Rule ruleInteger = Rule { name = "integer 0" , pattern = [ regex "(ноль|нуля|нисколько)" ] , prod = \_ -> integer 0 }
148
ruleInteger = Rule { name = "integer 0" , pattern = [ regex "(ноль|нуля|нисколько)" ] , prod = \_ -> integer 0 }
128
false
true
0
9
41
49
27
22
null
null
mhwombat/creatur-audio-wains
src/ALife/Creatur/Wain/Audio/Wain.hs
bsd-3-clause
adjustEnergy :: Simple Lens e (PatternWain a rt) -> Double -> Simple Lens s Double -> String -> Simple Lens e s -> (String -> StateT e IO ()) -> StateT e IO () adjustEnergy wainLens deltaE statLens reason summary report = do w <- use wainLens let (w', used) = W.adjustEnergy deltaE w report $ "Adjusting energy of " ++ agentId w ++ " because " ++ reason ++ ": " ++ printf "%.3f" (uiToDouble . W._energy $ w) ++ " + " ++ printf "%.3f" deltaE ++ " -> " ++ printf "%.3f" (uiToDouble . W._energy $ w') ++ " used=" ++ printf "%.3f" used ++ " leftover=" ++ printf "%.3f" (deltaE - used) (summary . statLens) += used assign wainLens w'
678
adjustEnergy :: Simple Lens e (PatternWain a rt) -> Double -> Simple Lens s Double -> String -> Simple Lens e s -> (String -> StateT e IO ()) -> StateT e IO () adjustEnergy wainLens deltaE statLens reason summary report = do w <- use wainLens let (w', used) = W.adjustEnergy deltaE w report $ "Adjusting energy of " ++ agentId w ++ " because " ++ reason ++ ": " ++ printf "%.3f" (uiToDouble . W._energy $ w) ++ " + " ++ printf "%.3f" deltaE ++ " -> " ++ printf "%.3f" (uiToDouble . W._energy $ w') ++ " used=" ++ printf "%.3f" used ++ " leftover=" ++ printf "%.3f" (deltaE - used) (summary . statLens) += used assign wainLens w'
678
adjustEnergy wainLens deltaE statLens reason summary report = do w <- use wainLens let (w', used) = W.adjustEnergy deltaE w report $ "Adjusting energy of " ++ agentId w ++ " because " ++ reason ++ ": " ++ printf "%.3f" (uiToDouble . W._energy $ w) ++ " + " ++ printf "%.3f" deltaE ++ " -> " ++ printf "%.3f" (uiToDouble . W._energy $ w') ++ " used=" ++ printf "%.3f" used ++ " leftover=" ++ printf "%.3f" (deltaE - used) (summary . statLens) += used assign wainLens w'
506
false
true
0
21
173
282
133
149
null
null
tjakway/ghcjvm
compiler/basicTypes/PatSyn.hs
bsd-3-clause
patSynArgs :: PatSyn -> [Type] patSynArgs = psArgs
50
patSynArgs :: PatSyn -> [Type] patSynArgs = psArgs
50
patSynArgs = psArgs
19
false
true
0
6
7
18
10
8
null
null
postgres-haskell/postgres-wire
tests/Protocol.hs
mit
assertContains :: Either Error [ServerMessage] -> (ServerMessage -> Bool) -> String -> Assertion assertContains (Left e) _ _ = assertFailure $ "Got Error" ++ show e
176
assertContains :: Either Error [ServerMessage] -> (ServerMessage -> Bool) -> String -> Assertion assertContains (Left e) _ _ = assertFailure $ "Got Error" ++ show e
176
assertContains (Left e) _ _ = assertFailure $ "Got Error" ++ show e
67
false
true
0
11
37
67
32
35
null
null
peterspackman/hsqc
src/Integrals.hs
gpl-3.0
g (0,0,i,0) gs = g (0,0,0,i) gs
31
g (0,0,i,0) gs = g (0,0,0,i) gs
31
g (0,0,i,0) gs = g (0,0,0,i) gs
31
false
false
1
6
6
42
23
19
null
null
twittner/zeromq-haskell
src/System/ZMQ4/Monadic.hs
mit
monitor :: [Z.EventType] -> Socket z t -> ZMQ z (Bool -> IO (Maybe Z.EventMsg)) monitor es s = onContext $ \ctx -> Z.monitor es ctx (_unsocket s)
145
monitor :: [Z.EventType] -> Socket z t -> ZMQ z (Bool -> IO (Maybe Z.EventMsg)) monitor es s = onContext $ \ctx -> Z.monitor es ctx (_unsocket s)
145
monitor es s = onContext $ \ctx -> Z.monitor es ctx (_unsocket s)
65
false
true
0
14
27
85
41
44
null
null
Gurmeet-Singh/Zeno
Example.hs
mit
filter p (x:xs) | p x = x : xs' | otherwise = xs' where xs' = filter p xs
79
filter p (x:xs) | p x = x : xs' | otherwise = xs' where xs' = filter p xs
79
filter p (x:xs) | p x = x : xs' | otherwise = xs' where xs' = filter p xs
79
false
false
3
8
25
62
25
37
null
null
rgrempel/frelm.org
src/Worker.hs
mit
toLogLevel :: Int -> LogLevel toLogLevel 0 = LevelError
55
toLogLevel :: Int -> LogLevel toLogLevel 0 = LevelError
55
toLogLevel 0 = LevelError
25
false
true
0
7
8
24
10
14
null
null
hvr/lens
src/Control/Lens/Internal/Reflection.hs
bsd-3-clause
byte7 :: p (Stable w0 (W b4 b5 b6 b7) a) -> Proxy b7 byte7 _ = Proxy
68
byte7 :: p (Stable w0 (W b4 b5 b6 b7) a) -> Proxy b7 byte7 _ = Proxy
68
byte7 _ = Proxy
15
false
true
0
10
17
46
22
24
null
null
open-etcs/openetcs-sdm
src/ETCS/SDM/Stepper.hs
bsd-3-clause
stepperF (_:_) [] _ = error "error evaluating stepperF on (_:_) []"
67
stepperF (_:_) [] _ = error "error evaluating stepperF on (_:_) []"
67
stepperF (_:_) [] _ = error "error evaluating stepperF on (_:_) []"
67
false
false
0
7
11
25
12
13
null
null
rueshyna/gogol
gogol-compute/gen/Network/Google/Compute/Types/Product.hs
mpl-2.0
-- | [Output Only] The gateway address for default routes to reach -- destination addresses outside this subnetwork. subGatewayAddress :: Lens' Subnetwork (Maybe Text) subGatewayAddress = lens _subGatewayAddress (\ s a -> s{_subGatewayAddress = a})
256
subGatewayAddress :: Lens' Subnetwork (Maybe Text) subGatewayAddress = lens _subGatewayAddress (\ s a -> s{_subGatewayAddress = a})
139
subGatewayAddress = lens _subGatewayAddress (\ s a -> s{_subGatewayAddress = a})
88
true
true
2
9
42
56
26
30
null
null
christiaanb/ghc
compiler/basicTypes/IdInfo.hs
bsd-3-clause
setDemandInfo :: IdInfo -> Demand -> IdInfo setDemandInfo info dd = dd `seq` info { demandInfo = dd }
101
setDemandInfo :: IdInfo -> Demand -> IdInfo setDemandInfo info dd = dd `seq` info { demandInfo = dd }
101
setDemandInfo info dd = dd `seq` info { demandInfo = dd }
57
false
true
0
7
18
38
21
17
null
null
haskoin/haskoin
src/Haskoin/Crypto/Hash.hs
unlicense
-- | Computes HMAC over SHA-256. hmac256 :: (ByteArrayAccess k, ByteArrayAccess m) => k -> m -> Hash256 hmac256 key msg = Hash256 $ BSS.toShort $ BA.convert (hmac key msg :: HMAC SHA256)
190
hmac256 :: (ByteArrayAccess k, ByteArrayAccess m) => k -> m -> Hash256 hmac256 key msg = Hash256 $ BSS.toShort $ BA.convert (hmac key msg :: HMAC SHA256)
157
hmac256 key msg = Hash256 $ BSS.toShort $ BA.convert (hmac key msg :: HMAC SHA256)
86
true
true
4
9
36
76
36
40
null
null
Michaelt293/Lipid-Haskell
src/Lipid/Parsers/KnownSn/Glycerophospholipid.hs
gpl-3.0
paOmegaP :: Parser (PA OmegaPosition) paOmegaP = paP radylOmegaP
64
paOmegaP :: Parser (PA OmegaPosition) paOmegaP = paP radylOmegaP
64
paOmegaP = paP radylOmegaP
26
false
true
2
6
8
30
11
19
null
null
imrehg/rwhaskell
ch03/ex05.hs
mit
isPali (x:[]) = True
20
isPali (x:[]) = True
20
isPali (x:[]) = True
20
false
false
0
8
3
18
9
9
null
null
msullivan/advent-of-code
2016/A11a.hs
mit
--next :: Table -> (Int, (Int, [[String]])) -> [(Int, (Int, [[String]]))] next map ((i, state)) = do guard $ Map.notMember (i, state) map let xs = state !! i parts <- things xs i' <- [i-1, i+1] guard $ i' >= 0 && i' <= 3 -- guard $ length parts == 1 || i' == i+1 let state' = replaceAtIndex i (xs \\ parts) (replaceAtIndex i' (sort (parts ++ (state !! i'))) state) guard $ all linesafe state' guard $ Map.notMember (i', state') map return (i', state')
497
next map ((i, state)) = do guard $ Map.notMember (i, state) map let xs = state !! i parts <- things xs i' <- [i-1, i+1] guard $ i' >= 0 && i' <= 3 -- guard $ length parts == 1 || i' == i+1 let state' = replaceAtIndex i (xs \\ parts) (replaceAtIndex i' (sort (parts ++ (state !! i'))) state) guard $ all linesafe state' guard $ Map.notMember (i', state') map return (i', state')
423
next map ((i, state)) = do guard $ Map.notMember (i, state) map let xs = state !! i parts <- things xs i' <- [i-1, i+1] guard $ i' >= 0 && i' <= 3 -- guard $ length parts == 1 || i' == i+1 let state' = replaceAtIndex i (xs \\ parts) (replaceAtIndex i' (sort (parts ++ (state !! i'))) state) guard $ all linesafe state' guard $ Map.notMember (i', state') map return (i', state')
423
true
false
0
18
133
203
101
102
null
null
andrewaguiar/s99-haskell
p11.hs
mit
{- Modified run-length encoding. -} runLengthEncoding :: (Eq a) => [a] -> [MyTuple a] runLengthEncoding [] = []
111
runLengthEncoding :: (Eq a) => [a] -> [MyTuple a] runLengthEncoding [] = []
75
runLengthEncoding [] = []
25
true
true
0
8
17
41
22
19
null
null
yxm4109/pandoc
src/Text/Pandoc/Writers/Docbook.hs
gpl-2.0
inlineToDocbook _ (HtmlInline _) = empty
40
inlineToDocbook _ (HtmlInline _) = empty
40
inlineToDocbook _ (HtmlInline _) = empty
40
false
false
1
6
5
20
8
12
null
null
forked-upstream-packages-for-ghcjs/ghc
compiler/coreSyn/CoreUtils.hs
bsd-3-clause
exprType (Let bind body) | NonRec tv rhs <- bind -- See Note [Type bindings] , Type ty <- rhs = substTyWith [tv] [ty] (exprType body) | otherwise = exprType body
195
exprType (Let bind body) | NonRec tv rhs <- bind -- See Note [Type bindings] , Type ty <- rhs = substTyWith [tv] [ty] (exprType body) | otherwise = exprType body
195
exprType (Let bind body) | NonRec tv rhs <- bind -- See Note [Type bindings] , Type ty <- rhs = substTyWith [tv] [ty] (exprType body) | otherwise = exprType body
195
false
false
1
9
64
73
35
38
null
null
mariefarrell/Hets
CspCASLProver/CspProverConsts.hs
gpl-2.0
cspProver_hidingAltArgPrios :: [Int] cspProver_hidingAltArgPrios = [84, 85]
75
cspProver_hidingAltArgPrios :: [Int] cspProver_hidingAltArgPrios = [84, 85]
75
cspProver_hidingAltArgPrios = [84, 85]
38
false
true
0
5
6
20
12
8
null
null
GaloisInc/pads-haskell
Examples/Regression.hs
bsd-3-clause
t27 = "type EvenInt = constrain x :: Digit where <|(x `mod` 2) == 0|>"
70
t27 = "type EvenInt = constrain x :: Digit where <|(x `mod` 2) == 0|>"
70
t27 = "type EvenInt = constrain x :: Digit where <|(x `mod` 2) == 0|>"
70
false
false
0
4
14
6
3
3
null
null
FreeON/spammpack
src-Haskell/MatrixTree.hs
bsd-3-clause
addVal (i, j, x) (Zero s) | s == 1 = Leaf 0 x | within [i,j] = Square s 0 (addVal (i, j, x) zro) zro zro zro | within [i,jr] = Square s 0 zro (addVal (i, jr, x) zro) zro zro | within [ib,j] = Square s 0 zro zro (addVal (ib, j, x) zro) zro | within [ib,jr] = Square s 0 zro zro zro (addVal (ib, jr, x) zro) where halfs = s `div` 2 within = all (<= halfs) ib = i - halfs ; jr = j - halfs zro = Zero halfs
445
addVal (i, j, x) (Zero s) | s == 1 = Leaf 0 x | within [i,j] = Square s 0 (addVal (i, j, x) zro) zro zro zro | within [i,jr] = Square s 0 zro (addVal (i, jr, x) zro) zro zro | within [ib,j] = Square s 0 zro zro (addVal (ib, j, x) zro) zro | within [ib,jr] = Square s 0 zro zro zro (addVal (ib, jr, x) zro) where halfs = s `div` 2 within = all (<= halfs) ib = i - halfs ; jr = j - halfs zro = Zero halfs
445
addVal (i, j, x) (Zero s) | s == 1 = Leaf 0 x | within [i,j] = Square s 0 (addVal (i, j, x) zro) zro zro zro | within [i,jr] = Square s 0 zro (addVal (i, jr, x) zro) zro zro | within [ib,j] = Square s 0 zro zro (addVal (ib, j, x) zro) zro | within [ib,jr] = Square s 0 zro zro zro (addVal (ib, jr, x) zro) where halfs = s `div` 2 within = all (<= halfs) ib = i - halfs ; jr = j - halfs zro = Zero halfs
445
false
false
7
8
142
281
150
131
null
null
alexander-at-github/eta
compiler/ETA/BasicTypes/Literal.hs
bsd-3-clause
cmpLit (MachFloat a) (MachFloat b) = a `compare` b
63
cmpLit (MachFloat a) (MachFloat b) = a `compare` b
63
cmpLit (MachFloat a) (MachFloat b) = a `compare` b
63
false
false
0
7
21
29
15
14
null
null
kishoredbn/barrelfish
tools/sockeye/SockeyeBackendProlog.hs
mit
om name@(c:cs) | isLower c && allAlphaNum cs = name | otherwise = quotes name where allAlphaNum cs = foldl (\acc c -> isAlphaNum c && acc) True cs
172
atom name@(c:cs) | isLower c && allAlphaNum cs = name | otherwise = quotes name where allAlphaNum cs = foldl (\acc c -> isAlphaNum c && acc) True cs
172
atom name@(c:cs) | isLower c && allAlphaNum cs = name | otherwise = quotes name where allAlphaNum cs = foldl (\acc c -> isAlphaNum c && acc) True cs
172
false
false
1
9
54
92
40
52
null
null
rahulmutt/ghcvm
compiler/Eta/Prelude/PrimOp.hs
bsd-3-clause
tagOf_PrimOp IndexByteArrayOp_Int64 = _ILIT(192)
48
tagOf_PrimOp IndexByteArrayOp_Int64 = _ILIT(192)
48
tagOf_PrimOp IndexByteArrayOp_Int64 = _ILIT(192)
48
false
false
0
6
3
15
7
8
null
null
neglectedvalue/xmobar-freebsd
Plugins/Monitors/CoreTemp.hs
bsd-3-clause
-- available -- replacements -- | -- Function retrieves monitor string holding the core temperature -- (or temperatures) runCoreTemp :: [String] -> Monitor String runCoreTemp _ = do let dir = "/sys/bus/platform/devices" file = "temp1_input" pattern = "coretemp." divisor = 1e3 :: Double failureMessage = "CoreTemp: N/A" checkedDataRetrieval failureMessage dir file pattern divisor
484
runCoreTemp :: [String] -> Monitor String runCoreTemp _ = do let dir = "/sys/bus/platform/devices" file = "temp1_input" pattern = "coretemp." divisor = 1e3 :: Double failureMessage = "CoreTemp: N/A" checkedDataRetrieval failureMessage dir file pattern divisor
299
runCoreTemp _ = do let dir = "/sys/bus/platform/devices" file = "temp1_input" pattern = "coretemp." divisor = 1e3 :: Double failureMessage = "CoreTemp: N/A" checkedDataRetrieval failureMessage dir file pattern divisor
257
true
true
0
9
156
79
42
37
null
null
yiannist/ganeti
src/Ganeti/Confd/Server.hs
bsd-2-clause
getNodePipByInstanceIp :: ConfigData -> LinkIpMap -> String -> String -> StatusAnswer getNodePipByInstanceIp cfg linkipmap link instip = case M.lookup instip (M.findWithDefault M.empty link linkipmap) of Nothing -> queryUnknownEntry Just instname -> case getInstPrimaryNode cfg instname of Bad _ -> queryUnknownEntry -- either instance or node not found Ok node -> (ReplyStatusOk, J.showJSON (nodePrimaryIp node), clusterSerial $ configCluster cfg) -- | Returns a node name for a given UUID
635
getNodePipByInstanceIp :: ConfigData -> LinkIpMap -> String -> String -> StatusAnswer getNodePipByInstanceIp cfg linkipmap link instip = case M.lookup instip (M.findWithDefault M.empty link linkipmap) of Nothing -> queryUnknownEntry Just instname -> case getInstPrimaryNode cfg instname of Bad _ -> queryUnknownEntry -- either instance or node not found Ok node -> (ReplyStatusOk, J.showJSON (nodePrimaryIp node), clusterSerial $ configCluster cfg) -- | Returns a node name for a given UUID
635
getNodePipByInstanceIp cfg linkipmap link instip = case M.lookup instip (M.findWithDefault M.empty link linkipmap) of Nothing -> queryUnknownEntry Just instname -> case getInstPrimaryNode cfg instname of Bad _ -> queryUnknownEntry -- either instance or node not found Ok node -> (ReplyStatusOk, J.showJSON (nodePrimaryIp node), clusterSerial $ configCluster cfg) -- | Returns a node name for a given UUID
457
false
true
0
14
212
132
65
67
null
null
kevinjardine/gruzeSnaplet
src/Snap/Snaplet/Gruze/Query.hs
gpl-2.0
queryResultToAggByObjSumCount :: GrzObjClass o => (GrzObj -> o) -- ^ type wrapper -> ([[SqlValue]],([(GrzString,Int)],[[SqlValue]])) -- ^ query result -> [(o,(Int,Int))] -- returns list of (obj, count) pairs queryResultToAggByObjSumCount w (r, (n,mr)) = map (queryRowToAggByObjSumCount w mq) r where mq = metadataQueryToAtomBoxDict n mr
438
queryResultToAggByObjSumCount :: GrzObjClass o => (GrzObj -> o) -- ^ type wrapper -> ([[SqlValue]],([(GrzString,Int)],[[SqlValue]])) -- ^ query result -> [(o,(Int,Int))] queryResultToAggByObjSumCount w (r, (n,mr)) = map (queryRowToAggByObjSumCount w mq) r where mq = metadataQueryToAtomBoxDict n mr
365
queryResultToAggByObjSumCount w (r, (n,mr)) = map (queryRowToAggByObjSumCount w mq) r where mq = metadataQueryToAtomBoxDict n mr
141
true
true
0
12
144
129
74
55
null
null
esengie/fpl-exploration-tool
src/langGenerator/CodeGen/RightSide/Solver.hs
bsd-3-clause
remLtoR :: Eq a => [a] -> [a] -> [Remover] remLtoR [] _ = []
60
remLtoR :: Eq a => [a] -> [a] -> [Remover] remLtoR [] _ = []
60
remLtoR [] _ = []
17
false
true
0
10
14
50
24
26
null
null
pegurnee/2015-01-341
haskell/someFunctions.hs
mit
initials :: String -> String -> String initials firstname lastname = [f] ++ ". " ++ [l] ++ "." where (f:_) = firstname (l:_) = lastname
153
initials :: String -> String -> String initials firstname lastname = [f] ++ ". " ++ [l] ++ "." where (f:_) = firstname (l:_) = lastname
153
initials firstname lastname = [f] ++ ". " ++ [l] ++ "." where (f:_) = firstname (l:_) = lastname
114
false
true
0
8
43
77
38
39
null
null
bitemyapp/ganeti
src/Ganeti/OpParams.hs
bsd-2-clause
pDiagnoseDataCollectorFilename :: Field pDiagnoseDataCollectorFilename = withDoc "Sets the filename of the script diagnose data collector should run" $ optionalStringField "diagnose_data_collector_filename"
210
pDiagnoseDataCollectorFilename :: Field pDiagnoseDataCollectorFilename = withDoc "Sets the filename of the script diagnose data collector should run" $ optionalStringField "diagnose_data_collector_filename"
210
pDiagnoseDataCollectorFilename = withDoc "Sets the filename of the script diagnose data collector should run" $ optionalStringField "diagnose_data_collector_filename"
170
false
true
0
6
23
21
10
11
null
null
derekelkins/tangohs
TangoFP.hs
bsd-3-clause
showStep :: (Show a) => TraceOp a -> String showStep (TraceRead {..}) = maybe ('*':) shows traceRuntimeId $ ": read r" ++ show traceOID
135
showStep :: (Show a) => TraceOp a -> String showStep (TraceRead {..}) = maybe ('*':) shows traceRuntimeId $ ": read r" ++ show traceOID
135
showStep (TraceRead {..}) = maybe ('*':) shows traceRuntimeId $ ": read r" ++ show traceOID
91
false
true
0
8
23
61
31
30
null
null
brendanhay/gogol
gogol-accessapproval/gen/Network/Google/Resource/AccessApproval/Projects/GetAccessApprovalSettings.hs
mpl-2.0
-- | Creates a value of 'ProjectsGetAccessApprovalSettings' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'pgaasXgafv' -- -- * 'pgaasUploadProtocol' -- -- * 'pgaasAccessToken' -- -- * 'pgaasUploadType' -- -- * 'pgaasName' -- -- * 'pgaasCallback' projectsGetAccessApprovalSettings :: Text -- ^ 'pgaasName' -> ProjectsGetAccessApprovalSettings projectsGetAccessApprovalSettings pPgaasName_ = ProjectsGetAccessApprovalSettings' { _pgaasXgafv = Nothing , _pgaasUploadProtocol = Nothing , _pgaasAccessToken = Nothing , _pgaasUploadType = Nothing , _pgaasName = pPgaasName_ , _pgaasCallback = Nothing }
721
projectsGetAccessApprovalSettings :: Text -- ^ 'pgaasName' -> ProjectsGetAccessApprovalSettings projectsGetAccessApprovalSettings pPgaasName_ = ProjectsGetAccessApprovalSettings' { _pgaasXgafv = Nothing , _pgaasUploadProtocol = Nothing , _pgaasAccessToken = Nothing , _pgaasUploadType = Nothing , _pgaasName = pPgaasName_ , _pgaasCallback = Nothing }
388
projectsGetAccessApprovalSettings pPgaasName_ = ProjectsGetAccessApprovalSettings' { _pgaasXgafv = Nothing , _pgaasUploadProtocol = Nothing , _pgaasAccessToken = Nothing , _pgaasUploadType = Nothing , _pgaasName = pPgaasName_ , _pgaasCallback = Nothing }
284
true
true
0
6
128
72
50
22
null
null
happlebao/Core-Haskell
SyntaxChecker.hs
bsd-3-clause
isCoreExportSpec (Just [EVar (UnQual (Ident n))]) | n == "main" = Right True
76
isCoreExportSpec (Just [EVar (UnQual (Ident n))]) | n == "main" = Right True
76
isCoreExportSpec (Just [EVar (UnQual (Ident n))]) | n == "main" = Right True
76
false
false
0
12
12
47
21
26
null
null
kejace/ethereum-data-sql
src/Blockchain/Data/AddressStateDB.hs
bsd-3-clause
addressAsNibbleString::Address->N.NibbleString addressAsNibbleString (Address s) = N.EvenNibbleString $ BL.toStrict $ encode s
126
addressAsNibbleString::Address->N.NibbleString addressAsNibbleString (Address s) = N.EvenNibbleString $ BL.toStrict $ encode s
126
addressAsNibbleString (Address s) = N.EvenNibbleString $ BL.toStrict $ encode s
79
false
true
0
9
10
47
21
26
null
null
Elvecent/HInt
src/Main.hs
bsd-3-clause
getEffects :: VarTable -> Input -> [String] -> LineEffects getEffects vars input (cmd:a:[]) | cmd == "PRINT" = (putStrLn $ ">> " ++ show (extractVar a vars),(+1),id,id) | cmd == "GET" = (return (),(+1),M.adjust (const $ head input) a,tail) | cmd == "VAR" = (return (),(+1),M.insert a 0,id) | cmd == "JMP" = (return (),const $ fromIntegral $ extractVar a vars,id,id) | cmd == "LABEL" = (return (),(+1),id,id) | otherwise = uknownCommandError cmd
457
getEffects :: VarTable -> Input -> [String] -> LineEffects getEffects vars input (cmd:a:[]) | cmd == "PRINT" = (putStrLn $ ">> " ++ show (extractVar a vars),(+1),id,id) | cmd == "GET" = (return (),(+1),M.adjust (const $ head input) a,tail) | cmd == "VAR" = (return (),(+1),M.insert a 0,id) | cmd == "JMP" = (return (),const $ fromIntegral $ extractVar a vars,id,id) | cmd == "LABEL" = (return (),(+1),id,id) | otherwise = uknownCommandError cmd
457
getEffects vars input (cmd:a:[]) | cmd == "PRINT" = (putStrLn $ ">> " ++ show (extractVar a vars),(+1),id,id) | cmd == "GET" = (return (),(+1),M.adjust (const $ head input) a,tail) | cmd == "VAR" = (return (),(+1),M.insert a 0,id) | cmd == "JMP" = (return (),const $ fromIntegral $ extractVar a vars,id,id) | cmd == "LABEL" = (return (),(+1),id,id) | otherwise = uknownCommandError cmd
398
false
true
5
10
85
270
143
127
null
null
ysukhoverkhov/velociraptor
src/GitHub/Api.hs
mit
githubRequest :: HTTP.Request githubRequest = HTTP.setRequestHost "api.github.com" . HTTP.setRequestMethod "GET" . HTTP.setRequestHeaders [("User-Agent", "Velociraptor")] . HTTP.setRequestSecure True . HTTP.setRequestPort 443 $ HTTP.defaultRequest
267
githubRequest :: HTTP.Request githubRequest = HTTP.setRequestHost "api.github.com" . HTTP.setRequestMethod "GET" . HTTP.setRequestHeaders [("User-Agent", "Velociraptor")] . HTTP.setRequestSecure True . HTTP.setRequestPort 443 $ HTTP.defaultRequest
267
githubRequest = HTTP.setRequestHost "api.github.com" . HTTP.setRequestMethod "GET" . HTTP.setRequestHeaders [("User-Agent", "Velociraptor")] . HTTP.setRequestSecure True . HTTP.setRequestPort 443 $ HTTP.defaultRequest
237
false
true
0
11
41
76
35
41
null
null
odr/xml-params
Text/ParamsL/ParseList.hs
mit
fstParam :: (Eq t, ApplyParam t, Monad m, Functor m) => (t -> m Bool) -> ParamsL' -> t -> m (Maybe ParamsL') fstParam f (ParamsL ns vss) t = fmap listToMaybe $ fmap (map snd) $ filterM (f . fst) $ zipWith fapp [1..] vss where cnt = length vss fapp k vs = ( appP t ExprParam {epRownum = k, epCount = cnt} (defBound, (ns,vs)) , ParamsL ns [vs] )
377
fstParam :: (Eq t, ApplyParam t, Monad m, Functor m) => (t -> m Bool) -> ParamsL' -> t -> m (Maybe ParamsL') fstParam f (ParamsL ns vss) t = fmap listToMaybe $ fmap (map snd) $ filterM (f . fst) $ zipWith fapp [1..] vss where cnt = length vss fapp k vs = ( appP t ExprParam {epRownum = k, epCount = cnt} (defBound, (ns,vs)) , ParamsL ns [vs] )
377
fstParam f (ParamsL ns vss) t = fmap listToMaybe $ fmap (map snd) $ filterM (f . fst) $ zipWith fapp [1..] vss where cnt = length vss fapp k vs = ( appP t ExprParam {epRownum = k, epCount = cnt} (defBound, (ns,vs)) , ParamsL ns [vs] )
264
false
true
7
11
105
202
102
100
null
null
rueshyna/gogol
gogol-analytics/gen/Network/Google/Resource/Analytics/Management/WebProperties/Patch.hs
mpl-2.0
-- | Creates a value of 'ManagementWebPropertiesPatch' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mwppWebPropertyId' -- -- * 'mwppPayload' -- -- * 'mwppAccountId' managementWebPropertiesPatch :: Text -- ^ 'mwppWebPropertyId' -> WebProperty -- ^ 'mwppPayload' -> Text -- ^ 'mwppAccountId' -> ManagementWebPropertiesPatch managementWebPropertiesPatch pMwppWebPropertyId_ pMwppPayload_ pMwppAccountId_ = ManagementWebPropertiesPatch' { _mwppWebPropertyId = pMwppWebPropertyId_ , _mwppPayload = pMwppPayload_ , _mwppAccountId = pMwppAccountId_ }
668
managementWebPropertiesPatch :: Text -- ^ 'mwppWebPropertyId' -> WebProperty -- ^ 'mwppPayload' -> Text -- ^ 'mwppAccountId' -> ManagementWebPropertiesPatch managementWebPropertiesPatch pMwppWebPropertyId_ pMwppPayload_ pMwppAccountId_ = ManagementWebPropertiesPatch' { _mwppWebPropertyId = pMwppWebPropertyId_ , _mwppPayload = pMwppPayload_ , _mwppAccountId = pMwppAccountId_ }
414
managementWebPropertiesPatch pMwppWebPropertyId_ pMwppPayload_ pMwppAccountId_ = ManagementWebPropertiesPatch' { _mwppWebPropertyId = pMwppWebPropertyId_ , _mwppPayload = pMwppPayload_ , _mwppAccountId = pMwppAccountId_ }
241
true
true
0
9
114
71
42
29
null
null
haraldsteinlechner/lambdaWolf
src/RenderTest.hs
gpl-3.0
sampleSg :: Sg sampleSg = Trafo left (shift $ V.Vec3F 1 0 0) where left = Trafo geometry (shift $ V.Vec3F 0 0 1) geometry = Leaf $ renderObj (renderObject Solid (Cube 1.0)) --lodSg :: Int -> Float -> Sg
212
sampleSg :: Sg sampleSg = Trafo left (shift $ V.Vec3F 1 0 0) where left = Trafo geometry (shift $ V.Vec3F 0 0 1) geometry = Leaf $ renderObj (renderObject Solid (Cube 1.0)) --lodSg :: Int -> Float -> Sg
212
sampleSg = Trafo left (shift $ V.Vec3F 1 0 0) where left = Trafo geometry (shift $ V.Vec3F 0 0 1) geometry = Leaf $ renderObj (renderObject Solid (Cube 1.0)) --lodSg :: Int -> Float -> Sg
197
false
true
1
10
49
89
44
45
null
null
sopvop/cabal
Cabal/Distribution/Simple/Command.hs
bsd-3-clause
liftOption :: (b -> a) -> (a -> (b -> b)) -> OptionField a -> OptionField b liftOption get' set' opt = opt { optionDescr = liftOptDescr get' set' `map` optionDescr opt}
170
liftOption :: (b -> a) -> (a -> (b -> b)) -> OptionField a -> OptionField b liftOption get' set' opt = opt { optionDescr = liftOptDescr get' set' `map` optionDescr opt}
170
liftOption get' set' opt = opt { optionDescr = liftOptDescr get' set' `map` optionDescr opt}
94
false
true
0
10
33
79
41
38
null
null
emptylambda/BLT
src/Boogie/AST.hs
gpl-3.0
valueType (BoolValue _) = BoolType
34
valueType (BoolValue _) = BoolType
34
valueType (BoolValue _) = BoolType
34
false
false
0
7
4
15
7
8
null
null
afwlehmann/rhm-io-iter
src/Main.hs
bsd-3-clause
-- | A tuple consisting of the first and second elements of the input stream. tuple :: Iteratee e (e,e) tuple = liftA2 (,) head head
132
tuple :: Iteratee e (e,e) tuple = liftA2 (,) head head
54
tuple = liftA2 (,) head head
28
true
true
0
6
25
33
18
15
null
null
rueshyna/gogol
gogol-doubleclick-search/gen/Network/Google/DoubleClickSearch/Types/Product.hs
mpl-2.0
-- | The type of device on which the conversion occurred. cDeviceType :: Lens' Conversion (Maybe Text) cDeviceType = lens _cDeviceType (\ s a -> s{_cDeviceType = a})
167
cDeviceType :: Lens' Conversion (Maybe Text) cDeviceType = lens _cDeviceType (\ s a -> s{_cDeviceType = a})
109
cDeviceType = lens _cDeviceType (\ s a -> s{_cDeviceType = a})
64
true
true
1
9
29
52
25
27
null
null
tlaitinen/sms
backend/Handler/DB/Esqueleto.hs
gpl-3.0
uncommas' :: Monoid a => [(TLB.Builder, a)] -> (TLB.Builder, a) uncommas' = (uncommas *** mconcat) . unzip
106
uncommas' :: Monoid a => [(TLB.Builder, a)] -> (TLB.Builder, a) uncommas' = (uncommas *** mconcat) . unzip
106
uncommas' = (uncommas *** mconcat) . unzip
42
false
true
0
9
16
52
29
23
null
null
schell/varying
src/Control/Varying/Spline.hs
mit
untilEvent_ :: Monad m => VarT m a b -> VarT m a (Event c) -> SplineT a b m b untilEvent_ v ve = fst <$> untilEvent v ve
132
untilEvent_ :: Monad m => VarT m a b -> VarT m a (Event c) -> SplineT a b m b untilEvent_ v ve = fst <$> untilEvent v ve
132
untilEvent_ v ve = fst <$> untilEvent v ve
42
false
true
0
10
41
69
32
37
null
null
pgavin/secdh
lib/SECDH/Eval.hs
bsd-3-clause
applyPrim EqPP [ConstA UnitC, ConstA UnitC] = trueA
79
applyPrim EqPP [ConstA UnitC, ConstA UnitC] = trueA
79
applyPrim EqPP [ConstA UnitC, ConstA UnitC] = trueA
79
false
false
0
6
35
25
11
14
null
null
bmuk/PipeDBHs
Main.hs
mit
maybeGetColumn headerName headers = fmap (flip (!!)) $ elemIndex headerName headers
83
maybeGetColumn headerName headers = fmap (flip (!!)) $ elemIndex headerName headers
83
maybeGetColumn headerName headers = fmap (flip (!!)) $ elemIndex headerName headers
83
false
false
0
8
10
31
15
16
null
null
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Haskell/basic_haskell/scanl1_1.hs
mit
scanl0 f q Nil = Nil
20
scanl0 f q Nil = Nil
20
scanl0 f q Nil = Nil
20
false
false
0
5
5
13
6
7
null
null
OliverFlecke/Funci
src/Main.hs
bsd-3-clause
main :: IO () main = do args <- getArgs case args of [] -> interactive E.empty file:rest -> do putStrLn $ file program <- readFile file case evaluateString program of Left s -> errorHandling s Right v -> printValue v
274
main :: IO () main = do args <- getArgs case args of [] -> interactive E.empty file:rest -> do putStrLn $ file program <- readFile file case evaluateString program of Left s -> errorHandling s Right v -> printValue v
274
main = do args <- getArgs case args of [] -> interactive E.empty file:rest -> do putStrLn $ file program <- readFile file case evaluateString program of Left s -> errorHandling s Right v -> printValue v
260
false
true
0
15
98
104
46
58
null
null
bombpersons/HaskellAsteroids
src/Main.hs
bsd-3-clause
makeWorld :: RenderWindow -> IO World makeWorld wnd = return $ window .~ Just wnd $ defWorld
92
makeWorld :: RenderWindow -> IO World makeWorld wnd = return $ window .~ Just wnd $ defWorld
92
makeWorld wnd = return $ window .~ Just wnd $ defWorld
54
false
true
0
7
16
41
18
23
null
null
mfpi/OpenGLRaw
src/Graphics/Rendering/OpenGL/Raw/EXT/VertexShader.hs
bsd-3-clause
gl_OP_MUL :: GLenum gl_OP_MUL = 0x8786
38
gl_OP_MUL :: GLenum gl_OP_MUL = 0x8786
38
gl_OP_MUL = 0x8786
18
false
true
0
6
5
18
7
11
null
null
kmate/HaRe
old/tools/hs2html/ParseMyDoc.hs
bsd-3-clause
chgTo s = do (ws,a,t) <- getSt setSt_ ((t,reverse a):ws,"",s)
69
chgTo s = do (ws,a,t) <- getSt setSt_ ((t,reverse a):ws,"",s)
69
chgTo s = do (ws,a,t) <- getSt setSt_ ((t,reverse a):ws,"",s)
69
false
false
1
12
17
57
28
29
null
null
brendanhay/gogol
gogol-slides/gen/Network/Google/Slides/Types/Product.hs
mpl-2.0
-- | Properties of the row. trTableRowProperties :: Lens' TableRow (Maybe TableRowProperties) trTableRowProperties = lens _trTableRowProperties (\ s a -> s{_trTableRowProperties = a})
191
trTableRowProperties :: Lens' TableRow (Maybe TableRowProperties) trTableRowProperties = lens _trTableRowProperties (\ s a -> s{_trTableRowProperties = a})
163
trTableRowProperties = lens _trTableRowProperties (\ s a -> s{_trTableRowProperties = a})
97
true
true
0
9
30
48
25
23
null
null
keera-studios/hsQt
Qtc/Gui/QWidget.hs
bsd-2-clause
isWindow :: QWidget a -> (()) -> IO (Bool) isWindow x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QWidget_isWindow cobj_x0
146
isWindow :: QWidget a -> (()) -> IO (Bool) isWindow x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QWidget_isWindow cobj_x0
146
isWindow x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QWidget_isWindow cobj_x0
103
false
true
0
9
31
63
30
33
null
null
petester42/haskell-hockey
src/Hockey/Database/Internal.hs
mit
process :: (MonadBaseControl IO m, MonadIO m) => Database -> Result a (m a) process database queries = case (logging database) of Debug -> db runStderrLoggingT (connection database) queries otherwise -> db runNoLoggingT (connection database) queries
257
process :: (MonadBaseControl IO m, MonadIO m) => Database -> Result a (m a) process database queries = case (logging database) of Debug -> db runStderrLoggingT (connection database) queries otherwise -> db runNoLoggingT (connection database) queries
257
process database queries = case (logging database) of Debug -> db runStderrLoggingT (connection database) queries otherwise -> db runNoLoggingT (connection database) queries
181
false
true
0
10
43
96
47
49
null
null
wereHamster/nauva
pkg/hs/nauva-catalog/src/Nauva/Catalog/Elements.hs
mit
pageElementContainer :: [Element] -> Element pageElementContainer = div_ [style_ style] where style = mkStyle $ do background "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAAAAACoWZBhAAAAF0lEQVQI12P4BAI/QICBFCaYBPNJYQIAkUZftTbC4sIAAAAASUVORK5CYII=)" borderRadius "2px" border none display block padding "20px" position relative width "100%"
416
pageElementContainer :: [Element] -> Element pageElementContainer = div_ [style_ style] where style = mkStyle $ do background "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAAAAACoWZBhAAAAF0lEQVQI12P4BAI/QICBFCaYBPNJYQIAkUZftTbC4sIAAAAASUVORK5CYII=)" borderRadius "2px" border none display block padding "20px" position relative width "100%"
416
pageElementContainer = div_ [style_ style] where style = mkStyle $ do background "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAAAAACoWZBhAAAAF0lEQVQI12P4BAI/QICBFCaYBPNJYQIAkUZftTbC4sIAAAAASUVORK5CYII=)" borderRadius "2px" border none display block padding "20px" position relative width "100%"
371
false
true
3
8
91
92
35
57
null
null
fmthoma/ghc
compiler/types/Type.hs
bsd-3-clause
applyTy (ForAllTy tv ty) arg = substTyWith [tv] [arg] ty
56
applyTy (ForAllTy tv ty) arg = substTyWith [tv] [arg] ty
56
applyTy (ForAllTy tv ty) arg = substTyWith [tv] [arg] ty
56
false
false
1
7
9
34
16
18
null
null
vikraman/ghc
compiler/simplCore/CoreMonad.hs
bsd-3-clause
pprTickCts (CaseElim v) = ppr v
47
pprTickCts (CaseElim v) = ppr v
47
pprTickCts (CaseElim v) = ppr v
47
false
false
0
7
21
18
8
10
null
null
ambiata/highlighting-kate
Text/Highlighting/Kate/Syntax/Latex.hs
gpl-2.0
pEndLine = do updateState $ \st -> st{ synStPrevNonspace = False } context <- currentContext contexts <- synStContexts `fmap` getState st <- getState if length contexts >= 2 then case context of _ | synStContinuation st -> updateState $ \st -> st{ synStContinuation = False } ("LaTeX","Normal Text") -> return () ("LaTeX","NoWeb") -> return () ("LaTeX","Sectioning") -> return () ("LaTeX","SectioningInside") -> return () ("LaTeX","SectioningContrSeq") -> (popContext) >> pEndLine ("LaTeX","SectioningMathMode") -> return () ("LaTeX","SectioningMathContrSeq") -> (popContext) >> pEndLine ("LaTeX","Footnoting") -> return () ("LaTeX","FootnotingInside") -> return () ("LaTeX","FootnotingMathMode") -> return () ("LaTeX","NewCommand") -> return () ("LaTeX","DefCommand") -> return () ("LaTeX","CommandParameterStart") -> return () ("LaTeX","CommandParameter") -> return () ("LaTeX","ContrSeq") -> (popContext) >> pEndLine ("LaTeX","ToEndOfLine") -> (popContext) >> pEndLine ("LaTeX","MintParam") -> return () ("LaTeX","Verb") -> (popContext >> popContext) >> pEndLine ("LaTeX","VerbEnd") -> (popContext >> popContext >> popContext) >> pEndLine ("LaTeX","Lstinline") -> (popContext >> popContext) >> pEndLine ("LaTeX","LstinlineEnd") -> (popContext >> popContext >> popContext) >> pEndLine ("LaTeX","LstinlineParameter") -> return () ("LaTeX","Label") -> return () ("LaTeX","LabelOption") -> return () ("LaTeX","LabelParameter") -> return () ("LaTeX","FancyLabel") -> return () ("LaTeX","FancyLabelParameter") -> return () ("LaTeX","FancyLabelOption") -> return () ("LaTeX","FancyLabelRoundBrackets") -> return () ("LaTeX","SpecialCommand") -> return () ("LaTeX","SpecialCommandParameterOption") -> return () ("LaTeX","FindEndEnvironment") -> return () ("LaTeX","EndEnvironment") -> return () ("LaTeX","EndLatexEnv") -> return () ("LaTeX","FindBeginEnvironment") -> return () ("LaTeX","BeginEnvironment") -> return () ("LaTeX","LatexEnv") -> return () ("LaTeX","VerbatimEnv") -> return () ("LaTeX","VerbatimEnvParam") -> return () ("LaTeX","ListingsEnvParam") -> return () ("LaTeX","MintedEnvParam") -> return () ("LaTeX","HighlightningSelector") -> return () ("LaTeX","HighlightningCommon") -> return () ("LaTeX","HighlightningBeginC++") -> return () ("LaTeX","HighlightningC++") -> return () ("LaTeX","HighlightningBeginPython") -> return () ("LaTeX","HighlightningPython") -> return () ("LaTeX","Verbatim") -> return () ("LaTeX","VerbFindEnd") -> (popContext) >> pEndLine ("LaTeX","CommentEnv") -> return () ("LaTeX","BlockComment") -> return () ("LaTeX","CommFindEnd") -> (popContext) >> pEndLine ("LaTeX","MathEnv") -> return () ("LaTeX","MathEnvParam") -> return () ("LaTeX","EnvCommon") -> return () ("LaTeX","MathModeEnv") -> return () ("LaTeX","MathFindEnd") -> (popContext) >> pEndLine ("LaTeX","TabEnv") -> return () ("LaTeX","Tab") -> return () ("LaTeX","Column Separator") -> return () ("LaTeX","TabFindEnd") -> (popContext) >> pEndLine ("LaTeX","MathMode") -> return () ("LaTeX","MathModeDisplay") -> return () ("LaTeX","MathModeEquation") -> return () ("LaTeX","MathModeEnsure") -> return () ("LaTeX","MathModeCommon") -> return () ("LaTeX","MathContrSeq") -> (popContext) >> pEndLine ("LaTeX","MathModeText") -> return () ("LaTeX","MathModeTextParameterStart") -> return () ("LaTeX","MathModeTextParameter") -> return () ("LaTeX","Multiline Comment") -> return () ("LaTeX","Comment") -> (popContext) >> pEndLine _ -> return () else return ()
3,916
pEndLine = do updateState $ \st -> st{ synStPrevNonspace = False } context <- currentContext contexts <- synStContexts `fmap` getState st <- getState if length contexts >= 2 then case context of _ | synStContinuation st -> updateState $ \st -> st{ synStContinuation = False } ("LaTeX","Normal Text") -> return () ("LaTeX","NoWeb") -> return () ("LaTeX","Sectioning") -> return () ("LaTeX","SectioningInside") -> return () ("LaTeX","SectioningContrSeq") -> (popContext) >> pEndLine ("LaTeX","SectioningMathMode") -> return () ("LaTeX","SectioningMathContrSeq") -> (popContext) >> pEndLine ("LaTeX","Footnoting") -> return () ("LaTeX","FootnotingInside") -> return () ("LaTeX","FootnotingMathMode") -> return () ("LaTeX","NewCommand") -> return () ("LaTeX","DefCommand") -> return () ("LaTeX","CommandParameterStart") -> return () ("LaTeX","CommandParameter") -> return () ("LaTeX","ContrSeq") -> (popContext) >> pEndLine ("LaTeX","ToEndOfLine") -> (popContext) >> pEndLine ("LaTeX","MintParam") -> return () ("LaTeX","Verb") -> (popContext >> popContext) >> pEndLine ("LaTeX","VerbEnd") -> (popContext >> popContext >> popContext) >> pEndLine ("LaTeX","Lstinline") -> (popContext >> popContext) >> pEndLine ("LaTeX","LstinlineEnd") -> (popContext >> popContext >> popContext) >> pEndLine ("LaTeX","LstinlineParameter") -> return () ("LaTeX","Label") -> return () ("LaTeX","LabelOption") -> return () ("LaTeX","LabelParameter") -> return () ("LaTeX","FancyLabel") -> return () ("LaTeX","FancyLabelParameter") -> return () ("LaTeX","FancyLabelOption") -> return () ("LaTeX","FancyLabelRoundBrackets") -> return () ("LaTeX","SpecialCommand") -> return () ("LaTeX","SpecialCommandParameterOption") -> return () ("LaTeX","FindEndEnvironment") -> return () ("LaTeX","EndEnvironment") -> return () ("LaTeX","EndLatexEnv") -> return () ("LaTeX","FindBeginEnvironment") -> return () ("LaTeX","BeginEnvironment") -> return () ("LaTeX","LatexEnv") -> return () ("LaTeX","VerbatimEnv") -> return () ("LaTeX","VerbatimEnvParam") -> return () ("LaTeX","ListingsEnvParam") -> return () ("LaTeX","MintedEnvParam") -> return () ("LaTeX","HighlightningSelector") -> return () ("LaTeX","HighlightningCommon") -> return () ("LaTeX","HighlightningBeginC++") -> return () ("LaTeX","HighlightningC++") -> return () ("LaTeX","HighlightningBeginPython") -> return () ("LaTeX","HighlightningPython") -> return () ("LaTeX","Verbatim") -> return () ("LaTeX","VerbFindEnd") -> (popContext) >> pEndLine ("LaTeX","CommentEnv") -> return () ("LaTeX","BlockComment") -> return () ("LaTeX","CommFindEnd") -> (popContext) >> pEndLine ("LaTeX","MathEnv") -> return () ("LaTeX","MathEnvParam") -> return () ("LaTeX","EnvCommon") -> return () ("LaTeX","MathModeEnv") -> return () ("LaTeX","MathFindEnd") -> (popContext) >> pEndLine ("LaTeX","TabEnv") -> return () ("LaTeX","Tab") -> return () ("LaTeX","Column Separator") -> return () ("LaTeX","TabFindEnd") -> (popContext) >> pEndLine ("LaTeX","MathMode") -> return () ("LaTeX","MathModeDisplay") -> return () ("LaTeX","MathModeEquation") -> return () ("LaTeX","MathModeEnsure") -> return () ("LaTeX","MathModeCommon") -> return () ("LaTeX","MathContrSeq") -> (popContext) >> pEndLine ("LaTeX","MathModeText") -> return () ("LaTeX","MathModeTextParameterStart") -> return () ("LaTeX","MathModeTextParameter") -> return () ("LaTeX","Multiline Comment") -> return () ("LaTeX","Comment") -> (popContext) >> pEndLine _ -> return () else return ()
3,916
pEndLine = do updateState $ \st -> st{ synStPrevNonspace = False } context <- currentContext contexts <- synStContexts `fmap` getState st <- getState if length contexts >= 2 then case context of _ | synStContinuation st -> updateState $ \st -> st{ synStContinuation = False } ("LaTeX","Normal Text") -> return () ("LaTeX","NoWeb") -> return () ("LaTeX","Sectioning") -> return () ("LaTeX","SectioningInside") -> return () ("LaTeX","SectioningContrSeq") -> (popContext) >> pEndLine ("LaTeX","SectioningMathMode") -> return () ("LaTeX","SectioningMathContrSeq") -> (popContext) >> pEndLine ("LaTeX","Footnoting") -> return () ("LaTeX","FootnotingInside") -> return () ("LaTeX","FootnotingMathMode") -> return () ("LaTeX","NewCommand") -> return () ("LaTeX","DefCommand") -> return () ("LaTeX","CommandParameterStart") -> return () ("LaTeX","CommandParameter") -> return () ("LaTeX","ContrSeq") -> (popContext) >> pEndLine ("LaTeX","ToEndOfLine") -> (popContext) >> pEndLine ("LaTeX","MintParam") -> return () ("LaTeX","Verb") -> (popContext >> popContext) >> pEndLine ("LaTeX","VerbEnd") -> (popContext >> popContext >> popContext) >> pEndLine ("LaTeX","Lstinline") -> (popContext >> popContext) >> pEndLine ("LaTeX","LstinlineEnd") -> (popContext >> popContext >> popContext) >> pEndLine ("LaTeX","LstinlineParameter") -> return () ("LaTeX","Label") -> return () ("LaTeX","LabelOption") -> return () ("LaTeX","LabelParameter") -> return () ("LaTeX","FancyLabel") -> return () ("LaTeX","FancyLabelParameter") -> return () ("LaTeX","FancyLabelOption") -> return () ("LaTeX","FancyLabelRoundBrackets") -> return () ("LaTeX","SpecialCommand") -> return () ("LaTeX","SpecialCommandParameterOption") -> return () ("LaTeX","FindEndEnvironment") -> return () ("LaTeX","EndEnvironment") -> return () ("LaTeX","EndLatexEnv") -> return () ("LaTeX","FindBeginEnvironment") -> return () ("LaTeX","BeginEnvironment") -> return () ("LaTeX","LatexEnv") -> return () ("LaTeX","VerbatimEnv") -> return () ("LaTeX","VerbatimEnvParam") -> return () ("LaTeX","ListingsEnvParam") -> return () ("LaTeX","MintedEnvParam") -> return () ("LaTeX","HighlightningSelector") -> return () ("LaTeX","HighlightningCommon") -> return () ("LaTeX","HighlightningBeginC++") -> return () ("LaTeX","HighlightningC++") -> return () ("LaTeX","HighlightningBeginPython") -> return () ("LaTeX","HighlightningPython") -> return () ("LaTeX","Verbatim") -> return () ("LaTeX","VerbFindEnd") -> (popContext) >> pEndLine ("LaTeX","CommentEnv") -> return () ("LaTeX","BlockComment") -> return () ("LaTeX","CommFindEnd") -> (popContext) >> pEndLine ("LaTeX","MathEnv") -> return () ("LaTeX","MathEnvParam") -> return () ("LaTeX","EnvCommon") -> return () ("LaTeX","MathModeEnv") -> return () ("LaTeX","MathFindEnd") -> (popContext) >> pEndLine ("LaTeX","TabEnv") -> return () ("LaTeX","Tab") -> return () ("LaTeX","Column Separator") -> return () ("LaTeX","TabFindEnd") -> (popContext) >> pEndLine ("LaTeX","MathMode") -> return () ("LaTeX","MathModeDisplay") -> return () ("LaTeX","MathModeEquation") -> return () ("LaTeX","MathModeEnsure") -> return () ("LaTeX","MathModeCommon") -> return () ("LaTeX","MathContrSeq") -> (popContext) >> pEndLine ("LaTeX","MathModeText") -> return () ("LaTeX","MathModeTextParameterStart") -> return () ("LaTeX","MathModeTextParameter") -> return () ("LaTeX","Multiline Comment") -> return () ("LaTeX","Comment") -> (popContext) >> pEndLine _ -> return () else return ()
3,916
false
false
0
15
831
1,399
749
650
null
null
Paow/encore
src/back/CodeGen/Function.hs
bsd-3-clause
-- TODO: different header from shared! functionWrapper :: (A.Function -> CCode Name) -> (A.Function -> CCode Name) -> A.Function -> CCode Toplevel functionWrapper nameOf wrapperNameOf f = let argList = encoreCtxVar : encoreRuntimeType : extractArgs in Function (Typ "value_t") name [(Ptr (Ptr encoreCtxT), encoreCtxVar), (Ptr (Ptr ponyTypeT), encoreRuntimeType), (Typ "value_t", Var "_args[]"), (Ptr void, Var "_env_not_used")] $ returnStmnt (Call (nameOf f) argList) typ where typ = A.functionType f name = wrapperNameOf f extractArgs :: [CCode Lval] extractArgs = let typeArgs = map A.ptype (A.functionParams f) in [getArg arg i | (arg, i) <- zip typeArgs [0..]] getArg :: Type -> Int -> CCode Lval getArg ty i = fromEncoreArgT (translate ty) $ AsExpr $ ArrAcc i $ Var "_args" returnStmnt :: UsableAs e Expr => CCode e -> Type -> CCode Stat returnStmnt var ty = Return $ asEncoreArgT (translate ty) var
1,010
functionWrapper :: (A.Function -> CCode Name) -> (A.Function -> CCode Name) -> A.Function -> CCode Toplevel functionWrapper nameOf wrapperNameOf f = let argList = encoreCtxVar : encoreRuntimeType : extractArgs in Function (Typ "value_t") name [(Ptr (Ptr encoreCtxT), encoreCtxVar), (Ptr (Ptr ponyTypeT), encoreRuntimeType), (Typ "value_t", Var "_args[]"), (Ptr void, Var "_env_not_used")] $ returnStmnt (Call (nameOf f) argList) typ where typ = A.functionType f name = wrapperNameOf f extractArgs :: [CCode Lval] extractArgs = let typeArgs = map A.ptype (A.functionParams f) in [getArg arg i | (arg, i) <- zip typeArgs [0..]] getArg :: Type -> Int -> CCode Lval getArg ty i = fromEncoreArgT (translate ty) $ AsExpr $ ArrAcc i $ Var "_args" returnStmnt :: UsableAs e Expr => CCode e -> Type -> CCode Stat returnStmnt var ty = Return $ asEncoreArgT (translate ty) var
971
functionWrapper nameOf wrapperNameOf f = let argList = encoreCtxVar : encoreRuntimeType : extractArgs in Function (Typ "value_t") name [(Ptr (Ptr encoreCtxT), encoreCtxVar), (Ptr (Ptr ponyTypeT), encoreRuntimeType), (Typ "value_t", Var "_args[]"), (Ptr void, Var "_env_not_used")] $ returnStmnt (Call (nameOf f) argList) typ where typ = A.functionType f name = wrapperNameOf f extractArgs :: [CCode Lval] extractArgs = let typeArgs = map A.ptype (A.functionParams f) in [getArg arg i | (arg, i) <- zip typeArgs [0..]] getArg :: Type -> Int -> CCode Lval getArg ty i = fromEncoreArgT (translate ty) $ AsExpr $ ArrAcc i $ Var "_args" returnStmnt :: UsableAs e Expr => CCode e -> Type -> CCode Stat returnStmnt var ty = Return $ asEncoreArgT (translate ty) var
859
true
true
13
10
247
357
183
174
null
null
hguenther/smtlib2
Language/SMTLib2/Internals/Expression.hs
gpl-3.0
renderFunction SMTRendering _ (Logic (AtLeast n) _) = showString "(_ at-least " . showsPrec 11 n . showChar ')'
121
renderFunction SMTRendering _ (Logic (AtLeast n) _) = showString "(_ at-least " . showsPrec 11 n . showChar ')'
121
renderFunction SMTRendering _ (Logic (AtLeast n) _) = showString "(_ at-least " . showsPrec 11 n . showChar ')'
121
false
false
1
9
28
51
21
30
null
null
brendanhay/gogol
gogol-storage/gen/Network/Google/Resource/Storage/Objects/Copy.hs
mpl-2.0
-- | Creates a value of 'ObjectsCopy' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ocDestinationPredefinedACL' -- -- * 'ocIfSourceGenerationMatch' -- -- * 'ocIfMetagenerationMatch' -- -- * 'ocIfGenerationNotMatch' -- -- * 'ocIfSourceMetagenerationNotMatch' -- -- * 'ocIfSourceMetagenerationMatch' -- -- * 'ocIfGenerationMatch' -- -- * 'ocSourceObject' -- -- * 'ocSourceBucket' -- -- * 'ocPayload' -- -- * 'ocUserProject' -- -- * 'ocDestinationBucket' -- -- * 'ocIfMetagenerationNotMatch' -- -- * 'ocIfSourceGenerationNotMatch' -- -- * 'ocProjection' -- -- * 'ocProvisionalUserProject' -- -- * 'ocSourceGeneration' -- -- * 'ocDestinationKmsKeyName' -- -- * 'ocDestinationObject' objectsCopy :: Text -- ^ 'ocSourceObject' -> Text -- ^ 'ocSourceBucket' -> Object -- ^ 'ocPayload' -> Text -- ^ 'ocDestinationBucket' -> Text -- ^ 'ocDestinationObject' -> ObjectsCopy objectsCopy pOcSourceObject_ pOcSourceBucket_ pOcPayload_ pOcDestinationBucket_ pOcDestinationObject_ = ObjectsCopy' { _ocDestinationPredefinedACL = Nothing , _ocIfSourceGenerationMatch = Nothing , _ocIfMetagenerationMatch = Nothing , _ocIfGenerationNotMatch = Nothing , _ocIfSourceMetagenerationNotMatch = Nothing , _ocIfSourceMetagenerationMatch = Nothing , _ocIfGenerationMatch = Nothing , _ocSourceObject = pOcSourceObject_ , _ocSourceBucket = pOcSourceBucket_ , _ocPayload = pOcPayload_ , _ocUserProject = Nothing , _ocDestinationBucket = pOcDestinationBucket_ , _ocIfMetagenerationNotMatch = Nothing , _ocIfSourceGenerationNotMatch = Nothing , _ocProjection = Nothing , _ocProvisionalUserProject = Nothing , _ocSourceGeneration = Nothing , _ocDestinationKmsKeyName = Nothing , _ocDestinationObject = pOcDestinationObject_ }
1,886
objectsCopy :: Text -- ^ 'ocSourceObject' -> Text -- ^ 'ocSourceBucket' -> Object -- ^ 'ocPayload' -> Text -- ^ 'ocDestinationBucket' -> Text -- ^ 'ocDestinationObject' -> ObjectsCopy objectsCopy pOcSourceObject_ pOcSourceBucket_ pOcPayload_ pOcDestinationBucket_ pOcDestinationObject_ = ObjectsCopy' { _ocDestinationPredefinedACL = Nothing , _ocIfSourceGenerationMatch = Nothing , _ocIfMetagenerationMatch = Nothing , _ocIfGenerationNotMatch = Nothing , _ocIfSourceMetagenerationNotMatch = Nothing , _ocIfSourceMetagenerationMatch = Nothing , _ocIfGenerationMatch = Nothing , _ocSourceObject = pOcSourceObject_ , _ocSourceBucket = pOcSourceBucket_ , _ocPayload = pOcPayload_ , _ocUserProject = Nothing , _ocDestinationBucket = pOcDestinationBucket_ , _ocIfMetagenerationNotMatch = Nothing , _ocIfSourceGenerationNotMatch = Nothing , _ocProjection = Nothing , _ocProvisionalUserProject = Nothing , _ocSourceGeneration = Nothing , _ocDestinationKmsKeyName = Nothing , _ocDestinationObject = pOcDestinationObject_ }
1,119
objectsCopy pOcSourceObject_ pOcSourceBucket_ pOcPayload_ pOcDestinationBucket_ pOcDestinationObject_ = ObjectsCopy' { _ocDestinationPredefinedACL = Nothing , _ocIfSourceGenerationMatch = Nothing , _ocIfMetagenerationMatch = Nothing , _ocIfGenerationNotMatch = Nothing , _ocIfSourceMetagenerationNotMatch = Nothing , _ocIfSourceMetagenerationMatch = Nothing , _ocIfGenerationMatch = Nothing , _ocSourceObject = pOcSourceObject_ , _ocSourceBucket = pOcSourceBucket_ , _ocPayload = pOcPayload_ , _ocUserProject = Nothing , _ocDestinationBucket = pOcDestinationBucket_ , _ocIfMetagenerationNotMatch = Nothing , _ocIfSourceGenerationNotMatch = Nothing , _ocProjection = Nothing , _ocProvisionalUserProject = Nothing , _ocSourceGeneration = Nothing , _ocDestinationKmsKeyName = Nothing , _ocDestinationObject = pOcDestinationObject_ }
911
true
true
0
11
324
213
146
67
null
null
tim6her/halculator
Main.hs
mit
-- | Starts the main recursion with empty stack main = calc []
62
main = calc []
14
main = calc []
14
true
false
1
6
12
16
6
10
null
null
mydaum/lottery
test/Spec.hs
gpl-3.0
lottery :: Spec lottery = describe "lottery" draw
49
lottery :: Spec lottery = describe "lottery" draw
49
lottery = describe "lottery" draw
33
false
true
0
6
7
22
9
13
null
null
maruks/haskell-book
src/Chapter17_applicative.hs
gpl-3.0
-- 2. Composition appComposition :: (Applicative f, Eq (f c)) => f (b->c) -> f (a->b) -> f a -> Bool appComposition u v w = (pure (.) <*> u <*> v <*> w) == (u <*> (v <*> w))
173
appComposition :: (Applicative f, Eq (f c)) => f (b->c) -> f (a->b) -> f a -> Bool appComposition u v w = (pure (.) <*> u <*> v <*> w) == (u <*> (v <*> w))
155
appComposition u v w = (pure (.) <*> u <*> v <*> w) == (u <*> (v <*> w))
72
true
true
0
10
39
113
59
54
null
null
phadej/ghc-select
src/Main.hs
bsd-3-clause
main :: IO () main = do pathEnv <- fromMaybe "" `fmap` lookupEnv "PATH" let paths = parsePath pathEnv knownPrograms <- sort . concat <$> traverse getKnownPrograms [minBound..maxBound] args <- getArgs case args of [] -> hPutStrLn stderr "Usage: ghc-select program [program...]" _ -> do paths' <- foldlM (modifyPath knownPrograms) paths args putStrLn $ "export PATH=" ++ intercalate ":" paths'
452
main :: IO () main = do pathEnv <- fromMaybe "" `fmap` lookupEnv "PATH" let paths = parsePath pathEnv knownPrograms <- sort . concat <$> traverse getKnownPrograms [minBound..maxBound] args <- getArgs case args of [] -> hPutStrLn stderr "Usage: ghc-select program [program...]" _ -> do paths' <- foldlM (modifyPath knownPrograms) paths args putStrLn $ "export PATH=" ++ intercalate ":" paths'
452
main = do pathEnv <- fromMaybe "" `fmap` lookupEnv "PATH" let paths = parsePath pathEnv knownPrograms <- sort . concat <$> traverse getKnownPrograms [minBound..maxBound] args <- getArgs case args of [] -> hPutStrLn stderr "Usage: ghc-select program [program...]" _ -> do paths' <- foldlM (modifyPath knownPrograms) paths args putStrLn $ "export PATH=" ++ intercalate ":" paths'
438
false
true
0
15
120
141
65
76
null
null
YoshikuniJujo/funpaala
samples/17_define_list/atPattern0.hs
bsd-3-clause
dupHead _ = []
14
dupHead _ = []
14
dupHead _ = []
14
false
false
0
5
3
11
5
6
null
null
angerman/HInvoice
Model.hs
bsd-3-clause
takeInt f = returnError ConversionFailed f "need an int"
79
takeInt f = returnError ConversionFailed f "need an int"
79
takeInt f = returnError ConversionFailed f "need an int"
79
false
false
0
5
31
16
7
9
null
null
abuiles/turbinado-blog
tmp/dependencies/haskell-src-exts-0.3.9/Language/Haskell/Exts/Lexer.hs
bsd-3-clause
lexOctal :: Lex a Integer lexOctal = do ds <- lexWhile isOctDigit return (parseInteger 8 ds) -- assumes at least one hexadecimal digit
143
lexOctal :: Lex a Integer lexOctal = do ds <- lexWhile isOctDigit return (parseInteger 8 ds) -- assumes at least one hexadecimal digit
143
lexOctal = do ds <- lexWhile isOctDigit return (parseInteger 8 ds) -- assumes at least one hexadecimal digit
117
false
true
0
9
31
41
19
22
null
null
kojiromike/Idris-dev
src/Idris/Reflection.hs
bsd-3-clause
reflectConstant c@(B16 _) = reflCall "B16" [RConstant c]
56
reflectConstant c@(B16 _) = reflCall "B16" [RConstant c]
56
reflectConstant c@(B16 _) = reflCall "B16" [RConstant c]
56
false
false
0
8
7
29
14
15
null
null
begriffs/postgrest
src/PostgREST/App.hs
mit
app :: DbStructure -> Maybe ProcDescription -> AppConfig -> ApiRequest -> H.Transaction Response app dbStructure proc conf apiRequest = case responseContentTypeOrError (iAccepts apiRequest) (iAction apiRequest) of Left errorResponse -> return errorResponse Right contentType -> case (iAction apiRequest, iTarget apiRequest, iPayload apiRequest) of (ActionRead, TargetIdent qi, Nothing) -> let partsField = (,) <$> readSqlParts <*> (binaryField contentType =<< fldNames) in case partsField of Left errorResponse -> return errorResponse Right ((q, cq), bField) -> do let stm = createReadStatement q cq (contentType == CTSingularJSON) shouldCount (contentType == CTTextCSV) bField row <- H.statement () stm let (tableTotal, queryTotal, _ , body) = row (status, contentRange) = rangeHeader queryTotal tableTotal canonical = iCanonicalQS apiRequest return $ if contentType == CTSingularJSON && queryTotal /= 1 then singularityError (toInteger queryTotal) else responseLBS status [toHeader contentType, contentRange, ("Content-Location", "/" <> toS (qiName qi) <> if BS.null canonical then "" else "?" <> toS canonical ) ] (toS body) (ActionCreate, TargetIdent (QualifiedIdentifier tSchema tName), Just pJson) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let pkCols = tablePKCols dbStructure tSchema tName stm = createWriteStatement sq mq (contentType == CTSingularJSON) True (contentType == CTTextCSV) (iPreferRepresentation apiRequest) pkCols row <- H.statement (toS $ pjRaw pJson) stm let (_, queryTotal, fs, body) = extractQueryResult row headers = catMaybes [ if null fs then Nothing else Just (hLocation, "/" <> toS tName <> renderLocationFields fs) , if iPreferRepresentation apiRequest == Full then Just $ toHeader contentType else Nothing , Just . contentRangeH 1 0 $ toInteger <$> if shouldCount then Just queryTotal else Nothing , if null pkCols then Nothing else (\x -> ("Preference-Applied", show x)) <$> iPreferResolution apiRequest ] if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else return . responseLBS status201 headers $ if iPreferRepresentation apiRequest == Full then toS body else "" (ActionUpdate, TargetIdent (QualifiedIdentifier tSchema tName), Just pJson) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let stm = createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] row <- H.statement (toS $ pjRaw pJson) stm let (_, queryTotal, _, body) = extractQueryResult row if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else do let r = contentRangeH 0 (toInteger $ queryTotal-1) (toInteger <$> if shouldCount then Just queryTotal else Nothing) s = if iPreferRepresentation apiRequest == Full then status200 else status204 return $ if iPreferRepresentation apiRequest == Full then responseLBS s [toHeader contentType, r] (toS body) else responseLBS s [r] "" (ActionSingleUpsert, TargetIdent (QualifiedIdentifier tSchema tName), Just ProcessedJSON{pjRaw, pjType, pjKeys}) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let isSingle = case pjType of PJArray len -> len == 1 PJObject -> True colNames = colName <$> tableCols dbStructure tSchema tName if topLevelRange /= allRange then return $ simpleError status400 [] "Range header and limit/offset querystring parameters are not allowed for PUT" else if not isSingle then return $ simpleError status400 [] "PUT payload must contain a single row" else if S.fromList colNames /= pjKeys then return $ simpleError status400 [] "You must specify all columns in the payload when using PUT" else do row <- H.statement (toS pjRaw) $ createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] let (_, queryTotal, _, body) = extractQueryResult row -- Makes sure the querystring pk matches the payload pk -- e.g. PUT /items?id=eq.1 { "id" : 1, .. } is accepted, PUT /items?id=eq.14 { "id" : 2, .. } is rejected -- If this condition is not satisfied then nothing is inserted, check the WHERE for INSERT in QueryBuilder.hs to see how it's done if queryTotal /= 1 then do HT.condemn return $ simpleError status400 [] "Payload values do not match URL in primary key column(s)" else return $ if iPreferRepresentation apiRequest == Full then responseLBS status200 [toHeader contentType] (toS body) else responseLBS status204 [] "" (ActionDelete, TargetIdent (QualifiedIdentifier tSchema tName), Nothing) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let stm = createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] row <- H.statement mempty stm let (_, queryTotal, _, body) = extractQueryResult row r = contentRangeH 1 0 $ toInteger <$> if shouldCount then Just queryTotal else Nothing if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else return $ if iPreferRepresentation apiRequest == Full then responseLBS status200 [toHeader contentType, r] (toS body) else responseLBS status204 [r] "" (ActionInfo, TargetIdent (QualifiedIdentifier tSchema tTable), Nothing) -> let mTable = find (\t -> tableName t == tTable && tableSchema t == tSchema) (dbTables dbStructure) in case mTable of Nothing -> return notFound Just table -> let acceptH = (hAllow, if tableInsertable table then "GET,POST,PATCH,DELETE" else "GET") in return $ responseLBS status200 [allOrigins, acceptH] "" (ActionInvoke _, TargetProc qi, Just pJson) -> let returnsScalar = case proc of Just ProcDescription{pdReturnType = (Single (Scalar _))} -> True _ -> False rpcBinaryField = if returnsScalar then Right Nothing else binaryField contentType =<< fldNames parts = (,) <$> readSqlParts <*> rpcBinaryField in case parts of Left errorResponse -> return errorResponse Right ((q, cq), bField) -> do let singular = contentType == CTSingularJSON specifiedPgArgs = filter ((`S.member` pjKeys pJson) . pgaName) $ maybe [] pdArgs proc row <- H.statement (toS $ pjRaw pJson) $ callProc qi specifiedPgArgs returnsScalar q cq shouldCount singular (iPreferSingleObjectParameter apiRequest) (contentType == CTTextCSV) (contentType == CTOctetStream) bField (pgVersion dbStructure) let (tableTotal, queryTotal, body, jsonHeaders) = fromMaybe (Just 0, 0, "[]", "[]") row (status, contentRange) = rangeHeader queryTotal tableTotal decodedHeaders = first toS $ JSON.eitherDecode $ toS jsonHeaders :: Either Text [GucHeader] case decodedHeaders of Left _ -> return gucHeadersError Right hs -> if singular && queryTotal /= 1 then do HT.condemn return $ singularityError (toInteger queryTotal) else return $ responseLBS status ([toHeader contentType, contentRange] ++ toHeaders hs) (toS body) (ActionInspect, TargetRoot, Nothing) -> do let host = configHost conf port = toInteger $ configPort conf proxy = pickProxy $ toS <$> configProxyUri conf uri Nothing = ("http", host, port, "/") uri (Just Proxy { proxyScheme = s, proxyHost = h, proxyPort = p, proxyPath = b }) = (s, h, p, b) uri' = uri proxy toTableInfo :: [Table] -> [(Table, [Column], [Text])] toTableInfo = map (\t -> let (s, tn) = (tableSchema t, tableName t) in (t, tableCols dbStructure s tn, tablePKCols dbStructure s tn)) encodeApi ti sd procs = encodeOpenAPI (concat $ M.elems procs) (toTableInfo ti) uri' sd $ dbPrimaryKeys dbStructure body <- encodeApi <$> H.statement schema accessibleTables <*> H.statement schema schemaDescription <*> H.statement schema accessibleProcs return $ responseLBS status200 [toHeader CTOpenAPI] $ toS body _ -> return notFound where notFound = responseLBS status404 [] "" allOrigins = ("Access-Control-Allow-Origin", "*") :: Header shouldCount = iPreferCount apiRequest schema = toS $ configSchema conf topLevelRange = fromMaybe allRange $ M.lookup "limit" $ iRange apiRequest rangeHeader queryTotal tableTotal = let lower = rangeOffset topLevelRange upper = lower + toInteger queryTotal - 1 contentRange = contentRangeH lower upper (toInteger <$> tableTotal) status = rangeStatus lower upper (toInteger <$> tableTotal) in (status, contentRange) readReq = readRequest (configMaxRows conf) (dbRelations dbStructure) proc apiRequest fldNames = fieldNames <$> readReq readDbRequest = DbRead <$> readReq selectQuery = requestToQuery schema False <$> readDbRequest countQuery = requestToCountQuery schema <$> readDbRequest readSqlParts = (,) <$> selectQuery <*> countQuery mutateSqlParts s t = (,) <$> selectQuery <*> (requestToQuery schema False . DbMutate <$> (mutateRequest apiRequest t (tablePKCols dbStructure s t) =<< fldNames))
12,290
app :: DbStructure -> Maybe ProcDescription -> AppConfig -> ApiRequest -> H.Transaction Response app dbStructure proc conf apiRequest = case responseContentTypeOrError (iAccepts apiRequest) (iAction apiRequest) of Left errorResponse -> return errorResponse Right contentType -> case (iAction apiRequest, iTarget apiRequest, iPayload apiRequest) of (ActionRead, TargetIdent qi, Nothing) -> let partsField = (,) <$> readSqlParts <*> (binaryField contentType =<< fldNames) in case partsField of Left errorResponse -> return errorResponse Right ((q, cq), bField) -> do let stm = createReadStatement q cq (contentType == CTSingularJSON) shouldCount (contentType == CTTextCSV) bField row <- H.statement () stm let (tableTotal, queryTotal, _ , body) = row (status, contentRange) = rangeHeader queryTotal tableTotal canonical = iCanonicalQS apiRequest return $ if contentType == CTSingularJSON && queryTotal /= 1 then singularityError (toInteger queryTotal) else responseLBS status [toHeader contentType, contentRange, ("Content-Location", "/" <> toS (qiName qi) <> if BS.null canonical then "" else "?" <> toS canonical ) ] (toS body) (ActionCreate, TargetIdent (QualifiedIdentifier tSchema tName), Just pJson) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let pkCols = tablePKCols dbStructure tSchema tName stm = createWriteStatement sq mq (contentType == CTSingularJSON) True (contentType == CTTextCSV) (iPreferRepresentation apiRequest) pkCols row <- H.statement (toS $ pjRaw pJson) stm let (_, queryTotal, fs, body) = extractQueryResult row headers = catMaybes [ if null fs then Nothing else Just (hLocation, "/" <> toS tName <> renderLocationFields fs) , if iPreferRepresentation apiRequest == Full then Just $ toHeader contentType else Nothing , Just . contentRangeH 1 0 $ toInteger <$> if shouldCount then Just queryTotal else Nothing , if null pkCols then Nothing else (\x -> ("Preference-Applied", show x)) <$> iPreferResolution apiRequest ] if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else return . responseLBS status201 headers $ if iPreferRepresentation apiRequest == Full then toS body else "" (ActionUpdate, TargetIdent (QualifiedIdentifier tSchema tName), Just pJson) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let stm = createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] row <- H.statement (toS $ pjRaw pJson) stm let (_, queryTotal, _, body) = extractQueryResult row if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else do let r = contentRangeH 0 (toInteger $ queryTotal-1) (toInteger <$> if shouldCount then Just queryTotal else Nothing) s = if iPreferRepresentation apiRequest == Full then status200 else status204 return $ if iPreferRepresentation apiRequest == Full then responseLBS s [toHeader contentType, r] (toS body) else responseLBS s [r] "" (ActionSingleUpsert, TargetIdent (QualifiedIdentifier tSchema tName), Just ProcessedJSON{pjRaw, pjType, pjKeys}) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let isSingle = case pjType of PJArray len -> len == 1 PJObject -> True colNames = colName <$> tableCols dbStructure tSchema tName if topLevelRange /= allRange then return $ simpleError status400 [] "Range header and limit/offset querystring parameters are not allowed for PUT" else if not isSingle then return $ simpleError status400 [] "PUT payload must contain a single row" else if S.fromList colNames /= pjKeys then return $ simpleError status400 [] "You must specify all columns in the payload when using PUT" else do row <- H.statement (toS pjRaw) $ createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] let (_, queryTotal, _, body) = extractQueryResult row -- Makes sure the querystring pk matches the payload pk -- e.g. PUT /items?id=eq.1 { "id" : 1, .. } is accepted, PUT /items?id=eq.14 { "id" : 2, .. } is rejected -- If this condition is not satisfied then nothing is inserted, check the WHERE for INSERT in QueryBuilder.hs to see how it's done if queryTotal /= 1 then do HT.condemn return $ simpleError status400 [] "Payload values do not match URL in primary key column(s)" else return $ if iPreferRepresentation apiRequest == Full then responseLBS status200 [toHeader contentType] (toS body) else responseLBS status204 [] "" (ActionDelete, TargetIdent (QualifiedIdentifier tSchema tName), Nothing) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let stm = createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] row <- H.statement mempty stm let (_, queryTotal, _, body) = extractQueryResult row r = contentRangeH 1 0 $ toInteger <$> if shouldCount then Just queryTotal else Nothing if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else return $ if iPreferRepresentation apiRequest == Full then responseLBS status200 [toHeader contentType, r] (toS body) else responseLBS status204 [r] "" (ActionInfo, TargetIdent (QualifiedIdentifier tSchema tTable), Nothing) -> let mTable = find (\t -> tableName t == tTable && tableSchema t == tSchema) (dbTables dbStructure) in case mTable of Nothing -> return notFound Just table -> let acceptH = (hAllow, if tableInsertable table then "GET,POST,PATCH,DELETE" else "GET") in return $ responseLBS status200 [allOrigins, acceptH] "" (ActionInvoke _, TargetProc qi, Just pJson) -> let returnsScalar = case proc of Just ProcDescription{pdReturnType = (Single (Scalar _))} -> True _ -> False rpcBinaryField = if returnsScalar then Right Nothing else binaryField contentType =<< fldNames parts = (,) <$> readSqlParts <*> rpcBinaryField in case parts of Left errorResponse -> return errorResponse Right ((q, cq), bField) -> do let singular = contentType == CTSingularJSON specifiedPgArgs = filter ((`S.member` pjKeys pJson) . pgaName) $ maybe [] pdArgs proc row <- H.statement (toS $ pjRaw pJson) $ callProc qi specifiedPgArgs returnsScalar q cq shouldCount singular (iPreferSingleObjectParameter apiRequest) (contentType == CTTextCSV) (contentType == CTOctetStream) bField (pgVersion dbStructure) let (tableTotal, queryTotal, body, jsonHeaders) = fromMaybe (Just 0, 0, "[]", "[]") row (status, contentRange) = rangeHeader queryTotal tableTotal decodedHeaders = first toS $ JSON.eitherDecode $ toS jsonHeaders :: Either Text [GucHeader] case decodedHeaders of Left _ -> return gucHeadersError Right hs -> if singular && queryTotal /= 1 then do HT.condemn return $ singularityError (toInteger queryTotal) else return $ responseLBS status ([toHeader contentType, contentRange] ++ toHeaders hs) (toS body) (ActionInspect, TargetRoot, Nothing) -> do let host = configHost conf port = toInteger $ configPort conf proxy = pickProxy $ toS <$> configProxyUri conf uri Nothing = ("http", host, port, "/") uri (Just Proxy { proxyScheme = s, proxyHost = h, proxyPort = p, proxyPath = b }) = (s, h, p, b) uri' = uri proxy toTableInfo :: [Table] -> [(Table, [Column], [Text])] toTableInfo = map (\t -> let (s, tn) = (tableSchema t, tableName t) in (t, tableCols dbStructure s tn, tablePKCols dbStructure s tn)) encodeApi ti sd procs = encodeOpenAPI (concat $ M.elems procs) (toTableInfo ti) uri' sd $ dbPrimaryKeys dbStructure body <- encodeApi <$> H.statement schema accessibleTables <*> H.statement schema schemaDescription <*> H.statement schema accessibleProcs return $ responseLBS status200 [toHeader CTOpenAPI] $ toS body _ -> return notFound where notFound = responseLBS status404 [] "" allOrigins = ("Access-Control-Allow-Origin", "*") :: Header shouldCount = iPreferCount apiRequest schema = toS $ configSchema conf topLevelRange = fromMaybe allRange $ M.lookup "limit" $ iRange apiRequest rangeHeader queryTotal tableTotal = let lower = rangeOffset topLevelRange upper = lower + toInteger queryTotal - 1 contentRange = contentRangeH lower upper (toInteger <$> tableTotal) status = rangeStatus lower upper (toInteger <$> tableTotal) in (status, contentRange) readReq = readRequest (configMaxRows conf) (dbRelations dbStructure) proc apiRequest fldNames = fieldNames <$> readReq readDbRequest = DbRead <$> readReq selectQuery = requestToQuery schema False <$> readDbRequest countQuery = requestToCountQuery schema <$> readDbRequest readSqlParts = (,) <$> selectQuery <*> countQuery mutateSqlParts s t = (,) <$> selectQuery <*> (requestToQuery schema False . DbMutate <$> (mutateRequest apiRequest t (tablePKCols dbStructure s t) =<< fldNames))
12,290
app dbStructure proc conf apiRequest = case responseContentTypeOrError (iAccepts apiRequest) (iAction apiRequest) of Left errorResponse -> return errorResponse Right contentType -> case (iAction apiRequest, iTarget apiRequest, iPayload apiRequest) of (ActionRead, TargetIdent qi, Nothing) -> let partsField = (,) <$> readSqlParts <*> (binaryField contentType =<< fldNames) in case partsField of Left errorResponse -> return errorResponse Right ((q, cq), bField) -> do let stm = createReadStatement q cq (contentType == CTSingularJSON) shouldCount (contentType == CTTextCSV) bField row <- H.statement () stm let (tableTotal, queryTotal, _ , body) = row (status, contentRange) = rangeHeader queryTotal tableTotal canonical = iCanonicalQS apiRequest return $ if contentType == CTSingularJSON && queryTotal /= 1 then singularityError (toInteger queryTotal) else responseLBS status [toHeader contentType, contentRange, ("Content-Location", "/" <> toS (qiName qi) <> if BS.null canonical then "" else "?" <> toS canonical ) ] (toS body) (ActionCreate, TargetIdent (QualifiedIdentifier tSchema tName), Just pJson) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let pkCols = tablePKCols dbStructure tSchema tName stm = createWriteStatement sq mq (contentType == CTSingularJSON) True (contentType == CTTextCSV) (iPreferRepresentation apiRequest) pkCols row <- H.statement (toS $ pjRaw pJson) stm let (_, queryTotal, fs, body) = extractQueryResult row headers = catMaybes [ if null fs then Nothing else Just (hLocation, "/" <> toS tName <> renderLocationFields fs) , if iPreferRepresentation apiRequest == Full then Just $ toHeader contentType else Nothing , Just . contentRangeH 1 0 $ toInteger <$> if shouldCount then Just queryTotal else Nothing , if null pkCols then Nothing else (\x -> ("Preference-Applied", show x)) <$> iPreferResolution apiRequest ] if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else return . responseLBS status201 headers $ if iPreferRepresentation apiRequest == Full then toS body else "" (ActionUpdate, TargetIdent (QualifiedIdentifier tSchema tName), Just pJson) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let stm = createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] row <- H.statement (toS $ pjRaw pJson) stm let (_, queryTotal, _, body) = extractQueryResult row if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else do let r = contentRangeH 0 (toInteger $ queryTotal-1) (toInteger <$> if shouldCount then Just queryTotal else Nothing) s = if iPreferRepresentation apiRequest == Full then status200 else status204 return $ if iPreferRepresentation apiRequest == Full then responseLBS s [toHeader contentType, r] (toS body) else responseLBS s [r] "" (ActionSingleUpsert, TargetIdent (QualifiedIdentifier tSchema tName), Just ProcessedJSON{pjRaw, pjType, pjKeys}) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let isSingle = case pjType of PJArray len -> len == 1 PJObject -> True colNames = colName <$> tableCols dbStructure tSchema tName if topLevelRange /= allRange then return $ simpleError status400 [] "Range header and limit/offset querystring parameters are not allowed for PUT" else if not isSingle then return $ simpleError status400 [] "PUT payload must contain a single row" else if S.fromList colNames /= pjKeys then return $ simpleError status400 [] "You must specify all columns in the payload when using PUT" else do row <- H.statement (toS pjRaw) $ createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] let (_, queryTotal, _, body) = extractQueryResult row -- Makes sure the querystring pk matches the payload pk -- e.g. PUT /items?id=eq.1 { "id" : 1, .. } is accepted, PUT /items?id=eq.14 { "id" : 2, .. } is rejected -- If this condition is not satisfied then nothing is inserted, check the WHERE for INSERT in QueryBuilder.hs to see how it's done if queryTotal /= 1 then do HT.condemn return $ simpleError status400 [] "Payload values do not match URL in primary key column(s)" else return $ if iPreferRepresentation apiRequest == Full then responseLBS status200 [toHeader contentType] (toS body) else responseLBS status204 [] "" (ActionDelete, TargetIdent (QualifiedIdentifier tSchema tName), Nothing) -> case mutateSqlParts tSchema tName of Left errorResponse -> return errorResponse Right (sq, mq) -> do let stm = createWriteStatement sq mq (contentType == CTSingularJSON) False (contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] row <- H.statement mempty stm let (_, queryTotal, _, body) = extractQueryResult row r = contentRangeH 1 0 $ toInteger <$> if shouldCount then Just queryTotal else Nothing if contentType == CTSingularJSON && queryTotal /= 1 && iPreferRepresentation apiRequest == Full then do HT.condemn return $ singularityError (toInteger queryTotal) else return $ if iPreferRepresentation apiRequest == Full then responseLBS status200 [toHeader contentType, r] (toS body) else responseLBS status204 [r] "" (ActionInfo, TargetIdent (QualifiedIdentifier tSchema tTable), Nothing) -> let mTable = find (\t -> tableName t == tTable && tableSchema t == tSchema) (dbTables dbStructure) in case mTable of Nothing -> return notFound Just table -> let acceptH = (hAllow, if tableInsertable table then "GET,POST,PATCH,DELETE" else "GET") in return $ responseLBS status200 [allOrigins, acceptH] "" (ActionInvoke _, TargetProc qi, Just pJson) -> let returnsScalar = case proc of Just ProcDescription{pdReturnType = (Single (Scalar _))} -> True _ -> False rpcBinaryField = if returnsScalar then Right Nothing else binaryField contentType =<< fldNames parts = (,) <$> readSqlParts <*> rpcBinaryField in case parts of Left errorResponse -> return errorResponse Right ((q, cq), bField) -> do let singular = contentType == CTSingularJSON specifiedPgArgs = filter ((`S.member` pjKeys pJson) . pgaName) $ maybe [] pdArgs proc row <- H.statement (toS $ pjRaw pJson) $ callProc qi specifiedPgArgs returnsScalar q cq shouldCount singular (iPreferSingleObjectParameter apiRequest) (contentType == CTTextCSV) (contentType == CTOctetStream) bField (pgVersion dbStructure) let (tableTotal, queryTotal, body, jsonHeaders) = fromMaybe (Just 0, 0, "[]", "[]") row (status, contentRange) = rangeHeader queryTotal tableTotal decodedHeaders = first toS $ JSON.eitherDecode $ toS jsonHeaders :: Either Text [GucHeader] case decodedHeaders of Left _ -> return gucHeadersError Right hs -> if singular && queryTotal /= 1 then do HT.condemn return $ singularityError (toInteger queryTotal) else return $ responseLBS status ([toHeader contentType, contentRange] ++ toHeaders hs) (toS body) (ActionInspect, TargetRoot, Nothing) -> do let host = configHost conf port = toInteger $ configPort conf proxy = pickProxy $ toS <$> configProxyUri conf uri Nothing = ("http", host, port, "/") uri (Just Proxy { proxyScheme = s, proxyHost = h, proxyPort = p, proxyPath = b }) = (s, h, p, b) uri' = uri proxy toTableInfo :: [Table] -> [(Table, [Column], [Text])] toTableInfo = map (\t -> let (s, tn) = (tableSchema t, tableName t) in (t, tableCols dbStructure s tn, tablePKCols dbStructure s tn)) encodeApi ti sd procs = encodeOpenAPI (concat $ M.elems procs) (toTableInfo ti) uri' sd $ dbPrimaryKeys dbStructure body <- encodeApi <$> H.statement schema accessibleTables <*> H.statement schema schemaDescription <*> H.statement schema accessibleProcs return $ responseLBS status200 [toHeader CTOpenAPI] $ toS body _ -> return notFound where notFound = responseLBS status404 [] "" allOrigins = ("Access-Control-Allow-Origin", "*") :: Header shouldCount = iPreferCount apiRequest schema = toS $ configSchema conf topLevelRange = fromMaybe allRange $ M.lookup "limit" $ iRange apiRequest rangeHeader queryTotal tableTotal = let lower = rangeOffset topLevelRange upper = lower + toInteger queryTotal - 1 contentRange = contentRangeH lower upper (toInteger <$> tableTotal) status = rangeStatus lower upper (toInteger <$> tableTotal) in (status, contentRange) readReq = readRequest (configMaxRows conf) (dbRelations dbStructure) proc apiRequest fldNames = fieldNames <$> readReq readDbRequest = DbRead <$> readReq selectQuery = requestToQuery schema False <$> readDbRequest countQuery = requestToCountQuery schema <$> readDbRequest readSqlParts = (,) <$> selectQuery <*> countQuery mutateSqlParts s t = (,) <$> selectQuery <*> (requestToQuery schema False . DbMutate <$> (mutateRequest apiRequest t (tablePKCols dbStructure s t) =<< fldNames))
12,193
false
true
68
24
4,545
3,042
1,554
1,488
null
null
d0kt0r0/Tidal
src/Sound/Tidal/Core.hs
gpl-3.0
zoomArc :: Arc -> Pattern a -> Pattern a zoomArc (Arc s e) p = splitQueries $ withResultArc (mapCycle ((/d) . subtract s)) $ withQueryArc (mapCycle ((+s) . (*d))) p where d = e-s -- | @fastGap@ is similar to 'fast' but maintains its cyclic -- alignment. For example, @fastGap 2 p@ would squash the events in -- pattern @p@ into the first half of each cycle (and the second -- halves would be empty). The factor should be at least 1
439
zoomArc :: Arc -> Pattern a -> Pattern a zoomArc (Arc s e) p = splitQueries $ withResultArc (mapCycle ((/d) . subtract s)) $ withQueryArc (mapCycle ((+s) . (*d))) p where d = e-s -- | @fastGap@ is similar to 'fast' but maintains its cyclic -- alignment. For example, @fastGap 2 p@ would squash the events in -- pattern @p@ into the first half of each cycle (and the second -- halves would be empty). The factor should be at least 1
439
zoomArc (Arc s e) p = splitQueries $ withResultArc (mapCycle ((/d) . subtract s)) $ withQueryArc (mapCycle ((+s) . (*d))) p where d = e-s -- | @fastGap@ is similar to 'fast' but maintains its cyclic -- alignment. For example, @fastGap 2 p@ would squash the events in -- pattern @p@ into the first half of each cycle (and the second -- halves would be empty). The factor should be at least 1
398
false
true
1
12
89
118
60
58
null
null
ml9951/ghc
compiler/typecheck/TcType.hs
bsd-3-clause
isAmbiguousTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv {} -> True RuntimeUnk {} -> True _ -> False
176
isAmbiguousTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv {} -> True RuntimeUnk {} -> True _ -> False
176
isAmbiguousTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv {} -> True RuntimeUnk {} -> True _ -> False
176
false
false
0
8
69
60
28
32
null
null
erochest/stat-nlp
src/StatNLP/Text/Utils.hs
apache-2.0
tTestNGramFreqsTotals :: (Eq a, Hashable a) => FreqMap (V.Vector a) -- ^ frequencies of n-grams -> Int -- ^ total number of n-grams -> FreqMap a -- ^ frequencies of items -> Int -- ^ total number of items -> V.Vector a -- ^ target n-gram -> Double -- ^ t-test output tTestNGramFreqsTotals (MHash ngrms) totalNGrams (MHash items) totalItems target = tTest expected actual stddev totalNGrams where lu h x = getSum $ M.lookupDefault 0 x h expected = getProduct $ foldMap ( Product . (/ totalItems') . fromIntegral . lu items) target actualFreq = fromIntegral $ lu ngrms target actual = actualFreq / totalNGrams' totalNGrams' :: Double totalNGrams' = fromIntegral totalNGrams totalItems' :: Double totalItems' = fromIntegral totalItems stddev = sqrt $ (1.0 / totalNGrams') * (hits + misses) hits = actualFreq * (1.0 - actual)^(2 :: Int) misses = (totalNGrams' - actualFreq) * (0.0 - actual)^(2 :: Int)
1,335
tTestNGramFreqsTotals :: (Eq a, Hashable a) => FreqMap (V.Vector a) -- ^ frequencies of n-grams -> Int -- ^ total number of n-grams -> FreqMap a -- ^ frequencies of items -> Int -- ^ total number of items -> V.Vector a -- ^ target n-gram -> Double tTestNGramFreqsTotals (MHash ngrms) totalNGrams (MHash items) totalItems target = tTest expected actual stddev totalNGrams where lu h x = getSum $ M.lookupDefault 0 x h expected = getProduct $ foldMap ( Product . (/ totalItems') . fromIntegral . lu items) target actualFreq = fromIntegral $ lu ngrms target actual = actualFreq / totalNGrams' totalNGrams' :: Double totalNGrams' = fromIntegral totalNGrams totalItems' :: Double totalItems' = fromIntegral totalItems stddev = sqrt $ (1.0 / totalNGrams') * (hits + misses) hits = actualFreq * (1.0 - actual)^(2 :: Int) misses = (totalNGrams' - actualFreq) * (0.0 - actual)^(2 :: Int)
1,300
tTestNGramFreqsTotals (MHash ngrms) totalNGrams (MHash items) totalItems target = tTest expected actual stddev totalNGrams where lu h x = getSum $ M.lookupDefault 0 x h expected = getProduct $ foldMap ( Product . (/ totalItems') . fromIntegral . lu items) target actualFreq = fromIntegral $ lu ngrms target actual = actualFreq / totalNGrams' totalNGrams' :: Double totalNGrams' = fromIntegral totalNGrams totalItems' :: Double totalItems' = fromIntegral totalItems stddev = sqrt $ (1.0 / totalNGrams') * (hits + misses) hits = actualFreq * (1.0 - actual)^(2 :: Int) misses = (totalNGrams' - actualFreq) * (0.0 - actual)^(2 :: Int)
855
true
true
18
14
587
313
159
154
null
null
andrewjanke/mytardis-dicom
src/Mytardis.hs
bsd-2-clause
-- FIXME WHAT HAPPENS WHEN ONE DATASET BELONGS TO MULTIPLE EXPERIMENTS? DO WE HAVE -- TO DEAL WITH THAT WHEN MATCHING DATASETS? -- FIXME only for testing, get rid of this. fromSuccess :: Result a -> a fromSuccess (Success s) = s
229
fromSuccess :: Result a -> a fromSuccess (Success s) = s
56
fromSuccess (Success s) = s
27
true
true
0
7
42
30
16
14
null
null
vikraman/ghc
compiler/coreSyn/CoreSyn.hs
bsd-3-clause
-- | If the expression is a 'Coercion', converts. exprToCoercion_maybe :: CoreExpr -> Maybe Coercion exprToCoercion_maybe (Coercion co) = Just co
145
exprToCoercion_maybe :: CoreExpr -> Maybe Coercion exprToCoercion_maybe (Coercion co) = Just co
95
exprToCoercion_maybe (Coercion co) = Just co
44
true
true
0
6
20
35
16
19
null
null
trskop/cabal
cabal-install/Distribution/Client/Dependency/Modular/PSQ.hs
bsd-3-clause
llength (PSQ _) = 3
26
llength (PSQ _) = 3
26
llength (PSQ _) = 3
26
false
false
0
7
11
15
7
8
null
null
tomberek/rulestesting
src/Morte/Core.hs
bsd-3-clause
normalize :: Expr a -> Expr a normalize e = case e of Lam x _A b -> case b' of App f a -> case a of Var v' | v == v' && not (v `freeIn` f) -> shift (-1) x f -- Eta reduce | otherwise -> e' where v = V x 0 _ -> e' _ -> e' where b' = normalize b e' = Lam x (normalize _A) b' Pi x _A _B -> Pi x (normalize _A) (normalize _B) App f a -> case normalize f of Lam x _A b -> normalize (shift (-1) x b') -- Beta reduce where a' = shift 1 x (normalize a) b' = subst x 0 a' b f' -> App f' (normalize a) Var _ -> e Const _ -> e Import p -> Import p -- | Pretty-print a value
868
normalize :: Expr a -> Expr a normalize e = case e of Lam x _A b -> case b' of App f a -> case a of Var v' | v == v' && not (v `freeIn` f) -> shift (-1) x f -- Eta reduce | otherwise -> e' where v = V x 0 _ -> e' _ -> e' where b' = normalize b e' = Lam x (normalize _A) b' Pi x _A _B -> Pi x (normalize _A) (normalize _B) App f a -> case normalize f of Lam x _A b -> normalize (shift (-1) x b') -- Beta reduce where a' = shift 1 x (normalize a) b' = subst x 0 a' b f' -> App f' (normalize a) Var _ -> e Const _ -> e Import p -> Import p -- | Pretty-print a value
868
normalize e = case e of Lam x _A b -> case b' of App f a -> case a of Var v' | v == v' && not (v `freeIn` f) -> shift (-1) x f -- Eta reduce | otherwise -> e' where v = V x 0 _ -> e' _ -> e' where b' = normalize b e' = Lam x (normalize _A) b' Pi x _A _B -> Pi x (normalize _A) (normalize _B) App f a -> case normalize f of Lam x _A b -> normalize (shift (-1) x b') -- Beta reduce where a' = shift 1 x (normalize a) b' = subst x 0 a' b f' -> App f' (normalize a) Var _ -> e Const _ -> e Import p -> Import p -- | Pretty-print a value
838
false
true
0
20
451
334
160
174
null
null
olorin/amazonka
amazonka-iam/gen/Network/AWS/IAM/UpdateAccessKey.hs
mpl-2.0
-- | The status you want to assign to the secret access key. 'Active' means -- the key can be used for API calls to AWS, while 'Inactive' means the key -- cannot be used. uakStatus :: Lens' UpdateAccessKey StatusType uakStatus = lens _uakStatus (\ s a -> s{_uakStatus = a})
273
uakStatus :: Lens' UpdateAccessKey StatusType uakStatus = lens _uakStatus (\ s a -> s{_uakStatus = a})
102
uakStatus = lens _uakStatus (\ s a -> s{_uakStatus = a})
56
true
true
1
9
50
48
24
24
null
null
geophf/1HaskellADay
exercises/HAD/Y2021/M03/D16/Exercise.hs
mit
readStems :: FilePath -> Bag String -> IO Stems readStems = undefined
69
readStems :: FilePath -> Bag String -> IO Stems readStems = undefined
69
readStems = undefined
21
false
true
0
7
11
25
12
13
null
null
maximilianhuber/univOpWrap
src/System/UnivOpWrap/Common.hs
bsd-3-clause
isNotNon _ = True
23
isNotNon _ = True
23
isNotNon _ = True
23
false
false
0
4
9
10
4
6
null
null
expipiplus1/vulkan
openxr/src/OpenXR/Extensions/XR_MSFT_spatial_anchor.hs
bsd-3-clause
withSpatialAnchorMSFT :: forall io r . MonadIO io => Session -> SpatialAnchorCreateInfoMSFT -> (io SpatialAnchorMSFT -> (SpatialAnchorMSFT -> io ()) -> r) -> r withSpatialAnchorMSFT session createInfo b = b (createSpatialAnchorMSFT session createInfo) (\(o0) -> destroySpatialAnchorMSFT o0)
296
withSpatialAnchorMSFT :: forall io r . MonadIO io => Session -> SpatialAnchorCreateInfoMSFT -> (io SpatialAnchorMSFT -> (SpatialAnchorMSFT -> io ()) -> r) -> r withSpatialAnchorMSFT session createInfo b = b (createSpatialAnchorMSFT session createInfo) (\(o0) -> destroySpatialAnchorMSFT o0)
296
withSpatialAnchorMSFT session createInfo b = b (createSpatialAnchorMSFT session createInfo) (\(o0) -> destroySpatialAnchorMSFT o0)
136
false
true
0
16
42
97
49
48
null
null
sol/aeson
Data/Aeson/Encoding/Internal.hs
bsd-3-clause
retagEncoding :: Encoding' a -> Encoding' b retagEncoding = Encoding . fromEncoding
83
retagEncoding :: Encoding' a -> Encoding' b retagEncoding = Encoding . fromEncoding
83
retagEncoding = Encoding . fromEncoding
39
false
true
0
6
11
25
12
13
null
null
haskell-opengl/OpenGLRaw
src/Graphics/GL/Functions/F19.hs
bsd-3-clause
-- glPathParameteriNV ---------------------------------------------------------- glPathParameteriNV :: MonadIO m => GLuint -- ^ @path@ of type @Path@. -> GLenum -- ^ @pname@ of type [PathParameter](Graphics-GL-Groups.html#PathParameter). -> GLint -- ^ @value@. -> m () glPathParameteriNV v1 v2 v3 = liftIO $ dyn491 ptr_glPathParameteriNV v1 v2 v3
357
glPathParameteriNV :: MonadIO m => GLuint -- ^ @path@ of type @Path@. -> GLenum -- ^ @pname@ of type [PathParameter](Graphics-GL-Groups.html#PathParameter). -> GLint -- ^ @value@. -> m () glPathParameteriNV v1 v2 v3 = liftIO $ dyn491 ptr_glPathParameteriNV v1 v2 v3
275
glPathParameteriNV v1 v2 v3 = liftIO $ dyn491 ptr_glPathParameteriNV v1 v2 v3
77
true
true
0
11
53
63
31
32
null
null
keera-studios/hsQt
Qt/Arthur/Style.hs
bsd-2-clause
polish2 :: ArthurStyle -> QPalette a -> IO () polish2 this palette = do c <- qColor (241::Int, 241::Int, 241::Int) setColor palette (eBackground, c)
158
polish2 :: ArthurStyle -> QPalette a -> IO () polish2 this palette = do c <- qColor (241::Int, 241::Int, 241::Int) setColor palette (eBackground, c)
158
polish2 this palette = do c <- qColor (241::Int, 241::Int, 241::Int) setColor palette (eBackground, c)
112
false
true
0
9
33
74
38
36
null
null
joelburget/graphreduction
src/Machine/Internal/Step.hs
bsd-3-clause
primStep state Eq = primComp state (==)
46
primStep state Eq = primComp state (==)
46
primStep state Eq = primComp state (==)
46
false
false
0
5
13
18
9
9
null
null
taojang/haskell-programming-book-exercise
src/ch14/Chapter14.hs
bsd-3-clause
prop_intId x = x == intId x
27
prop_intId x = x == intId x
27
prop_intId x = x == intId x
27
false
false
0
6
6
16
7
9
null
null
tismith/tlisp
src/Primitives.hs
mit
isLispValComplex (Ratio _) = True
33
isLispValComplex (Ratio _) = True
33
isLispValComplex (Ratio _) = True
33
false
false
0
7
4
15
7
8
null
null
adarqui/99problems-hs
Experimentation/P20.hs
gpl-3.0
removeAt_fold :: [a] -> Int -> (Maybe a,[a]) removeAt_fold lst n = decode (result) where decode (a,b,_) = (a,b) xfst (a,_,_) = a xsnd (_,b,_) = b xthird (_,_,c) = c result = foldl f (Nothing,[],1) lst where f a b | xthird a == n = (Just b, xsnd a, xthird a + 1) | otherwise = (xfst a, xsnd a ++ [b], xthird a + 1)
378
removeAt_fold :: [a] -> Int -> (Maybe a,[a]) removeAt_fold lst n = decode (result) where decode (a,b,_) = (a,b) xfst (a,_,_) = a xsnd (_,b,_) = b xthird (_,_,c) = c result = foldl f (Nothing,[],1) lst where f a b | xthird a == n = (Just b, xsnd a, xthird a + 1) | otherwise = (xfst a, xsnd a ++ [b], xthird a + 1)
378
removeAt_fold lst n = decode (result) where decode (a,b,_) = (a,b) xfst (a,_,_) = a xsnd (_,b,_) = b xthird (_,_,c) = c result = foldl f (Nothing,[],1) lst where f a b | xthird a == n = (Just b, xsnd a, xthird a + 1) | otherwise = (xfst a, xsnd a ++ [b], xthird a + 1)
333
false
true
1
10
132
252
126
126
null
null
bobjflong/hspec-slow
test/Spec.hs
bsd-3-clause
main :: IO () main = do conf <- configure 1 timedHspecParallel conf $ \it -> describe "Main" $ do it "should foo" $ do threadDelay 3000000 1 `shouldBe` 1 it "should bar" $ do threadDelay 1000 1 `shouldBe` 1 it "should baz" $ do threadDelay 4000000 1 `shouldBe` 1
336
main :: IO () main = do conf <- configure 1 timedHspecParallel conf $ \it -> describe "Main" $ do it "should foo" $ do threadDelay 3000000 1 `shouldBe` 1 it "should bar" $ do threadDelay 1000 1 `shouldBe` 1 it "should baz" $ do threadDelay 4000000 1 `shouldBe` 1
336
main = do conf <- configure 1 timedHspecParallel conf $ \it -> describe "Main" $ do it "should foo" $ do threadDelay 3000000 1 `shouldBe` 1 it "should bar" $ do threadDelay 1000 1 `shouldBe` 1 it "should baz" $ do threadDelay 4000000 1 `shouldBe` 1
322
false
true
1
21
123
128
55
73
null
null
quyse/flaw
flaw-gl/Flaw/Graphics/OpenGL/FFI.hs
mit
glNullTextureName :: TextureName glNullTextureName = 0
54
glNullTextureName :: TextureName glNullTextureName = 0
54
glNullTextureName = 0
21
false
true
0
4
5
11
6
5
null
null
gspindles/rftg-cards
src/Game/RftG/Cards/RvI.hs
mit
upliftCode :: Card upliftCode = Card Development "UPLIFT CODE" (Cost 6) QuestionMark (Just Prestige) [Uplift] [Produce]
133
upliftCode :: Card upliftCode = Card Development "UPLIFT CODE" (Cost 6) QuestionMark (Just Prestige) [Uplift] [Produce]
133
upliftCode = Card Development "UPLIFT CODE" (Cost 6) QuestionMark (Just Prestige) [Uplift] [Produce]
114
false
true
0
6
29
56
24
32
null
null
Arguggi/heed
heed-vty/src/Heed/Vty/MainWidget.hs
bsd-3-clause
appEvent s (BT.VtyEvent (V.EvKey (V.KChar 'o') [])) = openInBrowser s Chromium
78
appEvent s (BT.VtyEvent (V.EvKey (V.KChar 'o') [])) = openInBrowser s Chromium
78
appEvent s (BT.VtyEvent (V.EvKey (V.KChar 'o') [])) = openInBrowser s Chromium
78
false
false
0
12
10
44
21
23
null
null