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
hacoo/haskell-jps
pathfinding/Grid.hs
mit
isBlocked :: Grid -> Int -> Bool isBlocked (Grid dims squares) i = (not (isInBounds dims i)) || ((squares ! i) == 0)
116
isBlocked :: Grid -> Int -> Bool isBlocked (Grid dims squares) i = (not (isInBounds dims i)) || ((squares ! i) == 0)
116
isBlocked (Grid dims squares) i = (not (isInBounds dims i)) || ((squares ! i) == 0)
83
false
true
0
9
22
64
33
31
null
null
gridaphobe/ghc
compiler/typecheck/TcRnTypes.hs
bsd-3-clause
ctEvTerm ev = EvId (ctEvId ev)
30
ctEvTerm ev = EvId (ctEvId ev)
30
ctEvTerm ev = EvId (ctEvId ev)
30
false
false
1
7
5
22
8
14
null
null
ghcjs/jsaddle-dom
src/JSDOM/Generated/Enums.hs
mit
js_IDBCursorDirectionPrev = "prev"
34
js_IDBCursorDirectionPrev = "prev"
34
js_IDBCursorDirectionPrev = "prev"
34
false
false
0
4
2
6
3
3
null
null
DATx02-16-14/Hastings
src/ChineseCheckers/ChineseCheckers.hs
bsd-3-clause
squareContent :: Table -> Coord -> Content squareContent [] _ = error "Table does not contain coordinate"
113
squareContent :: Table -> Coord -> Content squareContent [] _ = error "Table does not contain coordinate"
113
squareContent [] _ = error "Table does not contain coordinate"
70
false
true
0
6
24
29
14
15
null
null
tolysz/prepare-ghcjs
spec-lts8/cabal/cabal-install/Distribution/Client/ProjectConfig.hs
bsd-3-clause
readSourcePackage _verbosity _ = fail $ "TODO: add support for fetching and reading local tarballs, remote " ++ "tarballs, remote repos and passing named packages through"
183
readSourcePackage _verbosity _ = fail $ "TODO: add support for fetching and reading local tarballs, remote " ++ "tarballs, remote repos and passing named packages through"
183
readSourcePackage _verbosity _ = fail $ "TODO: add support for fetching and reading local tarballs, remote " ++ "tarballs, remote repos and passing named packages through"
183
false
false
4
5
37
24
9
15
null
null
meimisaki/FingerTree
Data/FingerTree/Lazy.hs
mit
splitTree :: Measured a v => (v -> Bool) -> v -> FingerTree v a -> Split (FingerTree v) a splitTree _ _ (Single x) = Split Empty x Empty
136
splitTree :: Measured a v => (v -> Bool) -> v -> FingerTree v a -> Split (FingerTree v) a splitTree _ _ (Single x) = Split Empty x Empty
136
splitTree _ _ (Single x) = Split Empty x Empty
46
false
true
0
11
29
75
36
39
null
null
ghcjs/ghcjs
src/Compiler/GhcjsProgram.hs
mit
generateLib :: GhcjsSettings -> Ghc () generateLib _settings = do dflags1 <- getSessionDynFlags liftIO $ do (dflags2, pkgs0) <- initPackages dflags1 let pkgs = mapMaybe (\p -> fmap (T.pack (getInstalledPackageName dflags2 p),) (getInstalledPackageVersion dflags2 p)) pkgs0 base = getDataDir (getLibDir dflags2) </> "shims" pkgs' :: [(T.Text, Version)] pkgs' = M.toList $ M.fromListWith max pkgs (beforeFiles, afterFiles) <- Gen2.collectShims base pkgs' B.writeFile "lib.js" . mconcat =<< mapM B.readFile beforeFiles B.writeFile "lib1.js" . mconcat =<< mapM B.readFile afterFiles putStrLn "generated lib.js and lib1.js for:" mapM_ (\(p,v) -> putStrLn $ " " ++ T.unpack p ++ if isEmptyVersion v then "" else ("-" ++ T.unpack (showVersion v))) pkgs'
872
generateLib :: GhcjsSettings -> Ghc () generateLib _settings = do dflags1 <- getSessionDynFlags liftIO $ do (dflags2, pkgs0) <- initPackages dflags1 let pkgs = mapMaybe (\p -> fmap (T.pack (getInstalledPackageName dflags2 p),) (getInstalledPackageVersion dflags2 p)) pkgs0 base = getDataDir (getLibDir dflags2) </> "shims" pkgs' :: [(T.Text, Version)] pkgs' = M.toList $ M.fromListWith max pkgs (beforeFiles, afterFiles) <- Gen2.collectShims base pkgs' B.writeFile "lib.js" . mconcat =<< mapM B.readFile beforeFiles B.writeFile "lib1.js" . mconcat =<< mapM B.readFile afterFiles putStrLn "generated lib.js and lib1.js for:" mapM_ (\(p,v) -> putStrLn $ " " ++ T.unpack p ++ if isEmptyVersion v then "" else ("-" ++ T.unpack (showVersion v))) pkgs'
872
generateLib _settings = do dflags1 <- getSessionDynFlags liftIO $ do (dflags2, pkgs0) <- initPackages dflags1 let pkgs = mapMaybe (\p -> fmap (T.pack (getInstalledPackageName dflags2 p),) (getInstalledPackageVersion dflags2 p)) pkgs0 base = getDataDir (getLibDir dflags2) </> "shims" pkgs' :: [(T.Text, Version)] pkgs' = M.toList $ M.fromListWith max pkgs (beforeFiles, afterFiles) <- Gen2.collectShims base pkgs' B.writeFile "lib.js" . mconcat =<< mapM B.readFile beforeFiles B.writeFile "lib1.js" . mconcat =<< mapM B.readFile afterFiles putStrLn "generated lib.js and lib1.js for:" mapM_ (\(p,v) -> putStrLn $ " " ++ T.unpack p ++ if isEmptyVersion v then "" else ("-" ++ T.unpack (showVersion v))) pkgs'
833
false
true
0
21
230
302
147
155
null
null
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Haskell/basic_haskell/minimum_6.hs
mit
min1 x y MyFalse = min0 x y otherwise
37
min1 x y MyFalse = min0 x y otherwise
37
min1 x y MyFalse = min0 x y otherwise
37
false
false
0
5
8
20
9
11
null
null
haskell-opengl/OpenGLRaw
src/Graphics/GL/Functions/F14.hs
bsd-3-clause
ptr_glGetnPixelMapfv :: FunPtr (GLenum -> GLsizei -> Ptr GLfloat -> IO ()) ptr_glGetnPixelMapfv = unsafePerformIO $ getCommand "glGetnPixelMapfv"
145
ptr_glGetnPixelMapfv :: FunPtr (GLenum -> GLsizei -> Ptr GLfloat -> IO ()) ptr_glGetnPixelMapfv = unsafePerformIO $ getCommand "glGetnPixelMapfv"
145
ptr_glGetnPixelMapfv = unsafePerformIO $ getCommand "glGetnPixelMapfv"
70
false
true
1
11
17
47
21
26
null
null
chrisdotcode/hackage-server
tests/HighLevelTest.hs
bsd-3-clause
testpackage :: (FilePath, String, FilePath, String, FilePath, String) testpackage = mkPackage "testpackage"
107
testpackage :: (FilePath, String, FilePath, String, FilePath, String) testpackage = mkPackage "testpackage"
107
testpackage = mkPackage "testpackage"
37
false
true
0
5
11
32
19
13
null
null
schernichkin/BSPM
graphomania/src/Graphomania/Shumov/Internal.hs
bsd-3-clause
--TODO: consider streaming instead of inplace conversion -- | Inplace edge encoding conversion -- This function will rewrite source buffer and return unused part. unsafeConverEdge :: forall from to . (EndiannessAware from, EndiannessAware to) => Proxy from -> Proxy to -> ByteString -> IO ByteString unsafeConverEdge _ _ bs = do let edge = untag $ fst $ runGetStrict (get :: Get (Tagged from ShumovEdge)) bs unsafePutStrict (put (Tagged edge :: (Tagged to ShumovEdge))) bs
494
unsafeConverEdge :: forall from to . (EndiannessAware from, EndiannessAware to) => Proxy from -> Proxy to -> ByteString -> IO ByteString unsafeConverEdge _ _ bs = do let edge = untag $ fst $ runGetStrict (get :: Get (Tagged from ShumovEdge)) bs unsafePutStrict (put (Tagged edge :: (Tagged to ShumovEdge))) bs
330
unsafeConverEdge _ _ bs = do let edge = untag $ fst $ runGetStrict (get :: Get (Tagged from ShumovEdge)) bs unsafePutStrict (put (Tagged edge :: (Tagged to ShumovEdge))) bs
176
true
true
0
15
96
133
67
66
null
null
LambdaHack/LambdaHack
definition-src/Game/LambdaHack/Definition/Defs.hs
bsd-3-clause
ppCStore :: CStore -> (Text, Text) ppCStore CGround = ("on", "the ground")
74
ppCStore :: CStore -> (Text, Text) ppCStore CGround = ("on", "the ground")
74
ppCStore CGround = ("on", "the ground")
39
false
true
0
8
11
36
18
18
null
null
kawamuray/ganeti
src/Ganeti/OpParams.hs
gpl-2.0
pWaitForSyncFalse :: Field pWaitForSyncFalse = withDoc "Whether to wait for the disk to synchronize (defaults to false)" $ defaultField [| False |] pWaitForSync
164
pWaitForSyncFalse :: Field pWaitForSyncFalse = withDoc "Whether to wait for the disk to synchronize (defaults to false)" $ defaultField [| False |] pWaitForSync
164
pWaitForSyncFalse = withDoc "Whether to wait for the disk to synchronize (defaults to false)" $ defaultField [| False |] pWaitForSync
137
false
true
0
6
26
26
14
12
null
null
unisonweb/platform
parser-typechecker/src/Unison/Runtime/Machine.hs
mit
resolve _ _ bstk (Stk i) = peekOff bstk i
41
resolve _ _ bstk (Stk i) = peekOff bstk i
41
resolve _ _ bstk (Stk i) = peekOff bstk i
41
false
false
1
7
9
26
11
15
null
null
Some-T/Portfolio
HASKELL/Labs/H6/H6.hsproj/H6.hs
unlicense
--f: ff = flip const 3 5
26
ff = flip const 3 5
19
ff = flip const 3 5
19
true
false
0
5
8
14
7
7
null
null
folivetti/BIGDATA
08 - Classificação/LogisticRegression.hs
mit
gradDesc :: [[Double]] -> [Double] -> Double -> Int -> [Double] gradDesc x y α it = gradDesc' x y w0 α it where w0 = take (length' $ head x) [0.01,0.01..]
160
gradDesc :: [[Double]] -> [Double] -> Double -> Int -> [Double] gradDesc x y α it = gradDesc' x y w0 α it where w0 = take (length' $ head x) [0.01,0.01..]
160
gradDesc x y α it = gradDesc' x y w0 α it where w0 = take (length' $ head x) [0.01,0.01..]
96
false
true
0
9
37
88
46
42
null
null
shlevy/ghc
includes/CodeGen.Platform.hs
bsd-3-clause
{- Note [esi/edi not allocatable] %esi is mapped to R1, so %esi would normally be allocatable while it is not being used for R1. However, %esi has no 8-bit version on x86, and the linear register allocator is not sophisticated enough to handle this irregularity (we need more RegClasses). The graph-colouring allocator also cannot handle this - it was designed with more flexibility in mind, but the current implementation is restricted to the same set of classes as the linear allocator. Hence, on x86 esi and edi are treated as not allocatable. -} -- split patterns in two functions to prevent overlaps freeReg r = freeRegBase r
643
freeReg r = freeRegBase r
33
freeReg r = freeRegBase r
33
true
false
0
5
119
14
7
7
null
null
MichaeGon/stone
src/Eval.hs
bsd-3-clause
getLocalEnv (VObject _ _ z) = z
31
getLocalEnv (VObject _ _ z) = z
31
getLocalEnv (VObject _ _ z) = z
31
false
false
0
7
6
19
9
10
null
null
smlsharp/smlsharp
benchmark/benchmarks_parallel/cilksort/cilksort_ghc_par.hs
mit
init_d :: Int -> IO (IOUArray Int Double) init_d size = newArray (0, size - 1) 1234.5678
93
init_d :: Int -> IO (IOUArray Int Double) init_d size = newArray (0, size - 1) 1234.5678
93
init_d size = newArray (0, size - 1) 1234.5678
51
false
true
0
8
21
44
22
22
null
null
facebookincubator/duckling
Duckling/Time/SV/Rules.hs
bsd-3-clause
ruleNextCycle :: Rule ruleNextCycle = Rule { name = "next <cycle>" , pattern = [ regex "nästa|kommande" , dimension TimeGrain ] , prod = \tokens -> case tokens of (_:Token TimeGrain grain:_) -> tt $ cycleNth grain 1 _ -> Nothing }
270
ruleNextCycle :: Rule ruleNextCycle = Rule { name = "next <cycle>" , pattern = [ regex "nästa|kommande" , dimension TimeGrain ] , prod = \tokens -> case tokens of (_:Token TimeGrain grain:_) -> tt $ cycleNth grain 1 _ -> Nothing }
270
ruleNextCycle = Rule { name = "next <cycle>" , pattern = [ regex "nästa|kommande" , dimension TimeGrain ] , prod = \tokens -> case tokens of (_:Token TimeGrain grain:_) -> tt $ cycleNth grain 1 _ -> Nothing }
248
false
true
0
15
81
93
49
44
null
null
centromere/blake2
benchmarks/bench.hs
unlicense
main :: IO () main = defaultMain [ bgroup "blake2s" [ bench "1 kb" $ nf (B2s.hash 32 "") kb , bench "1 mb" $ nf (B2s.hash 32 "") mb , bench "1 gb" $ nf (B2s.hash 32 "") gb ] , bgroup "blake2sp" [ bench "1 kb" $ nf (B2sp.hash 32 "") kb , bench "1 mb" $ nf (B2sp.hash 32 "") mb , bench "1 gb" $ nf (B2sp.hash 32 "") gb ] , bgroup "blake2b" [ bench "1 kb" $ nf (B2b.hash 64 "") kb , bench "1 mb" $ nf (B2b.hash 64 "") mb , bench "1 gb" $ nf (B2b.hash 64 "") gb ] , bgroup "blake2bp" [ bench "1 kb" $ nf (B2bp.hash 64 "") kb , bench "1 mb" $ nf (B2bp.hash 64 "") mb , bench "1 gb" $ nf (B2bp.hash 64 "") gb ] ]
874
main :: IO () main = defaultMain [ bgroup "blake2s" [ bench "1 kb" $ nf (B2s.hash 32 "") kb , bench "1 mb" $ nf (B2s.hash 32 "") mb , bench "1 gb" $ nf (B2s.hash 32 "") gb ] , bgroup "blake2sp" [ bench "1 kb" $ nf (B2sp.hash 32 "") kb , bench "1 mb" $ nf (B2sp.hash 32 "") mb , bench "1 gb" $ nf (B2sp.hash 32 "") gb ] , bgroup "blake2b" [ bench "1 kb" $ nf (B2b.hash 64 "") kb , bench "1 mb" $ nf (B2b.hash 64 "") mb , bench "1 gb" $ nf (B2b.hash 64 "") gb ] , bgroup "blake2bp" [ bench "1 kb" $ nf (B2bp.hash 64 "") kb , bench "1 mb" $ nf (B2bp.hash 64 "") mb , bench "1 gb" $ nf (B2bp.hash 64 "") gb ] ]
874
main = defaultMain [ bgroup "blake2s" [ bench "1 kb" $ nf (B2s.hash 32 "") kb , bench "1 mb" $ nf (B2s.hash 32 "") mb , bench "1 gb" $ nf (B2s.hash 32 "") gb ] , bgroup "blake2sp" [ bench "1 kb" $ nf (B2sp.hash 32 "") kb , bench "1 mb" $ nf (B2sp.hash 32 "") mb , bench "1 gb" $ nf (B2sp.hash 32 "") gb ] , bgroup "blake2b" [ bench "1 kb" $ nf (B2b.hash 64 "") kb , bench "1 mb" $ nf (B2b.hash 64 "") mb , bench "1 gb" $ nf (B2b.hash 64 "") gb ] , bgroup "blake2bp" [ bench "1 kb" $ nf (B2bp.hash 64 "") kb , bench "1 mb" $ nf (B2bp.hash 64 "") mb , bench "1 gb" $ nf (B2bp.hash 64 "") gb ] ]
860
false
true
0
12
411
351
169
182
null
null
fgaray/erd
src/ER.hs
unlicense
-- | Hard-coded default options for all entities. defaultEntityOpts :: Options defaultEntityOpts = M.fromList [ ("border", Border 0) , ("cellborder", CellBorder 1) , ("cellspacing", CellSpacing 0) , ("cellpadding", CellPadding 4) , ("font", FontFace "Helvetica") ]
276
defaultEntityOpts :: Options defaultEntityOpts = M.fromList [ ("border", Border 0) , ("cellborder", CellBorder 1) , ("cellspacing", CellSpacing 0) , ("cellpadding", CellPadding 4) , ("font", FontFace "Helvetica") ]
226
defaultEntityOpts = M.fromList [ ("border", Border 0) , ("cellborder", CellBorder 1) , ("cellspacing", CellSpacing 0) , ("cellpadding", CellPadding 4) , ("font", FontFace "Helvetica") ]
197
true
true
0
7
46
77
44
33
null
null
keithodulaigh/Hets
CommonLogic/ParseCLAsLibDefn.hs
gpl-2.0
getImports_text :: TEXT -> Set.Set NAME getImports_text txt = case txt of Text p _ -> Set.fromList $ map impName $ filter isImportation p Named_text _ t _ -> getImports_text t
179
getImports_text :: TEXT -> Set.Set NAME getImports_text txt = case txt of Text p _ -> Set.fromList $ map impName $ filter isImportation p Named_text _ t _ -> getImports_text t
179
getImports_text txt = case txt of Text p _ -> Set.fromList $ map impName $ filter isImportation p Named_text _ t _ -> getImports_text t
139
false
true
4
7
34
52
27
25
null
null
brunoczim/PulseLambda
PulseLambda/TokenStream.hs
gpl-3.0
isIdentifierToken :: TokenValue -> Bool isIdentifierToken (IdentifierToken _) = True
84
isIdentifierToken :: TokenValue -> Bool isIdentifierToken (IdentifierToken _) = True
84
isIdentifierToken (IdentifierToken _) = True
44
false
true
0
7
9
24
12
12
null
null
phaazon/OpenGLRaw
src/Graphics/Rendering/OpenGL/Raw/Tokens.hs
bsd-3-clause
gl_POINT_TOKEN :: GLenum gl_POINT_TOKEN = 0x0701
48
gl_POINT_TOKEN :: GLenum gl_POINT_TOKEN = 0x0701
48
gl_POINT_TOKEN = 0x0701
23
false
true
0
4
5
11
6
5
null
null
tjakway/ghcjvm
compiler/cmm/CLabel.hs
bsd-3-clause
hasCAF _ = False
43
hasCAF _ = False
43
hasCAF _ = False
43
false
false
0
5
30
9
4
5
null
null
nsyee00/tinyblog
src/TinyBlog/Entry.hs
bsd-3-clause
sortByName (x@(_, xpath):xs) = greater ++ x:lesser where lesser = sortByName [y | y@(_, ypath) <- xs, ypath < xpath] greater = sortByName [y | y@(_, ypath) <- xs, ypath >= xpath] -- | sort entries by mtime {-- sortByMtime :: [(FileStatus, FilePath)] -> [(FileStatus, FilePath)] sortByMtime [] = [] sortByMtime (x@(xstat, _):xs) = greater ++ x:lesser where lesser = sortByMtime [y | y@(ystat, _) <- xs, (modificationTime ystat) < (modificationTime xstat) ] greater = sortByMtime [y | y@(ystat, _) <- xs, (modificationTime ystat) >= (modificationTime xstat) ] --} -- | get a JSON of entries
786
sortByName (x@(_, xpath):xs) = greater ++ x:lesser where lesser = sortByName [y | y@(_, ypath) <- xs, ypath < xpath] greater = sortByName [y | y@(_, ypath) <- xs, ypath >= xpath] -- | sort entries by mtime {-- sortByMtime :: [(FileStatus, FilePath)] -> [(FileStatus, FilePath)] sortByMtime [] = [] sortByMtime (x@(xstat, _):xs) = greater ++ x:lesser where lesser = sortByMtime [y | y@(ystat, _) <- xs, (modificationTime ystat) < (modificationTime xstat) ] greater = sortByMtime [y | y@(ystat, _) <- xs, (modificationTime ystat) >= (modificationTime xstat) ] --} -- | get a JSON of entries
786
sortByName (x@(_, xpath):xs) = greater ++ x:lesser where lesser = sortByName [y | y@(_, ypath) <- xs, ypath < xpath] greater = sortByName [y | y@(_, ypath) <- xs, ypath >= xpath] -- | sort entries by mtime {-- sortByMtime :: [(FileStatus, FilePath)] -> [(FileStatus, FilePath)] sortByMtime [] = [] sortByMtime (x@(xstat, _):xs) = greater ++ x:lesser where lesser = sortByMtime [y | y@(ystat, _) <- xs, (modificationTime ystat) < (modificationTime xstat) ] greater = sortByMtime [y | y@(ystat, _) <- xs, (modificationTime ystat) >= (modificationTime xstat) ] --} -- | get a JSON of entries
786
false
false
0
10
293
112
62
50
null
null
rueshyna/gogol
gogol-games/gen/Network/Google/Games/Types/Product.hs
mpl-2.0
-- | The ID of the event definition. peDefinitionId :: Lens' PlayerEvent (Maybe Text) peDefinitionId = lens _peDefinitionId (\ s a -> s{_peDefinitionId = a})
165
peDefinitionId :: Lens' PlayerEvent (Maybe Text) peDefinitionId = lens _peDefinitionId (\ s a -> s{_peDefinitionId = a})
128
peDefinitionId = lens _peDefinitionId (\ s a -> s{_peDefinitionId = a})
79
true
true
0
9
32
48
25
23
null
null
vikraman/ghc
compiler/basicTypes/VarSet.hs
bsd-3-clause
seqDVarSet :: DVarSet -> () seqDVarSet s = sizeDVarSet s `seq` ()
65
seqDVarSet :: DVarSet -> () seqDVarSet s = sizeDVarSet s `seq` ()
65
seqDVarSet s = sizeDVarSet s `seq` ()
37
false
true
0
6
11
31
16
15
null
null
koengit/induction-examples
Sort_QuickSort.hs
mit
prop_SortPermutes x (xs :: [OrdA]) = count x (qsort xs) == count x xs
71
prop_SortPermutes x (xs :: [OrdA]) = count x (qsort xs) == count x xs
71
prop_SortPermutes x (xs :: [OrdA]) = count x (qsort xs) == count x xs
71
false
false
1
7
15
43
19
24
null
null
gwright83/Wheeler
src/Math/Symbolic/Wheeler/Canonicalize.hs
bsd-3-clause
termPart x@(Sum _) = Product [x]
43
termPart x@(Sum _) = Product [x]
43
termPart x@(Sum _) = Product [x]
43
false
false
0
8
16
24
12
12
null
null
frantisekfarka/ghc-dsi
compiler/codeGen/StgCmmMonad.hs
bsd-3-clause
stateIncUsage :: CgState -> CgState -> CgState -- stateIncUsage@ e1 e2 incorporates in e1 -- the heap high water mark found in e2. stateIncUsage s1 s2@(MkCgState { cgs_hp_usg = hp_usg }) = s1 { cgs_hp_usg = cgs_hp_usg s1 `maxHpHw` virtHp hp_usg } `addCodeBlocksFrom` s2
284
stateIncUsage :: CgState -> CgState -> CgState stateIncUsage s1 s2@(MkCgState { cgs_hp_usg = hp_usg }) = s1 { cgs_hp_usg = cgs_hp_usg s1 `maxHpHw` virtHp hp_usg } `addCodeBlocksFrom` s2
200
stateIncUsage s1 s2@(MkCgState { cgs_hp_usg = hp_usg }) = s1 { cgs_hp_usg = cgs_hp_usg s1 `maxHpHw` virtHp hp_usg } `addCodeBlocksFrom` s2
153
true
true
0
10
58
70
39
31
null
null
leptonyu/mint
corn-node/src/Corn/Node.hs
bsd-3-clause
startApp :: IO () startApp = do let ip = "127.0.0.1" port = "10501" Right t <- createTransport ip port (\_ -> (ip, port)) defaultTCPParameters node <- newLocalNode t initRemoteTable runProcess node $ do -- get our own process id self <- getSelfPid send self ("hello" :: Text) hello <- expect :: Process String liftIO $ putStrLn hello return ()
381
startApp :: IO () startApp = do let ip = "127.0.0.1" port = "10501" Right t <- createTransport ip port (\_ -> (ip, port)) defaultTCPParameters node <- newLocalNode t initRemoteTable runProcess node $ do -- get our own process id self <- getSelfPid send self ("hello" :: Text) hello <- expect :: Process String liftIO $ putStrLn hello return ()
381
startApp = do let ip = "127.0.0.1" port = "10501" Right t <- createTransport ip port (\_ -> (ip, port)) defaultTCPParameters node <- newLocalNode t initRemoteTable runProcess node $ do -- get our own process id self <- getSelfPid send self ("hello" :: Text) hello <- expect :: Process String liftIO $ putStrLn hello return ()
363
false
true
0
11
97
138
65
73
null
null
buildsome/buildsome
src/Lib/FSHook/Protocol.hs
gpl-2.0
showFunc (SymLink target linkpath) = unwords ["symlink:", show target, show linkpath]
85
showFunc (SymLink target linkpath) = unwords ["symlink:", show target, show linkpath]
85
showFunc (SymLink target linkpath) = unwords ["symlink:", show target, show linkpath]
85
false
false
0
7
10
35
17
18
null
null
apyrgio/snf-ganeti
src/Ganeti/HTools/Cluster.hs
bsd-2-clause
updateEvacSolution :: (Node.List, Instance.List, EvacSolution) -> Idx -> Result (Node.List, Instance.List, [OpCodes.OpCode]) -> (Node.List, Instance.List, EvacSolution) updateEvacSolution (nl, il, es) idx (Bad msg) = (nl, il, es { esFailed = (idx, msg):esFailed es})
325
updateEvacSolution :: (Node.List, Instance.List, EvacSolution) -> Idx -> Result (Node.List, Instance.List, [OpCodes.OpCode]) -> (Node.List, Instance.List, EvacSolution) updateEvacSolution (nl, il, es) idx (Bad msg) = (nl, il, es { esFailed = (idx, msg):esFailed es})
325
updateEvacSolution (nl, il, es) idx (Bad msg) = (nl, il, es { esFailed = (idx, msg):esFailed es})
99
false
true
0
11
91
122
70
52
null
null
frenetic-lang/netcore-1.0
examples/ArpSpoof.hs
bsd-3-clause
-- Return a policy that queries all ARP request packets -- destined for serverIp and, upon receiving such a packet, -- injects an appropriate response. spoofSwitchArp :: Switch -> EthernetAddress -> IPAddress -> IO (Policy) spoofSwitchArp switchId serverMac serverIp = do (arpQueryChan, arpAct) <- getPkts packetOutChan <- newChan let pol = isQuery <&&> NwDst (IPAddressPrefix serverIp 32) ==> arpAct <+> SendPackets packetOutChan let loop a = do arpQueryPkt <- readChan arpQueryChan case generateReply arpQueryPkt of Nothing -> loop a Just replyPkt -> do writeChan packetOutChan replyPkt loop a forkIO $ loop True return $ pol <%> Switch switchId where -- Given an ARP query packet asking for the server, generate a response. If -- the located packet is malformed---eg. without a valid nwSrc field---return -- Nothing. generateReply :: LocPacket -> Maybe (Loc, ByteString) generateReply (Loc switch port, Packet {..}) = case pktNwSrc of Nothing -> Nothing Just fromIp -> Just (Loc switch port, arpReply serverMac (ipAddressToWord32 serverIp) pktDlSrc (ipAddressToWord32 fromIp))
1,283
spoofSwitchArp :: Switch -> EthernetAddress -> IPAddress -> IO (Policy) spoofSwitchArp switchId serverMac serverIp = do (arpQueryChan, arpAct) <- getPkts packetOutChan <- newChan let pol = isQuery <&&> NwDst (IPAddressPrefix serverIp 32) ==> arpAct <+> SendPackets packetOutChan let loop a = do arpQueryPkt <- readChan arpQueryChan case generateReply arpQueryPkt of Nothing -> loop a Just replyPkt -> do writeChan packetOutChan replyPkt loop a forkIO $ loop True return $ pol <%> Switch switchId where -- Given an ARP query packet asking for the server, generate a response. If -- the located packet is malformed---eg. without a valid nwSrc field---return -- Nothing. generateReply :: LocPacket -> Maybe (Loc, ByteString) generateReply (Loc switch port, Packet {..}) = case pktNwSrc of Nothing -> Nothing Just fromIp -> Just (Loc switch port, arpReply serverMac (ipAddressToWord32 serverIp) pktDlSrc (ipAddressToWord32 fromIp))
1,130
spoofSwitchArp switchId serverMac serverIp = do (arpQueryChan, arpAct) <- getPkts packetOutChan <- newChan let pol = isQuery <&&> NwDst (IPAddressPrefix serverIp 32) ==> arpAct <+> SendPackets packetOutChan let loop a = do arpQueryPkt <- readChan arpQueryChan case generateReply arpQueryPkt of Nothing -> loop a Just replyPkt -> do writeChan packetOutChan replyPkt loop a forkIO $ loop True return $ pol <%> Switch switchId where -- Given an ARP query packet asking for the server, generate a response. If -- the located packet is malformed---eg. without a valid nwSrc field---return -- Nothing. generateReply :: LocPacket -> Maybe (Loc, ByteString) generateReply (Loc switch port, Packet {..}) = case pktNwSrc of Nothing -> Nothing Just fromIp -> Just (Loc switch port, arpReply serverMac (ipAddressToWord32 serverIp) pktDlSrc (ipAddressToWord32 fromIp))
1,058
true
true
1
17
363
291
138
153
null
null
Th30n/hasgel
hasgel-model/src/Hasgel/Mesh/OBJ.hs
mit
parseFaceVertex :: A.Parser FaceComponent parseFaceVertex = do v <- A.decimal vt <- parseOptionalVertex $ "/" *> A.decimal vn <- case vt of Nothing -> parseOptionalVertex $ "//" *> A.decimal _ -> parseOptionalVertex $ "/" *> A.decimal pure (v, vt, vn) where parseOptionalVertex p = A.option Nothing $ Just <$> p
341
parseFaceVertex :: A.Parser FaceComponent parseFaceVertex = do v <- A.decimal vt <- parseOptionalVertex $ "/" *> A.decimal vn <- case vt of Nothing -> parseOptionalVertex $ "//" *> A.decimal _ -> parseOptionalVertex $ "/" *> A.decimal pure (v, vt, vn) where parseOptionalVertex p = A.option Nothing $ Just <$> p
341
parseFaceVertex = do v <- A.decimal vt <- parseOptionalVertex $ "/" *> A.decimal vn <- case vt of Nothing -> parseOptionalVertex $ "//" *> A.decimal _ -> parseOptionalVertex $ "/" *> A.decimal pure (v, vt, vn) where parseOptionalVertex p = A.option Nothing $ Just <$> p
299
false
true
0
12
79
123
60
63
null
null
prowdsponsor/country-codes
src/Data/CountryCodes/ISO31661.hs
bsd-3-clause
toName TT = "Trinidad and Tobago"
33
toName TT = "Trinidad and Tobago"
33
toName TT = "Trinidad and Tobago"
33
false
false
0
4
5
10
4
6
null
null
mfpi/spacepart
src/Data/SpacePart/QuadTree.hs
bsd-3-clause
parent_trees q = parent_trees' [q] where parent_trees' (q : qs) = let parents = imm_parents q in parents ++ parent_trees' (qs ++ parents) imm_parents q_child = map (quadtree_with_child_in_quad q_child) [PNQuad, PPQuad, NPQuad, NNQuad]
280
parent_trees q = parent_trees' [q] where parent_trees' (q : qs) = let parents = imm_parents q in parents ++ parent_trees' (qs ++ parents) imm_parents q_child = map (quadtree_with_child_in_quad q_child) [PNQuad, PPQuad, NPQuad, NNQuad]
280
parent_trees q = parent_trees' [q] where parent_trees' (q : qs) = let parents = imm_parents q in parents ++ parent_trees' (qs ++ parents) imm_parents q_child = map (quadtree_with_child_in_quad q_child) [PNQuad, PPQuad, NPQuad, NNQuad]
280
false
false
3
9
78
97
46
51
null
null
snoyberg/hl
src/HL/View/Template.hs
bsd-3-clause
-- | Breadcrumb. bread :: (Route App -> Text) -> [Route App] -> Html () bread url crumbs = ol_ [class_ "breadcrumb"] (forM_ crumbs (\route -> li_ (a_ [href_ (url route)] (toHtml (toHuman route)))))
258
bread :: (Route App -> Text) -> [Route App] -> Html () bread url crumbs = ol_ [class_ "breadcrumb"] (forM_ crumbs (\route -> li_ (a_ [href_ (url route)] (toHtml (toHuman route)))))
241
bread url crumbs = ol_ [class_ "breadcrumb"] (forM_ crumbs (\route -> li_ (a_ [href_ (url route)] (toHtml (toHuman route)))))
186
true
true
0
16
94
108
54
54
null
null
olsner/ghc
compiler/prelude/THNames.hs
bsd-3-clause
overlapsDataConName = thCon (fsLit "Overlaps") overlapsDataConKey
73
overlapsDataConName = thCon (fsLit "Overlaps") overlapsDataConKey
73
overlapsDataConName = thCon (fsLit "Overlaps") overlapsDataConKey
73
false
false
0
7
13
17
8
9
null
null
mapinguari/SC_HS_Proxy
src/Proxy/Query/Upgrade.hs
mit
whatResearches ScarabDamage = ProtossRoboticsSupportBay
55
whatResearches ScarabDamage = ProtossRoboticsSupportBay
55
whatResearches ScarabDamage = ProtossRoboticsSupportBay
55
false
false
0
5
3
9
4
5
null
null
erochest/cabal-brew
CabalBrew/Packages.hs
apache-2.0
makePackageSpec' :: PackageName -> Version -> T.Text makePackageSpec' n = makePackageSpec n . showVersion
105
makePackageSpec' :: PackageName -> Version -> T.Text makePackageSpec' n = makePackageSpec n . showVersion
105
makePackageSpec' n = makePackageSpec n . showVersion
52
false
true
0
7
13
31
15
16
null
null
DanBurton/MHask
MHask/Indexed/Monad.hs
bsd-3-clause
imapMonad :: (Monad m, Monad n, Monad (t j j n), IxMonad t) => (m ~> n) -> (t i j m ~> t i j n) imapMonad f = ibind (f ~>~ MHask.ireturn)
139
imapMonad :: (Monad m, Monad n, Monad (t j j n), IxMonad t) => (m ~> n) -> (t i j m ~> t i j n) imapMonad f = ibind (f ~>~ MHask.ireturn)
139
imapMonad f = ibind (f ~>~ MHask.ireturn)
41
false
true
0
11
35
101
49
52
null
null
phischu/fragnix
tests/packages/scotty/Data.Attoparsec.ByteString.Char8.hs
bsd-3-clause
-- | Parse and decode an unsigned hexadecimal number. The hex digits -- @\'a\'@ through @\'f\'@ may be upper or lower case. -- -- This parser does not accept a leading @\"0x\"@ string. hexadecimal :: (Integral a, Bits a) => Parser a hexadecimal = B8.foldl' step 0 `fmap` I.takeWhile1 isHexDigit where isHexDigit w = (w >= 48 && w <= 57) || (w >= 97 && w <= 102) || (w >= 65 && w <= 70) step a w | w >= 48 && w <= 57 = (a `shiftL` 4) .|. fromIntegral (w - 48) | w >= 97 = (a `shiftL` 4) .|. fromIntegral (w - 87) | otherwise = (a `shiftL` 4) .|. fromIntegral (w - 55)
665
hexadecimal :: (Integral a, Bits a) => Parser a hexadecimal = B8.foldl' step 0 `fmap` I.takeWhile1 isHexDigit where isHexDigit w = (w >= 48 && w <= 57) || (w >= 97 && w <= 102) || (w >= 65 && w <= 70) step a w | w >= 48 && w <= 57 = (a `shiftL` 4) .|. fromIntegral (w - 48) | w >= 97 = (a `shiftL` 4) .|. fromIntegral (w - 87) | otherwise = (a `shiftL` 4) .|. fromIntegral (w - 55)
479
hexadecimal = B8.foldl' step 0 `fmap` I.takeWhile1 isHexDigit where isHexDigit w = (w >= 48 && w <= 57) || (w >= 97 && w <= 102) || (w >= 65 && w <= 70) step a w | w >= 48 && w <= 57 = (a `shiftL` 4) .|. fromIntegral (w - 48) | w >= 97 = (a `shiftL` 4) .|. fromIntegral (w - 87) | otherwise = (a `shiftL` 4) .|. fromIntegral (w - 55)
431
true
true
2
10
219
241
125
116
null
null
meimisaki/Rin
src/Type/Types.hs
mit
extendKnEnv :: Name -> Kind -> TI a -> TI a extendKnEnv name kind ti = do env <- get put env { knEnv = M.insert name kind (knEnv env) } ti <* put env
155
extendKnEnv :: Name -> Kind -> TI a -> TI a extendKnEnv name kind ti = do env <- get put env { knEnv = M.insert name kind (knEnv env) } ti <* put env
155
extendKnEnv name kind ti = do env <- get put env { knEnv = M.insert name kind (knEnv env) } ti <* put env
111
false
true
0
12
40
82
38
44
null
null
seishun/aoc2016
day20.hs
mit
part1 :: String -> Int part1 = lowest 0 . sort . map parse . lines
66
part1 :: String -> Int part1 = lowest 0 . sort . map parse . lines
66
part1 = lowest 0 . sort . map parse . lines
43
false
true
0
8
15
33
16
17
null
null
brendanhay/gogol
gogol-customsearch/gen/Network/Google/Resource/Search/CSE/Siterestrict/List.hs
mpl-2.0
-- | The Programmable Search Engine ID to use for this request. cseslCx :: Lens' CSESiterestrictList (Maybe Text) cseslCx = lens _cseslCx (\ s a -> s{_cseslCx = a})
164
cseslCx :: Lens' CSESiterestrictList (Maybe Text) cseslCx = lens _cseslCx (\ s a -> s{_cseslCx = a})
100
cseslCx = lens _cseslCx (\ s a -> s{_cseslCx = a})
50
true
true
0
9
28
46
25
21
null
null
wavewave/hournal
xinput/Event.hs
bsd-2-clause
run exp = runCoroutineT exp
27
run exp = runCoroutineT exp
27
run exp = runCoroutineT exp
27
false
false
0
5
4
12
5
7
null
null
mino2357/Hello_Haskell
primeList/Main.hs
mit
rad' :: Integer -> [Integer] rad' n = [radWorker2 (primeFactorize (radWorker4 (primeFactorize n))), (radWorker2 (primeFactorize n))]
132
rad' :: Integer -> [Integer] rad' n = [radWorker2 (primeFactorize (radWorker4 (primeFactorize n))), (radWorker2 (primeFactorize n))]
132
rad' n = [radWorker2 (primeFactorize (radWorker4 (primeFactorize n))), (radWorker2 (primeFactorize n))]
103
false
true
0
12
15
60
31
29
null
null
romanb/amazonka
amazonka-cognito-sync/gen/Network/AWS/CognitoSync/GetIdentityPoolConfiguration.hs
mpl-2.0
-- | Options to apply to this identity pool for push synchronization. gipcrPushSync :: Lens' GetIdentityPoolConfigurationResponse (Maybe PushSync) gipcrPushSync = lens _gipcrPushSync (\s a -> s { _gipcrPushSync = a })
217
gipcrPushSync :: Lens' GetIdentityPoolConfigurationResponse (Maybe PushSync) gipcrPushSync = lens _gipcrPushSync (\s a -> s { _gipcrPushSync = a })
147
gipcrPushSync = lens _gipcrPushSync (\s a -> s { _gipcrPushSync = a })
70
true
true
0
9
30
46
25
21
null
null
bos/filemanip
System/FilePath/GlobPattern.hs
bsd-3-clause
matchTerms (MatchGroup g:ts) cs = msum (map matchGroup g) where matchGroup g = matchTerms (MatchLiteral g : ts) cs
118
matchTerms (MatchGroup g:ts) cs = msum (map matchGroup g) where matchGroup g = matchTerms (MatchLiteral g : ts) cs
118
matchTerms (MatchGroup g:ts) cs = msum (map matchGroup g) where matchGroup g = matchTerms (MatchLiteral g : ts) cs
118
false
false
2
8
22
63
27
36
null
null
bgold-cosmos/Tidal
src/Sound/Tidal/Core.hs
gpl-3.0
in97 :: Pattern Double in97 = cF 0 "97"
39
in97 :: Pattern Double in97 = cF 0 "97"
39
in97 = cF 0 "97"
16
false
true
0
6
8
26
10
16
null
null
judah/haskeline
System/Console/Haskeline.hs
bsd-3-clause
promptedInput :: MonadIO m => (TermOps -> Prefix -> InputT m a) -> (FileOps -> IO a) -> String -> InputT m a promptedInput doTerm doFile prompt = do -- If other parts of the program have written text, make sure that it -- appears before we interact with the user on the terminal. liftIO $ hFlush stdout rterm <- InputT ask case termOps rterm of Right fops -> liftIO $ do putStrOut rterm prompt wrapFileInput fops $ doFile fops Left tops -> do -- Convert the full prompt to graphemes (not just the last line) -- to account for the `\ESC...STX` appearing anywhere in it. let prompt' = stringToGraphemes prompt -- If the prompt contains newlines, print all but the last line. let (lastLine,rest) = break (`elem` stringToGraphemes "\r\n") $ reverse prompt' outputStr $ graphemesToString $ reverse rest doTerm tops $ reverse lastLine {- | If Ctrl-C is pressed during the given action, throw an exception of type 'Interrupt'. For example: > tryAction :: InputT IO () > tryAction = handle (\Interrupt -> outputStrLn "Cancelled.") > $ withInterrupt $ someLongAction The action can handle the interrupt itself; a new 'Interrupt' exception will be thrown every time Ctrl-C is pressed. > tryAction :: InputT IO () > tryAction = withInterrupt loop > where loop = handle (\Interrupt -> outputStrLn "Cancelled; try again." >> loop) > someLongAction This behavior differs from GHC's built-in Ctrl-C handling, which may immediately terminate the program after the second time that the user presses Ctrl-C. -}
1,789
promptedInput :: MonadIO m => (TermOps -> Prefix -> InputT m a) -> (FileOps -> IO a) -> String -> InputT m a promptedInput doTerm doFile prompt = do -- If other parts of the program have written text, make sure that it -- appears before we interact with the user on the terminal. liftIO $ hFlush stdout rterm <- InputT ask case termOps rterm of Right fops -> liftIO $ do putStrOut rterm prompt wrapFileInput fops $ doFile fops Left tops -> do -- Convert the full prompt to graphemes (not just the last line) -- to account for the `\ESC...STX` appearing anywhere in it. let prompt' = stringToGraphemes prompt -- If the prompt contains newlines, print all but the last line. let (lastLine,rest) = break (`elem` stringToGraphemes "\r\n") $ reverse prompt' outputStr $ graphemesToString $ reverse rest doTerm tops $ reverse lastLine {- | If Ctrl-C is pressed during the given action, throw an exception of type 'Interrupt'. For example: > tryAction :: InputT IO () > tryAction = handle (\Interrupt -> outputStrLn "Cancelled.") > $ withInterrupt $ someLongAction The action can handle the interrupt itself; a new 'Interrupt' exception will be thrown every time Ctrl-C is pressed. > tryAction :: InputT IO () > tryAction = withInterrupt loop > where loop = handle (\Interrupt -> outputStrLn "Cancelled; try again." >> loop) > someLongAction This behavior differs from GHC's built-in Ctrl-C handling, which may immediately terminate the program after the second time that the user presses Ctrl-C. -}
1,789
promptedInput doTerm doFile prompt = do -- If other parts of the program have written text, make sure that it -- appears before we interact with the user on the terminal. liftIO $ hFlush stdout rterm <- InputT ask case termOps rterm of Right fops -> liftIO $ do putStrOut rterm prompt wrapFileInput fops $ doFile fops Left tops -> do -- Convert the full prompt to graphemes (not just the last line) -- to account for the `\ESC...STX` appearing anywhere in it. let prompt' = stringToGraphemes prompt -- If the prompt contains newlines, print all but the last line. let (lastLine,rest) = break (`elem` stringToGraphemes "\r\n") $ reverse prompt' outputStr $ graphemesToString $ reverse rest doTerm tops $ reverse lastLine {- | If Ctrl-C is pressed during the given action, throw an exception of type 'Interrupt'. For example: > tryAction :: InputT IO () > tryAction = handle (\Interrupt -> outputStrLn "Cancelled.") > $ withInterrupt $ someLongAction The action can handle the interrupt itself; a new 'Interrupt' exception will be thrown every time Ctrl-C is pressed. > tryAction :: InputT IO () > tryAction = withInterrupt loop > where loop = handle (\Interrupt -> outputStrLn "Cancelled; try again." >> loop) > someLongAction This behavior differs from GHC's built-in Ctrl-C handling, which may immediately terminate the program after the second time that the user presses Ctrl-C. -}
1,632
false
true
0
18
546
221
103
118
null
null
siddhanathan/ghc
compiler/hsSyn/HsExpr.hs
bsd-3-clause
ppr_expr (RecordCon con_id _ rbinds) = hang (ppr con_id) 2 (ppr rbinds)
73
ppr_expr (RecordCon con_id _ rbinds) = hang (ppr con_id) 2 (ppr rbinds)
73
ppr_expr (RecordCon con_id _ rbinds) = hang (ppr con_id) 2 (ppr rbinds)
73
false
false
0
7
13
38
18
20
null
null
vasily-kartashov/playground
euler/problem-045.hs
apache-2.0
hexagonal n = n * (2 * n - 1)
29
hexagonal n = n * (2 * n - 1)
29
hexagonal n = n * (2 * n - 1)
29
false
false
0
8
9
24
12
12
null
null
input-output-hk/pos-haskell-prototype
auxx/src/Command/TyProjection.hs
mit
tyAddrDistrPart :: TyProjection AddrDistrPart tyAddrDistrPart = TyProjection "AddrDistrPart" (preview _ValueAddrDistrPart)
122
tyAddrDistrPart :: TyProjection AddrDistrPart tyAddrDistrPart = TyProjection "AddrDistrPart" (preview _ValueAddrDistrPart)
122
tyAddrDistrPart = TyProjection "AddrDistrPart" (preview _ValueAddrDistrPart)
76
false
true
0
7
9
25
12
13
null
null
aburnett88/HSat
tests-src/TestPrint/Problem/BSP/Common.hs
mit
name :: String name = "Common"
30
name :: String name = "Common"
30
name = "Common"
15
false
true
0
6
5
18
7
11
null
null
Spheniscida/cHaTTP
persistence-layer/Chattp/Persistence/Auth.hs
mit
eitherConst :: c -> (b -> c) -> Either a b -> c eitherConst c = either (const c)
80
eitherConst :: c -> (b -> c) -> Either a b -> c eitherConst c = either (const c)
80
eitherConst c = either (const c)
32
false
true
0
8
18
47
23
24
null
null
zaxtax/hakaru
haskell/Language/Hakaru/CodeGen/Types.hs
bsd-3-clause
-------------------------------------------------------------------------------- -- | buildType function do the work of describing how the Hakaru -- type will be stored in memory. Arrays needed their own -- declaration function for their arity buildType :: Sing (a :: Hakaru) -> [CTypeSpec] buildType SInt = [CInt]
324
buildType :: Sing (a :: Hakaru) -> [CTypeSpec] buildType SInt = [CInt]
79
buildType SInt = [CInt]
32
true
true
0
8
51
37
22
15
null
null
osa1/chsc
Core/Renaming.hs
bsd-3-clause
mkRename :: (forall a. (Renaming -> a -> a) -> Renaming -> ann a -> ann a) -> (IdSupply -> Renaming -> ann (TermF ann) -> ann (TermF ann), IdSupply -> Renaming -> [AltF ann] -> [AltF ann], IdSupply -> Renaming -> ann (ValueF ann) -> ann (ValueF ann), IdSupply -> Renaming -> ValueF ann -> ValueF ann) mkRename rec = (term, alternatives, value, value') where term ids rn = rec (term' ids) rn term' ids rn e = case e of Var x -> Var (rename rn x) Value v -> Value (value' ids rn v) App e1 x2 -> App (term ids rn e1) (rename rn x2) PrimOp pop es -> PrimOp pop (map (term ids rn) es) Case e alts -> Case (term ids rn e) (alternatives ids rn alts) LetRec xes e -> LetRec (map (second (renameIn (term ids'))) xes') (term ids' rn' e) where (ids', rn', xes') = renameBounds (\_ x' -> x') ids rn xes value ids rn = rec (value' ids) rn value' ids rn v = case v of Indirect x -> Indirect (rename rn x) Lambda x e -> Lambda x' (term ids' rn' e) where (ids', rn', x') = renameBinder ids rn x Data dc xs -> Data dc (map (rename rn) xs) Literal l -> Literal l alternatives ids rn = map (alternative ids rn) alternative ids rn (alt_con, alt_e) = (alt_con', term ids' rn' alt_e) where (ids', rn', alt_con') = renameAltCon ids rn alt_con
1,393
mkRename :: (forall a. (Renaming -> a -> a) -> Renaming -> ann a -> ann a) -> (IdSupply -> Renaming -> ann (TermF ann) -> ann (TermF ann), IdSupply -> Renaming -> [AltF ann] -> [AltF ann], IdSupply -> Renaming -> ann (ValueF ann) -> ann (ValueF ann), IdSupply -> Renaming -> ValueF ann -> ValueF ann) mkRename rec = (term, alternatives, value, value') where term ids rn = rec (term' ids) rn term' ids rn e = case e of Var x -> Var (rename rn x) Value v -> Value (value' ids rn v) App e1 x2 -> App (term ids rn e1) (rename rn x2) PrimOp pop es -> PrimOp pop (map (term ids rn) es) Case e alts -> Case (term ids rn e) (alternatives ids rn alts) LetRec xes e -> LetRec (map (second (renameIn (term ids'))) xes') (term ids' rn' e) where (ids', rn', xes') = renameBounds (\_ x' -> x') ids rn xes value ids rn = rec (value' ids) rn value' ids rn v = case v of Indirect x -> Indirect (rename rn x) Lambda x e -> Lambda x' (term ids' rn' e) where (ids', rn', x') = renameBinder ids rn x Data dc xs -> Data dc (map (rename rn) xs) Literal l -> Literal l alternatives ids rn = map (alternative ids rn) alternative ids rn (alt_con, alt_e) = (alt_con', term ids' rn' alt_e) where (ids', rn', alt_con') = renameAltCon ids rn alt_con
1,393
mkRename rec = (term, alternatives, value, value') where term ids rn = rec (term' ids) rn term' ids rn e = case e of Var x -> Var (rename rn x) Value v -> Value (value' ids rn v) App e1 x2 -> App (term ids rn e1) (rename rn x2) PrimOp pop es -> PrimOp pop (map (term ids rn) es) Case e alts -> Case (term ids rn e) (alternatives ids rn alts) LetRec xes e -> LetRec (map (second (renameIn (term ids'))) xes') (term ids' rn' e) where (ids', rn', xes') = renameBounds (\_ x' -> x') ids rn xes value ids rn = rec (value' ids) rn value' ids rn v = case v of Indirect x -> Indirect (rename rn x) Lambda x e -> Lambda x' (term ids' rn' e) where (ids', rn', x') = renameBinder ids rn x Data dc xs -> Data dc (map (rename rn) xs) Literal l -> Literal l alternatives ids rn = map (alternative ids rn) alternative ids rn (alt_con, alt_e) = (alt_con', term ids' rn' alt_e) where (ids', rn', alt_con') = renameAltCon ids rn alt_con
1,031
false
true
6
18
419
675
334
341
null
null
tadeboro/Formal
src/Training/Formal.hs
gpl-3.0
-- | Get first coeficient in series head :: Formal a -> a head (x :+: _) = x
76
head :: Formal a -> a head (x :+: _) = x
40
head (x :+: _) = x
18
true
true
0
7
18
29
15
14
null
null
LambdaLuminaries/illum
Handler/Blog.hs
bsd-2-clause
getArticleR :: ArticleId -> Handler RepHtml getArticleR articleId = do article <- runDB $ get404 articleId defaultLayout $ do setTitle $ toHtml $ articleTitle article $(widgetFile "article")
214
getArticleR :: ArticleId -> Handler RepHtml getArticleR articleId = do article <- runDB $ get404 articleId defaultLayout $ do setTitle $ toHtml $ articleTitle article $(widgetFile "article")
214
getArticleR articleId = do article <- runDB $ get404 articleId defaultLayout $ do setTitle $ toHtml $ articleTitle article $(widgetFile "article")
170
false
true
0
12
50
66
29
37
null
null
wstrinz/hask_bsb
.stack-work/dist/x86_64-windows/Cabal-1.18.1.5/build/autogen/Paths_new_template.hs
bsd-3-clause
version :: Version version = Version {versionBranch = [0,1,0,0], versionTags = []}
82
version :: Version version = Version {versionBranch = [0,1,0,0], versionTags = []}
82
version = Version {versionBranch = [0,1,0,0], versionTags = []}
63
false
true
0
8
11
49
26
23
null
null
AlexanderPankiv/ghc
compiler/types/InstEnv.hs
bsd-3-clause
classInstances :: InstEnvs -> Class -> [ClsInst] classInstances (InstEnvs { ie_global = pkg_ie, ie_local = home_ie, ie_visible = vis_mods }) cls = get home_ie ++ get pkg_ie where get env = case lookupUFM env cls of Just (ClsIE insts) -> filter (instIsVisible vis_mods) insts Nothing -> [] -- | Collects the names of concrete types and type constructors that make -- up the head of a class instance. For instance, given `class Foo a b`: -- -- `instance Foo (Either (Maybe Int) a) Bool` would yield -- [Either, Maybe, Int, Bool] -- -- Used in the implementation of ":info" in GHCi.
636
classInstances :: InstEnvs -> Class -> [ClsInst] classInstances (InstEnvs { ie_global = pkg_ie, ie_local = home_ie, ie_visible = vis_mods }) cls = get home_ie ++ get pkg_ie where get env = case lookupUFM env cls of Just (ClsIE insts) -> filter (instIsVisible vis_mods) insts Nothing -> [] -- | Collects the names of concrete types and type constructors that make -- up the head of a class instance. For instance, given `class Foo a b`: -- -- `instance Foo (Either (Maybe Int) a) Bool` would yield -- [Either, Maybe, Int, Bool] -- -- Used in the implementation of ":info" in GHCi.
636
classInstances (InstEnvs { ie_global = pkg_ie, ie_local = home_ie, ie_visible = vis_mods }) cls = get home_ie ++ get pkg_ie where get env = case lookupUFM env cls of Just (ClsIE insts) -> filter (instIsVisible vis_mods) insts Nothing -> [] -- | Collects the names of concrete types and type constructors that make -- up the head of a class instance. For instance, given `class Foo a b`: -- -- `instance Foo (Either (Maybe Int) a) Bool` would yield -- [Either, Maybe, Int, Bool] -- -- Used in the implementation of ":info" in GHCi.
587
false
true
0
10
157
121
65
56
null
null
gianlucagiorgolo/lambek-monad
TP.hs
mit
replaceWithConstants :: BinTree DecoratedSequent -> (Map Int LambdaTerm) -> BinTree DecoratedSequent replaceWithConstants t m = fmap (\n -> replaceWithConstantsInNode n m) t
173
replaceWithConstants :: BinTree DecoratedSequent -> (Map Int LambdaTerm) -> BinTree DecoratedSequent replaceWithConstants t m = fmap (\n -> replaceWithConstantsInNode n m) t
173
replaceWithConstants t m = fmap (\n -> replaceWithConstantsInNode n m) t
72
false
true
0
8
21
56
27
29
null
null
walkie/CC-TaglessFinal
src/Language/TTF/Arithmetic.hs
bsd-3-clause
-- | Nested plain expressions. e4 = neg e1 `add` chcB (lit 5) (lit 6 `add` lit 7)
81
e4 = neg e1 `add` chcB (lit 5) (lit 6 `add` lit 7)
50
e4 = neg e1 `add` chcB (lit 5) (lit 6 `add` lit 7)
50
true
false
1
8
17
50
23
27
null
null
Potregon/while
src/Parser/While.hs
gpl-3.0
state states@(13:_) stack input = case headMay input of Just ( PosToken _ (Id _) ) -> shift 51 states stack input _ -> error $ "unexpected " ++ if null input then "end of file" else show (head input) ++ "\nexpecting id"
253
state states@(13:_) stack input = case headMay input of Just ( PosToken _ (Id _) ) -> shift 51 states stack input _ -> error $ "unexpected " ++ if null input then "end of file" else show (head input) ++ "\nexpecting id"
253
state states@(13:_) stack input = case headMay input of Just ( PosToken _ (Id _) ) -> shift 51 states stack input _ -> error $ "unexpected " ++ if null input then "end of file" else show (head input) ++ "\nexpecting id"
253
false
false
1
13
76
99
48
51
null
null
romanb/amazonka
amazonka-ml/gen/Network/AWS/MachineLearning/CreateMLModel.hs
mpl-2.0
-- | A user-supplied ID that uniquely identifies the 'MLModel'. cmlmMLModelId :: Lens' CreateMLModel Text cmlmMLModelId = lens _cmlmMLModelId (\s a -> s { _cmlmMLModelId = a })
176
cmlmMLModelId :: Lens' CreateMLModel Text cmlmMLModelId = lens _cmlmMLModelId (\s a -> s { _cmlmMLModelId = a })
112
cmlmMLModelId = lens _cmlmMLModelId (\s a -> s { _cmlmMLModelId = a })
70
true
true
1
9
27
43
22
21
null
null
vTurbine/ghc
compiler/cmm/CmmExpr.hs
bsd-3-clause
cmmExprType _ (CmmLoad _ rep) = rep
44
cmmExprType _ (CmmLoad _ rep) = rep
44
cmmExprType _ (CmmLoad _ rep) = rep
44
false
false
0
7
15
19
9
10
null
null
VictorDenisov/mongodb
test/Main.hs
apache-2.0
main :: IO () main = do mongodbHost <- getEnv mongodbHostEnvVariable `catchIOError` (\_ -> return "localhost") p <- connect $ host mongodbHost version <- access p slaveOk "admin" serverVersion putStrLn $ "Running tests with mongodb version: " ++ (unpack version) hspecWith defaultConfig Spec.spec
306
main :: IO () main = do mongodbHost <- getEnv mongodbHostEnvVariable `catchIOError` (\_ -> return "localhost") p <- connect $ host mongodbHost version <- access p slaveOk "admin" serverVersion putStrLn $ "Running tests with mongodb version: " ++ (unpack version) hspecWith defaultConfig Spec.spec
306
main = do mongodbHost <- getEnv mongodbHostEnvVariable `catchIOError` (\_ -> return "localhost") p <- connect $ host mongodbHost version <- access p slaveOk "admin" serverVersion putStrLn $ "Running tests with mongodb version: " ++ (unpack version) hspecWith defaultConfig Spec.spec
292
false
true
0
12
52
106
48
58
null
null
thoughtpolice/infinity
src/Infinity/Core.hs
bsd-3-clause
-- | Parts a server partserv :: Server -> Bot -> Bot partserv serv x@(Bot s) = if serv `M.notMember` s then x else (Bot (M.delete serv s))
148
partserv :: Server -> Bot -> Bot partserv serv x@(Bot s) = if serv `M.notMember` s then x else (Bot (M.delete serv s))
128
partserv serv x@(Bot s) = if serv `M.notMember` s then x else (Bot (M.delete serv s))
95
true
true
0
10
37
66
36
30
null
null
haslab/SecreC
src/Language/SecreC/Transformation/Dafny.hs
gpl-3.0
dafnyAs :: DDoc -> DDoc -> DDoc dafnyAs x pt = dparens x <<+>> dtext "as" <<+>> pt
82
dafnyAs :: DDoc -> DDoc -> DDoc dafnyAs x pt = dparens x <<+>> dtext "as" <<+>> pt
82
dafnyAs x pt = dparens x <<+>> dtext "as" <<+>> pt
50
false
true
0
7
17
38
18
20
null
null
kfiz/IHaskell
ipython-kernel/src/IHaskell/IPython/Message/Parser.hs
mit
inspectRequestParser :: LByteString -> Message inspectRequestParser = requestParser $ \obj -> do code <- obj .: "code" pos <- obj .: "cursor_pos" dlevel <- obj .: "detail_level" return $ InspectRequest noHeader code pos dlevel
234
inspectRequestParser :: LByteString -> Message inspectRequestParser = requestParser $ \obj -> do code <- obj .: "code" pos <- obj .: "cursor_pos" dlevel <- obj .: "detail_level" return $ InspectRequest noHeader code pos dlevel
234
inspectRequestParser = requestParser $ \obj -> do code <- obj .: "code" pos <- obj .: "cursor_pos" dlevel <- obj .: "detail_level" return $ InspectRequest noHeader code pos dlevel
187
false
true
0
10
41
73
35
38
null
null
urbanslug/ghc
compiler/coreSyn/CoreUnfold.hs
bsd-3-clause
sizeExpr :: DynFlags -> FastInt -- Bomb out if it gets bigger than this -> [Id] -- Arguments; we're interested in which of these -- get case'd -> CoreExpr -> ExprSize -- Note [Computing the size of an expression] sizeExpr dflags bOMB_OUT_SIZE top_args expr = size_up expr where size_up (Cast e _) = size_up e size_up (Tick _ e) = size_up e size_up (Type _) = sizeZero -- Types cost nothing size_up (Coercion _) = sizeZero size_up (Lit lit) = sizeN (litSize lit) size_up (Var f) | isRealWorldId f = sizeZero -- Make sure we get constructor discounts even -- on nullary constructors | otherwise = size_up_call f [] 0 size_up (App fun arg) | isTyCoArg arg = size_up fun | otherwise = size_up arg `addSizeNSD` size_up_app fun [arg] (if isRealWorldExpr arg then 1 else 0) size_up (Lam b e) | isId b && not (isRealWorldId b) = lamScrutDiscount dflags (size_up e `addSizeN` 10) | otherwise = size_up e size_up (Let (NonRec binder rhs) body) = size_up rhs `addSizeNSD` size_up body `addSizeN` (if isUnLiftedType (idType binder) then 0 else 10) -- For the allocation -- If the binder has an unlifted type there is no allocation size_up (Let (Rec pairs) body) = foldr (addSizeNSD . size_up . snd) (size_up body `addSizeN` (10 * length pairs)) -- (length pairs) for the allocation pairs size_up (Case (Var v) _ _ alts) | v `elem` top_args -- We are scrutinising an argument variable = alts_size (foldr addAltSize sizeZero alt_sizes) (foldr maxSize sizeZero alt_sizes) -- Good to inline if an arg is scrutinised, because -- that may eliminate allocation in the caller -- And it eliminates the case itself where alt_sizes = map size_up_alt alts -- alts_size tries to compute a good discount for -- the case when we are scrutinising an argument variable alts_size (SizeIs tot tot_disc tot_scrut) -- Size of all alternatives (SizeIs max _ _) -- Size of biggest alternative = SizeIs tot (unitBag (v, iBox (_ILIT(20) +# tot -# max)) `unionBags` tot_disc) tot_scrut -- If the variable is known, we produce a discount that -- will take us back to 'max', the size of the largest alternative -- The 1+ is a little discount for reduced allocation in the caller -- -- Notice though, that we return tot_disc, the total discount from -- all branches. I think that's right. alts_size tot_size _ = tot_size size_up (Case e _ _ alts) = size_up e `addSizeNSD` foldr (addAltSize . size_up_alt) case_size alts where case_size | is_inline_scrut e, not (lengthExceeds alts 1) = sizeN (-10) | otherwise = sizeZero -- Normally we don't charge for the case itself, but -- we charge one per alternative (see size_up_alt, -- below) to account for the cost of the info table -- and comparisons. -- -- However, in certain cases (see is_inline_scrut -- below), no code is generated for the case unless -- there are multiple alts. In these cases we -- subtract one, making the first alt free. -- e.g. case x# +# y# of _ -> ... should cost 1 -- case touch# x# of _ -> ... should cost 0 -- (see #4978) -- -- I would like to not have the "not (lengthExceeds alts 1)" -- condition above, but without that some programs got worse -- (spectral/hartel/event and spectral/para). I don't fully -- understand why. (SDM 24/5/11) -- unboxed variables, inline primops and unsafe foreign calls -- are all "inline" things: is_inline_scrut (Var v) = isUnLiftedType (idType v) is_inline_scrut scrut | (Var f, _) <- collectArgs scrut = case idDetails f of FCallId fc -> not (isSafeForeignCall fc) PrimOpId op -> not (primOpOutOfLine op) _other -> False | otherwise = False ------------ -- size_up_app is used when there's ONE OR MORE value args size_up_app (App fun arg) args voids | isTyCoArg arg = size_up_app fun args voids | isRealWorldExpr arg = size_up_app fun (arg:args) (voids + 1) | otherwise = size_up arg `addSizeNSD` size_up_app fun (arg:args) voids size_up_app (Var fun) args voids = size_up_call fun args voids size_up_app (Tick _ expr) args voids = size_up_app expr args voids size_up_app other args voids = size_up other `addSizeN` (length args - voids) ------------ size_up_call :: Id -> [CoreExpr] -> Int -> ExprSize size_up_call fun val_args voids = case idDetails fun of FCallId _ -> sizeN (10 * (1 + length val_args)) DataConWorkId dc -> conSize dc (length val_args) PrimOpId op -> primOpSize op (length val_args) ClassOpId _ -> classOpSize dflags top_args val_args _ -> funSize dflags top_args fun (length val_args) voids ------------ size_up_alt (_con, _bndrs, rhs) = size_up rhs `addSizeN` 10 -- Don't charge for args, so that wrappers look cheap -- (See comments about wrappers with Case) -- -- IMPORATANT: *do* charge 1 for the alternative, else we -- find that giant case nests are treated as practically free -- A good example is Foreign.C.Error.errrnoToIOError ------------ -- These addSize things have to be here because -- I don't want to give them bOMB_OUT_SIZE as an argument addSizeN TooBig _ = TooBig addSizeN (SizeIs n xs d) m = mkSizeIs bOMB_OUT_SIZE (n +# iUnbox m) xs d -- addAltSize is used to add the sizes of case alternatives addAltSize TooBig _ = TooBig addAltSize _ TooBig = TooBig addAltSize (SizeIs n1 xs d1) (SizeIs n2 ys d2) = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) (d1 +# d2) -- Note [addAltSize result discounts] -- This variant ignores the result discount from its LEFT argument -- It's used when the second argument isn't part of the result addSizeNSD TooBig _ = TooBig addSizeNSD _ TooBig = TooBig addSizeNSD (SizeIs n1 xs _) (SizeIs n2 ys d2) = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) d2 -- Ignore d1 isRealWorldId id = idType id `eqType` realWorldStatePrimTy -- an expression of type State# RealWorld must be a variable isRealWorldExpr (Var id) = isRealWorldId id isRealWorldExpr (Tick _ e) = isRealWorldExpr e isRealWorldExpr _ = False -- | Finds a nominal size of a string literal.
7,764
sizeExpr :: DynFlags -> FastInt -- Bomb out if it gets bigger than this -> [Id] -- Arguments; we're interested in which of these -- get case'd -> CoreExpr -> ExprSize sizeExpr dflags bOMB_OUT_SIZE top_args expr = size_up expr where size_up (Cast e _) = size_up e size_up (Tick _ e) = size_up e size_up (Type _) = sizeZero -- Types cost nothing size_up (Coercion _) = sizeZero size_up (Lit lit) = sizeN (litSize lit) size_up (Var f) | isRealWorldId f = sizeZero -- Make sure we get constructor discounts even -- on nullary constructors | otherwise = size_up_call f [] 0 size_up (App fun arg) | isTyCoArg arg = size_up fun | otherwise = size_up arg `addSizeNSD` size_up_app fun [arg] (if isRealWorldExpr arg then 1 else 0) size_up (Lam b e) | isId b && not (isRealWorldId b) = lamScrutDiscount dflags (size_up e `addSizeN` 10) | otherwise = size_up e size_up (Let (NonRec binder rhs) body) = size_up rhs `addSizeNSD` size_up body `addSizeN` (if isUnLiftedType (idType binder) then 0 else 10) -- For the allocation -- If the binder has an unlifted type there is no allocation size_up (Let (Rec pairs) body) = foldr (addSizeNSD . size_up . snd) (size_up body `addSizeN` (10 * length pairs)) -- (length pairs) for the allocation pairs size_up (Case (Var v) _ _ alts) | v `elem` top_args -- We are scrutinising an argument variable = alts_size (foldr addAltSize sizeZero alt_sizes) (foldr maxSize sizeZero alt_sizes) -- Good to inline if an arg is scrutinised, because -- that may eliminate allocation in the caller -- And it eliminates the case itself where alt_sizes = map size_up_alt alts -- alts_size tries to compute a good discount for -- the case when we are scrutinising an argument variable alts_size (SizeIs tot tot_disc tot_scrut) -- Size of all alternatives (SizeIs max _ _) -- Size of biggest alternative = SizeIs tot (unitBag (v, iBox (_ILIT(20) +# tot -# max)) `unionBags` tot_disc) tot_scrut -- If the variable is known, we produce a discount that -- will take us back to 'max', the size of the largest alternative -- The 1+ is a little discount for reduced allocation in the caller -- -- Notice though, that we return tot_disc, the total discount from -- all branches. I think that's right. alts_size tot_size _ = tot_size size_up (Case e _ _ alts) = size_up e `addSizeNSD` foldr (addAltSize . size_up_alt) case_size alts where case_size | is_inline_scrut e, not (lengthExceeds alts 1) = sizeN (-10) | otherwise = sizeZero -- Normally we don't charge for the case itself, but -- we charge one per alternative (see size_up_alt, -- below) to account for the cost of the info table -- and comparisons. -- -- However, in certain cases (see is_inline_scrut -- below), no code is generated for the case unless -- there are multiple alts. In these cases we -- subtract one, making the first alt free. -- e.g. case x# +# y# of _ -> ... should cost 1 -- case touch# x# of _ -> ... should cost 0 -- (see #4978) -- -- I would like to not have the "not (lengthExceeds alts 1)" -- condition above, but without that some programs got worse -- (spectral/hartel/event and spectral/para). I don't fully -- understand why. (SDM 24/5/11) -- unboxed variables, inline primops and unsafe foreign calls -- are all "inline" things: is_inline_scrut (Var v) = isUnLiftedType (idType v) is_inline_scrut scrut | (Var f, _) <- collectArgs scrut = case idDetails f of FCallId fc -> not (isSafeForeignCall fc) PrimOpId op -> not (primOpOutOfLine op) _other -> False | otherwise = False ------------ -- size_up_app is used when there's ONE OR MORE value args size_up_app (App fun arg) args voids | isTyCoArg arg = size_up_app fun args voids | isRealWorldExpr arg = size_up_app fun (arg:args) (voids + 1) | otherwise = size_up arg `addSizeNSD` size_up_app fun (arg:args) voids size_up_app (Var fun) args voids = size_up_call fun args voids size_up_app (Tick _ expr) args voids = size_up_app expr args voids size_up_app other args voids = size_up other `addSizeN` (length args - voids) ------------ size_up_call :: Id -> [CoreExpr] -> Int -> ExprSize size_up_call fun val_args voids = case idDetails fun of FCallId _ -> sizeN (10 * (1 + length val_args)) DataConWorkId dc -> conSize dc (length val_args) PrimOpId op -> primOpSize op (length val_args) ClassOpId _ -> classOpSize dflags top_args val_args _ -> funSize dflags top_args fun (length val_args) voids ------------ size_up_alt (_con, _bndrs, rhs) = size_up rhs `addSizeN` 10 -- Don't charge for args, so that wrappers look cheap -- (See comments about wrappers with Case) -- -- IMPORATANT: *do* charge 1 for the alternative, else we -- find that giant case nests are treated as practically free -- A good example is Foreign.C.Error.errrnoToIOError ------------ -- These addSize things have to be here because -- I don't want to give them bOMB_OUT_SIZE as an argument addSizeN TooBig _ = TooBig addSizeN (SizeIs n xs d) m = mkSizeIs bOMB_OUT_SIZE (n +# iUnbox m) xs d -- addAltSize is used to add the sizes of case alternatives addAltSize TooBig _ = TooBig addAltSize _ TooBig = TooBig addAltSize (SizeIs n1 xs d1) (SizeIs n2 ys d2) = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) (d1 +# d2) -- Note [addAltSize result discounts] -- This variant ignores the result discount from its LEFT argument -- It's used when the second argument isn't part of the result addSizeNSD TooBig _ = TooBig addSizeNSD _ TooBig = TooBig addSizeNSD (SizeIs n1 xs _) (SizeIs n2 ys d2) = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) d2 -- Ignore d1 isRealWorldId id = idType id `eqType` realWorldStatePrimTy -- an expression of type State# RealWorld must be a variable isRealWorldExpr (Var id) = isRealWorldId id isRealWorldExpr (Tick _ e) = isRealWorldExpr e isRealWorldExpr _ = False -- | Finds a nominal size of a string literal.
7,716
sizeExpr dflags bOMB_OUT_SIZE top_args expr = size_up expr where size_up (Cast e _) = size_up e size_up (Tick _ e) = size_up e size_up (Type _) = sizeZero -- Types cost nothing size_up (Coercion _) = sizeZero size_up (Lit lit) = sizeN (litSize lit) size_up (Var f) | isRealWorldId f = sizeZero -- Make sure we get constructor discounts even -- on nullary constructors | otherwise = size_up_call f [] 0 size_up (App fun arg) | isTyCoArg arg = size_up fun | otherwise = size_up arg `addSizeNSD` size_up_app fun [arg] (if isRealWorldExpr arg then 1 else 0) size_up (Lam b e) | isId b && not (isRealWorldId b) = lamScrutDiscount dflags (size_up e `addSizeN` 10) | otherwise = size_up e size_up (Let (NonRec binder rhs) body) = size_up rhs `addSizeNSD` size_up body `addSizeN` (if isUnLiftedType (idType binder) then 0 else 10) -- For the allocation -- If the binder has an unlifted type there is no allocation size_up (Let (Rec pairs) body) = foldr (addSizeNSD . size_up . snd) (size_up body `addSizeN` (10 * length pairs)) -- (length pairs) for the allocation pairs size_up (Case (Var v) _ _ alts) | v `elem` top_args -- We are scrutinising an argument variable = alts_size (foldr addAltSize sizeZero alt_sizes) (foldr maxSize sizeZero alt_sizes) -- Good to inline if an arg is scrutinised, because -- that may eliminate allocation in the caller -- And it eliminates the case itself where alt_sizes = map size_up_alt alts -- alts_size tries to compute a good discount for -- the case when we are scrutinising an argument variable alts_size (SizeIs tot tot_disc tot_scrut) -- Size of all alternatives (SizeIs max _ _) -- Size of biggest alternative = SizeIs tot (unitBag (v, iBox (_ILIT(20) +# tot -# max)) `unionBags` tot_disc) tot_scrut -- If the variable is known, we produce a discount that -- will take us back to 'max', the size of the largest alternative -- The 1+ is a little discount for reduced allocation in the caller -- -- Notice though, that we return tot_disc, the total discount from -- all branches. I think that's right. alts_size tot_size _ = tot_size size_up (Case e _ _ alts) = size_up e `addSizeNSD` foldr (addAltSize . size_up_alt) case_size alts where case_size | is_inline_scrut e, not (lengthExceeds alts 1) = sizeN (-10) | otherwise = sizeZero -- Normally we don't charge for the case itself, but -- we charge one per alternative (see size_up_alt, -- below) to account for the cost of the info table -- and comparisons. -- -- However, in certain cases (see is_inline_scrut -- below), no code is generated for the case unless -- there are multiple alts. In these cases we -- subtract one, making the first alt free. -- e.g. case x# +# y# of _ -> ... should cost 1 -- case touch# x# of _ -> ... should cost 0 -- (see #4978) -- -- I would like to not have the "not (lengthExceeds alts 1)" -- condition above, but without that some programs got worse -- (spectral/hartel/event and spectral/para). I don't fully -- understand why. (SDM 24/5/11) -- unboxed variables, inline primops and unsafe foreign calls -- are all "inline" things: is_inline_scrut (Var v) = isUnLiftedType (idType v) is_inline_scrut scrut | (Var f, _) <- collectArgs scrut = case idDetails f of FCallId fc -> not (isSafeForeignCall fc) PrimOpId op -> not (primOpOutOfLine op) _other -> False | otherwise = False ------------ -- size_up_app is used when there's ONE OR MORE value args size_up_app (App fun arg) args voids | isTyCoArg arg = size_up_app fun args voids | isRealWorldExpr arg = size_up_app fun (arg:args) (voids + 1) | otherwise = size_up arg `addSizeNSD` size_up_app fun (arg:args) voids size_up_app (Var fun) args voids = size_up_call fun args voids size_up_app (Tick _ expr) args voids = size_up_app expr args voids size_up_app other args voids = size_up other `addSizeN` (length args - voids) ------------ size_up_call :: Id -> [CoreExpr] -> Int -> ExprSize size_up_call fun val_args voids = case idDetails fun of FCallId _ -> sizeN (10 * (1 + length val_args)) DataConWorkId dc -> conSize dc (length val_args) PrimOpId op -> primOpSize op (length val_args) ClassOpId _ -> classOpSize dflags top_args val_args _ -> funSize dflags top_args fun (length val_args) voids ------------ size_up_alt (_con, _bndrs, rhs) = size_up rhs `addSizeN` 10 -- Don't charge for args, so that wrappers look cheap -- (See comments about wrappers with Case) -- -- IMPORATANT: *do* charge 1 for the alternative, else we -- find that giant case nests are treated as practically free -- A good example is Foreign.C.Error.errrnoToIOError ------------ -- These addSize things have to be here because -- I don't want to give them bOMB_OUT_SIZE as an argument addSizeN TooBig _ = TooBig addSizeN (SizeIs n xs d) m = mkSizeIs bOMB_OUT_SIZE (n +# iUnbox m) xs d -- addAltSize is used to add the sizes of case alternatives addAltSize TooBig _ = TooBig addAltSize _ TooBig = TooBig addAltSize (SizeIs n1 xs d1) (SizeIs n2 ys d2) = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) (d1 +# d2) -- Note [addAltSize result discounts] -- This variant ignores the result discount from its LEFT argument -- It's used when the second argument isn't part of the result addSizeNSD TooBig _ = TooBig addSizeNSD _ TooBig = TooBig addSizeNSD (SizeIs n1 xs _) (SizeIs n2 ys d2) = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) d2 -- Ignore d1 isRealWorldId id = idType id `eqType` realWorldStatePrimTy -- an expression of type State# RealWorld must be a variable isRealWorldExpr (Var id) = isRealWorldId id isRealWorldExpr (Tick _ e) = isRealWorldExpr e isRealWorldExpr _ = False -- | Finds a nominal size of a string literal.
7,466
true
true
14
15
2,945
1,548
767
781
null
null
hvr/lens
lens-properties/src/Control/Lens/Properties.hs
bsd-3-clause
-------------------------------------------------------------------------------- -- | A 'Traversal' is only legal if it is a valid 'Setter' (see 'isSetter' for -- what makes a 'Setter' valid), and the following laws hold: -- -- 1. @t pure ≡ pure@ -- -- 2. @fmap (t f) . t g ≡ getCompose . t (Compose . fmap f . g)@ isTraversal :: (Arbitrary s, Arbitrary a, CoArbitrary a, Show s, Show a, Eq s, Function a) => Simple Traversal s a -> Property isTraversal l = isSetter l .&. traverse_pureMaybe l .&. traverse_pureList l .&. do as <- arbitrary bs <- arbitrary t <- arbitrary property $ traverse_compose l (\x -> as++[x]++bs) (\x -> if t then Just x else Nothing) -------------------------------------------------------------------------------- -- | A 'Lens' is only legal if it is a valid 'Traversal' (see 'isTraversal' for -- what this means), and if the following laws hold: -- -- 1. @view l (set l b a) ≡ b@ -- -- 2. @set l (view l a) a ≡ a@ -- -- 3. @set l c (set l b a) ≡ set l c a@
1,145
isTraversal :: (Arbitrary s, Arbitrary a, CoArbitrary a, Show s, Show a, Eq s, Function a) => Simple Traversal s a -> Property isTraversal l = isSetter l .&. traverse_pureMaybe l .&. traverse_pureList l .&. do as <- arbitrary bs <- arbitrary t <- arbitrary property $ traverse_compose l (\x -> as++[x]++bs) (\x -> if t then Just x else Nothing) -------------------------------------------------------------------------------- -- | A 'Lens' is only legal if it is a valid 'Traversal' (see 'isTraversal' for -- what this means), and if the following laws hold: -- -- 1. @view l (set l b a) ≡ b@ -- -- 2. @set l (view l a) a ≡ a@ -- -- 3. @set l c (set l b a) ≡ set l c a@
830
isTraversal l = isSetter l .&. traverse_pureMaybe l .&. traverse_pureList l .&. do as <- arbitrary bs <- arbitrary t <- arbitrary property $ traverse_compose l (\x -> as++[x]++bs) (\x -> if t then Just x else Nothing) -------------------------------------------------------------------------------- -- | A 'Lens' is only legal if it is a valid 'Traversal' (see 'isTraversal' for -- what this means), and if the following laws hold: -- -- 1. @view l (set l b a) ≡ b@ -- -- 2. @set l (view l a) a ≡ a@ -- -- 3. @set l c (set l b a) ≡ set l c a@
694
true
true
0
14
339
180
97
83
null
null
gridaphobe/ghc
compiler/coreSyn/CoreUtils.hs
bsd-3-clause
tryEtaReduce :: [Var] -> CoreExpr -> Maybe CoreExpr tryEtaReduce bndrs body = go (reverse bndrs) body (mkRepReflCo (exprType body)) where incoming_arity = count isId bndrs go :: [Var] -- Binders, innermost first, types [a3,a2,a1] -> CoreExpr -- Of type tr -> Coercion -- Of type tr ~ ts -> Maybe CoreExpr -- Of type a1 -> a2 -> a3 -> ts -- See Note [Eta reduction with casted arguments] -- for why we have an accumulating coercion go [] fun co | ok_fun fun , let used_vars = exprFreeVars fun `unionVarSet` tyCoVarsOfCo co , not (any (`elemVarSet` used_vars) bndrs) = Just (mkCast fun co) -- Check for any of the binders free in the result -- including the accumulated coercion go bs (Tick t e) co | tickishFloatable t = fmap (Tick t) $ go bs e co -- Float app ticks: \x -> Tick t (e x) ==> Tick t e go (b : bs) (App fun arg) co | Just (co', ticks) <- ok_arg b arg co = fmap (flip (foldr mkTick) ticks) $ go bs fun co' -- Float arg ticks: \x -> e (Tick t x) ==> Tick t e go _ _ _ = Nothing -- Failure! --------------- -- Note [Eta reduction conditions] ok_fun (App fun (Type {})) = ok_fun fun ok_fun (Cast fun _) = ok_fun fun ok_fun (Tick _ expr) = ok_fun expr ok_fun (Var fun_id) = ok_fun_id fun_id || all ok_lam bndrs ok_fun _fun = False --------------- ok_fun_id fun = fun_arity fun >= incoming_arity --------------- fun_arity fun -- See Note [Arity care] | isLocalId fun , isStrongLoopBreaker (idOccInfo fun) = 0 | arity > 0 = arity | isEvaldUnfolding (idUnfolding fun) = 1 -- See Note [Eta reduction of an eval'd function] | otherwise = 0 where arity = idArity fun --------------- ok_lam v = isTyVar v || isEvVar v --------------- ok_arg :: Var -- Of type bndr_t -> CoreExpr -- Of type arg_t -> Coercion -- Of kind (t1~t2) -> Maybe (Coercion -- Of type (arg_t -> t1 ~ bndr_t -> t2) -- (and similarly for tyvars, coercion args) , [Tickish Var]) -- See Note [Eta reduction with casted arguments] ok_arg bndr (Type ty) co | Just tv <- getTyVar_maybe ty , bndr == tv = Just (mkHomoForAllCos [tv] co, []) ok_arg bndr (Var v) co | bndr == v = let reflCo = mkRepReflCo (idType bndr) in Just (mkFunCo Representational reflCo co, []) ok_arg bndr (Cast e co_arg) co | (ticks, Var v) <- stripTicksTop tickishFloatable e , bndr == v = Just (mkFunCo Representational (mkSymCo co_arg) co, ticks) -- The simplifier combines multiple casts into one, -- so we can have a simple-minded pattern match here ok_arg bndr (Tick t arg) co | tickishFloatable t, Just (co', ticks) <- ok_arg bndr arg co = Just (co', t:ticks) ok_arg _ _ _ = Nothing {- Note [Eta reduction of an eval'd function] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In Haskell is is not true that f = \x. f x because f might be bottom, and 'seq' can distinguish them. But it *is* true that f = f `seq` \x. f x and we'd like to simplify the latter to the former. This amounts to the rule that * when there is just *one* value argument, * f is not bottom we can eta-reduce \x. f x ===> f This turned up in Trac #7542. ************************************************************************ * * \subsection{Determining non-updatable right-hand-sides} * * ************************************************************************ Top-level constructor applications can usually be allocated statically, but they can't if the constructor, or any of the arguments, come from another DLL (because we can't refer to static labels in other DLLs). If this happens we simply make the RHS into an updatable thunk, and 'execute' it rather than allocating it statically. -} -- | This function is called only on *top-level* right-hand sides. -- Returns @True@ if the RHS can be allocated statically in the output, -- with no thunks involved at all.
4,506
tryEtaReduce :: [Var] -> CoreExpr -> Maybe CoreExpr tryEtaReduce bndrs body = go (reverse bndrs) body (mkRepReflCo (exprType body)) where incoming_arity = count isId bndrs go :: [Var] -- Binders, innermost first, types [a3,a2,a1] -> CoreExpr -- Of type tr -> Coercion -- Of type tr ~ ts -> Maybe CoreExpr -- Of type a1 -> a2 -> a3 -> ts -- See Note [Eta reduction with casted arguments] -- for why we have an accumulating coercion go [] fun co | ok_fun fun , let used_vars = exprFreeVars fun `unionVarSet` tyCoVarsOfCo co , not (any (`elemVarSet` used_vars) bndrs) = Just (mkCast fun co) -- Check for any of the binders free in the result -- including the accumulated coercion go bs (Tick t e) co | tickishFloatable t = fmap (Tick t) $ go bs e co -- Float app ticks: \x -> Tick t (e x) ==> Tick t e go (b : bs) (App fun arg) co | Just (co', ticks) <- ok_arg b arg co = fmap (flip (foldr mkTick) ticks) $ go bs fun co' -- Float arg ticks: \x -> e (Tick t x) ==> Tick t e go _ _ _ = Nothing -- Failure! --------------- -- Note [Eta reduction conditions] ok_fun (App fun (Type {})) = ok_fun fun ok_fun (Cast fun _) = ok_fun fun ok_fun (Tick _ expr) = ok_fun expr ok_fun (Var fun_id) = ok_fun_id fun_id || all ok_lam bndrs ok_fun _fun = False --------------- ok_fun_id fun = fun_arity fun >= incoming_arity --------------- fun_arity fun -- See Note [Arity care] | isLocalId fun , isStrongLoopBreaker (idOccInfo fun) = 0 | arity > 0 = arity | isEvaldUnfolding (idUnfolding fun) = 1 -- See Note [Eta reduction of an eval'd function] | otherwise = 0 where arity = idArity fun --------------- ok_lam v = isTyVar v || isEvVar v --------------- ok_arg :: Var -- Of type bndr_t -> CoreExpr -- Of type arg_t -> Coercion -- Of kind (t1~t2) -> Maybe (Coercion -- Of type (arg_t -> t1 ~ bndr_t -> t2) -- (and similarly for tyvars, coercion args) , [Tickish Var]) -- See Note [Eta reduction with casted arguments] ok_arg bndr (Type ty) co | Just tv <- getTyVar_maybe ty , bndr == tv = Just (mkHomoForAllCos [tv] co, []) ok_arg bndr (Var v) co | bndr == v = let reflCo = mkRepReflCo (idType bndr) in Just (mkFunCo Representational reflCo co, []) ok_arg bndr (Cast e co_arg) co | (ticks, Var v) <- stripTicksTop tickishFloatable e , bndr == v = Just (mkFunCo Representational (mkSymCo co_arg) co, ticks) -- The simplifier combines multiple casts into one, -- so we can have a simple-minded pattern match here ok_arg bndr (Tick t arg) co | tickishFloatable t, Just (co', ticks) <- ok_arg bndr arg co = Just (co', t:ticks) ok_arg _ _ _ = Nothing {- Note [Eta reduction of an eval'd function] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In Haskell is is not true that f = \x. f x because f might be bottom, and 'seq' can distinguish them. But it *is* true that f = f `seq` \x. f x and we'd like to simplify the latter to the former. This amounts to the rule that * when there is just *one* value argument, * f is not bottom we can eta-reduce \x. f x ===> f This turned up in Trac #7542. ************************************************************************ * * \subsection{Determining non-updatable right-hand-sides} * * ************************************************************************ Top-level constructor applications can usually be allocated statically, but they can't if the constructor, or any of the arguments, come from another DLL (because we can't refer to static labels in other DLLs). If this happens we simply make the RHS into an updatable thunk, and 'execute' it rather than allocating it statically. -} -- | This function is called only on *top-level* right-hand sides. -- Returns @True@ if the RHS can be allocated statically in the output, -- with no thunks involved at all.
4,506
tryEtaReduce bndrs body = go (reverse bndrs) body (mkRepReflCo (exprType body)) where incoming_arity = count isId bndrs go :: [Var] -- Binders, innermost first, types [a3,a2,a1] -> CoreExpr -- Of type tr -> Coercion -- Of type tr ~ ts -> Maybe CoreExpr -- Of type a1 -> a2 -> a3 -> ts -- See Note [Eta reduction with casted arguments] -- for why we have an accumulating coercion go [] fun co | ok_fun fun , let used_vars = exprFreeVars fun `unionVarSet` tyCoVarsOfCo co , not (any (`elemVarSet` used_vars) bndrs) = Just (mkCast fun co) -- Check for any of the binders free in the result -- including the accumulated coercion go bs (Tick t e) co | tickishFloatable t = fmap (Tick t) $ go bs e co -- Float app ticks: \x -> Tick t (e x) ==> Tick t e go (b : bs) (App fun arg) co | Just (co', ticks) <- ok_arg b arg co = fmap (flip (foldr mkTick) ticks) $ go bs fun co' -- Float arg ticks: \x -> e (Tick t x) ==> Tick t e go _ _ _ = Nothing -- Failure! --------------- -- Note [Eta reduction conditions] ok_fun (App fun (Type {})) = ok_fun fun ok_fun (Cast fun _) = ok_fun fun ok_fun (Tick _ expr) = ok_fun expr ok_fun (Var fun_id) = ok_fun_id fun_id || all ok_lam bndrs ok_fun _fun = False --------------- ok_fun_id fun = fun_arity fun >= incoming_arity --------------- fun_arity fun -- See Note [Arity care] | isLocalId fun , isStrongLoopBreaker (idOccInfo fun) = 0 | arity > 0 = arity | isEvaldUnfolding (idUnfolding fun) = 1 -- See Note [Eta reduction of an eval'd function] | otherwise = 0 where arity = idArity fun --------------- ok_lam v = isTyVar v || isEvVar v --------------- ok_arg :: Var -- Of type bndr_t -> CoreExpr -- Of type arg_t -> Coercion -- Of kind (t1~t2) -> Maybe (Coercion -- Of type (arg_t -> t1 ~ bndr_t -> t2) -- (and similarly for tyvars, coercion args) , [Tickish Var]) -- See Note [Eta reduction with casted arguments] ok_arg bndr (Type ty) co | Just tv <- getTyVar_maybe ty , bndr == tv = Just (mkHomoForAllCos [tv] co, []) ok_arg bndr (Var v) co | bndr == v = let reflCo = mkRepReflCo (idType bndr) in Just (mkFunCo Representational reflCo co, []) ok_arg bndr (Cast e co_arg) co | (ticks, Var v) <- stripTicksTop tickishFloatable e , bndr == v = Just (mkFunCo Representational (mkSymCo co_arg) co, ticks) -- The simplifier combines multiple casts into one, -- so we can have a simple-minded pattern match here ok_arg bndr (Tick t arg) co | tickishFloatable t, Just (co', ticks) <- ok_arg bndr arg co = Just (co', t:ticks) ok_arg _ _ _ = Nothing {- Note [Eta reduction of an eval'd function] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In Haskell is is not true that f = \x. f x because f might be bottom, and 'seq' can distinguish them. But it *is* true that f = f `seq` \x. f x and we'd like to simplify the latter to the former. This amounts to the rule that * when there is just *one* value argument, * f is not bottom we can eta-reduce \x. f x ===> f This turned up in Trac #7542. ************************************************************************ * * \subsection{Determining non-updatable right-hand-sides} * * ************************************************************************ Top-level constructor applications can usually be allocated statically, but they can't if the constructor, or any of the arguments, come from another DLL (because we can't refer to static labels in other DLLs). If this happens we simply make the RHS into an updatable thunk, and 'execute' it rather than allocating it statically. -} -- | This function is called only on *top-level* right-hand sides. -- Returns @True@ if the RHS can be allocated statically in the output, -- with no thunks involved at all.
4,454
false
true
5
12
1,478
909
438
471
null
null
fgaz/shine
shine-examples/simple-interaction/Main.hs
mit
handleInput (MouseBtn BtnLeft Up _) = const False
49
handleInput (MouseBtn BtnLeft Up _) = const False
49
handleInput (MouseBtn BtnLeft Up _) = const False
49
false
false
0
7
7
22
10
12
null
null
nushio3/ghc
ghc/Main.hs
bsd-3-clause
needsInputsMode _ = False
39
needsInputsMode _ = False
39
needsInputsMode _ = False
39
false
false
0
5
17
9
4
5
null
null
urbanslug/ghc
compiler/codeGen/StgCmmArgRep.hs
bsd-3-clause
slowCallPattern (V: _) = (fsLit "stg_ap_v", 1)
61
slowCallPattern (V: _) = (fsLit "stg_ap_v", 1)
61
slowCallPattern (V: _) = (fsLit "stg_ap_v", 1)
61
false
false
0
7
21
25
13
12
null
null
diagrams/diagrams-contrib
src/Diagrams/TwoD/Path/Turtle.hs
bsd-3-clause
-- | Get the current turtle angle, in degrees. heading :: (OrderedField n, Monad m) => TurtleT n m n heading = ST.gets (L.view deg . T.heading)
143
heading :: (OrderedField n, Monad m) => TurtleT n m n heading = ST.gets (L.view deg . T.heading)
96
heading = ST.gets (L.view deg . T.heading)
42
true
true
0
9
26
59
28
31
null
null
apyrgio/ganeti
src/Ganeti/Query/Instance.hs
bsd-2-clause
-- | Get secondary node groups getSecondaryNodeGroups :: ConfigData -> Instance -> ErrorResult [NodeGroup] getSecondaryNodeGroups cfg inst = do sNodes <- getSecondaryNodes cfg inst return . catMaybes $ map (getGroupOfNode cfg) sNodes -- | Get attributes of secondary node groups
283
getSecondaryNodeGroups :: ConfigData -> Instance -> ErrorResult [NodeGroup] getSecondaryNodeGroups cfg inst = do sNodes <- getSecondaryNodes cfg inst return . catMaybes $ map (getGroupOfNode cfg) sNodes -- | Get attributes of secondary node groups
252
getSecondaryNodeGroups cfg inst = do sNodes <- getSecondaryNodes cfg inst return . catMaybes $ map (getGroupOfNode cfg) sNodes -- | Get attributes of secondary node groups
176
true
true
0
10
44
66
32
34
null
null
qnikst/numeric-ode
src/Math/Integrators/ImplicitEuler.hs
bsd-3-clause
-- | Integrator of the form: -- -- \[ y_{n+1} = y_n + h * f(\frac{y_n+y_{n+1}}{2}). \] -- -- This is a symmetric method of order 1. implicitEuler :: (Metric f, Ord a, Floating a) => (f a -> f a) -> a -> f a -> f a implicitEuler f = \h y -> fixedPoint (\x -> y ^+^ (h *^ (f x))) (\x1 x2 -> breakNormIR (x1^-^x2) eps) y
333
implicitEuler :: (Metric f, Ord a, Floating a) => (f a -> f a) -> a -> f a -> f a implicitEuler f = \h y -> fixedPoint (\x -> y ^+^ (h *^ (f x))) (\x1 x2 -> breakNormIR (x1^-^x2) eps) y
201
implicitEuler f = \h y -> fixedPoint (\x -> y ^+^ (h *^ (f x))) (\x1 x2 -> breakNormIR (x1^-^x2) eps) y
105
true
true
0
12
86
137
71
66
null
null
SaneApp/elastic-search-api
src/ElasticSearch/Query.hs
mit
match :: Query match = undefined
32
match :: Query match = undefined
32
match = undefined
17
false
true
0
4
5
11
6
5
null
null
tomjaguarpaw/postgresql-simple
test/Main.hs
bsd-3-clause
testCopyMalformedError :: TestEnv -> TestTree testCopyMalformedError TestEnv{..} = goldenTest "malformed input" $ handle (\(SomeException exc) -> return $ BL.pack $ show exc) $ do execute_ conn "CREATE TEMPORARY TABLE copy_malformed_input_error_test (x int PRIMARY KEY, y text)" copy_ conn "COPY copy_unique_constraint_error_test FROM STDIN (FORMAT CSV)" mapM_ (putCopyData conn) copyRows _n <- putCopyEnd conn return BL.empty where copyRows = ["1,foo\n" ,"2,bar\n" ,"z,baz\n"]
564
testCopyMalformedError :: TestEnv -> TestTree testCopyMalformedError TestEnv{..} = goldenTest "malformed input" $ handle (\(SomeException exc) -> return $ BL.pack $ show exc) $ do execute_ conn "CREATE TEMPORARY TABLE copy_malformed_input_error_test (x int PRIMARY KEY, y text)" copy_ conn "COPY copy_unique_constraint_error_test FROM STDIN (FORMAT CSV)" mapM_ (putCopyData conn) copyRows _n <- putCopyEnd conn return BL.empty where copyRows = ["1,foo\n" ,"2,bar\n" ,"z,baz\n"]
564
testCopyMalformedError TestEnv{..} = goldenTest "malformed input" $ handle (\(SomeException exc) -> return $ BL.pack $ show exc) $ do execute_ conn "CREATE TEMPORARY TABLE copy_malformed_input_error_test (x int PRIMARY KEY, y text)" copy_ conn "COPY copy_unique_constraint_error_test FROM STDIN (FORMAT CSV)" mapM_ (putCopyData conn) copyRows _n <- putCopyEnd conn return BL.empty where copyRows = ["1,foo\n" ,"2,bar\n" ,"z,baz\n"]
518
false
true
2
11
146
132
61
71
null
null
Shou/Brahmaputra
Server.hs
bsd-3-clause
etGamePlayer :: Text -> Game -> Maybe Player getGamePlayer k g = M.lookup k $ players g
88
getGamePlayer :: Text -> Game -> Maybe Player getGamePlayer k g = M.lookup k $ players g
88
getGamePlayer k g = M.lookup k $ players g
42
false
true
0
7
17
39
18
21
null
null
rahulmutt/ghcvm
compiler/Eta/TypeCheck/TcTypeNats.hs
bsd-3-clause
axAdd0R = mkAxiom1 "Add0R" $ \t -> (t .+. num 0) === t
61
axAdd0R = mkAxiom1 "Add0R" $ \t -> (t .+. num 0) === t
61
axAdd0R = mkAxiom1 "Add0R" $ \t -> (t .+. num 0) === t
61
false
false
1
10
19
36
16
20
null
null
brendanhay/gogol
gogol-cloudfunctions/gen/Network/Google/CloudFunctions/Types/Product.hs
mpl-2.0
-- | Output only. The version identifier of the Cloud Function. Each -- deployment attempt results in a new version of a function being created. cfVersionId :: Lens' CloudFunction (Maybe Int64) cfVersionId = lens _cfVersionId (\ s a -> s{_cfVersionId = a}) . mapping _Coerce
282
cfVersionId :: Lens' CloudFunction (Maybe Int64) cfVersionId = lens _cfVersionId (\ s a -> s{_cfVersionId = a}) . mapping _Coerce
137
cfVersionId = lens _cfVersionId (\ s a -> s{_cfVersionId = a}) . mapping _Coerce
88
true
true
0
10
52
56
29
27
null
null
fehu/itesm-ga
src/Parcial2/App.hs
mit
optSelIntactFrac :: Optional1 Float optSelIntactFrac = optional "" ["frac-intact"] ["Fraction of population left intact."] []
187
optSelIntactFrac :: Optional1 Float optSelIntactFrac = optional "" ["frac-intact"] ["Fraction of population left intact."] []
187
optSelIntactFrac = optional "" ["frac-intact"] ["Fraction of population left intact."] []
151
false
true
0
6
76
31
16
15
null
null
bitemyapp/ganeti
src/Ganeti/Constants.hs
bsd-2-clause
hvsParameters :: FrozenSet String hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
98
hvsParameters :: FrozenSet String hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
98
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
64
false
true
1
7
9
28
12
16
null
null
mightymoose/liquidhaskell
benchmarks/bytestring-0.9.2.1/Data/ByteString.T.hs
bsd-3-clause
-- | 'foldr1\'' is a variant of 'foldr1', but is strict in the -- accumulator. {-@ foldr1' :: (Word8 -> Word8 -> Word8) -> ByteStringNE -> Word8 @-} foldr1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 foldr1' f ps | null ps = errorEmptyList "foldr1" | otherwise = foldr' f (last ps) (init ps)
320
foldr1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 foldr1' f ps | null ps = errorEmptyList "foldr1" | otherwise = foldr' f (last ps) (init ps)
171
foldr1' f ps | null ps = errorEmptyList "foldr1" | otherwise = foldr' f (last ps) (init ps)
111
true
true
0
8
76
78
38
40
null
null
HairyDude/heal
EveApi/Types.hs
bsd-2-clause
medSlot MedSlot4 = Just 4
25
medSlot MedSlot4 = Just 4
25
medSlot MedSlot4 = Just 4
25
false
false
1
5
4
16
5
11
null
null
thoughtpolice/binary-serialise-cbor
tests/ReferenceTests.hs
bsd-3-clause
termToJson :: CBOR.Term -> Aeson.Value termToJson (TUInt n) = Aeson.Number (fromIntegral (fromUInt n))
107
termToJson :: CBOR.Term -> Aeson.Value termToJson (TUInt n) = Aeson.Number (fromIntegral (fromUInt n))
107
termToJson (TUInt n) = Aeson.Number (fromIntegral (fromUInt n))
68
false
true
0
9
17
45
22
23
null
null
uuhan/Idris-dev
src/Idris/AbsSyntaxTree.hs
bsd-3-clause
defined (PPostulate _ _ _ _ _ _ n t) = []
54
defined (PPostulate _ _ _ _ _ _ n t) = []
54
defined (PPostulate _ _ _ _ _ _ n t) = []
54
false
false
0
7
24
31
15
16
null
null
pparkkin/eta
compiler/ETA/Rename/RnTypes.hs
bsd-3-clause
extractRdrKindSigVars (Just k) = nub (fst (extract_lkind k ([],[])))
68
extractRdrKindSigVars (Just k) = nub (fst (extract_lkind k ([],[])))
68
extractRdrKindSigVars (Just k) = nub (fst (extract_lkind k ([],[])))
68
false
false
0
11
8
43
21
22
null
null
rsasse/tamarin-prover
lib/theory/src/Theory/Constraint/Solver/Heuristics.hs
gpl-3.0
goalRankingIdentifiers :: M.Map Char GoalRanking goalRankingIdentifiers = M.fromList [ ('s', SmartRanking False) , ('S', SmartRanking True) , ('o', OracleRanking "./oracle") , ('O', OracleSmartRanking "./oracle") , ('p', SapicRanking) , ('l', SapicLivenessRanking) , ('P', SapicPKCS11Ranking) , ('c', UsefulGoalNrRanking) , ('C', GoalNrRanking) , ('i', InjRanking False) , ('I', InjRanking True) ]
685
goalRankingIdentifiers :: M.Map Char GoalRanking goalRankingIdentifiers = M.fromList [ ('s', SmartRanking False) , ('S', SmartRanking True) , ('o', OracleRanking "./oracle") , ('O', OracleSmartRanking "./oracle") , ('p', SapicRanking) , ('l', SapicLivenessRanking) , ('P', SapicPKCS11Ranking) , ('c', UsefulGoalNrRanking) , ('C', GoalNrRanking) , ('i', InjRanking False) , ('I', InjRanking True) ]
685
goalRankingIdentifiers = M.fromList [ ('s', SmartRanking False) , ('S', SmartRanking True) , ('o', OracleRanking "./oracle") , ('O', OracleSmartRanking "./oracle") , ('p', SapicRanking) , ('l', SapicLivenessRanking) , ('P', SapicPKCS11Ranking) , ('c', UsefulGoalNrRanking) , ('C', GoalNrRanking) , ('i', InjRanking False) , ('I', InjRanking True) ]
636
false
true
0
8
335
140
83
57
null
null
fhaust/aer-utils
src/Data/SimpleMat.hs
mit
writeCSVImage :: (Show a, KnownNat w, KnownNat h) => FilePath -> Mat w h a -> IO () writeCSVImage fp m = writeFile fp $ unlines $ map (intercalate "," . map show . toList) $ rows m
182
writeCSVImage :: (Show a, KnownNat w, KnownNat h) => FilePath -> Mat w h a -> IO () writeCSVImage fp m = writeFile fp $ unlines $ map (intercalate "," . map show . toList) $ rows m
182
writeCSVImage fp m = writeFile fp $ unlines $ map (intercalate "," . map show . toList) $ rows m
96
false
true
0
11
39
95
45
50
null
null
ml9951/ghc
compiler/llvmGen/Llvm/PpLlvm.hs
bsd-3-clause
-- | Exclamation point. exclamation :: SDoc exclamation = char '!'
66
exclamation :: SDoc exclamation = char '!'
42
exclamation = char '!'
22
true
true
0
5
10
15
8
7
null
null
robdockins/edison
edison-core/src/Data/Edison/Assoc/TernaryTrie.hs
mit
nullFM (FM Nothing fmb) = nullFMB fmb
37
nullFM (FM Nothing fmb) = nullFMB fmb
37
nullFM (FM Nothing fmb) = nullFMB fmb
37
false
false
0
6
6
21
9
12
null
null
luigy/stack
src/Stack/Build/Source.hs
bsd-3-clause
checkDuplicateNames :: MonadThrow m => [(PackageName, (LocalPackageView, gpd))] -> m () checkDuplicateNames locals = case filter hasMultiples $ Map.toList $ Map.fromListWith (++) $ map toPair locals of [] -> return () x -> throwM $ DuplicateLocalPackageNames x where toPair (pn, (lpv, _)) = (pn, [lpvRoot lpv]) hasMultiples (_, _:_:_) = True hasMultiples _ = False
398
checkDuplicateNames :: MonadThrow m => [(PackageName, (LocalPackageView, gpd))] -> m () checkDuplicateNames locals = case filter hasMultiples $ Map.toList $ Map.fromListWith (++) $ map toPair locals of [] -> return () x -> throwM $ DuplicateLocalPackageNames x where toPair (pn, (lpv, _)) = (pn, [lpvRoot lpv]) hasMultiples (_, _:_:_) = True hasMultiples _ = False
398
checkDuplicateNames locals = case filter hasMultiples $ Map.toList $ Map.fromListWith (++) $ map toPair locals of [] -> return () x -> throwM $ DuplicateLocalPackageNames x where toPair (pn, (lpv, _)) = (pn, [lpvRoot lpv]) hasMultiples (_, _:_:_) = True hasMultiples _ = False
310
false
true
0
9
88
176
89
87
null
null