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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Shimuuar/banana-tcltk
|
UI/TclTk/AST.hs
|
bsd-3-clause
|
renderExpr n x (SeqE es ) = unwords $ map (renderExpr n x) es
| 62
|
renderExpr n x (SeqE es ) = unwords $ map (renderExpr n x) es
| 62
|
renderExpr n x (SeqE es ) = unwords $ map (renderExpr n x) es
| 62
| false
| false
| 0
| 8
| 14
| 39
| 17
| 22
| null | null |
crufter/hakit
|
tests/hakit/db/mongo.hs
|
bsd-3-clause
|
loc41 = ["server" .- "prim", "db" .- "db1", "coll" .- "coll1"]
| 62
|
loc41 = ["server" .- "prim", "db" .- "db1", "coll" .- "coll1"]
| 62
|
loc41 = ["server" .- "prim", "db" .- "db1", "coll" .- "coll1"]
| 62
| false
| false
| 0
| 6
| 10
| 27
| 15
| 12
| null | null |
garetxe/cabal
|
Cabal/Distribution/Simple/GHCJS.hs
|
bsd-3-clause
|
getLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath
getLibDir verbosity lbi =
(reverse . dropWhile isSpace . reverse) `fmap`
rawSystemProgramStdoutConf verbosity ghcjsProgram
(withPrograms lbi) ["--print-libdir"]
| 230
|
getLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath
getLibDir verbosity lbi =
(reverse . dropWhile isSpace . reverse) `fmap`
rawSystemProgramStdoutConf verbosity ghcjsProgram
(withPrograms lbi) ["--print-libdir"]
| 230
|
getLibDir verbosity lbi =
(reverse . dropWhile isSpace . reverse) `fmap`
rawSystemProgramStdoutConf verbosity ghcjsProgram
(withPrograms lbi) ["--print-libdir"]
| 174
| false
| true
| 0
| 9
| 38
| 65
| 33
| 32
| null | null |
tchagnon/cs636-raytracer
|
a1/Mesh.hs
|
apache-2.0
|
-- Take a list of Vertex indices and produce a Face
list2face :: VecArray -> [Int] -> Face
list2face verts (ai:bi:ci:_) =
let a = verts ! ai in
let b = verts ! bi in
let c = verts ! ci in
Face a (a-b) (a-c)
| 225
|
list2face :: VecArray -> [Int] -> Face
list2face verts (ai:bi:ci:_) =
let a = verts ! ai in
let b = verts ! bi in
let c = verts ! ci in
Face a (a-b) (a-c)
| 173
|
list2face verts (ai:bi:ci:_) =
let a = verts ! ai in
let b = verts ! bi in
let c = verts ! ci in
Face a (a-b) (a-c)
| 134
| true
| true
| 0
| 13
| 65
| 109
| 55
| 54
| null | null |
brendanhay/gogol
|
gogol-vault/gen/Network/Google/Resource/Vault/Matters/Holds/Accounts/Create.hs
|
mpl-2.0
|
-- | The matter ID.
mhacMatterId :: Lens' MattersHoldsAccountsCreate Text
mhacMatterId
= lens _mhacMatterId (\ s a -> s{_mhacMatterId = a})
| 141
|
mhacMatterId :: Lens' MattersHoldsAccountsCreate Text
mhacMatterId
= lens _mhacMatterId (\ s a -> s{_mhacMatterId = a})
| 121
|
mhacMatterId
= lens _mhacMatterId (\ s a -> s{_mhacMatterId = a})
| 67
| true
| true
| 0
| 9
| 22
| 42
| 22
| 20
| null | null |
exercism/xhaskell
|
exercises/practice/bank-account/src/BankAccount.hs
|
mit
|
getBalance :: BankAccount -> IO (Maybe Integer)
getBalance account = error "You need to implement this function."
| 113
|
getBalance :: BankAccount -> IO (Maybe Integer)
getBalance account = error "You need to implement this function."
| 113
|
getBalance account = error "You need to implement this function."
| 65
| false
| true
| 0
| 8
| 16
| 30
| 14
| 16
| null | null |
iblumenfeld/saw-core
|
src/Verifier/SAW/Simulator/BitBlast.hs
|
bsd-3-clause
|
toBool :: BValue l -> l
toBool (VBool l) = l
| 44
|
toBool :: BValue l -> l
toBool (VBool l) = l
| 44
|
toBool (VBool l) = l
| 20
| false
| true
| 0
| 7
| 10
| 27
| 13
| 14
| null | null |
ezyang/ghc
|
hadrian/src/Rules/Documentation.hs
|
bsd-3-clause
|
-- | Compile a Sphinx ReStructured Text package to LaTeX
buildSphinxPdf :: FilePath -> Rules ()
buildSphinxPdf path = do
"//" ++ path <.> "pdf" %> \file -> do
let context = vanillaContext Stage0 docPackage
withTempDir $ \dir -> do
build $ target context (Sphinx Latex) [pathPath path] [dir]
build $ target context Xelatex [path <.> "tex"] [dir]
copyFileUntracked (dir -/- path <.> "pdf") file
----------------------------------------------------------------------
-- Archive
-- | Build archives of documentation
| 569
|
buildSphinxPdf :: FilePath -> Rules ()
buildSphinxPdf path = do
"//" ++ path <.> "pdf" %> \file -> do
let context = vanillaContext Stage0 docPackage
withTempDir $ \dir -> do
build $ target context (Sphinx Latex) [pathPath path] [dir]
build $ target context Xelatex [path <.> "tex"] [dir]
copyFileUntracked (dir -/- path <.> "pdf") file
----------------------------------------------------------------------
-- Archive
-- | Build archives of documentation
| 512
|
buildSphinxPdf path = do
"//" ++ path <.> "pdf" %> \file -> do
let context = vanillaContext Stage0 docPackage
withTempDir $ \dir -> do
build $ target context (Sphinx Latex) [pathPath path] [dir]
build $ target context Xelatex [path <.> "tex"] [dir]
copyFileUntracked (dir -/- path <.> "pdf") file
----------------------------------------------------------------------
-- Archive
-- | Build archives of documentation
| 473
| true
| true
| 0
| 18
| 131
| 149
| 74
| 75
| null | null |
pgj/bead
|
src/Bead/View/Session.hs
|
bsd-3-clause
|
sessionVersionValue :: T.Text
sessionVersionValue = "1"
| 55
|
sessionVersionValue :: T.Text
sessionVersionValue = "1"
| 55
|
sessionVersionValue = "1"
| 25
| false
| true
| 0
| 5
| 5
| 13
| 7
| 6
| null | null |
jaspervdj/what-morphism
|
src/WhatMorphism/Expr.hs
|
bsd-3-clause
|
--------------------------------------------------------------------------------
withBinds :: Monad m => Bind b -> (b -> Expr b -> m (b, Expr b)) -> m (Bind b)
withBinds (NonRec b e) f = do
(b', e') <- f b e
return $ NonRec b' e'
| 237
|
withBinds :: Monad m => Bind b -> (b -> Expr b -> m (b, Expr b)) -> m (Bind b)
withBinds (NonRec b e) f = do
(b', e') <- f b e
return $ NonRec b' e'
| 156
|
withBinds (NonRec b e) f = do
(b', e') <- f b e
return $ NonRec b' e'
| 77
| true
| true
| 0
| 13
| 47
| 108
| 52
| 56
| null | null |
tomlokhorst/wol
|
src/Network/MacAddress.hs
|
bsd-3-clause
|
-- | Get all bytes in a mac address
bytes :: MacAddress -> [Word8]
bytes (MacAddress b0 b1 b2 b3 b4 b5) = [b0, b1, b2, b3, b4, b5]
| 130
|
bytes :: MacAddress -> [Word8]
bytes (MacAddress b0 b1 b2 b3 b4 b5) = [b0, b1, b2, b3, b4, b5]
| 94
|
bytes (MacAddress b0 b1 b2 b3 b4 b5) = [b0, b1, b2, b3, b4, b5]
| 63
| true
| true
| 0
| 6
| 28
| 60
| 33
| 27
| null | null |
brendanhay/gogol
|
gogol-websecurityscanner/gen/Network/Google/WebSecurityScanner/Types/Product.hs
|
mpl-2.0
|
-- | Creates a value of 'ScanConfig' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'scIgnoreHTTPStatusErrors'
--
-- * 'scSchedule'
--
-- * 'scStartingURLs'
--
-- * 'scAuthentication'
--
-- * 'scStaticIPScan'
--
-- * 'scMaxQps'
--
-- * 'scName'
--
-- * 'scManagedScan'
--
-- * 'scExportToSecurityCommandCenter'
--
-- * 'scDisplayName'
--
-- * 'scRiskLevel'
--
-- * 'scUserAgent'
--
-- * 'scBlackListPatterns'
scanConfig
:: ScanConfig
scanConfig =
ScanConfig'
{ _scIgnoreHTTPStatusErrors = Nothing
, _scSchedule = Nothing
, _scStartingURLs = Nothing
, _scAuthentication = Nothing
, _scStaticIPScan = Nothing
, _scMaxQps = Nothing
, _scName = Nothing
, _scManagedScan = Nothing
, _scExportToSecurityCommandCenter = Nothing
, _scDisplayName = Nothing
, _scRiskLevel = Nothing
, _scUserAgent = Nothing
, _scBlackListPatterns = Nothing
}
| 980
|
scanConfig
:: ScanConfig
scanConfig =
ScanConfig'
{ _scIgnoreHTTPStatusErrors = Nothing
, _scSchedule = Nothing
, _scStartingURLs = Nothing
, _scAuthentication = Nothing
, _scStaticIPScan = Nothing
, _scMaxQps = Nothing
, _scName = Nothing
, _scManagedScan = Nothing
, _scExportToSecurityCommandCenter = Nothing
, _scDisplayName = Nothing
, _scRiskLevel = Nothing
, _scUserAgent = Nothing
, _scBlackListPatterns = Nothing
}
| 485
|
scanConfig =
ScanConfig'
{ _scIgnoreHTTPStatusErrors = Nothing
, _scSchedule = Nothing
, _scStartingURLs = Nothing
, _scAuthentication = Nothing
, _scStaticIPScan = Nothing
, _scMaxQps = Nothing
, _scName = Nothing
, _scManagedScan = Nothing
, _scExportToSecurityCommandCenter = Nothing
, _scDisplayName = Nothing
, _scRiskLevel = Nothing
, _scUserAgent = Nothing
, _scBlackListPatterns = Nothing
}
| 456
| true
| true
| 1
| 7
| 202
| 127
| 89
| 38
| null | null |
siddhanathan/ghc
|
compiler/prelude/THNames.hs
|
bsd-3-clause
|
kindSigName = libFun (fsLit "kindSig") kindSigIdKey
| 60
|
kindSigName = libFun (fsLit "kindSig") kindSigIdKey
| 60
|
kindSigName = libFun (fsLit "kindSig") kindSigIdKey
| 60
| false
| false
| 1
| 7
| 14
| 20
| 8
| 12
| null | null |
PuZZleDucK/Hls
|
old-Hyes.hs
|
gpl-3.0
|
versionText :: [String]
versionText = [ "Hyes (Haskell implementation of GNU yes) 1.0"
, "derrived from: yes (GNU coreutils) 8.13"
, "Copyright (C) 2011 Free Software Foundation, Inc."
, "Written by David MacKenzie."
, "Ported by PuZZleDucK.\n\n"
]
| 318
|
versionText :: [String]
versionText = [ "Hyes (Haskell implementation of GNU yes) 1.0"
, "derrived from: yes (GNU coreutils) 8.13"
, "Copyright (C) 2011 Free Software Foundation, Inc."
, "Written by David MacKenzie."
, "Ported by PuZZleDucK.\n\n"
]
| 318
|
versionText = [ "Hyes (Haskell implementation of GNU yes) 1.0"
, "derrived from: yes (GNU coreutils) 8.13"
, "Copyright (C) 2011 Free Software Foundation, Inc."
, "Written by David MacKenzie."
, "Ported by PuZZleDucK.\n\n"
]
| 294
| false
| true
| 0
| 7
| 107
| 36
| 19
| 17
| null | null |
kawamuray/ganeti
|
src/Ganeti/Constants.hs
|
gpl-2.0
|
nodeEvacModes :: FrozenSet String
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
| 108
|
nodeEvacModes :: FrozenSet String
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
| 108
|
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
| 74
| false
| true
| 0
| 7
| 10
| 30
| 15
| 15
| null | null |
sinelaw/infernu
|
src/Infernu/Parse.hs
|
gpl-2.0
|
foldStmts f [x] expr = fromStatement f x expr
| 45
|
foldStmts f [x] expr = fromStatement f x expr
| 45
|
foldStmts f [x] expr = fromStatement f x expr
| 45
| false
| false
| 0
| 6
| 8
| 23
| 11
| 12
| null | null |
creswick/Newt
|
tests/src/Integration.hs
|
bsd-3-clause
|
test_inplaceReplace :: String -> String -> Assertion
test_inplaceReplace author oracleFile = do tmpFile <- getTmpFileName
let input = (testDir </> "simpleTest" </> "in.cabal")
source= "--source=" ++ tmpFile
oracle = (testDir </> "simpleTest" </> oracleFile)
params = [ "--inplace"
, "name=myProject"
, "author="++author]
cleanup [tmpFile] $ do
-- don't modify the original test input file:
copyFile input tmpFile
_ <- runNewt ([source] ++ params)
-- check file content:
assertFilesEqual "Generated file doesn't match" oracle tmpFile
| 1,096
|
test_inplaceReplace :: String -> String -> Assertion
test_inplaceReplace author oracleFile = do tmpFile <- getTmpFileName
let input = (testDir </> "simpleTest" </> "in.cabal")
source= "--source=" ++ tmpFile
oracle = (testDir </> "simpleTest" </> oracleFile)
params = [ "--inplace"
, "name=myProject"
, "author="++author]
cleanup [tmpFile] $ do
-- don't modify the original test input file:
copyFile input tmpFile
_ <- runNewt ([source] ++ params)
-- check file content:
assertFilesEqual "Generated file doesn't match" oracle tmpFile
| 1,096
|
test_inplaceReplace author oracleFile = do tmpFile <- getTmpFileName
let input = (testDir </> "simpleTest" </> "in.cabal")
source= "--source=" ++ tmpFile
oracle = (testDir </> "simpleTest" </> oracleFile)
params = [ "--inplace"
, "name=myProject"
, "author="++author]
cleanup [tmpFile] $ do
-- don't modify the original test input file:
copyFile input tmpFile
_ <- runNewt ([source] ++ params)
-- check file content:
assertFilesEqual "Generated file doesn't match" oracle tmpFile
| 1,043
| false
| true
| 0
| 14
| 637
| 147
| 75
| 72
| null | null |
gamelost/pcgen-rules
|
src/Restrictions.hs
|
apache-2.0
|
parsePreAlign :: PParser PreAlign
parsePreAlign = do
args <- tag "PREALIGN" >> parseWord `sepBy` char ','
return PreAlign { alignments = map parseAlignment args } where
parseAlignment :: String -> Alignment
parseAlignment x | x == "LG", x == "0" = LG
parseAlignment x | x == "LN", x == "1" = LN
parseAlignment x | x == "LE", x == "2" = LE
parseAlignment x | x == "NG", x == "3" = NG
parseAlignment x | x == "TN", x == "4" = TN
parseAlignment x | x == "NE", x == "5" = NE
parseAlignment x | x == "CG", x == "6" = CG
parseAlignment x | x == "CN", x == "7" = CN
parseAlignment x | x == "CE", x == "8" = CE
parseAlignment x | x == "Deity", x == "10" = Deity
parseAlignment _ = None
-- PREATTACK:x
-- x is base attack bonus number
| 780
|
parsePreAlign :: PParser PreAlign
parsePreAlign = do
args <- tag "PREALIGN" >> parseWord `sepBy` char ','
return PreAlign { alignments = map parseAlignment args } where
parseAlignment :: String -> Alignment
parseAlignment x | x == "LG", x == "0" = LG
parseAlignment x | x == "LN", x == "1" = LN
parseAlignment x | x == "LE", x == "2" = LE
parseAlignment x | x == "NG", x == "3" = NG
parseAlignment x | x == "TN", x == "4" = TN
parseAlignment x | x == "NE", x == "5" = NE
parseAlignment x | x == "CG", x == "6" = CG
parseAlignment x | x == "CN", x == "7" = CN
parseAlignment x | x == "CE", x == "8" = CE
parseAlignment x | x == "Deity", x == "10" = Deity
parseAlignment _ = None
-- PREATTACK:x
-- x is base attack bonus number
| 780
|
parsePreAlign = do
args <- tag "PREALIGN" >> parseWord `sepBy` char ','
return PreAlign { alignments = map parseAlignment args } where
parseAlignment :: String -> Alignment
parseAlignment x | x == "LG", x == "0" = LG
parseAlignment x | x == "LN", x == "1" = LN
parseAlignment x | x == "LE", x == "2" = LE
parseAlignment x | x == "NG", x == "3" = NG
parseAlignment x | x == "TN", x == "4" = TN
parseAlignment x | x == "NE", x == "5" = NE
parseAlignment x | x == "CG", x == "6" = CG
parseAlignment x | x == "CN", x == "7" = CN
parseAlignment x | x == "CE", x == "8" = CE
parseAlignment x | x == "Deity", x == "10" = Deity
parseAlignment _ = None
-- PREATTACK:x
-- x is base attack bonus number
| 746
| false
| true
| 0
| 10
| 208
| 337
| 159
| 178
| null | null |
purcell/adventofcodeteam
|
app/Five.hs
|
bsd-3-clause
|
vowels :: String
vowels = "aeiou"
| 33
|
vowels :: String
vowels = "aeiou"
| 33
|
vowels = "aeiou"
| 16
| false
| true
| 0
| 4
| 5
| 11
| 6
| 5
| null | null |
AjayRamanathan/plots
|
src/Plots/Axis/Ticks.hs
|
bsd-3-clause
|
-- | Do not show any ticks.
noTicks :: TickAlign
noTicks = NoTick
| 65
|
noTicks :: TickAlign
noTicks = NoTick
| 37
|
noTicks = NoTick
| 16
| true
| true
| 0
| 4
| 12
| 12
| 7
| 5
| null | null |
fendor/connect-four
|
src/Game.hs
|
bsd-2-clause
|
inBounds :: ConnectFour -> Pos -> Bool
inBounds c (a, b) = (0 < a && a <= x) && (0 < b && b <= y)
where
g = gamefield c
x = nrows g
y = ncols g
| 157
|
inBounds :: ConnectFour -> Pos -> Bool
inBounds c (a, b) = (0 < a && a <= x) && (0 < b && b <= y)
where
g = gamefield c
x = nrows g
y = ncols g
| 157
|
inBounds c (a, b) = (0 < a && a <= x) && (0 < b && b <= y)
where
g = gamefield c
x = nrows g
y = ncols g
| 118
| false
| true
| 0
| 9
| 53
| 91
| 47
| 44
| null | null |
orclev/adpasswd
|
Main.hs
|
gpl-3.0
|
buildPath :: [PathPiece] -> String
buildPath = concat . intersperse "," . map bp
where
bp (OU x) = "ou="++x
bp (DC x) = "DC="++x
| 138
|
buildPath :: [PathPiece] -> String
buildPath = concat . intersperse "," . map bp
where
bp (OU x) = "ou="++x
bp (DC x) = "DC="++x
| 138
|
buildPath = concat . intersperse "," . map bp
where
bp (OU x) = "ou="++x
bp (DC x) = "DC="++x
| 103
| false
| true
| 0
| 7
| 34
| 73
| 35
| 38
| null | null |
x-y-z/cabal
|
Cabal/Distribution/Simple/Utils.hs
|
bsd-3-clause
|
-- | Fix different systems silly line ending conventions
normaliseLineEndings :: String -> String
normaliseLineEndings [] = []
| 126
|
normaliseLineEndings :: String -> String
normaliseLineEndings [] = []
| 69
|
normaliseLineEndings [] = []
| 28
| true
| true
| 0
| 6
| 17
| 23
| 12
| 11
| null | null |
fibsifan/pandoc
|
src/Text/Pandoc/Readers/Docx/Parse.hs
|
gpl-2.0
|
getHeaderLevel :: NameSpaces -> Element -> Maybe (String,Int)
getHeaderLevel ns element
| Just styleId <- findAttr (elemName ns "w" "styleId") element
, Just index <- stripPrefix "Heading" styleId
, isNumericNotNull index = Just (styleId, read index)
| Just styleId <- findAttr (elemName ns "w" "styleId") element
, Just index <- findChild (elemName ns "w" "name") element >>=
findAttr (elemName ns "w" "val") >>=
stripPrefix "heading "
, isNumericNotNull index = Just (styleId, read index)
| 546
|
getHeaderLevel :: NameSpaces -> Element -> Maybe (String,Int)
getHeaderLevel ns element
| Just styleId <- findAttr (elemName ns "w" "styleId") element
, Just index <- stripPrefix "Heading" styleId
, isNumericNotNull index = Just (styleId, read index)
| Just styleId <- findAttr (elemName ns "w" "styleId") element
, Just index <- findChild (elemName ns "w" "name") element >>=
findAttr (elemName ns "w" "val") >>=
stripPrefix "heading "
, isNumericNotNull index = Just (styleId, read index)
| 546
|
getHeaderLevel ns element
| Just styleId <- findAttr (elemName ns "w" "styleId") element
, Just index <- stripPrefix "Heading" styleId
, isNumericNotNull index = Just (styleId, read index)
| Just styleId <- findAttr (elemName ns "w" "styleId") element
, Just index <- findChild (elemName ns "w" "name") element >>=
findAttr (elemName ns "w" "val") >>=
stripPrefix "heading "
, isNumericNotNull index = Just (styleId, read index)
| 484
| false
| true
| 0
| 13
| 129
| 198
| 92
| 106
| null | null |
Newlifer/libstep
|
src/Data/EXPRESS/Parsers.hs
|
mit
|
-- parameter_ref | variable_ref .
--
-- It's all SimpleId in the end
pGeneralRef :: Parser GeneralRef
pGeneralRef = pSimpleId
| 125
|
pGeneralRef :: Parser GeneralRef
pGeneralRef = pSimpleId
| 56
|
pGeneralRef = pSimpleId
| 23
| true
| true
| 0
| 5
| 19
| 17
| 10
| 7
| null | null |
olsner/ghc
|
compiler/prelude/PrelNames.hs
|
bsd-3-clause
|
coercibleSCSelIdKey = mkPreludeMiscIdUnique 512
| 47
|
coercibleSCSelIdKey = mkPreludeMiscIdUnique 512
| 47
|
coercibleSCSelIdKey = mkPreludeMiscIdUnique 512
| 47
| false
| false
| 0
| 5
| 3
| 9
| 4
| 5
| null | null |
jstolarek/haddock
|
haddock-api/src/Haddock/Backends/LaTeX.hs
|
bsd-2-clause
|
ppName :: Name -> LaTeX
ppName = ppOccName . nameOccName
| 56
|
ppName :: Name -> LaTeX
ppName = ppOccName . nameOccName
| 56
|
ppName = ppOccName . nameOccName
| 32
| false
| true
| 0
| 5
| 9
| 19
| 10
| 9
| null | null |
romanb/amazonka
|
amazonka-redshift/gen/Network/AWS/Redshift/Types.hs
|
mpl-2.0
|
-- | The number of days that automatic cluster snapshots are retained.
cAutomatedSnapshotRetentionPeriod :: Lens' Cluster (Maybe Int)
cAutomatedSnapshotRetentionPeriod =
lens _cAutomatedSnapshotRetentionPeriod
(\s a -> s { _cAutomatedSnapshotRetentionPeriod = a })
| 276
|
cAutomatedSnapshotRetentionPeriod :: Lens' Cluster (Maybe Int)
cAutomatedSnapshotRetentionPeriod =
lens _cAutomatedSnapshotRetentionPeriod
(\s a -> s { _cAutomatedSnapshotRetentionPeriod = a })
| 205
|
cAutomatedSnapshotRetentionPeriod =
lens _cAutomatedSnapshotRetentionPeriod
(\s a -> s { _cAutomatedSnapshotRetentionPeriod = a })
| 142
| true
| true
| 0
| 9
| 42
| 46
| 25
| 21
| null | null |
anchor/vaultaire-collector-ceilometer
|
test/Main.hs
|
mit
|
-- Network Rx/Tx
expectedNetworkRxPayload :: Word64
expectedNetworkRxPayload = 58832
| 85
|
expectedNetworkRxPayload :: Word64
expectedNetworkRxPayload = 58832
| 67
|
expectedNetworkRxPayload = 58832
| 32
| true
| true
| 0
| 4
| 9
| 12
| 7
| 5
| null | null |
Rufflewind/calico-hs
|
Calico/MonadIO.hs
|
mit
|
ioError :: MonadIO m => IOError -> m a
ioError = liftIO . ioError
| 65
|
ioError :: MonadIO m => IOError -> m a
ioError = liftIO . ioError
| 65
|
ioError = liftIO . ioError
| 26
| false
| true
| 0
| 7
| 13
| 29
| 14
| 15
| null | null |
YueLiPicasso/unification
|
UnifyTerms.hs
|
gpl-3.0
|
unifyTerms v@(Variable _ ) c@(Constant _ ) = Just [(c,v)]
| 57
|
unifyTerms v@(Variable _ ) c@(Constant _ ) = Just [(c,v)]
| 57
|
unifyTerms v@(Variable _ ) c@(Constant _ ) = Just [(c,v)]
| 57
| false
| false
| 0
| 8
| 9
| 41
| 22
| 19
| null | null |
exbb2/BlastItWithPiss
|
src/Import.hs
|
gpl-3.0
|
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust mb m = maybe (return ()) m mb
| 92
|
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust mb m = maybe (return ()) m mb
| 92
|
whenJust mb m = maybe (return ()) m mb
| 38
| false
| true
| 0
| 11
| 23
| 66
| 31
| 35
| null | null |
forked-upstream-packages-for-ghcjs/ghc
|
compiler/basicTypes/MkId.hs
|
bsd-3-clause
|
{-
************************************************************************
* *
\subsection{Primitive operations}
* *
************************************************************************
-}
mkPrimOpId :: PrimOp -> Id
mkPrimOpId prim_op
= id
where
(tyvars,arg_tys,res_ty, arity, strict_sig) = primOpSig prim_op
ty = mkForAllTys tyvars (mkFunTys arg_tys res_ty)
name = mkWiredInName gHC_PRIM (primOpOcc prim_op)
(mkPrimOpIdUnique (primOpTag prim_op))
(AnId id) UserSyntax
id = mkGlobalId (PrimOpId prim_op) name ty info
info = noCafIdInfo
`setSpecInfo` mkSpecInfo (maybeToList $ primOpRules name prim_op)
`setArityInfo` arity
`setStrictnessInfo` strict_sig
`setInlinePragInfo` neverInlinePragma
-- We give PrimOps a NOINLINE pragma so that we don't
-- get silly warnings from Desugar.dsRule (the inline_shadows_rule
-- test) about a RULE conflicting with a possible inlining
-- cf Trac #7287
-- For each ccall we manufacture a separate CCallOpId, giving it
-- a fresh unique, a type that is correct for this particular ccall,
-- and a CCall structure that gives the correct details about calling
-- convention etc.
--
-- The *name* of this Id is a local name whose OccName gives the full
-- details of the ccall, type and all. This means that the interface
-- file reader can reconstruct a suitable Id
| 1,650
|
mkPrimOpId :: PrimOp -> Id
mkPrimOpId prim_op
= id
where
(tyvars,arg_tys,res_ty, arity, strict_sig) = primOpSig prim_op
ty = mkForAllTys tyvars (mkFunTys arg_tys res_ty)
name = mkWiredInName gHC_PRIM (primOpOcc prim_op)
(mkPrimOpIdUnique (primOpTag prim_op))
(AnId id) UserSyntax
id = mkGlobalId (PrimOpId prim_op) name ty info
info = noCafIdInfo
`setSpecInfo` mkSpecInfo (maybeToList $ primOpRules name prim_op)
`setArityInfo` arity
`setStrictnessInfo` strict_sig
`setInlinePragInfo` neverInlinePragma
-- We give PrimOps a NOINLINE pragma so that we don't
-- get silly warnings from Desugar.dsRule (the inline_shadows_rule
-- test) about a RULE conflicting with a possible inlining
-- cf Trac #7287
-- For each ccall we manufacture a separate CCallOpId, giving it
-- a fresh unique, a type that is correct for this particular ccall,
-- and a CCall structure that gives the correct details about calling
-- convention etc.
--
-- The *name* of this Id is a local name whose OccName gives the full
-- details of the ccall, type and all. This means that the interface
-- file reader can reconstruct a suitable Id
| 1,317
|
mkPrimOpId prim_op
= id
where
(tyvars,arg_tys,res_ty, arity, strict_sig) = primOpSig prim_op
ty = mkForAllTys tyvars (mkFunTys arg_tys res_ty)
name = mkWiredInName gHC_PRIM (primOpOcc prim_op)
(mkPrimOpIdUnique (primOpTag prim_op))
(AnId id) UserSyntax
id = mkGlobalId (PrimOpId prim_op) name ty info
info = noCafIdInfo
`setSpecInfo` mkSpecInfo (maybeToList $ primOpRules name prim_op)
`setArityInfo` arity
`setStrictnessInfo` strict_sig
`setInlinePragInfo` neverInlinePragma
-- We give PrimOps a NOINLINE pragma so that we don't
-- get silly warnings from Desugar.dsRule (the inline_shadows_rule
-- test) about a RULE conflicting with a possible inlining
-- cf Trac #7287
-- For each ccall we manufacture a separate CCallOpId, giving it
-- a fresh unique, a type that is correct for this particular ccall,
-- and a CCall structure that gives the correct details about calling
-- convention etc.
--
-- The *name* of this Id is a local name whose OccName gives the full
-- details of the ccall, type and all. This means that the interface
-- file reader can reconstruct a suitable Id
| 1,290
| true
| true
| 4
| 13
| 524
| 180
| 102
| 78
| null | null |
siddhanathan/ghc
|
compiler/coreSyn/CoreUnfold.hs
|
bsd-3-clause
|
tryUnfolding :: DynFlags -> Id -> Bool -> [ArgSummary] -> CallCtxt
-> CoreExpr -> Bool -> Bool -> Bool -> UnfoldingGuidance
-> Maybe CoreExpr
tryUnfolding dflags id lone_variable
arg_infos cont_info unf_template is_top
is_wf is_exp guidance
= case guidance of
UnfNever -> traceInline dflags str (ptext (sLit "UnfNever")) Nothing
UnfWhen { ug_arity = uf_arity, ug_unsat_ok = unsat_ok, ug_boring_ok = boring_ok }
| enough_args && (boring_ok || some_benefit)
-- See Note [INLINE for small functions (3)]
-> traceInline dflags str (mk_doc some_benefit empty True) (Just unf_template)
| otherwise
-> traceInline dflags str (mk_doc some_benefit empty False) Nothing
where
some_benefit = calc_some_benefit uf_arity
enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0)
UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size }
| is_wf && some_benefit && small_enough
-> traceInline dflags str (mk_doc some_benefit extra_doc True) (Just unf_template)
| otherwise
-> traceInline dflags str (mk_doc some_benefit extra_doc False) Nothing
where
some_benefit = calc_some_benefit (length arg_discounts)
extra_doc = text "discounted size =" <+> int discounted_size
discounted_size = size - discount
small_enough = discounted_size <= ufUseThreshold dflags
discount = computeDiscount dflags arg_discounts
res_discount arg_infos cont_info
where
mk_doc some_benefit extra_doc yes_or_no
= vcat [ text "arg infos" <+> ppr arg_infos
, text "interesting continuation" <+> ppr cont_info
, text "some_benefit" <+> ppr some_benefit
, text "is exp:" <+> ppr is_exp
, text "is work-free:" <+> ppr is_wf
, text "guidance" <+> ppr guidance
, extra_doc
, text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"]
str = "Considering inlining: " ++ showSDocDump dflags (ppr id)
n_val_args = length arg_infos
-- some_benefit is used when the RHS is small enough
-- and the call has enough (or too many) value
-- arguments (ie n_val_args >= arity). But there must
-- be *something* interesting about some argument, or the
-- result context, to make it worth inlining
calc_some_benefit :: Arity -> Bool -- The Arity is the number of args
-- expected by the unfolding
calc_some_benefit uf_arity
| not saturated = interesting_args -- Under-saturated
-- Note [Unsaturated applications]
| otherwise = interesting_args -- Saturated or over-saturated
|| interesting_call
where
saturated = n_val_args >= uf_arity
over_saturated = n_val_args > uf_arity
interesting_args = any nonTriv arg_infos
-- NB: (any nonTriv arg_infos) looks at the
-- over-saturated args too which is "wrong";
-- but if over-saturated we inline anyway.
interesting_call
| over_saturated
= True
| otherwise
= case cont_info of
CaseCtxt -> not (lone_variable && is_wf) -- Note [Lone variables]
ValAppCtxt -> True -- Note [Cast then apply]
RuleArgCtxt -> uf_arity > 0 -- See Note [Unfold info lazy contexts]
DiscArgCtxt -> uf_arity > 0 --
RhsCtxt -> uf_arity > 0 --
_ -> not is_top && uf_arity > 0 -- Note [Nested functions]
-- Note [Inlining in ArgCtxt]
{-
Note [Unfold into lazy contexts], Note [RHS of lets]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When the call is the argument of a function with a RULE, or the RHS of a let,
we are a little bit keener to inline. For example
f y = (y,y,y)
g y = let x = f y in ...(case x of (a,b,c) -> ...) ...
We'd inline 'f' if the call was in a case context, and it kind-of-is,
only we can't see it. Also
x = f v
could be expensive whereas
x = case v of (a,b) -> a
is patently cheap and may allow more eta expansion.
So we treat the RHS of a let as not-totally-boring.
Note [Unsaturated applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a call is not saturated, we *still* inline if one of the
arguments has interesting structure. That's sometimes very important.
A good example is the Ord instance for Bool in Base:
Rec {
$fOrdBool =GHC.Classes.D:Ord
@ Bool
...
$cmin_ajX
$cmin_ajX [Occ=LoopBreaker] :: Bool -> Bool -> Bool
$cmin_ajX = GHC.Classes.$dmmin @ Bool $fOrdBool
}
But the defn of GHC.Classes.$dmmin is:
$dmmin :: forall a. GHC.Classes.Ord a => a -> a -> a
{- Arity: 3, HasNoCafRefs, Strictness: SLL,
Unfolding: (\ @ a $dOrd :: GHC.Classes.Ord a x :: a y :: a ->
case @ a GHC.Classes.<= @ a $dOrd x y of wild {
GHC.Types.False -> y GHC.Types.True -> x }) -}
We *really* want to inline $dmmin, even though it has arity 3, in
order to unravel the recursion.
Note [Things to watch]
~~~~~~~~~~~~~~~~~~~~~~
* { y = I# 3; x = y `cast` co; ...case (x `cast` co) of ... }
Assume x is exported, so not inlined unconditionally.
Then we want x to inline unconditionally; no reason for it
not to, and doing so avoids an indirection.
* { x = I# 3; ....f x.... }
Make sure that x does not inline unconditionally!
Lest we get extra allocation.
Note [Inlining an InlineRule]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An InlineRules is used for
(a) programmer INLINE pragmas
(b) inlinings from worker/wrapper
For (a) the RHS may be large, and our contract is that we *only* inline
when the function is applied to all the arguments on the LHS of the
source-code defn. (The uf_arity in the rule.)
However for worker/wrapper it may be worth inlining even if the
arity is not satisfied (as we do in the CoreUnfolding case) so we don't
require saturation.
Note [Nested functions]
~~~~~~~~~~~~~~~~~~~~~~~
If a function has a nested defn we also record some-benefit, on the
grounds that we are often able to eliminate the binding, and hence the
allocation, for the function altogether; this is good for join points.
But this only makes sense for *functions*; inlining a constructor
doesn't help allocation unless the result is scrutinised. UNLESS the
constructor occurs just once, albeit possibly in multiple case
branches. Then inlining it doesn't increase allocation, but it does
increase the chance that the constructor won't be allocated at all in
the branches that don't use it.
Note [Cast then apply]
~~~~~~~~~~~~~~~~~~~~~~
Consider
myIndex = __inline_me ( (/\a. <blah>) |> co )
co :: (forall a. a -> a) ~ (forall a. T a)
... /\a.\x. case ((myIndex a) |> sym co) x of { ... } ...
We need to inline myIndex to unravel this; but the actual call (myIndex a) has
no value arguments. The ValAppCtxt gives it enough incentive to inline.
Note [Inlining in ArgCtxt]
~~~~~~~~~~~~~~~~~~~~~~~~~~
The condition (arity > 0) here is very important, because otherwise
we end up inlining top-level stuff into useless places; eg
x = I# 3#
f = \y. g x
This can make a very big difference: it adds 16% to nofib 'integer' allocs,
and 20% to 'power'.
At one stage I replaced this condition by 'True' (leading to the above
slow-down). The motivation was test eyeball/inline1.hs; but that seems
to work ok now.
NOTE: arguably, we should inline in ArgCtxt only if the result of the
call is at least CONLIKE. At least for the cases where we use ArgCtxt
for the RHS of a 'let', we only profit from the inlining if we get a
CONLIKE thing (modulo lets).
Note [Lone variables] See also Note [Interaction of exprIsWorkFree and lone variables]
~~~~~~~~~~~~~~~~~~~~~ which appears below
The "lone-variable" case is important. I spent ages messing about
with unsatisfactory variants, but this is nice. The idea is that if a
variable appears all alone
as an arg of lazy fn, or rhs BoringCtxt
as scrutinee of a case CaseCtxt
as arg of a fn ArgCtxt
AND
it is bound to a cheap expression
then we should not inline it (unless there is some other reason,
e.g. is is the sole occurrence). That is what is happening at
the use of 'lone_variable' in 'interesting_call'.
Why? At least in the case-scrutinee situation, turning
let x = (a,b) in case x of y -> ...
into
let x = (a,b) in case (a,b) of y -> ...
and thence to
let x = (a,b) in let y = (a,b) in ...
is bad if the binding for x will remain.
Another example: I discovered that strings
were getting inlined straight back into applications of 'error'
because the latter is strict.
s = "foo"
f = \x -> ...(error s)...
Fundamentally such contexts should not encourage inlining because the
context can ``see'' the unfolding of the variable (e.g. case or a
RULE) so there's no gain. If the thing is bound to a value.
However, watch out:
* Consider this:
foo = _inline_ (\n. [n])
bar = _inline_ (foo 20)
baz = \n. case bar of { (m:_) -> m + n }
Here we really want to inline 'bar' so that we can inline 'foo'
and the whole thing unravels as it should obviously do. This is
important: in the NDP project, 'bar' generates a closure data
structure rather than a list.
So the non-inlining of lone_variables should only apply if the
unfolding is regarded as cheap; because that is when exprIsConApp_maybe
looks through the unfolding. Hence the "&& is_wf" in the
InlineRule branch.
* Even a type application or coercion isn't a lone variable.
Consider
case $fMonadST @ RealWorld of { :DMonad a b c -> c }
We had better inline that sucker! The case won't see through it.
For now, I'm treating treating a variable applied to types
in a *lazy* context "lone". The motivating example was
f = /\a. \x. BIG
g = /\a. \y. h (f a)
There's no advantage in inlining f here, and perhaps
a significant disadvantage. Hence some_val_args in the Stop case
Note [Interaction of exprIsWorkFree and lone variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The lone-variable test says "don't inline if a case expression
scrutines a lone variable whose unfolding is cheap". It's very
important that, under these circumstances, exprIsConApp_maybe
can spot a constructor application. So, for example, we don't
consider
let x = e in (x,x)
to be cheap, and that's good because exprIsConApp_maybe doesn't
think that expression is a constructor application.
In the 'not (lone_variable && is_wf)' test, I used to test is_value
rather than is_wf, which was utterly wrong, because the above
expression responds True to exprIsHNF, which is what sets is_value.
This kind of thing can occur if you have
{-# INLINE foo #-}
foo = let x = e in (x,x)
which Roman did.
-}
| 11,311
|
tryUnfolding :: DynFlags -> Id -> Bool -> [ArgSummary] -> CallCtxt
-> CoreExpr -> Bool -> Bool -> Bool -> UnfoldingGuidance
-> Maybe CoreExpr
tryUnfolding dflags id lone_variable
arg_infos cont_info unf_template is_top
is_wf is_exp guidance
= case guidance of
UnfNever -> traceInline dflags str (ptext (sLit "UnfNever")) Nothing
UnfWhen { ug_arity = uf_arity, ug_unsat_ok = unsat_ok, ug_boring_ok = boring_ok }
| enough_args && (boring_ok || some_benefit)
-- See Note [INLINE for small functions (3)]
-> traceInline dflags str (mk_doc some_benefit empty True) (Just unf_template)
| otherwise
-> traceInline dflags str (mk_doc some_benefit empty False) Nothing
where
some_benefit = calc_some_benefit uf_arity
enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0)
UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size }
| is_wf && some_benefit && small_enough
-> traceInline dflags str (mk_doc some_benefit extra_doc True) (Just unf_template)
| otherwise
-> traceInline dflags str (mk_doc some_benefit extra_doc False) Nothing
where
some_benefit = calc_some_benefit (length arg_discounts)
extra_doc = text "discounted size =" <+> int discounted_size
discounted_size = size - discount
small_enough = discounted_size <= ufUseThreshold dflags
discount = computeDiscount dflags arg_discounts
res_discount arg_infos cont_info
where
mk_doc some_benefit extra_doc yes_or_no
= vcat [ text "arg infos" <+> ppr arg_infos
, text "interesting continuation" <+> ppr cont_info
, text "some_benefit" <+> ppr some_benefit
, text "is exp:" <+> ppr is_exp
, text "is work-free:" <+> ppr is_wf
, text "guidance" <+> ppr guidance
, extra_doc
, text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"]
str = "Considering inlining: " ++ showSDocDump dflags (ppr id)
n_val_args = length arg_infos
-- some_benefit is used when the RHS is small enough
-- and the call has enough (or too many) value
-- arguments (ie n_val_args >= arity). But there must
-- be *something* interesting about some argument, or the
-- result context, to make it worth inlining
calc_some_benefit :: Arity -> Bool -- The Arity is the number of args
-- expected by the unfolding
calc_some_benefit uf_arity
| not saturated = interesting_args -- Under-saturated
-- Note [Unsaturated applications]
| otherwise = interesting_args -- Saturated or over-saturated
|| interesting_call
where
saturated = n_val_args >= uf_arity
over_saturated = n_val_args > uf_arity
interesting_args = any nonTriv arg_infos
-- NB: (any nonTriv arg_infos) looks at the
-- over-saturated args too which is "wrong";
-- but if over-saturated we inline anyway.
interesting_call
| over_saturated
= True
| otherwise
= case cont_info of
CaseCtxt -> not (lone_variable && is_wf) -- Note [Lone variables]
ValAppCtxt -> True -- Note [Cast then apply]
RuleArgCtxt -> uf_arity > 0 -- See Note [Unfold info lazy contexts]
DiscArgCtxt -> uf_arity > 0 --
RhsCtxt -> uf_arity > 0 --
_ -> not is_top && uf_arity > 0 -- Note [Nested functions]
-- Note [Inlining in ArgCtxt]
{-
Note [Unfold into lazy contexts], Note [RHS of lets]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When the call is the argument of a function with a RULE, or the RHS of a let,
we are a little bit keener to inline. For example
f y = (y,y,y)
g y = let x = f y in ...(case x of (a,b,c) -> ...) ...
We'd inline 'f' if the call was in a case context, and it kind-of-is,
only we can't see it. Also
x = f v
could be expensive whereas
x = case v of (a,b) -> a
is patently cheap and may allow more eta expansion.
So we treat the RHS of a let as not-totally-boring.
Note [Unsaturated applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a call is not saturated, we *still* inline if one of the
arguments has interesting structure. That's sometimes very important.
A good example is the Ord instance for Bool in Base:
Rec {
$fOrdBool =GHC.Classes.D:Ord
@ Bool
...
$cmin_ajX
$cmin_ajX [Occ=LoopBreaker] :: Bool -> Bool -> Bool
$cmin_ajX = GHC.Classes.$dmmin @ Bool $fOrdBool
}
But the defn of GHC.Classes.$dmmin is:
$dmmin :: forall a. GHC.Classes.Ord a => a -> a -> a
{- Arity: 3, HasNoCafRefs, Strictness: SLL,
Unfolding: (\ @ a $dOrd :: GHC.Classes.Ord a x :: a y :: a ->
case @ a GHC.Classes.<= @ a $dOrd x y of wild {
GHC.Types.False -> y GHC.Types.True -> x }) -}
We *really* want to inline $dmmin, even though it has arity 3, in
order to unravel the recursion.
Note [Things to watch]
~~~~~~~~~~~~~~~~~~~~~~
* { y = I# 3; x = y `cast` co; ...case (x `cast` co) of ... }
Assume x is exported, so not inlined unconditionally.
Then we want x to inline unconditionally; no reason for it
not to, and doing so avoids an indirection.
* { x = I# 3; ....f x.... }
Make sure that x does not inline unconditionally!
Lest we get extra allocation.
Note [Inlining an InlineRule]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An InlineRules is used for
(a) programmer INLINE pragmas
(b) inlinings from worker/wrapper
For (a) the RHS may be large, and our contract is that we *only* inline
when the function is applied to all the arguments on the LHS of the
source-code defn. (The uf_arity in the rule.)
However for worker/wrapper it may be worth inlining even if the
arity is not satisfied (as we do in the CoreUnfolding case) so we don't
require saturation.
Note [Nested functions]
~~~~~~~~~~~~~~~~~~~~~~~
If a function has a nested defn we also record some-benefit, on the
grounds that we are often able to eliminate the binding, and hence the
allocation, for the function altogether; this is good for join points.
But this only makes sense for *functions*; inlining a constructor
doesn't help allocation unless the result is scrutinised. UNLESS the
constructor occurs just once, albeit possibly in multiple case
branches. Then inlining it doesn't increase allocation, but it does
increase the chance that the constructor won't be allocated at all in
the branches that don't use it.
Note [Cast then apply]
~~~~~~~~~~~~~~~~~~~~~~
Consider
myIndex = __inline_me ( (/\a. <blah>) |> co )
co :: (forall a. a -> a) ~ (forall a. T a)
... /\a.\x. case ((myIndex a) |> sym co) x of { ... } ...
We need to inline myIndex to unravel this; but the actual call (myIndex a) has
no value arguments. The ValAppCtxt gives it enough incentive to inline.
Note [Inlining in ArgCtxt]
~~~~~~~~~~~~~~~~~~~~~~~~~~
The condition (arity > 0) here is very important, because otherwise
we end up inlining top-level stuff into useless places; eg
x = I# 3#
f = \y. g x
This can make a very big difference: it adds 16% to nofib 'integer' allocs,
and 20% to 'power'.
At one stage I replaced this condition by 'True' (leading to the above
slow-down). The motivation was test eyeball/inline1.hs; but that seems
to work ok now.
NOTE: arguably, we should inline in ArgCtxt only if the result of the
call is at least CONLIKE. At least for the cases where we use ArgCtxt
for the RHS of a 'let', we only profit from the inlining if we get a
CONLIKE thing (modulo lets).
Note [Lone variables] See also Note [Interaction of exprIsWorkFree and lone variables]
~~~~~~~~~~~~~~~~~~~~~ which appears below
The "lone-variable" case is important. I spent ages messing about
with unsatisfactory variants, but this is nice. The idea is that if a
variable appears all alone
as an arg of lazy fn, or rhs BoringCtxt
as scrutinee of a case CaseCtxt
as arg of a fn ArgCtxt
AND
it is bound to a cheap expression
then we should not inline it (unless there is some other reason,
e.g. is is the sole occurrence). That is what is happening at
the use of 'lone_variable' in 'interesting_call'.
Why? At least in the case-scrutinee situation, turning
let x = (a,b) in case x of y -> ...
into
let x = (a,b) in case (a,b) of y -> ...
and thence to
let x = (a,b) in let y = (a,b) in ...
is bad if the binding for x will remain.
Another example: I discovered that strings
were getting inlined straight back into applications of 'error'
because the latter is strict.
s = "foo"
f = \x -> ...(error s)...
Fundamentally such contexts should not encourage inlining because the
context can ``see'' the unfolding of the variable (e.g. case or a
RULE) so there's no gain. If the thing is bound to a value.
However, watch out:
* Consider this:
foo = _inline_ (\n. [n])
bar = _inline_ (foo 20)
baz = \n. case bar of { (m:_) -> m + n }
Here we really want to inline 'bar' so that we can inline 'foo'
and the whole thing unravels as it should obviously do. This is
important: in the NDP project, 'bar' generates a closure data
structure rather than a list.
So the non-inlining of lone_variables should only apply if the
unfolding is regarded as cheap; because that is when exprIsConApp_maybe
looks through the unfolding. Hence the "&& is_wf" in the
InlineRule branch.
* Even a type application or coercion isn't a lone variable.
Consider
case $fMonadST @ RealWorld of { :DMonad a b c -> c }
We had better inline that sucker! The case won't see through it.
For now, I'm treating treating a variable applied to types
in a *lazy* context "lone". The motivating example was
f = /\a. \x. BIG
g = /\a. \y. h (f a)
There's no advantage in inlining f here, and perhaps
a significant disadvantage. Hence some_val_args in the Stop case
Note [Interaction of exprIsWorkFree and lone variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The lone-variable test says "don't inline if a case expression
scrutines a lone variable whose unfolding is cheap". It's very
important that, under these circumstances, exprIsConApp_maybe
can spot a constructor application. So, for example, we don't
consider
let x = e in (x,x)
to be cheap, and that's good because exprIsConApp_maybe doesn't
think that expression is a constructor application.
In the 'not (lone_variable && is_wf)' test, I used to test is_value
rather than is_wf, which was utterly wrong, because the above
expression responds True to exprIsHNF, which is what sets is_value.
This kind of thing can occur if you have
{-# INLINE foo #-}
foo = let x = e in (x,x)
which Roman did.
-}
| 11,311
|
tryUnfolding dflags id lone_variable
arg_infos cont_info unf_template is_top
is_wf is_exp guidance
= case guidance of
UnfNever -> traceInline dflags str (ptext (sLit "UnfNever")) Nothing
UnfWhen { ug_arity = uf_arity, ug_unsat_ok = unsat_ok, ug_boring_ok = boring_ok }
| enough_args && (boring_ok || some_benefit)
-- See Note [INLINE for small functions (3)]
-> traceInline dflags str (mk_doc some_benefit empty True) (Just unf_template)
| otherwise
-> traceInline dflags str (mk_doc some_benefit empty False) Nothing
where
some_benefit = calc_some_benefit uf_arity
enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0)
UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size }
| is_wf && some_benefit && small_enough
-> traceInline dflags str (mk_doc some_benefit extra_doc True) (Just unf_template)
| otherwise
-> traceInline dflags str (mk_doc some_benefit extra_doc False) Nothing
where
some_benefit = calc_some_benefit (length arg_discounts)
extra_doc = text "discounted size =" <+> int discounted_size
discounted_size = size - discount
small_enough = discounted_size <= ufUseThreshold dflags
discount = computeDiscount dflags arg_discounts
res_discount arg_infos cont_info
where
mk_doc some_benefit extra_doc yes_or_no
= vcat [ text "arg infos" <+> ppr arg_infos
, text "interesting continuation" <+> ppr cont_info
, text "some_benefit" <+> ppr some_benefit
, text "is exp:" <+> ppr is_exp
, text "is work-free:" <+> ppr is_wf
, text "guidance" <+> ppr guidance
, extra_doc
, text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"]
str = "Considering inlining: " ++ showSDocDump dflags (ppr id)
n_val_args = length arg_infos
-- some_benefit is used when the RHS is small enough
-- and the call has enough (or too many) value
-- arguments (ie n_val_args >= arity). But there must
-- be *something* interesting about some argument, or the
-- result context, to make it worth inlining
calc_some_benefit :: Arity -> Bool -- The Arity is the number of args
-- expected by the unfolding
calc_some_benefit uf_arity
| not saturated = interesting_args -- Under-saturated
-- Note [Unsaturated applications]
| otherwise = interesting_args -- Saturated or over-saturated
|| interesting_call
where
saturated = n_val_args >= uf_arity
over_saturated = n_val_args > uf_arity
interesting_args = any nonTriv arg_infos
-- NB: (any nonTriv arg_infos) looks at the
-- over-saturated args too which is "wrong";
-- but if over-saturated we inline anyway.
interesting_call
| over_saturated
= True
| otherwise
= case cont_info of
CaseCtxt -> not (lone_variable && is_wf) -- Note [Lone variables]
ValAppCtxt -> True -- Note [Cast then apply]
RuleArgCtxt -> uf_arity > 0 -- See Note [Unfold info lazy contexts]
DiscArgCtxt -> uf_arity > 0 --
RhsCtxt -> uf_arity > 0 --
_ -> not is_top && uf_arity > 0 -- Note [Nested functions]
-- Note [Inlining in ArgCtxt]
{-
Note [Unfold into lazy contexts], Note [RHS of lets]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When the call is the argument of a function with a RULE, or the RHS of a let,
we are a little bit keener to inline. For example
f y = (y,y,y)
g y = let x = f y in ...(case x of (a,b,c) -> ...) ...
We'd inline 'f' if the call was in a case context, and it kind-of-is,
only we can't see it. Also
x = f v
could be expensive whereas
x = case v of (a,b) -> a
is patently cheap and may allow more eta expansion.
So we treat the RHS of a let as not-totally-boring.
Note [Unsaturated applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a call is not saturated, we *still* inline if one of the
arguments has interesting structure. That's sometimes very important.
A good example is the Ord instance for Bool in Base:
Rec {
$fOrdBool =GHC.Classes.D:Ord
@ Bool
...
$cmin_ajX
$cmin_ajX [Occ=LoopBreaker] :: Bool -> Bool -> Bool
$cmin_ajX = GHC.Classes.$dmmin @ Bool $fOrdBool
}
But the defn of GHC.Classes.$dmmin is:
$dmmin :: forall a. GHC.Classes.Ord a => a -> a -> a
{- Arity: 3, HasNoCafRefs, Strictness: SLL,
Unfolding: (\ @ a $dOrd :: GHC.Classes.Ord a x :: a y :: a ->
case @ a GHC.Classes.<= @ a $dOrd x y of wild {
GHC.Types.False -> y GHC.Types.True -> x }) -}
We *really* want to inline $dmmin, even though it has arity 3, in
order to unravel the recursion.
Note [Things to watch]
~~~~~~~~~~~~~~~~~~~~~~
* { y = I# 3; x = y `cast` co; ...case (x `cast` co) of ... }
Assume x is exported, so not inlined unconditionally.
Then we want x to inline unconditionally; no reason for it
not to, and doing so avoids an indirection.
* { x = I# 3; ....f x.... }
Make sure that x does not inline unconditionally!
Lest we get extra allocation.
Note [Inlining an InlineRule]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An InlineRules is used for
(a) programmer INLINE pragmas
(b) inlinings from worker/wrapper
For (a) the RHS may be large, and our contract is that we *only* inline
when the function is applied to all the arguments on the LHS of the
source-code defn. (The uf_arity in the rule.)
However for worker/wrapper it may be worth inlining even if the
arity is not satisfied (as we do in the CoreUnfolding case) so we don't
require saturation.
Note [Nested functions]
~~~~~~~~~~~~~~~~~~~~~~~
If a function has a nested defn we also record some-benefit, on the
grounds that we are often able to eliminate the binding, and hence the
allocation, for the function altogether; this is good for join points.
But this only makes sense for *functions*; inlining a constructor
doesn't help allocation unless the result is scrutinised. UNLESS the
constructor occurs just once, albeit possibly in multiple case
branches. Then inlining it doesn't increase allocation, but it does
increase the chance that the constructor won't be allocated at all in
the branches that don't use it.
Note [Cast then apply]
~~~~~~~~~~~~~~~~~~~~~~
Consider
myIndex = __inline_me ( (/\a. <blah>) |> co )
co :: (forall a. a -> a) ~ (forall a. T a)
... /\a.\x. case ((myIndex a) |> sym co) x of { ... } ...
We need to inline myIndex to unravel this; but the actual call (myIndex a) has
no value arguments. The ValAppCtxt gives it enough incentive to inline.
Note [Inlining in ArgCtxt]
~~~~~~~~~~~~~~~~~~~~~~~~~~
The condition (arity > 0) here is very important, because otherwise
we end up inlining top-level stuff into useless places; eg
x = I# 3#
f = \y. g x
This can make a very big difference: it adds 16% to nofib 'integer' allocs,
and 20% to 'power'.
At one stage I replaced this condition by 'True' (leading to the above
slow-down). The motivation was test eyeball/inline1.hs; but that seems
to work ok now.
NOTE: arguably, we should inline in ArgCtxt only if the result of the
call is at least CONLIKE. At least for the cases where we use ArgCtxt
for the RHS of a 'let', we only profit from the inlining if we get a
CONLIKE thing (modulo lets).
Note [Lone variables] See also Note [Interaction of exprIsWorkFree and lone variables]
~~~~~~~~~~~~~~~~~~~~~ which appears below
The "lone-variable" case is important. I spent ages messing about
with unsatisfactory variants, but this is nice. The idea is that if a
variable appears all alone
as an arg of lazy fn, or rhs BoringCtxt
as scrutinee of a case CaseCtxt
as arg of a fn ArgCtxt
AND
it is bound to a cheap expression
then we should not inline it (unless there is some other reason,
e.g. is is the sole occurrence). That is what is happening at
the use of 'lone_variable' in 'interesting_call'.
Why? At least in the case-scrutinee situation, turning
let x = (a,b) in case x of y -> ...
into
let x = (a,b) in case (a,b) of y -> ...
and thence to
let x = (a,b) in let y = (a,b) in ...
is bad if the binding for x will remain.
Another example: I discovered that strings
were getting inlined straight back into applications of 'error'
because the latter is strict.
s = "foo"
f = \x -> ...(error s)...
Fundamentally such contexts should not encourage inlining because the
context can ``see'' the unfolding of the variable (e.g. case or a
RULE) so there's no gain. If the thing is bound to a value.
However, watch out:
* Consider this:
foo = _inline_ (\n. [n])
bar = _inline_ (foo 20)
baz = \n. case bar of { (m:_) -> m + n }
Here we really want to inline 'bar' so that we can inline 'foo'
and the whole thing unravels as it should obviously do. This is
important: in the NDP project, 'bar' generates a closure data
structure rather than a list.
So the non-inlining of lone_variables should only apply if the
unfolding is regarded as cheap; because that is when exprIsConApp_maybe
looks through the unfolding. Hence the "&& is_wf" in the
InlineRule branch.
* Even a type application or coercion isn't a lone variable.
Consider
case $fMonadST @ RealWorld of { :DMonad a b c -> c }
We had better inline that sucker! The case won't see through it.
For now, I'm treating treating a variable applied to types
in a *lazy* context "lone". The motivating example was
f = /\a. \x. BIG
g = /\a. \y. h (f a)
There's no advantage in inlining f here, and perhaps
a significant disadvantage. Hence some_val_args in the Stop case
Note [Interaction of exprIsWorkFree and lone variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The lone-variable test says "don't inline if a case expression
scrutines a lone variable whose unfolding is cheap". It's very
important that, under these circumstances, exprIsConApp_maybe
can spot a constructor application. So, for example, we don't
consider
let x = e in (x,x)
to be cheap, and that's good because exprIsConApp_maybe doesn't
think that expression is a constructor application.
In the 'not (lone_variable && is_wf)' test, I used to test is_value
rather than is_wf, which was utterly wrong, because the above
expression responds True to exprIsHNF, which is what sets is_value.
This kind of thing can occur if you have
{-# INLINE foo #-}
foo = let x = e in (x,x)
which Roman did.
-}
| 11,143
| false
| true
| 0
| 15
| 3,034
| 740
| 377
| 363
| null | null |
bitemyapp/persistent
|
persistent-mongoDB/Database/Persist/MongoDB.hs
|
mit
|
eitherFromPersistValues :: (PersistEntity record) => EntityDef -> [DB.Field] -> Either T.Text (Entity record)
eitherFromPersistValues entDef doc = case mKey of
Nothing -> addDetail $ Left $ "could not find _id field: "
Just kpv -> do
body <- addDetail (fromPersistValues (map snd $ orderPersistValues (toEmbedEntityDef entDef) castDoc))
key <- keyFromValues [kpv]
return $ Entity key body
where
addDetail :: Either Text a -> Either Text a
addDetail = mapLeft (\msg -> msg `mappend` " for doc: " `mappend` T.pack (show doc))
castDoc = assocListFromDoc doc
-- normally _id is the first field
mKey = lookup id_ castDoc
-- | unlike many SQL databases, MongoDB makes no guarantee of the ordering
-- of the fields returned in the document.
-- Ordering might be maintained if persistent were the only user of the db,
-- but other tools may be using MongoDB.
--
-- Persistent creates a Haskell record from a list of PersistValue
-- But most importantly it puts all PersistValues in the proper order
| 1,038
|
eitherFromPersistValues :: (PersistEntity record) => EntityDef -> [DB.Field] -> Either T.Text (Entity record)
eitherFromPersistValues entDef doc = case mKey of
Nothing -> addDetail $ Left $ "could not find _id field: "
Just kpv -> do
body <- addDetail (fromPersistValues (map snd $ orderPersistValues (toEmbedEntityDef entDef) castDoc))
key <- keyFromValues [kpv]
return $ Entity key body
where
addDetail :: Either Text a -> Either Text a
addDetail = mapLeft (\msg -> msg `mappend` " for doc: " `mappend` T.pack (show doc))
castDoc = assocListFromDoc doc
-- normally _id is the first field
mKey = lookup id_ castDoc
-- | unlike many SQL databases, MongoDB makes no guarantee of the ordering
-- of the fields returned in the document.
-- Ordering might be maintained if persistent were the only user of the db,
-- but other tools may be using MongoDB.
--
-- Persistent creates a Haskell record from a list of PersistValue
-- But most importantly it puts all PersistValues in the proper order
| 1,038
|
eitherFromPersistValues entDef doc = case mKey of
Nothing -> addDetail $ Left $ "could not find _id field: "
Just kpv -> do
body <- addDetail (fromPersistValues (map snd $ orderPersistValues (toEmbedEntityDef entDef) castDoc))
key <- keyFromValues [kpv]
return $ Entity key body
where
addDetail :: Either Text a -> Either Text a
addDetail = mapLeft (\msg -> msg `mappend` " for doc: " `mappend` T.pack (show doc))
castDoc = assocListFromDoc doc
-- normally _id is the first field
mKey = lookup id_ castDoc
-- | unlike many SQL databases, MongoDB makes no guarantee of the ordering
-- of the fields returned in the document.
-- Ordering might be maintained if persistent were the only user of the db,
-- but other tools may be using MongoDB.
--
-- Persistent creates a Haskell record from a list of PersistValue
-- But most importantly it puts all PersistValues in the proper order
| 928
| false
| true
| 2
| 18
| 211
| 244
| 118
| 126
| null | null |
walck/learn-physics
|
src/Physics/Learn/Curve.hs
|
bsd-3-clause
|
evalCurve :: Curve -- ^ the curve
-> Double -- ^ the parameter
-> Position -- ^ position of the point on the curve at that parameter
evalCurve (Curve f _ _) t = f t
| 192
|
evalCurve :: Curve -- ^ the curve
-> Double -- ^ the parameter
-> Position
evalCurve (Curve f _ _) t = f t
| 133
|
evalCurve (Curve f _ _) t = f t
| 31
| true
| true
| 0
| 10
| 63
| 45
| 22
| 23
| null | null |
quyse/flaw
|
flaw-graphics/Flaw/Graphics/Program.hs
|
mit
|
constf :: Float -> Node Float
constf = cnst
| 43
|
constf :: Float -> Node Float
constf = cnst
| 43
|
constf = cnst
| 13
| false
| true
| 0
| 6
| 8
| 18
| 9
| 9
| null | null |
dan-t/cabal-bounds
|
lib/CabalBounds/Args.hs
|
bsd-3-clause
|
defaultFormat :: Args
defaultFormat = Format
{ output = def
, cabalFile = def
}
| 91
|
defaultFormat :: Args
defaultFormat = Format
{ output = def
, cabalFile = def
}
| 91
|
defaultFormat = Format
{ output = def
, cabalFile = def
}
| 69
| false
| true
| 0
| 7
| 26
| 29
| 16
| 13
| null | null |
juhp/gtk2hs
|
gtk/demo/gtkbuilder/GtkBuilderTest.hs
|
lgpl-3.0
|
main = do
initGUI
-- Create the builder, and load the UI file
builder <- builderNew
builderAddFromFile builder "simple.ui"
-- Retrieve some objects from the UI
window <- builderGetObject builder castToWindow "window1"
button <- builderGetObject builder castToButton "button1"
-- Basic user interation
on button buttonActivated $ putStrLn "button pressed!"
on window objectDestroy mainQuit
-- Display the window
widgetShowAll window
mainGUI
| 547
|
main = do
initGUI
-- Create the builder, and load the UI file
builder <- builderNew
builderAddFromFile builder "simple.ui"
-- Retrieve some objects from the UI
window <- builderGetObject builder castToWindow "window1"
button <- builderGetObject builder castToButton "button1"
-- Basic user interation
on button buttonActivated $ putStrLn "button pressed!"
on window objectDestroy mainQuit
-- Display the window
widgetShowAll window
mainGUI
| 547
|
main = do
initGUI
-- Create the builder, and load the UI file
builder <- builderNew
builderAddFromFile builder "simple.ui"
-- Retrieve some objects from the UI
window <- builderGetObject builder castToWindow "window1"
button <- builderGetObject builder castToButton "button1"
-- Basic user interation
on button buttonActivated $ putStrLn "button pressed!"
on window objectDestroy mainQuit
-- Display the window
widgetShowAll window
mainGUI
| 547
| false
| false
| 0
| 8
| 167
| 90
| 39
| 51
| null | null |
oldmanmike/ghc
|
compiler/codeGen/StgCmmPrim.hs
|
bsd-3-clause
|
doVecUnpackOp :: Maybe MachOp -- Cast from vector component to element result
-> CmmType -- Type of vector
-> CmmExpr -- Vector
-> [CmmFormal] -- Element results
-> FCode ()
doVecUnpackOp maybe_post_read_cast ty e res =
vecUnpack res 0
where
vecUnpack :: [CmmFormal] -> Int -> FCode ()
vecUnpack [] _ =
return ()
vecUnpack (r : rs) i = do
if isFloatType (vecElemType ty)
then emitAssign (CmmLocal r) (cast (CmmMachOp (MO_VF_Extract len wid)
[e, iLit]))
else emitAssign (CmmLocal r) (cast (CmmMachOp (MO_V_Extract len wid)
[e, iLit]))
vecUnpack rs (i + 1)
where
-- vector indices are always 32-bits
iLit = CmmLit (CmmInt (toInteger i) W32)
cast :: CmmExpr -> CmmExpr
cast val = case maybe_post_read_cast of
Nothing -> val
Just cast -> CmmMachOp cast [val]
len :: Length
len = vecLength ty
wid :: Width
wid = typeWidth (vecElemType ty)
| 1,142
|
doVecUnpackOp :: Maybe MachOp -- Cast from vector component to element result
-> CmmType -- Type of vector
-> CmmExpr -- Vector
-> [CmmFormal] -- Element results
-> FCode ()
doVecUnpackOp maybe_post_read_cast ty e res =
vecUnpack res 0
where
vecUnpack :: [CmmFormal] -> Int -> FCode ()
vecUnpack [] _ =
return ()
vecUnpack (r : rs) i = do
if isFloatType (vecElemType ty)
then emitAssign (CmmLocal r) (cast (CmmMachOp (MO_VF_Extract len wid)
[e, iLit]))
else emitAssign (CmmLocal r) (cast (CmmMachOp (MO_V_Extract len wid)
[e, iLit]))
vecUnpack rs (i + 1)
where
-- vector indices are always 32-bits
iLit = CmmLit (CmmInt (toInteger i) W32)
cast :: CmmExpr -> CmmExpr
cast val = case maybe_post_read_cast of
Nothing -> val
Just cast -> CmmMachOp cast [val]
len :: Length
len = vecLength ty
wid :: Width
wid = typeWidth (vecElemType ty)
| 1,142
|
doVecUnpackOp maybe_post_read_cast ty e res =
vecUnpack res 0
where
vecUnpack :: [CmmFormal] -> Int -> FCode ()
vecUnpack [] _ =
return ()
vecUnpack (r : rs) i = do
if isFloatType (vecElemType ty)
then emitAssign (CmmLocal r) (cast (CmmMachOp (MO_VF_Extract len wid)
[e, iLit]))
else emitAssign (CmmLocal r) (cast (CmmMachOp (MO_V_Extract len wid)
[e, iLit]))
vecUnpack rs (i + 1)
where
-- vector indices are always 32-bits
iLit = CmmLit (CmmInt (toInteger i) W32)
cast :: CmmExpr -> CmmExpr
cast val = case maybe_post_read_cast of
Nothing -> val
Just cast -> CmmMachOp cast [val]
len :: Length
len = vecLength ty
wid :: Width
wid = typeWidth (vecElemType ty)
| 897
| false
| true
| 0
| 14
| 449
| 341
| 169
| 172
| null | null |
Garygunn94/DFS
|
FileServer/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen/Paths_FileServer.hs
|
bsd-3-clause
|
getSysconfDir = catchIO (getEnv "FileServer_sysconfdir") (\_ -> return sysconfdir)
| 82
|
getSysconfDir = catchIO (getEnv "FileServer_sysconfdir") (\_ -> return sysconfdir)
| 82
|
getSysconfDir = catchIO (getEnv "FileServer_sysconfdir") (\_ -> return sysconfdir)
| 82
| false
| false
| 1
| 8
| 8
| 32
| 14
| 18
| null | null |
rueshyna/gogol
|
gogol-books/gen/Network/Google/Books/Types/Product.hs
|
mpl-2.0
|
-- | Creates a value of 'CategoryItemsItem' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ciiName'
--
-- * 'ciiCategoryId'
--
-- * 'ciiBadgeURL'
categoryItemsItem
:: CategoryItemsItem
categoryItemsItem =
CategoryItemsItem'
{ _ciiName = Nothing
, _ciiCategoryId = Nothing
, _ciiBadgeURL = Nothing
}
| 409
|
categoryItemsItem
:: CategoryItemsItem
categoryItemsItem =
CategoryItemsItem'
{ _ciiName = Nothing
, _ciiCategoryId = Nothing
, _ciiBadgeURL = Nothing
}
| 176
|
categoryItemsItem =
CategoryItemsItem'
{ _ciiName = Nothing
, _ciiCategoryId = Nothing
, _ciiBadgeURL = Nothing
}
| 133
| true
| true
| 0
| 7
| 84
| 50
| 30
| 20
| null | null |
aaronvargo/aaronvargo.github.io
|
src/Main.hs
|
bsd-3-clause
|
postCompiler :: Compiler (Item String)
postCompiler =
myPandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= saveSnapshot contentSnapshot
>>= loadAndApplyTemplate "templates/title.html" postCtx
>>= saveSnapshot titledContentSnapshot
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
| 344
|
postCompiler :: Compiler (Item String)
postCompiler =
myPandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= saveSnapshot contentSnapshot
>>= loadAndApplyTemplate "templates/title.html" postCtx
>>= saveSnapshot titledContentSnapshot
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
| 344
|
postCompiler =
myPandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= saveSnapshot contentSnapshot
>>= loadAndApplyTemplate "templates/title.html" postCtx
>>= saveSnapshot titledContentSnapshot
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
| 305
| false
| true
| 14
| 6
| 41
| 87
| 36
| 51
| null | null |
Fuco1/mpris
|
src/DBus/Mpris/MediaPlayer2/Player/Methods.hs
|
gpl-3.0
|
mprisCall :: MemberName -> MethodCall
mprisCall = methodCall "/org/mpris/MediaPlayer2" "org.mpris.MediaPlayer2.Player"
| 118
|
mprisCall :: MemberName -> MethodCall
mprisCall = methodCall "/org/mpris/MediaPlayer2" "org.mpris.MediaPlayer2.Player"
| 118
|
mprisCall = methodCall "/org/mpris/MediaPlayer2" "org.mpris.MediaPlayer2.Player"
| 80
| false
| true
| 0
| 5
| 9
| 20
| 10
| 10
| null | null |
b1g3ar5/Spreadsheet
|
Arithmetic.hs
|
mit
|
-- | log function
vln :: [Value] -> Value
vln (x:[]) = log x
| 60
|
vln :: [Value] -> Value
vln (x:[]) = log x
| 42
|
vln (x:[]) = log x
| 18
| true
| true
| 0
| 8
| 13
| 34
| 18
| 16
| null | null |
siddhanathan/ghc
|
compiler/prelude/PrelNames.hs
|
bsd-3-clause
|
boolTyConKey = mkPreludeTyConUnique 4
| 65
|
boolTyConKey = mkPreludeTyConUnique 4
| 65
|
boolTyConKey = mkPreludeTyConUnique 4
| 65
| false
| false
| 0
| 5
| 31
| 9
| 4
| 5
| null | null |
rpereira/servant-blog
|
src/Api/Registration.hs
|
bsd-3-clause
|
login :: Usr Login -> App (Usr (Maybe AuthUser))
login (Usr (Login email password)) = do
maybeUser <- runDb $
selectFirst [UserEmail ==. email, UserPassword ==. password] []
case maybeUser of
Nothing -> throwError err401 { errBody = "Incorrect username or password" }
Just user -> return . Usr $ fmap userToAuth maybeUser
| 349
|
login :: Usr Login -> App (Usr (Maybe AuthUser))
login (Usr (Login email password)) = do
maybeUser <- runDb $
selectFirst [UserEmail ==. email, UserPassword ==. password] []
case maybeUser of
Nothing -> throwError err401 { errBody = "Incorrect username or password" }
Just user -> return . Usr $ fmap userToAuth maybeUser
| 349
|
login (Usr (Login email password)) = do
maybeUser <- runDb $
selectFirst [UserEmail ==. email, UserPassword ==. password] []
case maybeUser of
Nothing -> throwError err401 { errBody = "Incorrect username or password" }
Just user -> return . Usr $ fmap userToAuth maybeUser
| 300
| false
| true
| 0
| 13
| 80
| 133
| 63
| 70
| null | null |
ebakan/haskell-gates
|
gates.hs
|
mit
|
apply4 fn _ = []
| 16
|
apply4 fn _ = []
| 16
|
apply4 fn _ = []
| 16
| false
| false
| 0
| 5
| 4
| 13
| 6
| 7
| null | null |
mzini/TcT
|
source/Tct/Interactive.hs
|
gpl-3.0
|
loadIDC :: FilePath -> IO ()
loadIDC n = load' n >> setIDC
| 58
|
loadIDC :: FilePath -> IO ()
loadIDC n = load' n >> setIDC
| 58
|
loadIDC n = load' n >> setIDC
| 29
| false
| true
| 2
| 8
| 12
| 36
| 15
| 21
| null | null |
beni55/haste-compiler
|
libraries/ghc-7.10/base/include/HaskellConstants.hs
|
bsd-3-clause
|
mAX_SPEC_FUN_SIZE :: Int
mAX_SPEC_FUN_SIZE = MAX_SPEC_FUN_SIZE
| 62
|
mAX_SPEC_FUN_SIZE :: Int
mAX_SPEC_FUN_SIZE = MAX_SPEC_FUN_SIZE
| 62
|
mAX_SPEC_FUN_SIZE = MAX_SPEC_FUN_SIZE
| 37
| false
| true
| 0
| 6
| 5
| 18
| 7
| 11
| null | null |
sgillespie/ghc
|
compiler/codeGen/StgCmmPrim.hs
|
bsd-3-clause
|
-- IndexXXXArray
emitPrimOp dflags res IndexByteArrayOp_Char args = doIndexByteArrayOp (Just (mo_u_8ToWord dflags)) b8 res args
| 142
|
emitPrimOp dflags res IndexByteArrayOp_Char args = doIndexByteArrayOp (Just (mo_u_8ToWord dflags)) b8 res args
| 124
|
emitPrimOp dflags res IndexByteArrayOp_Char args = doIndexByteArrayOp (Just (mo_u_8ToWord dflags)) b8 res args
| 124
| true
| false
| 0
| 9
| 29
| 37
| 18
| 19
| null | null |
nomeata/ghc
|
compiler/codeGen/CgPrimOp.hs
|
bsd-3-clause
|
emitPrimOp res IndexOffAddrOp_Word8 args _ = doIndexOffAddrOp (Just mo_u_8ToWord) b8 res args
| 99
|
emitPrimOp res IndexOffAddrOp_Word8 args _ = doIndexOffAddrOp (Just mo_u_8ToWord) b8 res args
| 99
|
emitPrimOp res IndexOffAddrOp_Word8 args _ = doIndexOffAddrOp (Just mo_u_8ToWord) b8 res args
| 99
| false
| false
| 0
| 7
| 17
| 33
| 14
| 19
| null | null |
xnning/TypeInfer
|
src/Environment.hs
|
gpl-3.0
|
genTVar :: (Fresh m) => m Expr
genTVar = do nm <- genName
return (TVar nm)
-----------------------------------------
-- instantiation
-----------------------------------------
-- instantiation used in var
| 220
|
genTVar :: (Fresh m) => m Expr
genTVar = do nm <- genName
return (TVar nm)
-----------------------------------------
-- instantiation
-----------------------------------------
-- instantiation used in var
| 220
|
genTVar = do nm <- genName
return (TVar nm)
-----------------------------------------
-- instantiation
-----------------------------------------
-- instantiation used in var
| 189
| false
| true
| 0
| 10
| 40
| 52
| 25
| 27
| null | null |
nilscc/weightlifting.cc
|
src-hs/LiftMe/Html/MainPage.hs
|
bsd-3-clause
|
defaultMainPage
:: Html -- ^ Menu
-> Html -- ^ Content
-> Html -- ^ Footer
-> MainPage
defaultMainPage menu content footer = emptyMainPage
{ css = [ LinkStylesheet "style/main.css" ]
, js = [ LinkJavascript "js/main.js" [] ]
, menu = menu
, content = content
, footer = footer
}
| 317
|
defaultMainPage
:: Html -- ^ Menu
-> Html -- ^ Content
-> Html -- ^ Footer
-> MainPage
defaultMainPage menu content footer = emptyMainPage
{ css = [ LinkStylesheet "style/main.css" ]
, js = [ LinkJavascript "js/main.js" [] ]
, menu = menu
, content = content
, footer = footer
}
| 317
|
defaultMainPage menu content footer = emptyMainPage
{ css = [ LinkStylesheet "style/main.css" ]
, js = [ LinkJavascript "js/main.js" [] ]
, menu = menu
, content = content
, footer = footer
}
| 216
| false
| true
| 0
| 10
| 90
| 90
| 49
| 41
| null | null |
TomMD/ghc
|
testsuite/tests/simplCore/should_run/T5441a.hs
|
bsd-3-clause
|
showNat :: Nat -> String
showNat = coe2 (showInBase Z)
| 55
|
showNat :: Nat -> String
showNat = coe2 (showInBase Z)
| 54
|
showNat = coe2 (showInBase Z)
| 29
| false
| true
| 0
| 7
| 10
| 24
| 12
| 12
| null | null |
sleexyz/haskell-fun
|
TTFI.hs
|
bsd-3-clause
|
zeroAddPass :: Optimization IsZero
zeroAddPass program sym = bwd (program nextSym)
where
MkOptData { fwd, bwd } = getOptData sym
baseOpt@MkSymantics { .. } = getBaseOpt sym
nextSym = baseOpt {
int = \x -> if x == 0 then WrapZero else int x,
add = \x y -> case (x, y) of
(WrapZero, x) -> x
(x, WrapZero) -> x
(x, y) -> add x y
}
| 381
|
zeroAddPass :: Optimization IsZero
zeroAddPass program sym = bwd (program nextSym)
where
MkOptData { fwd, bwd } = getOptData sym
baseOpt@MkSymantics { .. } = getBaseOpt sym
nextSym = baseOpt {
int = \x -> if x == 0 then WrapZero else int x,
add = \x y -> case (x, y) of
(WrapZero, x) -> x
(x, WrapZero) -> x
(x, y) -> add x y
}
| 381
|
zeroAddPass program sym = bwd (program nextSym)
where
MkOptData { fwd, bwd } = getOptData sym
baseOpt@MkSymantics { .. } = getBaseOpt sym
nextSym = baseOpt {
int = \x -> if x == 0 then WrapZero else int x,
add = \x y -> case (x, y) of
(WrapZero, x) -> x
(x, WrapZero) -> x
(x, y) -> add x y
}
| 346
| false
| true
| 0
| 11
| 121
| 164
| 88
| 76
| null | null |
aartifact/aartifact-verifier
|
src/ExpSubst.hs
|
mit
|
exmchq' ps ns xs e xs' e' =
let ps' = [(x,x') | (x,x')<-ps, not (x `elem` xs || x' `elem` xs')]
in if xs `eql` xs' then
exmch' ps' (ns `diff` xs) e e'
else if length xs == length xs' then
exmch' (ps'++(zip xs xs')) ((ns `diff` xs) `diff` xs') e e'
else Nothing
| 288
|
exmchq' ps ns xs e xs' e' =
let ps' = [(x,x') | (x,x')<-ps, not (x `elem` xs || x' `elem` xs')]
in if xs `eql` xs' then
exmch' ps' (ns `diff` xs) e e'
else if length xs == length xs' then
exmch' (ps'++(zip xs xs')) ((ns `diff` xs) `diff` xs') e e'
else Nothing
| 288
|
exmchq' ps ns xs e xs' e' =
let ps' = [(x,x') | (x,x')<-ps, not (x `elem` xs || x' `elem` xs')]
in if xs `eql` xs' then
exmch' ps' (ns `diff` xs) e e'
else if length xs == length xs' then
exmch' (ps'++(zip xs xs')) ((ns `diff` xs) `diff` xs') e e'
else Nothing
| 288
| false
| false
| 0
| 15
| 83
| 171
| 95
| 76
| null | null |
harendra-kumar/asyncly
|
src/Streamly/Internal/Data/Stream/StreamD/Type.hs
|
bsd-3-clause
|
toStreamK :: Monad m => Stream m a -> K.Stream m a
toStreamK (Stream step state) = go state
where
go st = K.mkStream $ \gst yld _ stp ->
let go' ss = do
r <- step gst ss
case r of
Yield x s -> yld x (go s)
Skip s -> go' s
Stop -> stp
in go' st
#ifndef DISABLE_FUSION
| 363
|
toStreamK :: Monad m => Stream m a -> K.Stream m a
toStreamK (Stream step state) = go state
where
go st = K.mkStream $ \gst yld _ stp ->
let go' ss = do
r <- step gst ss
case r of
Yield x s -> yld x (go s)
Skip s -> go' s
Stop -> stp
in go' st
#ifndef DISABLE_FUSION
| 363
|
toStreamK (Stream step state) = go state
where
go st = K.mkStream $ \gst yld _ stp ->
let go' ss = do
r <- step gst ss
case r of
Yield x s -> yld x (go s)
Skip s -> go' s
Stop -> stp
in go' st
#ifndef DISABLE_FUSION
| 312
| false
| true
| 0
| 20
| 160
| 152
| 70
| 82
| null | null |
DanBurton/sexy
|
src/Sexy/Functions/Bool.hs
|
bsd-3-clause
|
toBool :: (BoolC b) => b -> Bool
toBool = fromBool
| 50
|
toBool :: (BoolC b) => b -> Bool
toBool = fromBool
| 50
|
toBool = fromBool
| 17
| false
| true
| 0
| 8
| 10
| 31
| 14
| 17
| null | null |
lukexi/cabal
|
cabal-install/Main.hs
|
bsd-3-clause
|
wrapperCmd :: Monoid flags => CommandUI flags -> (flags -> Flag Verbosity)
-> (flags -> Flag String) -> CommandSpec Action
wrapperCmd ui verbosity distPref =
CommandSpec ui (\ui' -> wrapperAction ui' verbosity distPref) NormalCommand
| 246
|
wrapperCmd :: Monoid flags => CommandUI flags -> (flags -> Flag Verbosity)
-> (flags -> Flag String) -> CommandSpec Action
wrapperCmd ui verbosity distPref =
CommandSpec ui (\ui' -> wrapperAction ui' verbosity distPref) NormalCommand
| 246
|
wrapperCmd ui verbosity distPref =
CommandSpec ui (\ui' -> wrapperAction ui' verbosity distPref) NormalCommand
| 112
| false
| true
| 0
| 12
| 46
| 91
| 42
| 49
| null | null |
BartMassey/list-combinators
|
Data/List/Combinator.hs
|
bsd-3-clause
|
-- | The 'dropWhileEnd' function drops the largest suffix of a list
-- in which the given predicate holds for all elements. Some examples:
--
-- > dropWhileEnd isSpace "foo\n" == "foo"
-- > dropWhileEnd isSpace "foo bar" == "foo bar"
-- > dropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined
--
-- /O(n)/ plus the cost of evaluating the predicate. Laws:
--
-- > forall p x xs | not (p x) .
-- > dropWhileEnd p (xs ++ [x]) == xs ++ [x]
-- > forall p x xs | p x .
-- > dropWhileEnd p (xs ++ [x]) == dropWhileEnd p xs
dropWhileEnd :: (a -> Bool) -> [a] -> [a]
dropWhileEnd p xs = fst $ spanEnd p xs
| 617
|
dropWhileEnd :: (a -> Bool) -> [a] -> [a]
dropWhileEnd p xs = fst $ spanEnd p xs
| 80
|
dropWhileEnd p xs = fst $ spanEnd p xs
| 38
| true
| true
| 0
| 7
| 133
| 59
| 37
| 22
| null | null |
nikita-volkov/type-structure
|
src/TypeStructure/Prelude/Data.hs
|
mit
|
packText = Data.Text.pack
| 25
|
packText = Data.Text.pack
| 25
|
packText = Data.Text.pack
| 25
| false
| false
| 0
| 5
| 2
| 9
| 5
| 4
| null | null |
rueshyna/gogol
|
gogol-storage/gen/Network/Google/Storage/Types/Product.hs
|
mpl-2.0
|
-- | The email address associated with the entity, if any.
oacaEmail :: Lens' ObjectAccessControl (Maybe Text)
oacaEmail
= lens _oacaEmail (\ s a -> s{_oacaEmail = a})
| 169
|
oacaEmail :: Lens' ObjectAccessControl (Maybe Text)
oacaEmail
= lens _oacaEmail (\ s a -> s{_oacaEmail = a})
| 110
|
oacaEmail
= lens _oacaEmail (\ s a -> s{_oacaEmail = a})
| 58
| true
| true
| 0
| 9
| 29
| 48
| 25
| 23
| null | null |
svenssonjoel/GCDObsidian
|
Obsidian/GCDObsidian/Exp.hs
|
bsd-3-clause
|
expToCExpGeneral e@(BinOp Max e1 e2) = cFuncExpr "max" [expToCExp e1, expToCExp e2] (typeToCType (typeOf e))
| 108
|
expToCExpGeneral e@(BinOp Max e1 e2) = cFuncExpr "max" [expToCExp e1, expToCExp e2] (typeToCType (typeOf e))
| 108
|
expToCExpGeneral e@(BinOp Max e1 e2) = cFuncExpr "max" [expToCExp e1, expToCExp e2] (typeToCType (typeOf e))
| 108
| false
| false
| 0
| 9
| 14
| 53
| 26
| 27
| null | null |
ulricha/dsh
|
src/Database/DSH/CL/Opt/Auxiliary.hs
|
bsd-3-clause
|
subst (If ty e1 e2 e3) = If ty <$> subst e1 <*> subst e2 <*> subst e3
| 69
|
subst (If ty e1 e2 e3) = If ty <$> subst e1 <*> subst e2 <*> subst e3
| 69
|
subst (If ty e1 e2 e3) = If ty <$> subst e1 <*> subst e2 <*> subst e3
| 69
| false
| false
| 2
| 7
| 17
| 47
| 20
| 27
| null | null |
micxjo/regex-ast
|
src/Text/Regex/AST.hs
|
bsd-3-clause
|
builder (Repeat sub 0 Nothing) = builder sub <> singleton '*'
| 61
|
builder (Repeat sub 0 Nothing) = builder sub <> singleton '*'
| 61
|
builder (Repeat sub 0 Nothing) = builder sub <> singleton '*'
| 61
| false
| false
| 0
| 7
| 10
| 29
| 13
| 16
| null | null |
tomjnixon/buzzlang
|
src/Parser.hs
|
mit
|
cdrParser = do reserved "centralise"
arg <- expressionParser
return $ Cdr arg
| 107
|
cdrParser = do reserved "centralise"
arg <- expressionParser
return $ Cdr arg
| 107
|
cdrParser = do reserved "centralise"
arg <- expressionParser
return $ Cdr arg
| 107
| false
| false
| 0
| 8
| 41
| 29
| 12
| 17
| null | null |
jtdaugherty/vty-ui-builder-xml
|
tests/Validation.hs
|
bsd-3-clause
|
partitionBy :: (Eq a) => [a] -> a -> [[a]]
partitionBy stuff d = partitionBy' stuff d []
where
partitionBy' [] _ cur = if null cur
then []
else [cur]
partitionBy' (e:es) delim cur =
if e == delim
then [cur] ++ partitionBy' es delim []
else partitionBy' es delim (cur ++ [e])
| 380
|
partitionBy :: (Eq a) => [a] -> a -> [[a]]
partitionBy stuff d = partitionBy' stuff d []
where
partitionBy' [] _ cur = if null cur
then []
else [cur]
partitionBy' (e:es) delim cur =
if e == delim
then [cur] ++ partitionBy' es delim []
else partitionBy' es delim (cur ++ [e])
| 380
|
partitionBy stuff d = partitionBy' stuff d []
where
partitionBy' [] _ cur = if null cur
then []
else [cur]
partitionBy' (e:es) delim cur =
if e == delim
then [cur] ++ partitionBy' es delim []
else partitionBy' es delim (cur ++ [e])
| 337
| false
| true
| 1
| 11
| 159
| 158
| 79
| 79
| null | null |
todays-mitsui/discussion
|
test/UnitBool.hs
|
mit
|
case_x_is_bound_in_term =
assertBool "" $ x `isBoundIn` App [VarT z, Lambda [y] (App [VarT y, VarT x]), VarT y]
| 113
|
case_x_is_bound_in_term =
assertBool "" $ x `isBoundIn` App [VarT z, Lambda [y] (App [VarT y, VarT x]), VarT y]
| 113
|
case_x_is_bound_in_term =
assertBool "" $ x `isBoundIn` App [VarT z, Lambda [y] (App [VarT y, VarT x]), VarT y]
| 113
| false
| false
| 0
| 12
| 20
| 63
| 32
| 31
| null | null |
trxeste/wrk
|
haskell/haskellTextEditor/haskellEd.hs
|
bsd-3-clause
|
edt _ = do
setCursorPosition 16 0
clearFromCursorToScreenBeginning
let buff= fillDocument "-- "
process buff
runInputT defaultSettings (repl buff)
| 156
|
edt _ = do
setCursorPosition 16 0
clearFromCursorToScreenBeginning
let buff= fillDocument "-- "
process buff
runInputT defaultSettings (repl buff)
| 156
|
edt _ = do
setCursorPosition 16 0
clearFromCursorToScreenBeginning
let buff= fillDocument "-- "
process buff
runInputT defaultSettings (repl buff)
| 156
| false
| false
| 0
| 10
| 28
| 52
| 21
| 31
| null | null |
christiaanb/ghc
|
testsuite/tests/typecheck/should_compile/Improvement.hs
|
bsd-3-clause
|
foo :: Bool
foo = blug undefined
| 32
|
foo :: Bool
foo = blug undefined
| 32
|
foo = blug undefined
| 20
| false
| true
| 0
| 6
| 6
| 20
| 8
| 12
| null | null |
akegalj/snowdrift
|
tests/NotifyTest.hs
|
agpl-3.0
|
projectNotificationContent
:: From query expr backend (expr (Entity ProjectNotification))
=> UserId -> ProjectNotificationType
-> query (expr (Value Markdown))
projectNotificationContent =
notificationContent
ProjectNotificationTo ProjectNotificationType ProjectNotificationContent
| 305
|
projectNotificationContent
:: From query expr backend (expr (Entity ProjectNotification))
=> UserId -> ProjectNotificationType
-> query (expr (Value Markdown))
projectNotificationContent =
notificationContent
ProjectNotificationTo ProjectNotificationType ProjectNotificationContent
| 305
|
projectNotificationContent =
notificationContent
ProjectNotificationTo ProjectNotificationType ProjectNotificationContent
| 133
| false
| true
| 0
| 13
| 47
| 72
| 33
| 39
| null | null |
josuf107/Adverb
|
Adverb/Common.hs
|
gpl-3.0
|
formally = id
| 13
|
formally = id
| 13
|
formally = id
| 13
| false
| false
| 0
| 4
| 2
| 6
| 3
| 3
| null | null |
hguenther/fac
|
Formula.hs
|
gpl-3.0
|
flattenFormula (Or x y) = Or (flattenFormula x) (flattenFormula y)
| 66
|
flattenFormula (Or x y) = Or (flattenFormula x) (flattenFormula y)
| 66
|
flattenFormula (Or x y) = Or (flattenFormula x) (flattenFormula y)
| 66
| false
| false
| 0
| 7
| 9
| 35
| 16
| 19
| null | null |
nevrenato/Hets_Fork
|
SoftFOL/DFGParser.hs
|
gpl-2.0
|
proofList :: Parser SPProofList
proofList = do
listOf "proof"
pa <- optionMaybe $ parensDot $ do
pt <- optionMaybe getproofType
assList <- option Map.empty (comma >> assocList)
return (pt, assList)
steps <- many proofStep
endOfList
return $ case pa of
Nothing -> SPProofList
{ proofType = Nothing
, plAssocList = Map.empty
, step = steps}
Just (pt, mal) -> SPProofList
{ proofType = pt
, plAssocList = mal
, step = steps}
| 525
|
proofList :: Parser SPProofList
proofList = do
listOf "proof"
pa <- optionMaybe $ parensDot $ do
pt <- optionMaybe getproofType
assList <- option Map.empty (comma >> assocList)
return (pt, assList)
steps <- many proofStep
endOfList
return $ case pa of
Nothing -> SPProofList
{ proofType = Nothing
, plAssocList = Map.empty
, step = steps}
Just (pt, mal) -> SPProofList
{ proofType = pt
, plAssocList = mal
, step = steps}
| 525
|
proofList = do
listOf "proof"
pa <- optionMaybe $ parensDot $ do
pt <- optionMaybe getproofType
assList <- option Map.empty (comma >> assocList)
return (pt, assList)
steps <- many proofStep
endOfList
return $ case pa of
Nothing -> SPProofList
{ proofType = Nothing
, plAssocList = Map.empty
, step = steps}
Just (pt, mal) -> SPProofList
{ proofType = pt
, plAssocList = mal
, step = steps}
| 493
| false
| true
| 0
| 14
| 175
| 165
| 84
| 81
| null | null |
olsner/ghc
|
compiler/prelude/PrelNames.hs
|
bsd-3-clause
|
compose_RDR :: RdrName
compose_RDR = varQual_RDR gHC_BASE (fsLit ".")
| 81
|
compose_RDR :: RdrName
compose_RDR = varQual_RDR gHC_BASE (fsLit ".")
| 81
|
compose_RDR = varQual_RDR gHC_BASE (fsLit ".")
| 58
| false
| true
| 0
| 7
| 20
| 22
| 11
| 11
| null | null |
riwsky/wiwinwlh
|
src/free_dsl.hs
|
mit
|
interp :: IOFree a -> IO a
interp (Pure r) = return r
| 53
|
interp :: IOFree a -> IO a
interp (Pure r) = return r
| 53
|
interp (Pure r) = return r
| 26
| false
| true
| 0
| 7
| 12
| 33
| 15
| 18
| null | null |
facebookincubator/duckling
|
Duckling/Time/EN/TT/Rules.hs
|
bsd-3-clause
|
ruleDDMMYYYY :: Rule
ruleDDMMYYYY = Rule
{ name = "dd/mm/yyyy"
, pattern =
[ regex "(3[01]|[12]\\d|0?[1-9])[-/\\s](1[0-2]|0?[1-9])[-/\\s](\\d{2,4})"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (dd:mm:yy:_)):_) -> do
y <- parseInt yy
d <- parseInt dd
m <- parseInt mm
tt $ yearMonthDay y m d
_ -> Nothing
}
| 388
|
ruleDDMMYYYY :: Rule
ruleDDMMYYYY = Rule
{ name = "dd/mm/yyyy"
, pattern =
[ regex "(3[01]|[12]\\d|0?[1-9])[-/\\s](1[0-2]|0?[1-9])[-/\\s](\\d{2,4})"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (dd:mm:yy:_)):_) -> do
y <- parseInt yy
d <- parseInt dd
m <- parseInt mm
tt $ yearMonthDay y m d
_ -> Nothing
}
| 388
|
ruleDDMMYYYY = Rule
{ name = "dd/mm/yyyy"
, pattern =
[ regex "(3[01]|[12]\\d|0?[1-9])[-/\\s](1[0-2]|0?[1-9])[-/\\s](\\d{2,4})"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (dd:mm:yy:_)):_) -> do
y <- parseInt yy
d <- parseInt dd
m <- parseInt mm
tt $ yearMonthDay y m d
_ -> Nothing
}
| 367
| false
| true
| 0
| 20
| 112
| 139
| 69
| 70
| null | null |
tjakway/ghcjvm
|
compiler/codeGen/StgCmmMonad.hs
|
bsd-3-clause
|
getCmm :: FCode () -> FCode CmmGroup
-- Get all the CmmTops (there should be no stmts)
-- Return a single Cmm which may be split from other Cmms by
-- object splitting (at a later stage)
getCmm code
= do { state1 <- getState
; ((), state2) <- withState code (state1 { cgs_tops = nilOL })
; setState $ state2 { cgs_tops = cgs_tops state1 }
; return (fromOL (cgs_tops state2)) }
| 404
|
getCmm :: FCode () -> FCode CmmGroup
getCmm code
= do { state1 <- getState
; ((), state2) <- withState code (state1 { cgs_tops = nilOL })
; setState $ state2 { cgs_tops = cgs_tops state1 }
; return (fromOL (cgs_tops state2)) }
| 254
|
getCmm code
= do { state1 <- getState
; ((), state2) <- withState code (state1 { cgs_tops = nilOL })
; setState $ state2 { cgs_tops = cgs_tops state1 }
; return (fromOL (cgs_tops state2)) }
| 217
| true
| true
| 0
| 12
| 100
| 113
| 58
| 55
| null | null |
mitchellwrosen/srcloc
|
Data/Loc.hs
|
bsd-3-clause
|
-- | Format a position in a human-readable way.
displaySPos :: Pos -> ShowS
displaySPos p = displaySLoc (Loc p p)
| 113
|
displaySPos :: Pos -> ShowS
displaySPos p = displaySLoc (Loc p p)
| 65
|
displaySPos p = displaySLoc (Loc p p)
| 37
| true
| true
| 0
| 7
| 20
| 30
| 15
| 15
| null | null |
termite2/debug
|
Debug/CodeWin.hs
|
bsd-3-clause
|
isMBActive :: MBDescr -> Bool
isMBActive (MBA _) = True
| 55
|
isMBActive :: MBDescr -> Bool
isMBActive (MBA _) = True
| 55
|
isMBActive (MBA _) = True
| 25
| false
| true
| 0
| 7
| 9
| 24
| 12
| 12
| null | null |
keithodulaigh/Hets
|
Common/Keywords.hs
|
gpl-2.0
|
left_assocS :: String
left_assocS = "left_assoc"
| 48
|
left_assocS :: String
left_assocS = "left_assoc"
| 48
|
left_assocS = "left_assoc"
| 26
| false
| true
| 0
| 4
| 5
| 11
| 6
| 5
| null | null |
amccausl/Swish
|
Swish/HaskellRDF/RDFGraphTest.hs
|
lgpl-2.1
|
lt2 = Just (langName "EN")
| 26
|
lt2 = Just (langName "EN")
| 26
|
lt2 = Just (langName "EN")
| 26
| false
| false
| 1
| 7
| 4
| 18
| 7
| 11
| null | null |
trskop/cabal
|
cabal-install/Main.hs
|
bsd-3-clause
|
updateAction :: Flag Verbosity -> [String] -> Action
updateAction verbosityFlag extraArgs globalFlags = do
unless (null extraArgs) $
die $ "'update' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag verbosityFlag
(_useSandbox, config) <- loadConfigOrSandboxConfig verbosity
(globalFlags { globalRequireSandbox = Flag False })
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
transport <- configureTransport verbosity (flagToMaybe (globalHttpTransport globalFlags'))
update transport verbosity (globalRepos globalFlags')
| 610
|
updateAction :: Flag Verbosity -> [String] -> Action
updateAction verbosityFlag extraArgs globalFlags = do
unless (null extraArgs) $
die $ "'update' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag verbosityFlag
(_useSandbox, config) <- loadConfigOrSandboxConfig verbosity
(globalFlags { globalRequireSandbox = Flag False })
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
transport <- configureTransport verbosity (flagToMaybe (globalHttpTransport globalFlags'))
update transport verbosity (globalRepos globalFlags')
| 610
|
updateAction verbosityFlag extraArgs globalFlags = do
unless (null extraArgs) $
die $ "'update' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag verbosityFlag
(_useSandbox, config) <- loadConfigOrSandboxConfig verbosity
(globalFlags { globalRequireSandbox = Flag False })
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
transport <- configureTransport verbosity (flagToMaybe (globalHttpTransport globalFlags'))
update transport verbosity (globalRepos globalFlags')
| 557
| false
| true
| 0
| 12
| 108
| 161
| 77
| 84
| null | null |
esmolanka/haddock
|
haddock-api/src/Haddock/Backends/LaTeX.hs
|
bsd-2-clause
|
--------------------------------------------------------------------------------
-- * Type applications
--------------------------------------------------------------------------------
-- | Print an application of a DocName and two lists of HsTypes (kinds, types)
ppAppNameTypes :: DocName -> [HsType DocName] -> [HsType DocName] -> Bool -> LaTeX
ppAppNameTypes n ks ts unicode = ppTypeApp n ks ts ppDocName (ppParendType unicode)
| 432
|
ppAppNameTypes :: DocName -> [HsType DocName] -> [HsType DocName] -> Bool -> LaTeX
ppAppNameTypes n ks ts unicode = ppTypeApp n ks ts ppDocName (ppParendType unicode)
| 166
|
ppAppNameTypes n ks ts unicode = ppTypeApp n ks ts ppDocName (ppParendType unicode)
| 83
| true
| true
| 0
| 9
| 48
| 69
| 36
| 33
| null | null |
acowley/ghc
|
compiler/coreSyn/CoreUtils.hs
|
bsd-3-clause
|
-- Is an application of this function to n *value* args
-- always cheap, assuming the arguments are cheap?
-- Mainly true of partial applications, data constructors,
-- and of course true if the number of args is zero
isCheapApp :: CheapAppFun
isCheapApp fn n_val_args
= isDataConWorkId fn
|| n_val_args == 0
|| n_val_args < idArity fn
| 349
|
isCheapApp :: CheapAppFun
isCheapApp fn n_val_args
= isDataConWorkId fn
|| n_val_args == 0
|| n_val_args < idArity fn
| 124
|
isCheapApp fn n_val_args
= isDataConWorkId fn
|| n_val_args == 0
|| n_val_args < idArity fn
| 98
| true
| true
| 3
| 5
| 70
| 45
| 23
| 22
| null | null |
tjakway/ghcjvm
|
compiler/typecheck/TcType.hs
|
bsd-3-clause
|
isFskTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
FlatSkol {} -> True
_ -> False
| 136
|
isFskTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
FlatSkol {} -> True
_ -> False
| 136
|
isFskTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
FlatSkol {} -> True
_ -> False
| 136
| false
| false
| 0
| 9
| 51
| 49
| 23
| 26
| null | null |
tomjaguarpaw/postgresql-simple
|
tools/StringsQQ.hs
|
bsd-3-clause
|
longstringExp ('\n':xs) = stringE xs
| 36
|
longstringExp ('\n':xs) = stringE xs
| 36
|
longstringExp ('\n':xs) = stringE xs
| 36
| false
| false
| 0
| 7
| 4
| 19
| 9
| 10
| null | null |
bitemyapp/persistent
|
persistent-mongoDB/Database/Persist/MongoDB.hs
|
mit
|
collectionNameFromKey :: (PersistEntity record, PersistEntityBackend record ~ DB.MongoContext)
=> Key record -> Text
collectionNameFromKey = collectionName . recordTypeFromKey
| 197
|
collectionNameFromKey :: (PersistEntity record, PersistEntityBackend record ~ DB.MongoContext)
=> Key record -> Text
collectionNameFromKey = collectionName . recordTypeFromKey
| 197
|
collectionNameFromKey = collectionName . recordTypeFromKey
| 58
| false
| true
| 0
| 9
| 39
| 51
| 23
| 28
| null | null |
SavinaRoja/SavinaRoja.github.io
|
assets/centraldogma.hs
|
mit
|
-- Serine
geneticCode "AUA" = 'I'
| 33
|
geneticCode "AUA" = 'I'
| 23
|
geneticCode "AUA" = 'I'
| 23
| true
| false
| 0
| 5
| 5
| 10
| 5
| 5
| null | null |
danidiaz/Haskell-Foldl-Library
|
src/Control/Foldl.hs
|
bsd-3-clause
|
{-| Generalize a `Fold` to a `FoldM`
> generalize (pure r) = pure r
>
> generalize (f <*> x) = generalize f <*> generalize x
-}
generalize :: Monad m => Fold a b -> FoldM m a b
generalize (Fold step begin done) = FoldM step' begin' done'
where
step' x a = return (step x a)
begin' = return begin
done' x = return (done x)
| 343
|
generalize :: Monad m => Fold a b -> FoldM m a b
generalize (Fold step begin done) = FoldM step' begin' done'
where
step' x a = return (step x a)
begin' = return begin
done' x = return (done x)
| 214
|
generalize (Fold step begin done) = FoldM step' begin' done'
where
step' x a = return (step x a)
begin' = return begin
done' x = return (done x)
| 165
| true
| true
| 0
| 7
| 90
| 104
| 49
| 55
| null | null |
ulricha/dsh
|
src/Database/DSH/Tests/CombinatorTests.hs
|
bsd-3-clause
|
prop_map_eq :: (BackendVector b, VectorLang v) => (Integer, [Integer]) -> DSHProperty (v TExpr TExpr) b
prop_map_eq = makePropEq (\x -> Q.map (Q.fst x Q.==) $ Q.snd x) (\(x,xs) -> map (x ==) xs)
| 194
|
prop_map_eq :: (BackendVector b, VectorLang v) => (Integer, [Integer]) -> DSHProperty (v TExpr TExpr) b
prop_map_eq = makePropEq (\x -> Q.map (Q.fst x Q.==) $ Q.snd x) (\(x,xs) -> map (x ==) xs)
| 194
|
prop_map_eq = makePropEq (\x -> Q.map (Q.fst x Q.==) $ Q.snd x) (\(x,xs) -> map (x ==) xs)
| 90
| false
| true
| 0
| 12
| 32
| 118
| 62
| 56
| null | null |
mariefarrell/Hets
|
Comorphisms/ExtModal2HasCASL.hs
|
gpl-2.0
|
worldTy :: Type
worldTy = toType world
| 38
|
worldTy :: Type
worldTy = toType world
| 38
|
worldTy = toType world
| 22
| false
| true
| 0
| 5
| 6
| 14
| 7
| 7
| null | null |
jsavatgy/xroads-game
|
code/io-segs.hs
|
gpl-2.0
|
dirHalves = map
(\(a,b) -> b + 0.5*a)
(zip dirBetween (pairwise (\a b -> a) dirAngles))
| 93
|
dirHalves = map
(\(a,b) -> b + 0.5*a)
(zip dirBetween (pairwise (\a b -> a) dirAngles))
| 93
|
dirHalves = map
(\(a,b) -> b + 0.5*a)
(zip dirBetween (pairwise (\a b -> a) dirAngles))
| 93
| false
| false
| 0
| 10
| 21
| 60
| 32
| 28
| null | null |
JacksonGariety/euler.hs
|
024.hs
|
bsd-3-clause
|
permutations' xs n = x : permutations' (delete x xs) (snd y)
where m = factorial $ length xs - 1
y = quotRem n m
x = xs !! (fst y)
| 148
|
permutations' xs n = x : permutations' (delete x xs) (snd y)
where m = factorial $ length xs - 1
y = quotRem n m
x = xs !! (fst y)
| 148
|
permutations' xs n = x : permutations' (delete x xs) (snd y)
where m = factorial $ length xs - 1
y = quotRem n m
x = xs !! (fst y)
| 148
| false
| false
| 5
| 8
| 49
| 90
| 38
| 52
| null | null |
djeik/goto
|
libgoto/Language/Cpp/Compile.hs
|
mit
|
compileUnaryOp :: UnaryOp a -> Compiler Doc
compileUnaryOp un = pure $ case un of
BitwiseNot -> text "~"
_ -> pretty un
| 127
|
compileUnaryOp :: UnaryOp a -> Compiler Doc
compileUnaryOp un = pure $ case un of
BitwiseNot -> text "~"
_ -> pretty un
| 127
|
compileUnaryOp un = pure $ case un of
BitwiseNot -> text "~"
_ -> pretty un
| 83
| false
| true
| 0
| 9
| 30
| 54
| 24
| 30
| null | null |
treeowl/GADTSeq
|
Data/Sequence.hs
|
bsd-3-clause
|
appendTree3 :: FingerTree (S n) a -> Tree23 (S n) a -> Tree23 (S n) a -> Tree23 (S n) a -> FingerTree (S n) a -> FingerTree (S n) a
appendTree3 Empty a b c xs =
a `consTree` b `consTree` c `consTree` xs
| 206
|
appendTree3 :: FingerTree (S n) a -> Tree23 (S n) a -> Tree23 (S n) a -> Tree23 (S n) a -> FingerTree (S n) a -> FingerTree (S n) a
appendTree3 Empty a b c xs =
a `consTree` b `consTree` c `consTree` xs
| 206
|
appendTree3 Empty a b c xs =
a `consTree` b `consTree` c `consTree` xs
| 74
| false
| true
| 0
| 12
| 48
| 126
| 63
| 63
| null | null |
robdockins/edison
|
edison-core/src/Data/Edison/Assoc/TernaryTrie.hs
|
mit
|
maxElemFMB (I _ _ _ _ _ r) = maxElemFMB r
| 54
|
maxElemFMB (I _ _ _ _ _ r) = maxElemFMB r
| 54
|
maxElemFMB (I _ _ _ _ _ r) = maxElemFMB r
| 54
| false
| false
| 0
| 7
| 23
| 28
| 13
| 15
| null | null |
stevedonnelly/haskell
|
code/Geometry/Line.hs
|
mit
|
setPoint0 = setFirst2
| 21
|
setPoint0 = setFirst2
| 21
|
setPoint0 = setFirst2
| 21
| false
| false
| 1
| 5
| 2
| 10
| 3
| 7
| null | null |
jvilar/hrows
|
lib/Model/Field.hs
|
gpl-2.0
|
doConvert (ADouble d _) TypeInt0 = AnInt i $ showt i
where i = truncate d
| 108
|
doConvert (ADouble d _) TypeInt0 = AnInt i $ showt i
where i = truncate d
| 108
|
doConvert (ADouble d _) TypeInt0 = AnInt i $ showt i
where i = truncate d
| 108
| false
| false
| 0
| 7
| 50
| 39
| 18
| 21
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.