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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
amccausl/Swish | Swish/HaskellUtils/Network/URI.hs | lgpl-2.1 | uriHexDigitChar :: UriParser Char
uriHexDigitChar = hexDigit | 61 | uriHexDigitChar :: UriParser Char
uriHexDigitChar = hexDigit | 60 | uriHexDigitChar = hexDigit | 26 | false | true | 0 | 5 | 7 | 14 | 7 | 7 | null | null |
riccardotommasini/plp16 | haskell/prepared/ESE20181120/Bintree.hs | apache-2.0 | treeFoldr f acc EmptyTree = acc | 31 | treeFoldr f acc EmptyTree = acc | 31 | treeFoldr f acc EmptyTree = acc | 31 | false | false | 1 | 5 | 5 | 19 | 6 | 13 | null | null |
utilForever/ProgrammingPractice | Solutions/MoNaDDu/Grade Management System/2/Part2.hs | mit | qsort (x:xs) = qsort [a | a <- xs, a > x] ++ x : qsort [a | a <- xs, x >= a] | 76 | qsort (x:xs) = qsort [a | a <- xs, a > x] ++ x : qsort [a | a <- xs, x >= a] | 76 | qsort (x:xs) = qsort [a | a <- xs, a > x] ++ x : qsort [a | a <- xs, x >= a] | 76 | false | false | 0 | 10 | 23 | 69 | 34 | 35 | null | null |
takoeight0821/malgo | src/Malgo/Syntax.hs | bsd-3-clause | freevars :: (Eq (XId x), Hashable (XId x)) => Exp x -> HashSet (XId x)
freevars (Var _ (WithPrefix v)) = one (v ^. value) | 121 | freevars :: (Eq (XId x), Hashable (XId x)) => Exp x -> HashSet (XId x)
freevars (Var _ (WithPrefix v)) = one (v ^. value) | 121 | freevars (Var _ (WithPrefix v)) = one (v ^. value) | 50 | false | true | 0 | 9 | 24 | 85 | 41 | 44 | null | null |
conal/hermit | src/HERMIT/Dictionary/Reasoning.hs | bsd-2-clause | (\/) :: Clause -> Clause -> Clause
(\/) = Disj | 46 | (\/) :: Clause -> Clause -> Clause
(\/) = Disj | 46 | (\/) = Disj | 11 | false | true | 0 | 6 | 9 | 23 | 14 | 9 | null | null |
keithodulaigh/Hets | Haskell/TranslateId.hs | gpl-2.0 | -- | Converts an identifier to a valid lower or upper case Haskell name
translateIdWithType :: IdCase -> Id -> String
translateIdWithType ty i =
let s = translateId i ""
c = if null s then error "translateIdWithTyper" else head s
in case ty of
UpperId ->
if isLower c || c == '_' || isDigit c
then "A__" ++ s else s
LowerId ->
if isUpper c || c == '_' || isDigit c || s `Set.member` lowerCaseList
then "a__" ++ s else s
-- reserved Haskell keywords | 511 | translateIdWithType :: IdCase -> Id -> String
translateIdWithType ty i =
let s = translateId i ""
c = if null s then error "translateIdWithTyper" else head s
in case ty of
UpperId ->
if isLower c || c == '_' || isDigit c
then "A__" ++ s else s
LowerId ->
if isUpper c || c == '_' || isDigit c || s `Set.member` lowerCaseList
then "a__" ++ s else s
-- reserved Haskell keywords | 439 | translateIdWithType ty i =
let s = translateId i ""
c = if null s then error "translateIdWithTyper" else head s
in case ty of
UpperId ->
if isLower c || c == '_' || isDigit c
then "A__" ++ s else s
LowerId ->
if isUpper c || c == '_' || isDigit c || s `Set.member` lowerCaseList
then "a__" ++ s else s
-- reserved Haskell keywords | 393 | true | true | 0 | 16 | 152 | 158 | 78 | 80 | null | null |
gmalecha/skip-list | src/Data/SkipList.hs | mit | toSkipList :: Int -- ^ The step size in the index.
-> [a] -- ^ The list to convert.
-> SkipList a
toSkipList quant = SkipList quant . toSkipIndex quant | 173 | toSkipList :: Int -- ^ The step size in the index.
-> [a] -- ^ The list to convert.
-> SkipList a
toSkipList quant = SkipList quant . toSkipIndex quant | 173 | toSkipList quant = SkipList quant . toSkipIndex quant | 53 | false | true | 0 | 8 | 51 | 44 | 21 | 23 | null | null |
cchalmers/shaped | src/Data/Dense/Storable.hs | bsd-3-clause | -- | Zip three arrays using the given function. If the array's don't
-- have the same shape, the new array with be the intersection of the
-- two shapes.
zipWith3 :: (Shape f, Storable a, Storable b, Storable c, Storable d)
=> (a -> b -> c -> d)
-> SArray f a
-> SArray f b
-> SArray f c
-> SArray f d
zipWith3 = G.zipWith3 | 372 | zipWith3 :: (Shape f, Storable a, Storable b, Storable c, Storable d)
=> (a -> b -> c -> d)
-> SArray f a
-> SArray f b
-> SArray f c
-> SArray f d
zipWith3 = G.zipWith3 | 214 | zipWith3 = G.zipWith3 | 21 | true | true | 0 | 11 | 117 | 106 | 52 | 54 | null | null |
fmapfmapfmap/amazonka | amazonka-iam/gen/Network/AWS/IAM/ListSAMLProviders.hs | mpl-2.0 | -- | The response status code.
lsamlprsResponseStatus :: Lens' ListSAMLProvidersResponse Int
lsamlprsResponseStatus = lens _lsamlprsResponseStatus (\ s a -> s{_lsamlprsResponseStatus = a}) | 188 | lsamlprsResponseStatus :: Lens' ListSAMLProvidersResponse Int
lsamlprsResponseStatus = lens _lsamlprsResponseStatus (\ s a -> s{_lsamlprsResponseStatus = a}) | 157 | lsamlprsResponseStatus = lens _lsamlprsResponseStatus (\ s a -> s{_lsamlprsResponseStatus = a}) | 95 | true | true | 0 | 9 | 21 | 40 | 22 | 18 | null | null |
kazu-yamamoto/llrbtree | Data/Set/LLRBTree.hs | bsd-3-clause | deleteEQ _ _ _ _ _ _ = error "deleteEQ" | 39 | deleteEQ _ _ _ _ _ _ = error "deleteEQ" | 39 | deleteEQ _ _ _ _ _ _ = error "deleteEQ" | 39 | false | false | 1 | 5 | 9 | 19 | 9 | 10 | null | null |
robeverest/accelerate | Data/Array/Accelerate/Interpreter.hs | bsd-3-clause | evalBRotateR :: IntegralType a -> ((a, Int) -> a)
evalBRotateR ty | IntegralDict <- integralDict ty = uncurry rotateR | 117 | evalBRotateR :: IntegralType a -> ((a, Int) -> a)
evalBRotateR ty | IntegralDict <- integralDict ty = uncurry rotateR | 117 | evalBRotateR ty | IntegralDict <- integralDict ty = uncurry rotateR | 67 | false | true | 0 | 9 | 18 | 50 | 24 | 26 | null | null |
Acidburn0zzz/haddock | haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs | bsd-2-clause | hypSrcModuleUrl :: Module -> String
hypSrcModuleUrl = hypSrcModuleFile | 70 | hypSrcModuleUrl :: Module -> String
hypSrcModuleUrl = hypSrcModuleFile | 70 | hypSrcModuleUrl = hypSrcModuleFile | 34 | false | true | 0 | 5 | 7 | 15 | 8 | 7 | null | null |
svalaskevicius/hob | src/lib/Hob/Command/ReloadSidebarTree.hs | gpl-3.0 | reloadSidebarTreeCommandHandler :: CommandHandler
reloadSidebarTreeCommandHandler = CommandHandler Nothing reloadCmd | 116 | reloadSidebarTreeCommandHandler :: CommandHandler
reloadSidebarTreeCommandHandler = CommandHandler Nothing reloadCmd | 116 | reloadSidebarTreeCommandHandler = CommandHandler Nothing reloadCmd | 66 | false | true | 0 | 5 | 7 | 16 | 8 | 8 | null | null |
fmapfmapfmap/amazonka | amazonka-ssm/gen/Network/AWS/SSM/CreateAssociation.hs | mpl-2.0 | -- | The ID of the instance.
caInstanceId :: Lens' CreateAssociation Text
caInstanceId = lens _caInstanceId (\ s a -> s{_caInstanceId = a}) | 139 | caInstanceId :: Lens' CreateAssociation Text
caInstanceId = lens _caInstanceId (\ s a -> s{_caInstanceId = a}) | 110 | caInstanceId = lens _caInstanceId (\ s a -> s{_caInstanceId = a}) | 65 | true | true | 0 | 9 | 22 | 40 | 22 | 18 | null | null |
EJahren/haskell-sdl2 | Tests/Interactive/DrawLines.hs | gpl-3.0 | windowHeight = 240 | 18 | windowHeight = 240 | 18 | windowHeight = 240 | 18 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
leroux/packages-haskeline | System/Console/Haskeline/Backend/Terminfo.hs | bsd-2-clause | clearLayoutT :: ActionM ()
clearLayoutT = do
h <- asks height
output (clearAll h)
put initTermPos | 109 | clearLayoutT :: ActionM ()
clearLayoutT = do
h <- asks height
output (clearAll h)
put initTermPos | 109 | clearLayoutT = do
h <- asks height
output (clearAll h)
put initTermPos | 82 | false | true | 0 | 9 | 27 | 44 | 19 | 25 | null | null |
y-usuzumi/survive-the-course | www.icourse163.org/ZJU-93001/第一周编程作业/2.hs | bsd-3-clause | maxSubseqSum :: [Int] -> (Int, Int, Int)
maxSubseqSum a = _maxSubseqSum a $ ResultRepr 0 0 0 0 (head a) 0 True
where
_maxSubseqSum :: [Int] -> ResultRepr -> (Int, Int, Int)
_maxSubseqSum [] resultRepr@ResultRepr{..} =
if allNeg then (0, head a, last a) else (currMax, maxL, maxR)
_maxSubseqSum (x:xs) resultRepr@ResultRepr{..}
| currSum + x < 0 = let
currL' = head xs
in
_maxSubseqSum xs resultRepr{ currSum = 0
, currL = currL'
, currR = currL'
}
| otherwise = let
currSum' = currSum + x
currR' = x
in
_maxSubseqSum xs $ if currSum' > currMax
then
resultRepr{ currSum = currSum'
, currMax = currSum'
, maxL = currL
, maxR = currR'
, currR = currR'
, allNeg = False
}
else
resultRepr{ currSum = currSum'
, currR = currR'
, allNeg = False
} | 1,441 | maxSubseqSum :: [Int] -> (Int, Int, Int)
maxSubseqSum a = _maxSubseqSum a $ ResultRepr 0 0 0 0 (head a) 0 True
where
_maxSubseqSum :: [Int] -> ResultRepr -> (Int, Int, Int)
_maxSubseqSum [] resultRepr@ResultRepr{..} =
if allNeg then (0, head a, last a) else (currMax, maxL, maxR)
_maxSubseqSum (x:xs) resultRepr@ResultRepr{..}
| currSum + x < 0 = let
currL' = head xs
in
_maxSubseqSum xs resultRepr{ currSum = 0
, currL = currL'
, currR = currL'
}
| otherwise = let
currSum' = currSum + x
currR' = x
in
_maxSubseqSum xs $ if currSum' > currMax
then
resultRepr{ currSum = currSum'
, currMax = currSum'
, maxL = currL
, maxR = currR'
, currR = currR'
, allNeg = False
}
else
resultRepr{ currSum = currSum'
, currR = currR'
, allNeg = False
} | 1,441 | maxSubseqSum a = _maxSubseqSum a $ ResultRepr 0 0 0 0 (head a) 0 True
where
_maxSubseqSum :: [Int] -> ResultRepr -> (Int, Int, Int)
_maxSubseqSum [] resultRepr@ResultRepr{..} =
if allNeg then (0, head a, last a) else (currMax, maxL, maxR)
_maxSubseqSum (x:xs) resultRepr@ResultRepr{..}
| currSum + x < 0 = let
currL' = head xs
in
_maxSubseqSum xs resultRepr{ currSum = 0
, currL = currL'
, currR = currL'
}
| otherwise = let
currSum' = currSum + x
currR' = x
in
_maxSubseqSum xs $ if currSum' > currMax
then
resultRepr{ currSum = currSum'
, currMax = currSum'
, maxL = currL
, maxR = currR'
, currR = currR'
, allNeg = False
}
else
resultRepr{ currSum = currSum'
, currR = currR'
, allNeg = False
} | 1,400 | false | true | 0 | 11 | 840 | 324 | 179 | 145 | null | null |
YellPika/effin | src/Data/Union.hs | bsd-3-clause | wrap :: f a -> Union (f ':+ l) a
wrap = inject | 46 | wrap :: f a -> Union (f ':+ l) a
wrap = inject | 46 | wrap = inject | 13 | false | true | 0 | 9 | 12 | 38 | 17 | 21 | null | null |
rueshyna/gogol | gogol-adexchange-buyer/gen/Network/Google/AdExchangeBuyer/Types/Product.hs | mpl-2.0 | -- | Account name.
biAccountName :: Lens' BillingInfo (Maybe Text)
biAccountName
= lens _biAccountName
(\ s a -> s{_biAccountName = a}) | 143 | biAccountName :: Lens' BillingInfo (Maybe Text)
biAccountName
= lens _biAccountName
(\ s a -> s{_biAccountName = a}) | 124 | biAccountName
= lens _biAccountName
(\ s a -> s{_biAccountName = a}) | 76 | true | true | 1 | 9 | 28 | 51 | 25 | 26 | null | null |
patperry/hs-linear-algebra | tests/STVector.hs | bsd-3-clause | prop_getNorm2 t x = runST $
x `readOnlyVector` \mx -> do
n <- V.getNorm2 mx
return $ n === V.norm2 x
where
_ = typed t x | 146 | prop_getNorm2 t x = runST $
x `readOnlyVector` \mx -> do
n <- V.getNorm2 mx
return $ n === V.norm2 x
where
_ = typed t x | 146 | prop_getNorm2 t x = runST $
x `readOnlyVector` \mx -> do
n <- V.getNorm2 mx
return $ n === V.norm2 x
where
_ = typed t x | 146 | false | false | 0 | 11 | 52 | 68 | 32 | 36 | null | null |
fthomasmorel/Sudoku-solver | Sudoku.hs | mit | ------------------------------------------------------------------------------------------------------------------------
-- DATA TO SUDOKU --
------------------------------------------------------------------------------------------------------------------------
stringToInt :: [String] -> [Line]
stringToInt s = map (\x -> map (digitToInt) x) s | 446 | stringToInt :: [String] -> [Line]
stringToInt s = map (\x -> map (digitToInt) x) s | 82 | stringToInt s = map (\x -> map (digitToInt) x) s | 48 | true | true | 0 | 9 | 122 | 48 | 27 | 21 | null | null |
dashea/bdcs | importer/BDCS/Exceptions.hs | lgpl-2.1 | throwIfNothingOtherwise :: Exception e => Maybe a -> e -> (a -> b) -> b
throwIfNothingOtherwise (Just v) _ fn = fn v | 118 | throwIfNothingOtherwise :: Exception e => Maybe a -> e -> (a -> b) -> b
throwIfNothingOtherwise (Just v) _ fn = fn v | 118 | throwIfNothingOtherwise (Just v) _ fn = fn v | 46 | false | true | 0 | 10 | 24 | 56 | 27 | 29 | null | null |
thoughtpolice/cabal | Cabal/Distribution/PackageDescription/Check.hs | bsd-3-clause | checkLicense :: PackageDescription -> [PackageCheck]
checkLicense pkg =
catMaybes [
check (license pkg == UnspecifiedLicense) $
PackageDistInexcusable
"The 'license' field is missing."
, check (license pkg == AllRightsReserved) $
PackageDistSuspicious
"The 'license' is AllRightsReserved. Is that really what you want?"
, case license pkg of
UnknownLicense l -> Just $
PackageBuildWarning $
quote ("license: " ++ l) ++ " is not a recognised license. The "
++ "known licenses are: "
++ commaSep (map display knownLicenses)
_ -> Nothing
, check (license pkg == BSD4) $
PackageDistSuspicious $
"Using 'license: BSD4' is almost always a misunderstanding. 'BSD4' "
++ "refers to the old 4-clause BSD license with the advertising "
++ "clause. 'BSD3' refers the new 3-clause BSD license."
, case unknownLicenseVersion (license pkg) of
Just knownVersions -> Just $
PackageDistSuspicious $
"'license: " ++ display (license pkg) ++ "' is not a known "
++ "version of that license. The known versions are "
++ commaSep (map display knownVersions)
++ ". If this is not a mistake and you think it should be a known "
++ "version then please file a ticket."
_ -> Nothing
, check (license pkg `notElem` [ AllRightsReserved
, UnspecifiedLicense, PublicDomain]
-- AllRightsReserved and PublicDomain are not strictly
-- licenses so don't need license files.
&& null (licenseFiles pkg)) $
PackageDistSuspicious "A 'license-file' is not specified."
]
where
unknownLicenseVersion (GPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | GPL (Just v') <- knownLicenses ]
unknownLicenseVersion (LGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | LGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (AGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | AGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (Apache (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
unknownLicenseVersion _ = Nothing | 2,426 | checkLicense :: PackageDescription -> [PackageCheck]
checkLicense pkg =
catMaybes [
check (license pkg == UnspecifiedLicense) $
PackageDistInexcusable
"The 'license' field is missing."
, check (license pkg == AllRightsReserved) $
PackageDistSuspicious
"The 'license' is AllRightsReserved. Is that really what you want?"
, case license pkg of
UnknownLicense l -> Just $
PackageBuildWarning $
quote ("license: " ++ l) ++ " is not a recognised license. The "
++ "known licenses are: "
++ commaSep (map display knownLicenses)
_ -> Nothing
, check (license pkg == BSD4) $
PackageDistSuspicious $
"Using 'license: BSD4' is almost always a misunderstanding. 'BSD4' "
++ "refers to the old 4-clause BSD license with the advertising "
++ "clause. 'BSD3' refers the new 3-clause BSD license."
, case unknownLicenseVersion (license pkg) of
Just knownVersions -> Just $
PackageDistSuspicious $
"'license: " ++ display (license pkg) ++ "' is not a known "
++ "version of that license. The known versions are "
++ commaSep (map display knownVersions)
++ ". If this is not a mistake and you think it should be a known "
++ "version then please file a ticket."
_ -> Nothing
, check (license pkg `notElem` [ AllRightsReserved
, UnspecifiedLicense, PublicDomain]
-- AllRightsReserved and PublicDomain are not strictly
-- licenses so don't need license files.
&& null (licenseFiles pkg)) $
PackageDistSuspicious "A 'license-file' is not specified."
]
where
unknownLicenseVersion (GPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | GPL (Just v') <- knownLicenses ]
unknownLicenseVersion (LGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | LGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (AGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | AGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (Apache (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
unknownLicenseVersion _ = Nothing | 2,426 | checkLicense pkg =
catMaybes [
check (license pkg == UnspecifiedLicense) $
PackageDistInexcusable
"The 'license' field is missing."
, check (license pkg == AllRightsReserved) $
PackageDistSuspicious
"The 'license' is AllRightsReserved. Is that really what you want?"
, case license pkg of
UnknownLicense l -> Just $
PackageBuildWarning $
quote ("license: " ++ l) ++ " is not a recognised license. The "
++ "known licenses are: "
++ commaSep (map display knownLicenses)
_ -> Nothing
, check (license pkg == BSD4) $
PackageDistSuspicious $
"Using 'license: BSD4' is almost always a misunderstanding. 'BSD4' "
++ "refers to the old 4-clause BSD license with the advertising "
++ "clause. 'BSD3' refers the new 3-clause BSD license."
, case unknownLicenseVersion (license pkg) of
Just knownVersions -> Just $
PackageDistSuspicious $
"'license: " ++ display (license pkg) ++ "' is not a known "
++ "version of that license. The known versions are "
++ commaSep (map display knownVersions)
++ ". If this is not a mistake and you think it should be a known "
++ "version then please file a ticket."
_ -> Nothing
, check (license pkg `notElem` [ AllRightsReserved
, UnspecifiedLicense, PublicDomain]
-- AllRightsReserved and PublicDomain are not strictly
-- licenses so don't need license files.
&& null (licenseFiles pkg)) $
PackageDistSuspicious "A 'license-file' is not specified."
]
where
unknownLicenseVersion (GPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | GPL (Just v') <- knownLicenses ]
unknownLicenseVersion (LGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | LGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (AGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | AGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (Apache (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
unknownLicenseVersion _ = Nothing | 2,373 | false | true | 0 | 18 | 672 | 563 | 278 | 285 | null | null |
emwap/syntactic | tests/NanoFeldsparTests.hs | bsd-3-clause | prop_alphaEqBad a = alphaEq a (badRename a) | 43 | prop_alphaEqBad a = alphaEq a (badRename a) | 43 | prop_alphaEqBad a = alphaEq a (badRename a) | 43 | false | false | 0 | 7 | 6 | 20 | 9 | 11 | null | null |
OS2World/DEV-UTIL-HUGS | libraries/Graphics/Rendering/OpenGL/GL/DisplayLists.hs | bsd-3-clause | callLists :: GLsizei -> DataType -> Ptr a -> IO ()
callLists n = glCallLists n . marshalDataType | 96 | callLists :: GLsizei -> DataType -> Ptr a -> IO ()
callLists n = glCallLists n . marshalDataType | 96 | callLists n = glCallLists n . marshalDataType | 45 | false | true | 0 | 10 | 17 | 46 | 20 | 26 | null | null |
MasseR/zsh-battery | Symbols.hs | bsd-3-clause | barsymbol = '▶' | 15 | barsymbol = '▶' | 15 | barsymbol = '▶' | 15 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
zeniuseducation/poly-euler | haskell/clojure.hs | epl-1.0 | distinct ls = map ( head . group . sort ) $ ls | 46 | distinct ls = map ( head . group . sort ) $ ls | 46 | distinct ls = map ( head . group . sort ) $ ls | 46 | false | false | 1 | 9 | 12 | 31 | 13 | 18 | null | null |
bitemyapp/ganeti | src/Ganeti/MaintD/Server.hs | bsd-2-clause | httpInterface :: IORef MemoryState -> Snap ()
httpInterface memstate =
ifTop (method GET $ plainJSON [1 :: Int])
<|> dir "1" (ifTop (plainJSON J.JSNull)
<|> route [ ("jobs", exposeState msJobs memstate)
, ("evacuated", exposeState msEvacuated memstate)
, ("status", exposeState msIncidents memstate)
])
<|> error404 | 411 | httpInterface :: IORef MemoryState -> Snap ()
httpInterface memstate =
ifTop (method GET $ plainJSON [1 :: Int])
<|> dir "1" (ifTop (plainJSON J.JSNull)
<|> route [ ("jobs", exposeState msJobs memstate)
, ("evacuated", exposeState msEvacuated memstate)
, ("status", exposeState msIncidents memstate)
])
<|> error404 | 411 | httpInterface memstate =
ifTop (method GET $ plainJSON [1 :: Int])
<|> dir "1" (ifTop (plainJSON J.JSNull)
<|> route [ ("jobs", exposeState msJobs memstate)
, ("evacuated", exposeState msEvacuated memstate)
, ("status", exposeState msIncidents memstate)
])
<|> error404 | 365 | false | true | 6 | 10 | 139 | 136 | 68 | 68 | null | null |
phadej/denotational-frp | src/Reactive/Denotational/Events.hs | mit | concatTimeMap :: (Time -> a -> Events b) -> Events a -> Events b
concatTimeMap f = Events . impl (Time 0) . fromEvents
where impl _ [] = []
impl t ((t', x) : es) = let ys = f (maxTime t t') x
t'' = maxTime (maxTime t t') (endTime ys)
in fromEvents ys ++ impl t'' es | 356 | concatTimeMap :: (Time -> a -> Events b) -> Events a -> Events b
concatTimeMap f = Events . impl (Time 0) . fromEvents
where impl _ [] = []
impl t ((t', x) : es) = let ys = f (maxTime t t') x
t'' = maxTime (maxTime t t') (endTime ys)
in fromEvents ys ++ impl t'' es | 356 | concatTimeMap f = Events . impl (Time 0) . fromEvents
where impl _ [] = []
impl t ((t', x) : es) = let ys = f (maxTime t t') x
t'' = maxTime (maxTime t t') (endTime ys)
in fromEvents ys ++ impl t'' es | 291 | false | true | 1 | 11 | 150 | 169 | 79 | 90 | null | null |
jberryman/chan-benchmarks | TestAtomics.hs | bsd-3-clause | maxInt = maxBound :: Int | 24 | maxInt = maxBound :: Int | 24 | maxInt = maxBound :: Int | 24 | false | false | 0 | 4 | 4 | 9 | 5 | 4 | null | null |
dblia/nosql-ganeti | test/hs/Test/Ganeti/Utils.hs | gpl-2.0 | prop_niceSort_single :: Property
prop_niceSort_single =
forAll genName $ \name ->
conjoin
[ printTestCase "single string" $ [name] ==? niceSort [name]
, printTestCase "single plus empty" $ ["", name] ==? niceSort [name, ""]
] | 235 | prop_niceSort_single :: Property
prop_niceSort_single =
forAll genName $ \name ->
conjoin
[ printTestCase "single string" $ [name] ==? niceSort [name]
, printTestCase "single plus empty" $ ["", name] ==? niceSort [name, ""]
] | 235 | prop_niceSort_single =
forAll genName $ \name ->
conjoin
[ printTestCase "single string" $ [name] ==? niceSort [name]
, printTestCase "single plus empty" $ ["", name] ==? niceSort [name, ""]
] | 202 | false | true | 0 | 8 | 42 | 78 | 41 | 37 | null | null |
deech/stack | src/Stack/Runners.hs | bsd-3-clause | withUserFileLock :: (MonadBaseControl IO m, MonadIO m)
=> GlobalOpts
-> Path Abs Dir
-> (Maybe FileLock -> m a)
-> m a
withUserFileLock go@GlobalOpts{} dir act = do
env <- liftIO getEnvironment
let toLock = lookup "STACK_LOCK" env == Just "true"
if toLock
then do
let lockfile = $(mkRelFile "lockfile")
let pth = dir </> lockfile
ensureDir dir
-- Just in case of asynchronous exceptions, we need to be careful
-- when using tryLockFile here:
EL.bracket (liftIO $ tryLockFile (toFilePath pth) Exclusive)
(maybe (return ()) (liftIO . unlockFile))
(\fstTry ->
case fstTry of
Just lk -> EL.finally (act $ Just lk) (liftIO $ unlockFile lk)
Nothing ->
do let chatter = globalLogLevel go /= LevelOther "silent"
when chatter $
liftIO $ hPutStrLn stderr $ "Failed to grab lock ("++show pth++
"); other stack instance running. Waiting..."
EL.bracket (liftIO $ lockFile (toFilePath pth) Exclusive)
(liftIO . unlockFile)
(\lk -> do
when chatter $
liftIO $ hPutStrLn stderr "Lock acquired, proceeding."
act $ Just lk))
else act Nothing | 1,707 | withUserFileLock :: (MonadBaseControl IO m, MonadIO m)
=> GlobalOpts
-> Path Abs Dir
-> (Maybe FileLock -> m a)
-> m a
withUserFileLock go@GlobalOpts{} dir act = do
env <- liftIO getEnvironment
let toLock = lookup "STACK_LOCK" env == Just "true"
if toLock
then do
let lockfile = $(mkRelFile "lockfile")
let pth = dir </> lockfile
ensureDir dir
-- Just in case of asynchronous exceptions, we need to be careful
-- when using tryLockFile here:
EL.bracket (liftIO $ tryLockFile (toFilePath pth) Exclusive)
(maybe (return ()) (liftIO . unlockFile))
(\fstTry ->
case fstTry of
Just lk -> EL.finally (act $ Just lk) (liftIO $ unlockFile lk)
Nothing ->
do let chatter = globalLogLevel go /= LevelOther "silent"
when chatter $
liftIO $ hPutStrLn stderr $ "Failed to grab lock ("++show pth++
"); other stack instance running. Waiting..."
EL.bracket (liftIO $ lockFile (toFilePath pth) Exclusive)
(liftIO . unlockFile)
(\lk -> do
when chatter $
liftIO $ hPutStrLn stderr "Lock acquired, proceeding."
act $ Just lk))
else act Nothing | 1,707 | withUserFileLock go@GlobalOpts{} dir act = do
env <- liftIO getEnvironment
let toLock = lookup "STACK_LOCK" env == Just "true"
if toLock
then do
let lockfile = $(mkRelFile "lockfile")
let pth = dir </> lockfile
ensureDir dir
-- Just in case of asynchronous exceptions, we need to be careful
-- when using tryLockFile here:
EL.bracket (liftIO $ tryLockFile (toFilePath pth) Exclusive)
(maybe (return ()) (liftIO . unlockFile))
(\fstTry ->
case fstTry of
Just lk -> EL.finally (act $ Just lk) (liftIO $ unlockFile lk)
Nothing ->
do let chatter = globalLogLevel go /= LevelOther "silent"
when chatter $
liftIO $ hPutStrLn stderr $ "Failed to grab lock ("++show pth++
"); other stack instance running. Waiting..."
EL.bracket (liftIO $ lockFile (toFilePath pth) Exclusive)
(liftIO . unlockFile)
(\lk -> do
when chatter $
liftIO $ hPutStrLn stderr "Lock acquired, proceeding."
act $ Just lk))
else act Nothing | 1,520 | false | true | 31 | 9 | 850 | 360 | 186 | 174 | null | null |
ewestern/geos | tests/Data/Geometry/Geos/SerializeSpec.hs | mit | multiLineStringWKB = "0105000020C46E000001000000010200000004000000EE2DE25E859A20410829F224364B5A41BD757FB6679A204115C6D8E9304B5A4177111862469A2041A03F04E32C4B5A41BC1D3ADD459A2041793C8CD92C4B5A41" :: BS.ByteString | 212 | multiLineStringWKB = "0105000020C46E000001000000010200000004000000EE2DE25E859A20410829F224364B5A41BD757FB6679A204115C6D8E9304B5A4177111862469A2041A03F04E32C4B5A41BC1D3ADD459A2041793C8CD92C4B5A41" :: BS.ByteString | 212 | multiLineStringWKB = "0105000020C46E000001000000010200000004000000EE2DE25E859A20410829F224364B5A41BD757FB6679A204115C6D8E9304B5A4177111862469A2041A03F04E32C4B5A41BC1D3ADD459A2041793C8CD92C4B5A41" :: BS.ByteString | 212 | false | false | 0 | 5 | 4 | 11 | 6 | 5 | null | null |
Javran/Project-Euler | src/ProjectEuler/Problem68.hs | mit | solutions :: StateT [Int] [] [Int]
solutions = do
outer@[a1,a2,a3,a4,a5] <- replicateM 5 pickOne'
guard $ 10 `elem` outer
b1 <- pickOne'
b2 <- pickOne'
let correctSum = guard . (== a1 + b1 + b2)
b3 <- pickOne'
correctSum $ a2 + b2 + b3
b4 <- pickOne'
correctSum $ a3 + b3 + b4
b5 <- pickOne'
correctSum $ a4 + b4 + b5
correctSum $ a5 + b5 + b1
return $ encodeResult [[a1,b1,b2]
,[a2,b2,b3]
,[a3,b3,b4]
,[a4,b4,b5]
,[a5,b5,b1]
]
where
-- clockwise, lowest external node
encodeResult arms = head [ concat enc
| enc@(firstArm:restArms) <- pickOne arms
, all ((> head firstArm) . head) restArms
] | 871 | solutions :: StateT [Int] [] [Int]
solutions = do
outer@[a1,a2,a3,a4,a5] <- replicateM 5 pickOne'
guard $ 10 `elem` outer
b1 <- pickOne'
b2 <- pickOne'
let correctSum = guard . (== a1 + b1 + b2)
b3 <- pickOne'
correctSum $ a2 + b2 + b3
b4 <- pickOne'
correctSum $ a3 + b3 + b4
b5 <- pickOne'
correctSum $ a4 + b4 + b5
correctSum $ a5 + b5 + b1
return $ encodeResult [[a1,b1,b2]
,[a2,b2,b3]
,[a3,b3,b4]
,[a4,b4,b5]
,[a5,b5,b1]
]
where
-- clockwise, lowest external node
encodeResult arms = head [ concat enc
| enc@(firstArm:restArms) <- pickOne arms
, all ((> head firstArm) . head) restArms
] | 871 | solutions = do
outer@[a1,a2,a3,a4,a5] <- replicateM 5 pickOne'
guard $ 10 `elem` outer
b1 <- pickOne'
b2 <- pickOne'
let correctSum = guard . (== a1 + b1 + b2)
b3 <- pickOne'
correctSum $ a2 + b2 + b3
b4 <- pickOne'
correctSum $ a3 + b3 + b4
b5 <- pickOne'
correctSum $ a4 + b4 + b5
correctSum $ a5 + b5 + b1
return $ encodeResult [[a1,b1,b2]
,[a2,b2,b3]
,[a3,b3,b4]
,[a4,b4,b5]
,[a5,b5,b1]
]
where
-- clockwise, lowest external node
encodeResult arms = head [ concat enc
| enc@(firstArm:restArms) <- pickOne arms
, all ((> head firstArm) . head) restArms
] | 836 | false | true | 1 | 13 | 387 | 333 | 172 | 161 | null | null |
mrkkrp/stack | src/Stack/Docker.hs | bsd-3-clause | runContainerAndExit :: (StackM env m, HasConfig env)
=> GetCmdArgs env m
-> Maybe (Path Abs Dir) -- ^ Project root (maybe)
-> m () -- ^ Action to run before
-> m () -- ^ Action to run after
-> m ()
runContainerAndExit getCmdArgs
mprojectRoot
before
after =
do config <- view configL
let docker = configDocker config
envOverride <- getEnvOverride (configPlatform config)
checkDockerVersion envOverride docker
(env,isStdinTerminal,isStderrTerminal,homeDir) <- liftIO $
(,,,)
<$> getEnvironment
<*> hIsTerminalDevice stdin
<*> hIsTerminalDevice stderr
<*> (parseAbsDir =<< getHomeDirectory)
isStdoutTerminal <- view terminalL
let dockerHost = lookup "DOCKER_HOST" env
dockerCertPath = lookup "DOCKER_CERT_PATH" env
bamboo = lookup "bamboo_buildKey" env
jenkins = lookup "JENKINS_HOME" env
msshAuthSock = lookup "SSH_AUTH_SOCK" env
muserEnv = lookup "USER" env
isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
image = dockerImage docker
when (isRemoteDocker &&
maybe False (isInfixOf "boot2docker") dockerCertPath)
($logWarn "Warning: Using boot2docker is NOT supported, and not likely to perform well.")
maybeImageInfo <- inspect envOverride image
imageInfo@Inspect{..} <- case maybeImageInfo of
Just ii -> return ii
Nothing
| dockerAutoPull docker ->
do pullImage envOverride docker image
mii2 <- inspect envOverride image
case mii2 of
Just ii2 -> return ii2
Nothing -> throwM (InspectFailedException image)
| otherwise -> throwM (NotPulledException image)
sandboxDir <- projectDockerSandboxDir projectRoot
let ImageConfig {..} = iiConfig
imageEnvVars = map (break (== '=')) icEnv
platformVariant = show $ hashRepoName image
stackRoot = configStackRoot config
sandboxHomeDir = sandboxDir </> homeDirName
isTerm = not (dockerDetach docker) &&
isStdinTerminal &&
isStdoutTerminal &&
isStderrTerminal
keepStdinOpen = not (dockerDetach docker) &&
-- Workaround for https://github.com/docker/docker/issues/12319
-- This is fixed in Docker 1.9.1, but will leave the workaround
-- in place for now, for users who haven't upgraded yet.
(isTerm || (isNothing bamboo && isNothing jenkins))
hostBinDirPath <- parseAbsDir hostBinDir
newPathEnv <- augmentPath
[ hostBinDirPath
, sandboxHomeDir </> $(mkRelDir ".local/bin")]
(T.pack <$> lookupImageEnv "PATH" imageEnvVars)
(cmnd,args,envVars,extraMount) <- getCmdArgs docker envOverride imageInfo isRemoteDocker
pwd <- getCurrentDir
liftIO
(do updateDockerImageLastUsed config iiId (toFilePath projectRoot)
mapM_ ensureDir [sandboxHomeDir, stackRoot])
-- Since $HOME is now mounted in the same place in the container we can
-- just symlink $HOME/.ssh to the right place for the stack docker user
let sshDir = homeDir </> sshRelDir
sshDirExists <- doesDirExist sshDir
sshSandboxDirExists <-
liftIO
(Files.fileExist
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
when (sshDirExists && not sshSandboxDirExists)
(liftIO
(Files.createSymbolicLink
(toFilePathNoTrailingSep sshDir)
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir))))
containerID <- (trim . decodeUtf8) <$> readDockerProcess
envOverride
(Just projectRoot)
(concat
[["create"
,"--net=host"
,"-e",inContainerEnvVar ++ "=1"
,"-e",stackRootEnvVar ++ "=" ++ toFilePathNoTrailingSep stackRoot
,"-e",platformVariantEnvVar ++ "=dk" ++ platformVariant
,"-e","HOME=" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-e","PATH=" ++ T.unpack newPathEnv
,"-e","PWD=" ++ toFilePathNoTrailingSep pwd
,"-v",toFilePathNoTrailingSep homeDir ++ ":" ++ toFilePathNoTrailingSep homeDir
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toFilePathNoTrailingSep stackRoot
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-w",toFilePathNoTrailingSep pwd]
,case muserEnv of
Nothing -> []
Just userEnv -> ["-e","USER=" ++ userEnv]
,case msshAuthSock of
Nothing -> []
Just sshAuthSock ->
["-e","SSH_AUTH_SOCK=" ++ sshAuthSock
,"-v",sshAuthSock ++ ":" ++ sshAuthSock]
-- Disable the deprecated entrypoint in FP Complete-generated images
,["--entrypoint=/usr/bin/env"
| isJust (lookupImageEnv oldSandboxIdEnvVar imageEnvVars) &&
(icEntrypoint == ["/usr/local/sbin/docker-entrypoint"] ||
icEntrypoint == ["/root/entrypoint.sh"])]
,concatMap (\(k,v) -> ["-e", k ++ "=" ++ v]) envVars
,concatMap mountArg (extraMount ++ dockerMount docker)
,concatMap (\nv -> ["-e", nv]) (dockerEnv docker)
,case dockerContainerName docker of
Just name -> ["--name=" ++ name]
Nothing -> []
,["-t" | isTerm]
,["-i" | keepStdinOpen]
,dockerRunArgs docker
,[image]
,[cmnd]
,args])
before
#ifndef WINDOWS
runInBase <- Control.liftBaseWith $ \run -> return (void . run)
oldHandlers <- forM [sigINT,sigABRT,sigHUP,sigPIPE,sigTERM,sigUSR1,sigUSR2] $ \sig -> do
let sigHandler = runInBase $ do
readProcessNull Nothing envOverride "docker"
["kill","--signal=" ++ show sig,containerID]
when (sig `elem` [sigTERM,sigABRT]) $ do
-- Give the container 30 seconds to exit gracefully, then send a sigKILL to force it
liftIO $ threadDelay 30000000
readProcessNull Nothing envOverride "docker" ["kill",containerID]
oldHandler <- liftIO $ installHandler sig (Catch sigHandler) Nothing
return (sig, oldHandler)
#endif
let cmd = Cmd Nothing
"docker"
envOverride
(concat [["start"]
,["-a" | not (dockerDetach docker)]
,["-i" | keepStdinOpen]
,[containerID]])
e <- finally
(try $ callProcess'
(\cp -> cp { delegate_ctlc = False })
cmd)
(do unless (dockerPersist docker || dockerDetach docker) $
catch
(readProcessNull Nothing envOverride "docker" ["rm","-f",containerID])
(\(_::ReadProcessException) -> return ())
#ifndef WINDOWS
forM_ oldHandlers $ \(sig,oldHandler) ->
liftIO $ installHandler sig oldHandler Nothing
#endif
)
case e of
Left (ProcessExitedUnsuccessfully _ ec) -> liftIO (exitWith ec)
Right () -> do after
liftIO exitSuccess
where
-- This is using a hash of the Docker repository (without tag or digest) to ensure
-- binaries/libraries aren't shared between Docker and host (or incompatible Docker images)
hashRepoName :: String -> Hash.Digest Hash.MD5
hashRepoName = Hash.hash . BS.pack . takeWhile (\c -> c /= ':' && c /= '@')
lookupImageEnv name vars =
case lookup name vars of
Just ('=':val) -> Just val
_ -> Nothing
mountArg (Mount host container) = ["-v",host ++ ":" ++ container]
projectRoot = fromMaybeProjectRoot mprojectRoot
sshRelDir = $(mkRelDir ".ssh/")
-- | Clean-up old docker images and containers. | 8,168 | runContainerAndExit :: (StackM env m, HasConfig env)
=> GetCmdArgs env m
-> Maybe (Path Abs Dir) -- ^ Project root (maybe)
-> m () -- ^ Action to run before
-> m () -- ^ Action to run after
-> m ()
runContainerAndExit getCmdArgs
mprojectRoot
before
after =
do config <- view configL
let docker = configDocker config
envOverride <- getEnvOverride (configPlatform config)
checkDockerVersion envOverride docker
(env,isStdinTerminal,isStderrTerminal,homeDir) <- liftIO $
(,,,)
<$> getEnvironment
<*> hIsTerminalDevice stdin
<*> hIsTerminalDevice stderr
<*> (parseAbsDir =<< getHomeDirectory)
isStdoutTerminal <- view terminalL
let dockerHost = lookup "DOCKER_HOST" env
dockerCertPath = lookup "DOCKER_CERT_PATH" env
bamboo = lookup "bamboo_buildKey" env
jenkins = lookup "JENKINS_HOME" env
msshAuthSock = lookup "SSH_AUTH_SOCK" env
muserEnv = lookup "USER" env
isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
image = dockerImage docker
when (isRemoteDocker &&
maybe False (isInfixOf "boot2docker") dockerCertPath)
($logWarn "Warning: Using boot2docker is NOT supported, and not likely to perform well.")
maybeImageInfo <- inspect envOverride image
imageInfo@Inspect{..} <- case maybeImageInfo of
Just ii -> return ii
Nothing
| dockerAutoPull docker ->
do pullImage envOverride docker image
mii2 <- inspect envOverride image
case mii2 of
Just ii2 -> return ii2
Nothing -> throwM (InspectFailedException image)
| otherwise -> throwM (NotPulledException image)
sandboxDir <- projectDockerSandboxDir projectRoot
let ImageConfig {..} = iiConfig
imageEnvVars = map (break (== '=')) icEnv
platformVariant = show $ hashRepoName image
stackRoot = configStackRoot config
sandboxHomeDir = sandboxDir </> homeDirName
isTerm = not (dockerDetach docker) &&
isStdinTerminal &&
isStdoutTerminal &&
isStderrTerminal
keepStdinOpen = not (dockerDetach docker) &&
-- Workaround for https://github.com/docker/docker/issues/12319
-- This is fixed in Docker 1.9.1, but will leave the workaround
-- in place for now, for users who haven't upgraded yet.
(isTerm || (isNothing bamboo && isNothing jenkins))
hostBinDirPath <- parseAbsDir hostBinDir
newPathEnv <- augmentPath
[ hostBinDirPath
, sandboxHomeDir </> $(mkRelDir ".local/bin")]
(T.pack <$> lookupImageEnv "PATH" imageEnvVars)
(cmnd,args,envVars,extraMount) <- getCmdArgs docker envOverride imageInfo isRemoteDocker
pwd <- getCurrentDir
liftIO
(do updateDockerImageLastUsed config iiId (toFilePath projectRoot)
mapM_ ensureDir [sandboxHomeDir, stackRoot])
-- Since $HOME is now mounted in the same place in the container we can
-- just symlink $HOME/.ssh to the right place for the stack docker user
let sshDir = homeDir </> sshRelDir
sshDirExists <- doesDirExist sshDir
sshSandboxDirExists <-
liftIO
(Files.fileExist
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
when (sshDirExists && not sshSandboxDirExists)
(liftIO
(Files.createSymbolicLink
(toFilePathNoTrailingSep sshDir)
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir))))
containerID <- (trim . decodeUtf8) <$> readDockerProcess
envOverride
(Just projectRoot)
(concat
[["create"
,"--net=host"
,"-e",inContainerEnvVar ++ "=1"
,"-e",stackRootEnvVar ++ "=" ++ toFilePathNoTrailingSep stackRoot
,"-e",platformVariantEnvVar ++ "=dk" ++ platformVariant
,"-e","HOME=" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-e","PATH=" ++ T.unpack newPathEnv
,"-e","PWD=" ++ toFilePathNoTrailingSep pwd
,"-v",toFilePathNoTrailingSep homeDir ++ ":" ++ toFilePathNoTrailingSep homeDir
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toFilePathNoTrailingSep stackRoot
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-w",toFilePathNoTrailingSep pwd]
,case muserEnv of
Nothing -> []
Just userEnv -> ["-e","USER=" ++ userEnv]
,case msshAuthSock of
Nothing -> []
Just sshAuthSock ->
["-e","SSH_AUTH_SOCK=" ++ sshAuthSock
,"-v",sshAuthSock ++ ":" ++ sshAuthSock]
-- Disable the deprecated entrypoint in FP Complete-generated images
,["--entrypoint=/usr/bin/env"
| isJust (lookupImageEnv oldSandboxIdEnvVar imageEnvVars) &&
(icEntrypoint == ["/usr/local/sbin/docker-entrypoint"] ||
icEntrypoint == ["/root/entrypoint.sh"])]
,concatMap (\(k,v) -> ["-e", k ++ "=" ++ v]) envVars
,concatMap mountArg (extraMount ++ dockerMount docker)
,concatMap (\nv -> ["-e", nv]) (dockerEnv docker)
,case dockerContainerName docker of
Just name -> ["--name=" ++ name]
Nothing -> []
,["-t" | isTerm]
,["-i" | keepStdinOpen]
,dockerRunArgs docker
,[image]
,[cmnd]
,args])
before
#ifndef WINDOWS
runInBase <- Control.liftBaseWith $ \run -> return (void . run)
oldHandlers <- forM [sigINT,sigABRT,sigHUP,sigPIPE,sigTERM,sigUSR1,sigUSR2] $ \sig -> do
let sigHandler = runInBase $ do
readProcessNull Nothing envOverride "docker"
["kill","--signal=" ++ show sig,containerID]
when (sig `elem` [sigTERM,sigABRT]) $ do
-- Give the container 30 seconds to exit gracefully, then send a sigKILL to force it
liftIO $ threadDelay 30000000
readProcessNull Nothing envOverride "docker" ["kill",containerID]
oldHandler <- liftIO $ installHandler sig (Catch sigHandler) Nothing
return (sig, oldHandler)
#endif
let cmd = Cmd Nothing
"docker"
envOverride
(concat [["start"]
,["-a" | not (dockerDetach docker)]
,["-i" | keepStdinOpen]
,[containerID]])
e <- finally
(try $ callProcess'
(\cp -> cp { delegate_ctlc = False })
cmd)
(do unless (dockerPersist docker || dockerDetach docker) $
catch
(readProcessNull Nothing envOverride "docker" ["rm","-f",containerID])
(\(_::ReadProcessException) -> return ())
#ifndef WINDOWS
forM_ oldHandlers $ \(sig,oldHandler) ->
liftIO $ installHandler sig oldHandler Nothing
#endif
)
case e of
Left (ProcessExitedUnsuccessfully _ ec) -> liftIO (exitWith ec)
Right () -> do after
liftIO exitSuccess
where
-- This is using a hash of the Docker repository (without tag or digest) to ensure
-- binaries/libraries aren't shared between Docker and host (or incompatible Docker images)
hashRepoName :: String -> Hash.Digest Hash.MD5
hashRepoName = Hash.hash . BS.pack . takeWhile (\c -> c /= ':' && c /= '@')
lookupImageEnv name vars =
case lookup name vars of
Just ('=':val) -> Just val
_ -> Nothing
mountArg (Mount host container) = ["-v",host ++ ":" ++ container]
projectRoot = fromMaybeProjectRoot mprojectRoot
sshRelDir = $(mkRelDir ".ssh/")
-- | Clean-up old docker images and containers. | 8,168 | runContainerAndExit getCmdArgs
mprojectRoot
before
after =
do config <- view configL
let docker = configDocker config
envOverride <- getEnvOverride (configPlatform config)
checkDockerVersion envOverride docker
(env,isStdinTerminal,isStderrTerminal,homeDir) <- liftIO $
(,,,)
<$> getEnvironment
<*> hIsTerminalDevice stdin
<*> hIsTerminalDevice stderr
<*> (parseAbsDir =<< getHomeDirectory)
isStdoutTerminal <- view terminalL
let dockerHost = lookup "DOCKER_HOST" env
dockerCertPath = lookup "DOCKER_CERT_PATH" env
bamboo = lookup "bamboo_buildKey" env
jenkins = lookup "JENKINS_HOME" env
msshAuthSock = lookup "SSH_AUTH_SOCK" env
muserEnv = lookup "USER" env
isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
image = dockerImage docker
when (isRemoteDocker &&
maybe False (isInfixOf "boot2docker") dockerCertPath)
($logWarn "Warning: Using boot2docker is NOT supported, and not likely to perform well.")
maybeImageInfo <- inspect envOverride image
imageInfo@Inspect{..} <- case maybeImageInfo of
Just ii -> return ii
Nothing
| dockerAutoPull docker ->
do pullImage envOverride docker image
mii2 <- inspect envOverride image
case mii2 of
Just ii2 -> return ii2
Nothing -> throwM (InspectFailedException image)
| otherwise -> throwM (NotPulledException image)
sandboxDir <- projectDockerSandboxDir projectRoot
let ImageConfig {..} = iiConfig
imageEnvVars = map (break (== '=')) icEnv
platformVariant = show $ hashRepoName image
stackRoot = configStackRoot config
sandboxHomeDir = sandboxDir </> homeDirName
isTerm = not (dockerDetach docker) &&
isStdinTerminal &&
isStdoutTerminal &&
isStderrTerminal
keepStdinOpen = not (dockerDetach docker) &&
-- Workaround for https://github.com/docker/docker/issues/12319
-- This is fixed in Docker 1.9.1, but will leave the workaround
-- in place for now, for users who haven't upgraded yet.
(isTerm || (isNothing bamboo && isNothing jenkins))
hostBinDirPath <- parseAbsDir hostBinDir
newPathEnv <- augmentPath
[ hostBinDirPath
, sandboxHomeDir </> $(mkRelDir ".local/bin")]
(T.pack <$> lookupImageEnv "PATH" imageEnvVars)
(cmnd,args,envVars,extraMount) <- getCmdArgs docker envOverride imageInfo isRemoteDocker
pwd <- getCurrentDir
liftIO
(do updateDockerImageLastUsed config iiId (toFilePath projectRoot)
mapM_ ensureDir [sandboxHomeDir, stackRoot])
-- Since $HOME is now mounted in the same place in the container we can
-- just symlink $HOME/.ssh to the right place for the stack docker user
let sshDir = homeDir </> sshRelDir
sshDirExists <- doesDirExist sshDir
sshSandboxDirExists <-
liftIO
(Files.fileExist
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
when (sshDirExists && not sshSandboxDirExists)
(liftIO
(Files.createSymbolicLink
(toFilePathNoTrailingSep sshDir)
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir))))
containerID <- (trim . decodeUtf8) <$> readDockerProcess
envOverride
(Just projectRoot)
(concat
[["create"
,"--net=host"
,"-e",inContainerEnvVar ++ "=1"
,"-e",stackRootEnvVar ++ "=" ++ toFilePathNoTrailingSep stackRoot
,"-e",platformVariantEnvVar ++ "=dk" ++ platformVariant
,"-e","HOME=" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-e","PATH=" ++ T.unpack newPathEnv
,"-e","PWD=" ++ toFilePathNoTrailingSep pwd
,"-v",toFilePathNoTrailingSep homeDir ++ ":" ++ toFilePathNoTrailingSep homeDir
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toFilePathNoTrailingSep stackRoot
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-w",toFilePathNoTrailingSep pwd]
,case muserEnv of
Nothing -> []
Just userEnv -> ["-e","USER=" ++ userEnv]
,case msshAuthSock of
Nothing -> []
Just sshAuthSock ->
["-e","SSH_AUTH_SOCK=" ++ sshAuthSock
,"-v",sshAuthSock ++ ":" ++ sshAuthSock]
-- Disable the deprecated entrypoint in FP Complete-generated images
,["--entrypoint=/usr/bin/env"
| isJust (lookupImageEnv oldSandboxIdEnvVar imageEnvVars) &&
(icEntrypoint == ["/usr/local/sbin/docker-entrypoint"] ||
icEntrypoint == ["/root/entrypoint.sh"])]
,concatMap (\(k,v) -> ["-e", k ++ "=" ++ v]) envVars
,concatMap mountArg (extraMount ++ dockerMount docker)
,concatMap (\nv -> ["-e", nv]) (dockerEnv docker)
,case dockerContainerName docker of
Just name -> ["--name=" ++ name]
Nothing -> []
,["-t" | isTerm]
,["-i" | keepStdinOpen]
,dockerRunArgs docker
,[image]
,[cmnd]
,args])
before
#ifndef WINDOWS
runInBase <- Control.liftBaseWith $ \run -> return (void . run)
oldHandlers <- forM [sigINT,sigABRT,sigHUP,sigPIPE,sigTERM,sigUSR1,sigUSR2] $ \sig -> do
let sigHandler = runInBase $ do
readProcessNull Nothing envOverride "docker"
["kill","--signal=" ++ show sig,containerID]
when (sig `elem` [sigTERM,sigABRT]) $ do
-- Give the container 30 seconds to exit gracefully, then send a sigKILL to force it
liftIO $ threadDelay 30000000
readProcessNull Nothing envOverride "docker" ["kill",containerID]
oldHandler <- liftIO $ installHandler sig (Catch sigHandler) Nothing
return (sig, oldHandler)
#endif
let cmd = Cmd Nothing
"docker"
envOverride
(concat [["start"]
,["-a" | not (dockerDetach docker)]
,["-i" | keepStdinOpen]
,[containerID]])
e <- finally
(try $ callProcess'
(\cp -> cp { delegate_ctlc = False })
cmd)
(do unless (dockerPersist docker || dockerDetach docker) $
catch
(readProcessNull Nothing envOverride "docker" ["rm","-f",containerID])
(\(_::ReadProcessException) -> return ())
#ifndef WINDOWS
forM_ oldHandlers $ \(sig,oldHandler) ->
liftIO $ installHandler sig oldHandler Nothing
#endif
)
case e of
Left (ProcessExitedUnsuccessfully _ ec) -> liftIO (exitWith ec)
Right () -> do after
liftIO exitSuccess
where
-- This is using a hash of the Docker repository (without tag or digest) to ensure
-- binaries/libraries aren't shared between Docker and host (or incompatible Docker images)
hashRepoName :: String -> Hash.Digest Hash.MD5
hashRepoName = Hash.hash . BS.pack . takeWhile (\c -> c /= ':' && c /= '@')
lookupImageEnv name vars =
case lookup name vars of
Just ('=':val) -> Just val
_ -> Nothing
mountArg (Mount host container) = ["-v",host ++ ":" ++ container]
projectRoot = fromMaybeProjectRoot mprojectRoot
sshRelDir = $(mkRelDir ".ssh/")
-- | Clean-up old docker images and containers. | 7,934 | false | true | 7 | 22 | 2,559 | 1,968 | 994 | 974 | null | null |
GaloisInc/halvm-ghc | compiler/deSugar/Coverage.hs | bsd-3-clause | isGoodBreakExpr (HsAppTypeOut {}) = True | 40 | isGoodBreakExpr (HsAppTypeOut {}) = True | 40 | isGoodBreakExpr (HsAppTypeOut {}) = True | 40 | false | false | 0 | 7 | 4 | 16 | 8 | 8 | null | null |
sgillespie/ghc | testsuite/tests/deriving/should_run/drvrun006.hs | bsd-3-clause | val2 :: Tree Int
val2 = Leaf 2 :^: Leaf (-1) | 44 | val2 :: Tree Int
val2 = Leaf 2 :^: Leaf (-1) | 44 | val2 = Leaf 2 :^: Leaf (-1) | 27 | false | true | 0 | 8 | 10 | 29 | 14 | 15 | null | null |
thomie/vector | Data/Vector/Fusion/Stream/Monadic.hs | bsd-3-clause | enumFromTo_intlike x y = x `seq` y `seq` Stream step x
where
{-# INLINE_INNER step #-}
step z | z <= y = return $ Yield z (z+1)
| otherwise = return $ Done
| 181 | enumFromTo_intlike x y = x `seq` y `seq` Stream step x
where
{-# INLINE_INNER step #-}
step z | z <= y = return $ Yield z (z+1)
| otherwise = return $ Done
| 181 | enumFromTo_intlike x y = x `seq` y `seq` Stream step x
where
{-# INLINE_INNER step #-}
step z | z <= y = return $ Yield z (z+1)
| otherwise = return $ Done
| 181 | false | false | 1 | 9 | 59 | 91 | 42 | 49 | null | null |
peterson/lets-tree | src/Lets/RoseTree.hs | bsd-3-clause | --
-- sample
--
rt1 = singleton 1 | 34 | rt1 = singleton 1 | 17 | rt1 = singleton 1 | 17 | true | false | 1 | 5 | 8 | 15 | 7 | 8 | null | null |
brendanhay/gogol | gogol-run/gen/Network/Google/Resource/Run/Projects/Locations/Services/SetIAMPolicy.hs | mpl-2.0 | -- | V1 error format.
plssipXgafv :: Lens' ProjectsLocationsServicesSetIAMPolicy (Maybe Xgafv)
plssipXgafv
= lens _plssipXgafv (\ s a -> s{_plssipXgafv = a}) | 159 | plssipXgafv :: Lens' ProjectsLocationsServicesSetIAMPolicy (Maybe Xgafv)
plssipXgafv
= lens _plssipXgafv (\ s a -> s{_plssipXgafv = a}) | 137 | plssipXgafv
= lens _plssipXgafv (\ s a -> s{_plssipXgafv = a}) | 64 | true | true | 0 | 9 | 23 | 46 | 25 | 21 | null | null |
zepto-lang/zepto-js | src/Zepto/Parser.hs | gpl-2.0 | bin2digx digint (x:xs) = let old = 2 * digint + (if x == '0' then 0 else 1) in
bin2digx old xs | 122 | bin2digx digint (x:xs) = let old = 2 * digint + (if x == '0' then 0 else 1) in
bin2digx old xs | 122 | bin2digx digint (x:xs) = let old = 2 * digint + (if x == '0' then 0 else 1) in
bin2digx old xs | 122 | false | false | 0 | 12 | 50 | 58 | 29 | 29 | null | null |
davidsd/snaplet-liftajax | src/Snap/Snaplet/LiftAjax/Splice.hs | bsd-3-clause | jsonButton :: (HasAjax b, FromJSON a) =>
JExpr -> ButtonCallback b a -> Splice (Handler b b)
jsonButton j c = ajaxButton $ onClick $ callWithJson j c | 163 | jsonButton :: (HasAjax b, FromJSON a) =>
JExpr -> ButtonCallback b a -> Splice (Handler b b)
jsonButton j c = ajaxButton $ onClick $ callWithJson j c | 163 | jsonButton j c = ajaxButton $ onClick $ callWithJson j c | 56 | false | true | 0 | 10 | 41 | 68 | 33 | 35 | null | null |
deweyvm/starstats | src/StarStats/DB/Utils.hs | mit | assemble :: [(String, Int, Int)] -> [[(String, Int, Int)]]
assemble xs = groupBy (\(n, _, _) (m, _, _) -> n == m) xs | 117 | assemble :: [(String, Int, Int)] -> [[(String, Int, Int)]]
assemble xs = groupBy (\(n, _, _) (m, _, _) -> n == m) xs | 116 | assemble xs = groupBy (\(n, _, _) (m, _, _) -> n == m) xs | 57 | false | true | 0 | 8 | 24 | 82 | 49 | 33 | null | null |
facebookincubator/duckling | Duckling/AmountOfMoney/AR/Rules.hs | bsd-3-clause | ruleIntervalMin :: Rule
ruleIntervalMin = Rule
{ name = "at least/over/above/more than <amount-of-money>"
, pattern =
[ regex "فوق||[أا]كثر من|على ال[اأ]قل"
, Predicate isSimpleAmountOfMoney
]
, prod = \tokens -> case tokens of
(_:
Token AmountOfMoney AmountOfMoneyData {TAmountOfMoney.value = Just to, TAmountOfMoney.currency = c}:
_) -> Just . Token AmountOfMoney . withMin to $ currencyOnly c
_ -> Nothing
} | 456 | ruleIntervalMin :: Rule
ruleIntervalMin = Rule
{ name = "at least/over/above/more than <amount-of-money>"
, pattern =
[ regex "فوق||[أا]كثر من|على ال[اأ]قل"
, Predicate isSimpleAmountOfMoney
]
, prod = \tokens -> case tokens of
(_:
Token AmountOfMoney AmountOfMoneyData {TAmountOfMoney.value = Just to, TAmountOfMoney.currency = c}:
_) -> Just . Token AmountOfMoney . withMin to $ currencyOnly c
_ -> Nothing
} | 456 | ruleIntervalMin = Rule
{ name = "at least/over/above/more than <amount-of-money>"
, pattern =
[ regex "فوق||[أا]كثر من|على ال[اأ]قل"
, Predicate isSimpleAmountOfMoney
]
, prod = \tokens -> case tokens of
(_:
Token AmountOfMoney AmountOfMoneyData {TAmountOfMoney.value = Just to, TAmountOfMoney.currency = c}:
_) -> Just . Token AmountOfMoney . withMin to $ currencyOnly c
_ -> Nothing
} | 432 | false | true | 0 | 19 | 105 | 127 | 66 | 61 | null | null |
vladfi1/hs-misc | SimplePHOAS.hs | mit | showExp' (v:vs) (Lam f) = "(\\" ++ v ++ " -> " ++ showExp' vs (f v) ++ ")" | 74 | showExp' (v:vs) (Lam f) = "(\\" ++ v ++ " -> " ++ showExp' vs (f v) ++ ")" | 74 | showExp' (v:vs) (Lam f) = "(\\" ++ v ++ " -> " ++ showExp' vs (f v) ++ ")" | 74 | false | false | 0 | 9 | 18 | 51 | 25 | 26 | null | null |
edofic/effect-handlers | test/Examples/Exception.hs | mit | -------------------------------------------------------
prg1 = throw "something went wrong" | 92 | prg1 = throw "something went wrong" | 35 | prg1 = throw "something went wrong" | 35 | true | false | 0 | 5 | 7 | 10 | 5 | 5 | null | null |
leepike/copilot-language | src/Copilot/Language/Operators/Extern.hs | bsd-3-clause | externW8 :: String -> Maybe [Word8] -> Stream Word8
externW8 = extern | 71 | externW8 :: String -> Maybe [Word8] -> Stream Word8
externW8 = extern | 71 | externW8 = extern | 18 | false | true | 0 | 8 | 13 | 28 | 14 | 14 | null | null |
statusfailed/pp | Language/PP/Eval.hs | mit | genIO (Free (P m)) = m >>= (genIO . snd) | 40 | genIO (Free (P m)) = m >>= (genIO . snd) | 40 | genIO (Free (P m)) = m >>= (genIO . snd) | 40 | false | false | 0 | 9 | 9 | 32 | 16 | 16 | null | null |
scolobb/fgl | Data/Graph/Inductive/Example.hs | bsd-3-clause | clr528 = mkGraph [(1,'s'),(2,'u'),(3,'v'),(4,'x'),(5,'y')]
[(1,2,10),(1,4,5),(2,3,1),(2,4,2),(3,5,4),
(4,2,3),(4,3,9),(4,5,2),(5,1,7),(5,3,6)] | 177 | clr528 = mkGraph [(1,'s'),(2,'u'),(3,'v'),(4,'x'),(5,'y')]
[(1,2,10),(1,4,5),(2,3,1),(2,4,2),(3,5,4),
(4,2,3),(4,3,9),(4,5,2),(5,1,7),(5,3,6)] | 177 | clr528 = mkGraph [(1,'s'),(2,'u'),(3,'v'),(4,'x'),(5,'y')]
[(1,2,10),(1,4,5),(2,3,1),(2,4,2),(3,5,4),
(4,2,3),(4,3,9),(4,5,2),(5,1,7),(5,3,6)] | 177 | false | false | 1 | 6 | 40 | 180 | 115 | 65 | null | null |
dysinger/amazonka | amazonka-cloudtrail/gen/Network/AWS/CloudTrail/UpdateTrail.hs | mpl-2.0 | -- | Specifies whether the trail is publishing events from global services such as
-- IAM to the log files.
utrIncludeGlobalServiceEvents :: Lens' UpdateTrailResponse (Maybe Bool)
utrIncludeGlobalServiceEvents =
lens _utrIncludeGlobalServiceEvents
(\s a -> s { _utrIncludeGlobalServiceEvents = a }) | 310 | utrIncludeGlobalServiceEvents :: Lens' UpdateTrailResponse (Maybe Bool)
utrIncludeGlobalServiceEvents =
lens _utrIncludeGlobalServiceEvents
(\s a -> s { _utrIncludeGlobalServiceEvents = a }) | 202 | utrIncludeGlobalServiceEvents =
lens _utrIncludeGlobalServiceEvents
(\s a -> s { _utrIncludeGlobalServiceEvents = a }) | 130 | true | true | 0 | 8 | 50 | 48 | 26 | 22 | null | null |
pniedzielski/fowlie-mga | src/Main.hs | gpl-3.0 | nullToNothing x = Just x | 25 | nullToNothing x = Just x | 25 | nullToNothing x = Just x | 25 | false | false | 0 | 5 | 5 | 12 | 5 | 7 | null | null |
tcoenraad/functioneel-programmeren | practica/serie3/8.balance-tree.hs | mit | depth Leaf1c = 1 | 16 | depth Leaf1c = 1 | 16 | depth Leaf1c = 1 | 16 | false | false | 0 | 4 | 3 | 10 | 4 | 6 | null | null |
oldmanmike/ghc | compiler/types/Coercion.hs | bsd-3-clause | ppr_co p co@(TransCo {}) = maybeParen p FunPrec $
case trans_co_list co [] of
[] -> panic "ppr_co"
(co:cos) -> sep ( ppr_co FunPrec co
: [ char ';' <+> ppr_co FunPrec co | co <- cos]) | 313 | ppr_co p co@(TransCo {}) = maybeParen p FunPrec $
case trans_co_list co [] of
[] -> panic "ppr_co"
(co:cos) -> sep ( ppr_co FunPrec co
: [ char ';' <+> ppr_co FunPrec co | co <- cos]) | 313 | ppr_co p co@(TransCo {}) = maybeParen p FunPrec $
case trans_co_list co [] of
[] -> panic "ppr_co"
(co:cos) -> sep ( ppr_co FunPrec co
: [ char ';' <+> ppr_co FunPrec co | co <- cos]) | 313 | false | false | 0 | 14 | 166 | 103 | 50 | 53 | null | null |
suhailshergill/liboleg | Control/CCRef.hs | bsd-3-clause | testls0 = (expect [] =<<) . runCC $ do
p <- newPrompt
pushPrompt p (
(return . ("a":)) =<<
(pushPrompt p (shift0P p (\_ -> (shift0P p (\_ -> return [])))))) | 182 | testls0 = (expect [] =<<) . runCC $ do
p <- newPrompt
pushPrompt p (
(return . ("a":)) =<<
(pushPrompt p (shift0P p (\_ -> (shift0P p (\_ -> return [])))))) | 182 | testls0 = (expect [] =<<) . runCC $ do
p <- newPrompt
pushPrompt p (
(return . ("a":)) =<<
(pushPrompt p (shift0P p (\_ -> (shift0P p (\_ -> return [])))))) | 182 | false | false | 4 | 22 | 56 | 107 | 53 | 54 | null | null |
ambiata/tatooine-cli | src/Ambiata/Cli/Env.hs | apache-2.0 | runmode :: Bool -> RunMode
runmode True = OneShot | 49 | runmode :: Bool -> RunMode
runmode True = OneShot | 49 | runmode True = OneShot | 22 | false | true | 0 | 5 | 8 | 18 | 9 | 9 | null | null |
tpsinnem/Idris-dev | src/IRTS/CodegenC.hs | bsd-3-clause | gccDbg _ = "-O2" | 16 | gccDbg _ = "-O2" | 16 | gccDbg _ = "-O2" | 16 | false | false | 0 | 4 | 3 | 10 | 4 | 6 | null | null |
Persi/shellcheck | ShellCheck/Parser.hs | gpl-3.0 | readConditionContents single =
readCondContents `attempting` lookAhead (do
pos <- getPosition
s <- many1 letter
when (s `elem` commonCommands) $
parseProblemAt pos WarningC 1009 "Use 'if cmd; then ..' to check exit code, or 'if [[ $(cmd) == .. ]]' to check output.")
where
spacingOrLf = condSpacing True
condSpacing required = do
pos <- getPosition
space <- allspacing
when (required && null space) $
parseProblemAt pos ErrorC 1035 "You are missing a required space here."
when (single && '\n' `elem` space) $
parseProblemAt pos ErrorC 1080 "When breaking lines in [ ], you need \\ before the linefeed."
return space
typ = if single then SingleBracket else DoubleBracket
readCondBinaryOp = try $ do
optional guardArithmetic
id <- getNextId
op <- choice (map tryOp ["==", "!=", "<=", ">=", "=~", ">", "<", "=", "\\<=", "\\>=", "\\<", "\\>"]) <|> otherOp
spacingOrLf
return op
where
tryOp s = try $ do
id <- getNextId
string s
return $ TC_Binary id typ s
otherOp = try $ do
id <- getNextId
s <- readOp
when (s == "-a" || s == "-o") $ fail "Unexpected operator"
return $ TC_Binary id typ s
guardArithmetic = do
try . lookAhead $ disregard (oneOf "+*/%") <|> disregard (string "- ")
parseProblem ErrorC 1076 $
if single
then "Trying to do math? Use e.g. [ $((i/2+7)) -ge 18 ]."
else "Trying to do math? Use e.g. [[ $((i/2+7)) -ge 18 ]]."
readCondUnaryExp = do
op <- readCondUnaryOp
pos <- getPosition
(readCondWord >>= return . op) `orFail` do
parseProblemAt pos ErrorC 1019 "Expected this to be an argument to the unary condition."
return "Expected an argument for the unary operator"
readCondUnaryOp = try $ do
id <- getNextId
s <- readOp
spacingOrLf
return $ TC_Unary id typ s
readOp = try $ do
char '-'
s <- many1 letter
return ('-':s)
readCondWord = do
notFollowedBy2 (try (spacing >> string "]"))
x <- readNormalWord
pos <- getPosition
when (endedWith "]" x) $ do
parseProblemAt pos ErrorC 1020 $
"You need a space before the " ++ (if single then "]" else "]]") ++ "."
fail "Missing space before ]"
when (single && endedWith ")" x) $ do
parseProblemAt pos ErrorC 1021
"You need a space before the \\)"
fail "Missing space before )"
disregard spacing
return x
where endedWith str (T_NormalWord id s@(_:_)) =
case last s of T_Literal id s -> str `isSuffixOf` s
_ -> False
endedWith _ _ = False
readCondAndOp = do
id <- getNextId
x <- try (readAndOrOp "&&" False <|> readAndOrOp "-a" True)
return $ TC_And id typ x
readCondOrOp = do
optional guardArithmetic
id <- getNextId
x <- try (readAndOrOp "||" False <|> readAndOrOp "-o" True)
return $ TC_Or id typ x
readAndOrOp op requiresSpacing = do
x <- string op
condSpacing requiresSpacing
return x
readCondNoaryOrBinary = do
id <- getNextId
x <- readCondWord `attempting` (do
pos <- getPosition
lookAhead (char '[')
parseProblemAt pos ErrorC 1026 $ if single
then "If grouping expressions inside [..], use \\( ..\\)."
else "If grouping expressions inside [[..]], use ( .. )."
)
(do
pos <- getPosition
isRegex <- regexOperatorAhead
op <- readCondBinaryOp
y <- if isRegex
then readRegex
else readCondWord <|> (parseProblemAt pos ErrorC 1027 "Expected another argument for this operator." >> mzero)
return (x `op` y)
) <|> return (TC_Noary id typ x)
readCondGroup = do
id <- getNextId
pos <- getPosition
lparen <- try $ string "(" <|> string "\\("
when (single && lparen == "(") $
parseProblemAt pos ErrorC 1028 "In [..] you have to escape (). Use [[..]] instead."
when (not single && lparen == "\\(") $
parseProblemAt pos ErrorC 1029 "In [[..]] you shouldn't escape ()."
condSpacing single
x <- readCondContents
cpos <- getPosition
rparen <- string ")" <|> string "\\)"
condSpacing single
when (single && rparen == ")") $
parseProblemAt cpos ErrorC 1030 "In [..] you have to escape (). Use [[..]] instead."
when (not single && rparen == "\\)") $
parseProblemAt cpos ErrorC 1031 "In [[..]] you shouldn't escape ()."
when (isEscaped lparen `xor` isEscaped rparen) $
parseProblemAt pos ErrorC 1032 "Did you just escape one half of () but not the other?"
return $ TC_Group id typ x
where
isEscaped ('\\':_) = True
isEscaped _ = False
xor x y = x && not y || not x && y
-- Currently a bit of a hack since parsing rules are obscure
regexOperatorAhead = lookAhead (do
try (string "=~") <|> try (string "~=")
return True)
<|> return False
readRegex = called "regex" $ do
id <- getNextId
parts <- many1 (
readGroup <|>
readSingleQuoted <|>
readDoubleQuoted <|>
readDollarExpression <|>
readNormalLiteral "( " <|>
readPipeLiteral <|>
readGlobLiteral)
disregard spacing
return $ T_NormalWord id parts
where
readGlobLiteral = do
id <- getNextId
s <- many1 (extglobStart <|> oneOf "{}[]$")
return $ T_Literal id s
readGroup = called "regex grouping" $ do
id <- getNextId
char '('
parts <- many (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollarExpression <|> readRegexLiteral <|> readGlobLiteral)
char ')'
return $ T_NormalWord id parts
readRegexLiteral = do
id <- getNextId
str <- readGenericLiteral1 (singleQuote <|> doubleQuotable <|> oneOf "()")
return $ T_Literal id str
readPipeLiteral = do
id <- getNextId
str <- string "|"
return $ T_Literal id str
readCondTerm = do
term <- readCondNot <|> readCondExpr
condSpacing False
return term
readCondNot = do
id <- getNextId
char '!'
spacingOrLf
expr <- readCondExpr
return $ TC_Unary id typ "!" expr
readCondExpr =
readCondGroup <|> readCondUnaryExp <|> readCondNoaryOrBinary
readCondOr = chainl1 readCondAnd readCondAndOp
readCondAnd = chainl1 readCondTerm readCondOrOp
readCondContents = readCondOr | 7,289 | readConditionContents single =
readCondContents `attempting` lookAhead (do
pos <- getPosition
s <- many1 letter
when (s `elem` commonCommands) $
parseProblemAt pos WarningC 1009 "Use 'if cmd; then ..' to check exit code, or 'if [[ $(cmd) == .. ]]' to check output.")
where
spacingOrLf = condSpacing True
condSpacing required = do
pos <- getPosition
space <- allspacing
when (required && null space) $
parseProblemAt pos ErrorC 1035 "You are missing a required space here."
when (single && '\n' `elem` space) $
parseProblemAt pos ErrorC 1080 "When breaking lines in [ ], you need \\ before the linefeed."
return space
typ = if single then SingleBracket else DoubleBracket
readCondBinaryOp = try $ do
optional guardArithmetic
id <- getNextId
op <- choice (map tryOp ["==", "!=", "<=", ">=", "=~", ">", "<", "=", "\\<=", "\\>=", "\\<", "\\>"]) <|> otherOp
spacingOrLf
return op
where
tryOp s = try $ do
id <- getNextId
string s
return $ TC_Binary id typ s
otherOp = try $ do
id <- getNextId
s <- readOp
when (s == "-a" || s == "-o") $ fail "Unexpected operator"
return $ TC_Binary id typ s
guardArithmetic = do
try . lookAhead $ disregard (oneOf "+*/%") <|> disregard (string "- ")
parseProblem ErrorC 1076 $
if single
then "Trying to do math? Use e.g. [ $((i/2+7)) -ge 18 ]."
else "Trying to do math? Use e.g. [[ $((i/2+7)) -ge 18 ]]."
readCondUnaryExp = do
op <- readCondUnaryOp
pos <- getPosition
(readCondWord >>= return . op) `orFail` do
parseProblemAt pos ErrorC 1019 "Expected this to be an argument to the unary condition."
return "Expected an argument for the unary operator"
readCondUnaryOp = try $ do
id <- getNextId
s <- readOp
spacingOrLf
return $ TC_Unary id typ s
readOp = try $ do
char '-'
s <- many1 letter
return ('-':s)
readCondWord = do
notFollowedBy2 (try (spacing >> string "]"))
x <- readNormalWord
pos <- getPosition
when (endedWith "]" x) $ do
parseProblemAt pos ErrorC 1020 $
"You need a space before the " ++ (if single then "]" else "]]") ++ "."
fail "Missing space before ]"
when (single && endedWith ")" x) $ do
parseProblemAt pos ErrorC 1021
"You need a space before the \\)"
fail "Missing space before )"
disregard spacing
return x
where endedWith str (T_NormalWord id s@(_:_)) =
case last s of T_Literal id s -> str `isSuffixOf` s
_ -> False
endedWith _ _ = False
readCondAndOp = do
id <- getNextId
x <- try (readAndOrOp "&&" False <|> readAndOrOp "-a" True)
return $ TC_And id typ x
readCondOrOp = do
optional guardArithmetic
id <- getNextId
x <- try (readAndOrOp "||" False <|> readAndOrOp "-o" True)
return $ TC_Or id typ x
readAndOrOp op requiresSpacing = do
x <- string op
condSpacing requiresSpacing
return x
readCondNoaryOrBinary = do
id <- getNextId
x <- readCondWord `attempting` (do
pos <- getPosition
lookAhead (char '[')
parseProblemAt pos ErrorC 1026 $ if single
then "If grouping expressions inside [..], use \\( ..\\)."
else "If grouping expressions inside [[..]], use ( .. )."
)
(do
pos <- getPosition
isRegex <- regexOperatorAhead
op <- readCondBinaryOp
y <- if isRegex
then readRegex
else readCondWord <|> (parseProblemAt pos ErrorC 1027 "Expected another argument for this operator." >> mzero)
return (x `op` y)
) <|> return (TC_Noary id typ x)
readCondGroup = do
id <- getNextId
pos <- getPosition
lparen <- try $ string "(" <|> string "\\("
when (single && lparen == "(") $
parseProblemAt pos ErrorC 1028 "In [..] you have to escape (). Use [[..]] instead."
when (not single && lparen == "\\(") $
parseProblemAt pos ErrorC 1029 "In [[..]] you shouldn't escape ()."
condSpacing single
x <- readCondContents
cpos <- getPosition
rparen <- string ")" <|> string "\\)"
condSpacing single
when (single && rparen == ")") $
parseProblemAt cpos ErrorC 1030 "In [..] you have to escape (). Use [[..]] instead."
when (not single && rparen == "\\)") $
parseProblemAt cpos ErrorC 1031 "In [[..]] you shouldn't escape ()."
when (isEscaped lparen `xor` isEscaped rparen) $
parseProblemAt pos ErrorC 1032 "Did you just escape one half of () but not the other?"
return $ TC_Group id typ x
where
isEscaped ('\\':_) = True
isEscaped _ = False
xor x y = x && not y || not x && y
-- Currently a bit of a hack since parsing rules are obscure
regexOperatorAhead = lookAhead (do
try (string "=~") <|> try (string "~=")
return True)
<|> return False
readRegex = called "regex" $ do
id <- getNextId
parts <- many1 (
readGroup <|>
readSingleQuoted <|>
readDoubleQuoted <|>
readDollarExpression <|>
readNormalLiteral "( " <|>
readPipeLiteral <|>
readGlobLiteral)
disregard spacing
return $ T_NormalWord id parts
where
readGlobLiteral = do
id <- getNextId
s <- many1 (extglobStart <|> oneOf "{}[]$")
return $ T_Literal id s
readGroup = called "regex grouping" $ do
id <- getNextId
char '('
parts <- many (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollarExpression <|> readRegexLiteral <|> readGlobLiteral)
char ')'
return $ T_NormalWord id parts
readRegexLiteral = do
id <- getNextId
str <- readGenericLiteral1 (singleQuote <|> doubleQuotable <|> oneOf "()")
return $ T_Literal id str
readPipeLiteral = do
id <- getNextId
str <- string "|"
return $ T_Literal id str
readCondTerm = do
term <- readCondNot <|> readCondExpr
condSpacing False
return term
readCondNot = do
id <- getNextId
char '!'
spacingOrLf
expr <- readCondExpr
return $ TC_Unary id typ "!" expr
readCondExpr =
readCondGroup <|> readCondUnaryExp <|> readCondNoaryOrBinary
readCondOr = chainl1 readCondAnd readCondAndOp
readCondAnd = chainl1 readCondTerm readCondOrOp
readCondContents = readCondOr | 7,289 | readConditionContents single =
readCondContents `attempting` lookAhead (do
pos <- getPosition
s <- many1 letter
when (s `elem` commonCommands) $
parseProblemAt pos WarningC 1009 "Use 'if cmd; then ..' to check exit code, or 'if [[ $(cmd) == .. ]]' to check output.")
where
spacingOrLf = condSpacing True
condSpacing required = do
pos <- getPosition
space <- allspacing
when (required && null space) $
parseProblemAt pos ErrorC 1035 "You are missing a required space here."
when (single && '\n' `elem` space) $
parseProblemAt pos ErrorC 1080 "When breaking lines in [ ], you need \\ before the linefeed."
return space
typ = if single then SingleBracket else DoubleBracket
readCondBinaryOp = try $ do
optional guardArithmetic
id <- getNextId
op <- choice (map tryOp ["==", "!=", "<=", ">=", "=~", ">", "<", "=", "\\<=", "\\>=", "\\<", "\\>"]) <|> otherOp
spacingOrLf
return op
where
tryOp s = try $ do
id <- getNextId
string s
return $ TC_Binary id typ s
otherOp = try $ do
id <- getNextId
s <- readOp
when (s == "-a" || s == "-o") $ fail "Unexpected operator"
return $ TC_Binary id typ s
guardArithmetic = do
try . lookAhead $ disregard (oneOf "+*/%") <|> disregard (string "- ")
parseProblem ErrorC 1076 $
if single
then "Trying to do math? Use e.g. [ $((i/2+7)) -ge 18 ]."
else "Trying to do math? Use e.g. [[ $((i/2+7)) -ge 18 ]]."
readCondUnaryExp = do
op <- readCondUnaryOp
pos <- getPosition
(readCondWord >>= return . op) `orFail` do
parseProblemAt pos ErrorC 1019 "Expected this to be an argument to the unary condition."
return "Expected an argument for the unary operator"
readCondUnaryOp = try $ do
id <- getNextId
s <- readOp
spacingOrLf
return $ TC_Unary id typ s
readOp = try $ do
char '-'
s <- many1 letter
return ('-':s)
readCondWord = do
notFollowedBy2 (try (spacing >> string "]"))
x <- readNormalWord
pos <- getPosition
when (endedWith "]" x) $ do
parseProblemAt pos ErrorC 1020 $
"You need a space before the " ++ (if single then "]" else "]]") ++ "."
fail "Missing space before ]"
when (single && endedWith ")" x) $ do
parseProblemAt pos ErrorC 1021
"You need a space before the \\)"
fail "Missing space before )"
disregard spacing
return x
where endedWith str (T_NormalWord id s@(_:_)) =
case last s of T_Literal id s -> str `isSuffixOf` s
_ -> False
endedWith _ _ = False
readCondAndOp = do
id <- getNextId
x <- try (readAndOrOp "&&" False <|> readAndOrOp "-a" True)
return $ TC_And id typ x
readCondOrOp = do
optional guardArithmetic
id <- getNextId
x <- try (readAndOrOp "||" False <|> readAndOrOp "-o" True)
return $ TC_Or id typ x
readAndOrOp op requiresSpacing = do
x <- string op
condSpacing requiresSpacing
return x
readCondNoaryOrBinary = do
id <- getNextId
x <- readCondWord `attempting` (do
pos <- getPosition
lookAhead (char '[')
parseProblemAt pos ErrorC 1026 $ if single
then "If grouping expressions inside [..], use \\( ..\\)."
else "If grouping expressions inside [[..]], use ( .. )."
)
(do
pos <- getPosition
isRegex <- regexOperatorAhead
op <- readCondBinaryOp
y <- if isRegex
then readRegex
else readCondWord <|> (parseProblemAt pos ErrorC 1027 "Expected another argument for this operator." >> mzero)
return (x `op` y)
) <|> return (TC_Noary id typ x)
readCondGroup = do
id <- getNextId
pos <- getPosition
lparen <- try $ string "(" <|> string "\\("
when (single && lparen == "(") $
parseProblemAt pos ErrorC 1028 "In [..] you have to escape (). Use [[..]] instead."
when (not single && lparen == "\\(") $
parseProblemAt pos ErrorC 1029 "In [[..]] you shouldn't escape ()."
condSpacing single
x <- readCondContents
cpos <- getPosition
rparen <- string ")" <|> string "\\)"
condSpacing single
when (single && rparen == ")") $
parseProblemAt cpos ErrorC 1030 "In [..] you have to escape (). Use [[..]] instead."
when (not single && rparen == "\\)") $
parseProblemAt cpos ErrorC 1031 "In [[..]] you shouldn't escape ()."
when (isEscaped lparen `xor` isEscaped rparen) $
parseProblemAt pos ErrorC 1032 "Did you just escape one half of () but not the other?"
return $ TC_Group id typ x
where
isEscaped ('\\':_) = True
isEscaped _ = False
xor x y = x && not y || not x && y
-- Currently a bit of a hack since parsing rules are obscure
regexOperatorAhead = lookAhead (do
try (string "=~") <|> try (string "~=")
return True)
<|> return False
readRegex = called "regex" $ do
id <- getNextId
parts <- many1 (
readGroup <|>
readSingleQuoted <|>
readDoubleQuoted <|>
readDollarExpression <|>
readNormalLiteral "( " <|>
readPipeLiteral <|>
readGlobLiteral)
disregard spacing
return $ T_NormalWord id parts
where
readGlobLiteral = do
id <- getNextId
s <- many1 (extglobStart <|> oneOf "{}[]$")
return $ T_Literal id s
readGroup = called "regex grouping" $ do
id <- getNextId
char '('
parts <- many (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollarExpression <|> readRegexLiteral <|> readGlobLiteral)
char ')'
return $ T_NormalWord id parts
readRegexLiteral = do
id <- getNextId
str <- readGenericLiteral1 (singleQuote <|> doubleQuotable <|> oneOf "()")
return $ T_Literal id str
readPipeLiteral = do
id <- getNextId
str <- string "|"
return $ T_Literal id str
readCondTerm = do
term <- readCondNot <|> readCondExpr
condSpacing False
return term
readCondNot = do
id <- getNextId
char '!'
spacingOrLf
expr <- readCondExpr
return $ TC_Unary id typ "!" expr
readCondExpr =
readCondGroup <|> readCondUnaryExp <|> readCondNoaryOrBinary
readCondOr = chainl1 readCondAnd readCondAndOp
readCondAnd = chainl1 readCondTerm readCondOrOp
readCondContents = readCondOr | 7,289 | false | false | 5 | 16 | 2,699 | 1,859 | 861 | 998 | null | null |
glguy/ssh-hans | src/Network/SSH/Protocol.hs | bsd-3-clause | getNameList :: Get [ShortByteString]
getNameList =
do len <- getWord32be
bytes <- getBytes (fromIntegral len)
return (map toShort (S.split comma bytes))
where
comma = fromIntegral (ord ',') | 208 | getNameList :: Get [ShortByteString]
getNameList =
do len <- getWord32be
bytes <- getBytes (fromIntegral len)
return (map toShort (S.split comma bytes))
where
comma = fromIntegral (ord ',') | 208 | getNameList =
do len <- getWord32be
bytes <- getBytes (fromIntegral len)
return (map toShort (S.split comma bytes))
where
comma = fromIntegral (ord ',') | 171 | false | true | 0 | 12 | 45 | 81 | 38 | 43 | null | null |
nickbart1980/pandoc | src/Text/Pandoc/Readers/Markdown.hs | gpl-2.0 | lhsCodeBlock :: MarkdownParser (F Blocks)
lhsCodeBlock = do
guardEnabled Ext_literate_haskell
(return . B.codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
(lhsCodeBlockBird <|> lhsCodeBlockLaTeX))
<|> (return . B.codeBlockWith ("",["sourceCode","haskell"],[]) <$>
lhsCodeBlockInverseBird) | 329 | lhsCodeBlock :: MarkdownParser (F Blocks)
lhsCodeBlock = do
guardEnabled Ext_literate_haskell
(return . B.codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
(lhsCodeBlockBird <|> lhsCodeBlockLaTeX))
<|> (return . B.codeBlockWith ("",["sourceCode","haskell"],[]) <$>
lhsCodeBlockInverseBird) | 329 | lhsCodeBlock = do
guardEnabled Ext_literate_haskell
(return . B.codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
(lhsCodeBlockBird <|> lhsCodeBlockLaTeX))
<|> (return . B.codeBlockWith ("",["sourceCode","haskell"],[]) <$>
lhsCodeBlockInverseBird) | 287 | false | true | 0 | 13 | 52 | 109 | 59 | 50 | null | null |
jano017/Discord.hs | src/Network/Discord/Framework.hs | mit | handle a@(Event s p) (D.UnknownEvent v o)
| s == v = runAsync (clientProxy a) $ p o | 108 | handle a@(Event s p) (D.UnknownEvent v o)
| s == v = runAsync (clientProxy a) $ p o | 108 | handle a@(Event s p) (D.UnknownEvent v o)
| s == v = runAsync (clientProxy a) $ p o | 108 | false | false | 0 | 9 | 42 | 58 | 27 | 31 | null | null |
vituscze/logic | src/Logic/Checked.hs | bsd-3-clause | prepend t (F x:qs) f = case prepend t qs f of
Some t' f' pf -> Some (mergeSing t' JustForallS) (Forall x f')
(mergeLeq t t' pf) | 139 | prepend t (F x:qs) f = case prepend t qs f of
Some t' f' pf -> Some (mergeSing t' JustForallS) (Forall x f')
(mergeLeq t t' pf) | 139 | prepend t (F x:qs) f = case prepend t qs f of
Some t' f' pf -> Some (mergeSing t' JustForallS) (Forall x f')
(mergeLeq t t' pf) | 139 | false | false | 1 | 10 | 39 | 85 | 38 | 47 | null | null |
snowmantw/Frag | src/AFRPMiscellany.hs | gpl-2.0 | sel5_3 :: (t, t1, t2, t3, t4) -> t2
sel5_3 (_,_,x,_,_) = x | 58 | sel5_3 :: (t, t1, t2, t3, t4) -> t2
sel5_3 (_,_,x,_,_) = x | 58 | sel5_3 (_,_,x,_,_) = x | 22 | false | true | 0 | 6 | 12 | 48 | 29 | 19 | null | null |
brendanhay/pagerduty | src/Network/PagerDuty/REST/Schedules.hs | mpl-2.0 | -- | Filters the result, showing only the schedules whose name matches the query.
lsQuery :: Lens' (Request ListSchedules s b) (Maybe Text)
lsQuery = upd.lsQuery' | 162 | lsQuery :: Lens' (Request ListSchedules s b) (Maybe Text)
lsQuery = upd.lsQuery' | 80 | lsQuery = upd.lsQuery' | 22 | true | true | 3 | 7 | 25 | 47 | 19 | 28 | null | null |
Noeda/compiled-expressions | src/Data/CompiledExpression/Internal.hs | mit | jitThread :: MVar () -> IO ()
jitThread ready_mvar = mask $ \restore -> do
setMultithreaded True
withContext $ \ctx -> withJIT ctx 0 $ \jit -> do
i_own_context <- atomically $ do
result <- readTMVar globalJit
case result of
Nothing -> do
void $ takeTMVar globalJit
putTMVar globalJit (Just (jit, ctx)) >> return True
Just _ -> return False
when i_own_context $ do
putMVar ready_mvar ()
restore $ forever $ threadDelay 100000000 >> touch jit >> touch ctx | 597 | jitThread :: MVar () -> IO ()
jitThread ready_mvar = mask $ \restore -> do
setMultithreaded True
withContext $ \ctx -> withJIT ctx 0 $ \jit -> do
i_own_context <- atomically $ do
result <- readTMVar globalJit
case result of
Nothing -> do
void $ takeTMVar globalJit
putTMVar globalJit (Just (jit, ctx)) >> return True
Just _ -> return False
when i_own_context $ do
putMVar ready_mvar ()
restore $ forever $ threadDelay 100000000 >> touch jit >> touch ctx | 597 | jitThread ready_mvar = mask $ \restore -> do
setMultithreaded True
withContext $ \ctx -> withJIT ctx 0 $ \jit -> do
i_own_context <- atomically $ do
result <- readTMVar globalJit
case result of
Nothing -> do
void $ takeTMVar globalJit
putTMVar globalJit (Just (jit, ctx)) >> return True
Just _ -> return False
when i_own_context $ do
putMVar ready_mvar ()
restore $ forever $ threadDelay 100000000 >> touch jit >> touch ctx | 567 | false | true | 0 | 28 | 222 | 200 | 90 | 110 | null | null |
FranklinChen/music-score | sketch/old/update/update6.hs | bsd-3-clause | -- down :: (HasPitches a a, AffineSpace (Pitch a)) => Interval a -> a -> a
down a = pitches %~ (.-^ a) | 102 | down a = pitches %~ (.-^ a) | 27 | down a = pitches %~ (.-^ a) | 27 | true | false | 3 | 6 | 22 | 24 | 11 | 13 | null | null |
silkapp/ordered-list | src/Data/List/Ordered.hs | bsd-3-clause | -- | /O(1)/ Create a singleton ordered list.
singleton :: a -> List a
singleton x = let s = [x] in FromBoth s s | 112 | singleton :: a -> List a
singleton x = let s = [x] in FromBoth s s | 66 | singleton x = let s = [x] in FromBoth s s | 41 | true | true | 0 | 9 | 25 | 41 | 20 | 21 | null | null |
fmapfmapfmap/amazonka | amazonka-dynamodb/test/Test/AWS/Gen/DynamoDB.hs | mpl-2.0 | testBatchGetItemResponse :: BatchGetItemResponse -> TestTree
testBatchGetItemResponse = res
"BatchGetItemResponse"
"fixture/BatchGetItemResponse.proto"
dynamoDB
(Proxy :: Proxy BatchGetItem) | 206 | testBatchGetItemResponse :: BatchGetItemResponse -> TestTree
testBatchGetItemResponse = res
"BatchGetItemResponse"
"fixture/BatchGetItemResponse.proto"
dynamoDB
(Proxy :: Proxy BatchGetItem) | 206 | testBatchGetItemResponse = res
"BatchGetItemResponse"
"fixture/BatchGetItemResponse.proto"
dynamoDB
(Proxy :: Proxy BatchGetItem) | 145 | false | true | 0 | 6 | 30 | 36 | 17 | 19 | null | null |
kmilner/tamarin-prover | lib/theory/src/Theory/Model/Fact.hs | gpl-3.0 | isProtoFact _ = False | 48 | isProtoFact _ = False | 48 | isProtoFact _ = False | 48 | false | false | 0 | 5 | 30 | 9 | 4 | 5 | null | null |
brendanhay/gogol | gogol-ml/gen/Network/Google/MachineLearning/Types/Product.hs | mpl-2.0 | -- | Size in GB of the boot disk (default is 100GB).
gcmvdcBootDiskSizeGb :: Lens' GoogleCloudMlV1__DiskConfig (Maybe Int32)
gcmvdcBootDiskSizeGb
= lens _gcmvdcBootDiskSizeGb
(\ s a -> s{_gcmvdcBootDiskSizeGb = a})
. mapping _Coerce | 246 | gcmvdcBootDiskSizeGb :: Lens' GoogleCloudMlV1__DiskConfig (Maybe Int32)
gcmvdcBootDiskSizeGb
= lens _gcmvdcBootDiskSizeGb
(\ s a -> s{_gcmvdcBootDiskSizeGb = a})
. mapping _Coerce | 193 | gcmvdcBootDiskSizeGb
= lens _gcmvdcBootDiskSizeGb
(\ s a -> s{_gcmvdcBootDiskSizeGb = a})
. mapping _Coerce | 121 | true | true | 0 | 10 | 45 | 55 | 28 | 27 | null | null |
uduki/hsQt | Qtc/Enums/Gui/QGraphicsItem.hs | bsd-2-clause | eItemClipsChildrenToShape :: GraphicsItemFlag
eItemClipsChildrenToShape
= ieGraphicsItemFlag $ 16 | 99 | eItemClipsChildrenToShape :: GraphicsItemFlag
eItemClipsChildrenToShape
= ieGraphicsItemFlag $ 16 | 99 | eItemClipsChildrenToShape
= ieGraphicsItemFlag $ 16 | 53 | false | true | 0 | 6 | 9 | 18 | 8 | 10 | null | null |
FranklinChen/IHaskell | ipython-kernel/examples/Calc.hs | mit | execRazor val Count clear send = do
i <- liftIO $ takeMVar val
modify (first $ consRes (Got Count i))
sendState
liftIO $ putMVar val (i + 1)
return i
where
sendState = liftIO clear >> fst <$> get >>= liftIO . send
-- | Generate a language configuration for some initial state | 293 | execRazor val Count clear send = do
i <- liftIO $ takeMVar val
modify (first $ consRes (Got Count i))
sendState
liftIO $ putMVar val (i + 1)
return i
where
sendState = liftIO clear >> fst <$> get >>= liftIO . send
-- | Generate a language configuration for some initial state | 293 | execRazor val Count clear send = do
i <- liftIO $ takeMVar val
modify (first $ consRes (Got Count i))
sendState
liftIO $ putMVar val (i + 1)
return i
where
sendState = liftIO clear >> fst <$> get >>= liftIO . send
-- | Generate a language configuration for some initial state | 293 | false | false | 0 | 12 | 70 | 109 | 50 | 59 | null | null |
ancientlanguage/haskell-analysis | greek-morph/src/Grammar/Greek/Morph/ShouldElide/Round.hs | mit | shouldElide :: Round InvalidElisionForm InvalidElisionCandidate
(CoreWord :* Elision :* InitialAspiration)
(CoreWord :* ShouldElide :* InitialAspiration)
shouldElide = Round (over _Failure pure . to) (over _Failure pure . from)
where
to (w :^ IsElided :^ nasp)
| Just (w' :^ nasp') <- Map.lookup (w :^ nasp) reverseElisionForms
= Success $ w' :^ ShouldElide :^ nasp'
to (w :^ NotElided :^ nasp) = Success $ w :^ ShouldNotElide :^ nasp
to x = Failure $ InvalidElisionForm x
from (w :^ ShouldElide :^ nasp) =
let w' :^ nasp' = elide $ w :^ nasp
in Success $ w' :^ IsElided :^ nasp'
from (w :^ ShouldNotElide :^ nasp) = Success $ w :^ NotElided :^ nasp
from x = Failure $ InvalidElisionCandidate x | 729 | shouldElide :: Round InvalidElisionForm InvalidElisionCandidate
(CoreWord :* Elision :* InitialAspiration)
(CoreWord :* ShouldElide :* InitialAspiration)
shouldElide = Round (over _Failure pure . to) (over _Failure pure . from)
where
to (w :^ IsElided :^ nasp)
| Just (w' :^ nasp') <- Map.lookup (w :^ nasp) reverseElisionForms
= Success $ w' :^ ShouldElide :^ nasp'
to (w :^ NotElided :^ nasp) = Success $ w :^ ShouldNotElide :^ nasp
to x = Failure $ InvalidElisionForm x
from (w :^ ShouldElide :^ nasp) =
let w' :^ nasp' = elide $ w :^ nasp
in Success $ w' :^ IsElided :^ nasp'
from (w :^ ShouldNotElide :^ nasp) = Success $ w :^ NotElided :^ nasp
from x = Failure $ InvalidElisionCandidate x | 729 | shouldElide = Round (over _Failure pure . to) (over _Failure pure . from)
where
to (w :^ IsElided :^ nasp)
| Just (w' :^ nasp') <- Map.lookup (w :^ nasp) reverseElisionForms
= Success $ w' :^ ShouldElide :^ nasp'
to (w :^ NotElided :^ nasp) = Success $ w :^ ShouldNotElide :^ nasp
to x = Failure $ InvalidElisionForm x
from (w :^ ShouldElide :^ nasp) =
let w' :^ nasp' = elide $ w :^ nasp
in Success $ w' :^ IsElided :^ nasp'
from (w :^ ShouldNotElide :^ nasp) = Success $ w :^ NotElided :^ nasp
from x = Failure $ InvalidElisionCandidate x | 571 | false | true | 0 | 11 | 155 | 288 | 142 | 146 | null | null |
wavewave/EventAnalysis | lib/HEP/Automation/EventAnalysis/FileDriver.hs | bsd-2-clause | -- |
-- :: DecayTopSink LHEvent PtlInfoMap CountIO c -> Conduit Event CountIO (Int,(),c)
lheventIter :: Monad m => Conduit Event m (Maybe (LHEvent, PtlInfoMap, [DecayTop PtlIDInfo]))
lheventIter = parseEvent =$= decayTopConduit =$= ordDecayTopConduit | 253 | lheventIter :: Monad m => Conduit Event m (Maybe (LHEvent, PtlInfoMap, [DecayTop PtlIDInfo]))
lheventIter = parseEvent =$= decayTopConduit =$= ordDecayTopConduit | 161 | lheventIter = parseEvent =$= decayTopConduit =$= ordDecayTopConduit | 67 | true | true | 0 | 11 | 36 | 56 | 30 | 26 | null | null |
spechub/Hets | CSL/Keywords.hs | gpl-2.0 | floorS :: String
floorS = "floor" | 33 | floorS :: String
floorS = "floor" | 33 | floorS = "floor" | 16 | false | true | 0 | 6 | 5 | 18 | 7 | 11 | null | null |
beni55/text | tests/Tests/Properties.hs | bsd-2-clause | tb_hexadecimal_word64 (a::Word64) = tb_hex a | 44 | tb_hexadecimal_word64 (a::Word64) = tb_hex a | 44 | tb_hexadecimal_word64 (a::Word64) = tb_hex a | 44 | false | false | 0 | 7 | 4 | 19 | 9 | 10 | null | null |
liangcun/ConceptsOfSpatialInformation | CoreConceptsHs/Location.hs | apache-2.0 | errorSRS = "spatial reference system error" | 43 | errorSRS = "spatial reference system error" | 43 | errorSRS = "spatial reference system error" | 43 | false | false | 0 | 4 | 5 | 6 | 3 | 3 | null | null |
polarina/sdl2 | Graphics/UI/SDL/Filesystem.hs | bsd-3-clause | writeBE64 :: MonadIO m => Ptr RWops -> Word64 -> m CSize
writeBE64 v1 v2 = liftIO $ writeBE64' v1 v2 | 100 | writeBE64 :: MonadIO m => Ptr RWops -> Word64 -> m CSize
writeBE64 v1 v2 = liftIO $ writeBE64' v1 v2 | 100 | writeBE64 v1 v2 = liftIO $ writeBE64' v1 v2 | 43 | false | true | 0 | 8 | 20 | 46 | 21 | 25 | null | null |
pparkkin/eta | compiler/ETA/Utils/Encoding.hs | bsd-3-clause | countUTF8Chars :: Ptr Word8 -> Int -> IO Int
countUTF8Chars ptr len = go ptr 0
where
!end = ptr `plusPtr` len
go p !n
| p >= end = return n
| otherwise = do
case utf8DecodeChar# (unPtr p) of
(# _, nBytes# #) -> go (p `plusPtr#` nBytes#) (n+1) | 318 | countUTF8Chars :: Ptr Word8 -> Int -> IO Int
countUTF8Chars ptr len = go ptr 0
where
!end = ptr `plusPtr` len
go p !n
| p >= end = return n
| otherwise = do
case utf8DecodeChar# (unPtr p) of
(# _, nBytes# #) -> go (p `plusPtr#` nBytes#) (n+1) | 318 | countUTF8Chars ptr len = go ptr 0
where
!end = ptr `plusPtr` len
go p !n
| p >= end = return n
| otherwise = do
case utf8DecodeChar# (unPtr p) of
(# _, nBytes# #) -> go (p `plusPtr#` nBytes#) (n+1) | 273 | false | true | 1 | 13 | 126 | 137 | 64 | 73 | null | null |
eigengrau/hlint | data/Default.hs | bsd-3-clause | error "Evaluate" = foldl f z [] ==> z | 37 | error "Evaluate" = foldl f z [] ==> z | 37 | error "Evaluate" = foldl f z [] ==> z | 37 | false | false | 2 | 5 | 8 | 31 | 11 | 20 | null | null |
ulricha/dsh-tpc-h | gen/TradeGen.hs | bsd-3-clause | genDayStockTrades opts day stock trades nextTs n = do
price <- uniformR (1 :: Double, 10000) (o_gen opts)
let trade = Trade price stock nextTs day
tsOffset <- uniformR (1, 10) (o_gen opts)
genDayStockTrades opts day stock (trade <| trades) (nextTs + tsOffset) (n - 1) | 286 | genDayStockTrades opts day stock trades nextTs n = do
price <- uniformR (1 :: Double, 10000) (o_gen opts)
let trade = Trade price stock nextTs day
tsOffset <- uniformR (1, 10) (o_gen opts)
genDayStockTrades opts day stock (trade <| trades) (nextTs + tsOffset) (n - 1) | 286 | genDayStockTrades opts day stock trades nextTs n = do
price <- uniformR (1 :: Double, 10000) (o_gen opts)
let trade = Trade price stock nextTs day
tsOffset <- uniformR (1, 10) (o_gen opts)
genDayStockTrades opts day stock (trade <| trades) (nextTs + tsOffset) (n - 1) | 286 | false | false | 0 | 10 | 64 | 125 | 62 | 63 | null | null |
isomorphism/webgl | src/Graphics/Rendering/WebGL/EnumConvert.hs | mit | getWrapParamEnum TAxis = gl_TEXTURE_WRAP_T | 42 | getWrapParamEnum TAxis = gl_TEXTURE_WRAP_T | 42 | getWrapParamEnum TAxis = gl_TEXTURE_WRAP_T | 42 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
Teino1978-Corp/Teino1978-Corp-alex | src/ParseMonad.hs | bsd-3-clause | newRMac :: String -> RExp -> P ()
newRMac rmac rexp
= P $ \s -> Right (s{rmac_env = Map.insert rmac rexp (rmac_env s)}, ()) | 126 | newRMac :: String -> RExp -> P ()
newRMac rmac rexp
= P $ \s -> Right (s{rmac_env = Map.insert rmac rexp (rmac_env s)}, ()) | 126 | newRMac rmac rexp
= P $ \s -> Right (s{rmac_env = Map.insert rmac rexp (rmac_env s)}, ()) | 92 | false | true | 0 | 13 | 27 | 72 | 37 | 35 | null | null |
Paow/encore | src/ir/AST/Util.hs | bsd-3-clause | getChildren ArrayLiteral {args} = args | 38 | getChildren ArrayLiteral {args} = args | 38 | getChildren ArrayLiteral {args} = args | 38 | false | false | 1 | 6 | 4 | 20 | 8 | 12 | null | null |
sordina/Edn | Print.hs | mit | (<>) :: Builder -> Builder -> Builder
(<>) = mappend | 52 | (<>) :: Builder -> Builder -> Builder
(<>) = mappend | 52 | (<>) = mappend | 14 | false | true | 0 | 8 | 9 | 30 | 15 | 15 | null | null |
alpheccar/diagrams-pdf | src/Diagrams/Backend/Pdf.hs | bsd-3-clause | pdfImage :: (Monad m, PDFGlobals m)
=> PDFReference PDFJpeg -- ^ Reference to the Jpeg image in the PDF resources
-> m (Diagram Pdf R2)
pdfImage ref = do
(w,h) <- P.bounds ref
let r :: Path R2
r = rect w h # moveOriginTo (p2 (-w/2, h/2.0))
diag = mkQD (Prim (PdfImage mempty ref))
(getEnvelope r)
(getTrace r)
mempty
(Query $ \p -> Any (isInsideEvenOdd p r))
return (diag # moveOriginTo (p2 (w/2.0,h/2.0))) | 533 | pdfImage :: (Monad m, PDFGlobals m)
=> PDFReference PDFJpeg -- ^ Reference to the Jpeg image in the PDF resources
-> m (Diagram Pdf R2)
pdfImage ref = do
(w,h) <- P.bounds ref
let r :: Path R2
r = rect w h # moveOriginTo (p2 (-w/2, h/2.0))
diag = mkQD (Prim (PdfImage mempty ref))
(getEnvelope r)
(getTrace r)
mempty
(Query $ \p -> Any (isInsideEvenOdd p r))
return (diag # moveOriginTo (p2 (w/2.0,h/2.0))) | 533 | pdfImage ref = do
(w,h) <- P.bounds ref
let r :: Path R2
r = rect w h # moveOriginTo (p2 (-w/2, h/2.0))
diag = mkQD (Prim (PdfImage mempty ref))
(getEnvelope r)
(getTrace r)
mempty
(Query $ \p -> Any (isInsideEvenOdd p r))
return (diag # moveOriginTo (p2 (w/2.0,h/2.0))) | 379 | false | true | 0 | 17 | 200 | 223 | 110 | 113 | null | null |
markuspf/Idris-dev | src/Idris/IBC.hs | bsd-3-clause | processRecords :: Archive -> Idris ()
processRecords ar = do
rs <- getEntry [] "ibc_records" ar
mapM_ (\ (n, r) ->
updateIState (\i -> i { idris_records = addDef n r (idris_records i) })) rs | 206 | processRecords :: Archive -> Idris ()
processRecords ar = do
rs <- getEntry [] "ibc_records" ar
mapM_ (\ (n, r) ->
updateIState (\i -> i { idris_records = addDef n r (idris_records i) })) rs | 206 | processRecords ar = do
rs <- getEntry [] "ibc_records" ar
mapM_ (\ (n, r) ->
updateIState (\i -> i { idris_records = addDef n r (idris_records i) })) rs | 168 | false | true | 0 | 17 | 50 | 93 | 47 | 46 | null | null |
spechub/Hets | THF/Sublogic.hs | gpl-2.0 | joinCoreSl _ THFP = THFP | 24 | joinCoreSl _ THFP = THFP | 24 | joinCoreSl _ THFP = THFP | 24 | false | false | 1 | 5 | 4 | 13 | 5 | 8 | null | null |
energyflowanalysis/efa-2.1 | demo/additiveTermsStatic/Main.hs | bsd-3-clause | simplify :: Term -> Term
simplify =
Op.toNormalTerm .
NonEmpty.sum . Op.expand .
Op.fromNormalTerm | 107 | simplify :: Term -> Term
simplify =
Op.toNormalTerm .
NonEmpty.sum . Op.expand .
Op.fromNormalTerm | 107 | simplify =
Op.toNormalTerm .
NonEmpty.sum . Op.expand .
Op.fromNormalTerm | 82 | false | true | 0 | 8 | 22 | 35 | 18 | 17 | null | null |
energyflowanalysis/efa-2.1 | src/EFA/Signal/ConvertTable.hs | bsd-3-clause | {-
Diese ganzen 'error's sind hier falsch.
Die Fehler muessen im Parser abgefangen werden.
-}
getPowerSignals ::
(Functor f) =>
Map String (TPT.T Double) ->
f String ->
f (Sig.TSignal [] Double, Sig.PSignal [] Double)
getPowerSignals tabPower =
fmap
(f . convertToSignal2D .
flip (Map.findWithDefault (error "getPowerSignals: signal not found")) tabPower)
where f (x, NonEmpty.Cons y []) = (x, y)
f _ = error $ "getPowerSignals: NonEmpty.Cons contains more than one element" | 513 | getPowerSignals ::
(Functor f) =>
Map String (TPT.T Double) ->
f String ->
f (Sig.TSignal [] Double, Sig.PSignal [] Double)
getPowerSignals tabPower =
fmap
(f . convertToSignal2D .
flip (Map.findWithDefault (error "getPowerSignals: signal not found")) tabPower)
where f (x, NonEmpty.Cons y []) = (x, y)
f _ = error $ "getPowerSignals: NonEmpty.Cons contains more than one element" | 418 | getPowerSignals tabPower =
fmap
(f . convertToSignal2D .
flip (Map.findWithDefault (error "getPowerSignals: signal not found")) tabPower)
where f (x, NonEmpty.Cons y []) = (x, y)
f _ = error $ "getPowerSignals: NonEmpty.Cons contains more than one element" | 282 | true | true | 2 | 12 | 110 | 160 | 77 | 83 | null | null |
urbanslug/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | ratioDataConName = conName gHC_REAL (fsLit ":%") ratioDataConKey | 77 | ratioDataConName = conName gHC_REAL (fsLit ":%") ratioDataConKey | 77 | ratioDataConName = conName gHC_REAL (fsLit ":%") ratioDataConKey | 77 | false | false | 0 | 7 | 19 | 19 | 9 | 10 | null | null |
jacekszymanski/wxHaskell | wxcore/src/haskell/Graphics/UI/WXCore/WxcDefs.hs | lgpl-2.1 | wxLC_SORT_ASCENDING :: Int
wxLC_SORT_ASCENDING = 16384 | 54 | wxLC_SORT_ASCENDING :: Int
wxLC_SORT_ASCENDING = 16384 | 54 | wxLC_SORT_ASCENDING = 16384 | 27 | false | true | 0 | 4 | 5 | 11 | 6 | 5 | null | null |
CBMM/petersonfaces | petersonfaces-frontend/src/Main.hs | bsd-3-clause | apWidget :: MonadWidget t m => m (Dynamic t (a -> b)) -> m (Dynamic t a) -> m (Dynamic t b)
apWidget mf ma = do
f <- mf
a <- ma
return $ zipDynWith ($) f a | 161 | apWidget :: MonadWidget t m => m (Dynamic t (a -> b)) -> m (Dynamic t a) -> m (Dynamic t b)
apWidget mf ma = do
f <- mf
a <- ma
return $ zipDynWith ($) f a | 161 | apWidget mf ma = do
f <- mf
a <- ma
return $ zipDynWith ($) f a | 69 | false | true | 0 | 11 | 44 | 103 | 49 | 54 | null | null |
zeniuseducation/poly-euler | haskell/prob201-300.hs | epl-1.0 | usePrimes = primesUnder 25 | 26 | usePrimes = primesUnder 25 | 26 | usePrimes = primesUnder 25 | 26 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
sumitsahrawat/calculator | src/Math/REPL/Prim/Bindings.hs | gpl-2.0 | -- | Get a variable from @Bindings@
getVar :: String -> Bindings -> Maybe Double
getVar s b = M.lookup s (varMap b) | 115 | getVar :: String -> Bindings -> Maybe Double
getVar s b = M.lookup s (varMap b) | 79 | getVar s b = M.lookup s (varMap b) | 34 | true | true | 0 | 8 | 22 | 46 | 21 | 25 | null | null |
brendanhay/gogol | gogol-civicinfo/gen/Network/Google/CivicInfo/Types/Product.hs | mpl-2.0 | -- | A URL provided by this administrative body for looking up general
-- election information.
abElectionInfoURL :: Lens' AdministrativeBody (Maybe Text)
abElectionInfoURL
= lens _abElectionInfoURL
(\ s a -> s{_abElectionInfoURL = a}) | 243 | abElectionInfoURL :: Lens' AdministrativeBody (Maybe Text)
abElectionInfoURL
= lens _abElectionInfoURL
(\ s a -> s{_abElectionInfoURL = a}) | 147 | abElectionInfoURL
= lens _abElectionInfoURL
(\ s a -> s{_abElectionInfoURL = a}) | 88 | true | true | 2 | 9 | 40 | 56 | 26 | 30 | null | null |
rubenpieters/gre-project | shared/src/UserInput.hs | bsd-3-clause | clearDmg = singleton ClearDmg | 29 | clearDmg = singleton ClearDmg | 29 | clearDmg = singleton ClearDmg | 29 | false | false | 1 | 5 | 3 | 12 | 4 | 8 | null | null |
jean-edouard/manager | xenmgr/XenMgr/Config.hs | gpl-2.0 | appGetSwitcherResistance :: Rpc Int
appGetSwitcherResistance = dbReadWithDefault 10 "/switcher/resistance" | 106 | appGetSwitcherResistance :: Rpc Int
appGetSwitcherResistance = dbReadWithDefault 10 "/switcher/resistance" | 106 | appGetSwitcherResistance = dbReadWithDefault 10 "/switcher/resistance" | 70 | false | true | 0 | 5 | 8 | 19 | 9 | 10 | null | null |
MaxOw/awesomium | src/Graphics/UI/Awesomium/WebCore.hs | lgpl-3.0 | -- | Deletes a certain cookie on a certain URL.
deleteCookie
:: String -- ^ The URL that we will be deleting cookies on.
-> String -- ^ The name of the cookie that will be deleted.
-> IO ()
deleteCookie = awe_webcore_delete_cookie | 242 | deleteCookie
:: String -- ^ The URL that we will be deleting cookies on.
-> String -- ^ The name of the cookie that will be deleted.
-> IO ()
deleteCookie = awe_webcore_delete_cookie | 194 | deleteCookie = awe_webcore_delete_cookie | 40 | true | true | 0 | 8 | 54 | 27 | 15 | 12 | null | null |
bch29/streaming-png | src/Codec/Picture/Png/Streaming/MainData.hs | lgpl-3.0 | --------------------------------------------------------------------------------
-- Main function
{-|
Given a stream of PNG chunks, decode the image data from it. The resulting bytes
can be directly interpreted as pixels, whose format depends on the image's
colour type.
-}
decodeImageData
:: (MonadThrow m, MonadIO m)
=> HeaderData
-> Stream (PNGChunk m) m r
-> ByteString m r
decodeImageData hd@HeaderData{..} =
let prevByteDistance =
case getBitsPerPixel hdBitDepth hdColourType of
Just bpp -> (fromIntegral bpp + 4) `div` 8
Nothing -> 1
in Q.fromChunks
. reconstructScanlines prevByteDistance
. splitImageDataByScanlines hd
. getDecompressedImageData | 716 | decodeImageData
:: (MonadThrow m, MonadIO m)
=> HeaderData
-> Stream (PNGChunk m) m r
-> ByteString m r
decodeImageData hd@HeaderData{..} =
let prevByteDistance =
case getBitsPerPixel hdBitDepth hdColourType of
Just bpp -> (fromIntegral bpp + 4) `div` 8
Nothing -> 1
in Q.fromChunks
. reconstructScanlines prevByteDistance
. splitImageDataByScanlines hd
. getDecompressedImageData | 441 | decodeImageData hd@HeaderData{..} =
let prevByteDistance =
case getBitsPerPixel hdBitDepth hdColourType of
Just bpp -> (fromIntegral bpp + 4) `div` 8
Nothing -> 1
in Q.fromChunks
. reconstructScanlines prevByteDistance
. splitImageDataByScanlines hd
. getDecompressedImageData | 320 | true | true | 9 | 8 | 147 | 119 | 65 | 54 | null | null |
abakst/liquidhaskell | tests/todo/Aliases.hs | bsd-3-clause | foo :: [Int]
{-@ foo :: Foos @-}
foo = [] | 41 | foo :: [Int]
foo = [] | 21 | foo = [] | 8 | true | true | 0 | 5 | 10 | 17 | 10 | 7 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.