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
urbanslug/ghc
compiler/typecheck/TcGenGenerics.hs
bsd-3-clause
mkM1_P :: LPat RdrName -> LPat RdrName mkM1_P p = m1DataCon_RDR `nlConPat` [p]
78
mkM1_P :: LPat RdrName -> LPat RdrName mkM1_P p = m1DataCon_RDR `nlConPat` [p]
78
mkM1_P p = m1DataCon_RDR `nlConPat` [p]
39
false
true
0
7
12
40
19
21
null
null
emc2/compiler-misc
src/Data/Position/DWARFPosition.hs
bsd-3-clause
basicPosition TypeDef { typeDefPos = Point { pointPos = pos } } = BasicPosition.Point { BasicPosition.pointPos = pos }
120
basicPosition TypeDef { typeDefPos = Point { pointPos = pos } } = BasicPosition.Point { BasicPosition.pointPos = pos }
120
basicPosition TypeDef { typeDefPos = Point { pointPos = pos } } = BasicPosition.Point { BasicPosition.pointPos = pos }
120
false
false
0
11
20
39
21
18
null
null
maciejpirog/modules
src/Control/Monad/Module/Resumption.hs
mit
hoistMoggiR :: (Functor f, Functor t, Monad m, Monad n) => (forall x. f x -> t x) -> (forall x. m x -> n x) -> MoggiResumption f m a -> MoggiResumption t n a hoistMoggiR g h (MoggiR r) = MoggiR $ hoistResumption h (FM . g . fmap h . unFM) r
246
hoistMoggiR :: (Functor f, Functor t, Monad m, Monad n) => (forall x. f x -> t x) -> (forall x. m x -> n x) -> MoggiResumption f m a -> MoggiResumption t n a hoistMoggiR g h (MoggiR r) = MoggiR $ hoistResumption h (FM . g . fmap h . unFM) r
246
hoistMoggiR g h (MoggiR r) = MoggiR $ hoistResumption h (FM . g . fmap h . unFM) r
84
false
true
0
11
60
142
70
72
null
null
DanielSchuessler/hstri
Blender/Build.hs
gpl-3.0
newMeshObj :: (?sceneE::Python ()) => PythonVar -> Mesh -> Python () newMeshObj var m = do let _meshVar = pyv "decoConeMesh" mesh_init _meshVar m newObj var (meshName m) _meshVar setActiveObject ?sceneE var -- don't know how to determine whether we are in editmode already (seems to be determined at random for new objects...), so try/catch ln "try:" indent $ do normals_make_consistent ln "except RuntimeError:" indent $ do editmode_toggle normals_make_consistent editmode_toggle
605
newMeshObj :: (?sceneE::Python ()) => PythonVar -> Mesh -> Python () newMeshObj var m = do let _meshVar = pyv "decoConeMesh" mesh_init _meshVar m newObj var (meshName m) _meshVar setActiveObject ?sceneE var -- don't know how to determine whether we are in editmode already (seems to be determined at random for new objects...), so try/catch ln "try:" indent $ do normals_make_consistent ln "except RuntimeError:" indent $ do editmode_toggle normals_make_consistent editmode_toggle
605
newMeshObj var m = do let _meshVar = pyv "decoConeMesh" mesh_init _meshVar m newObj var (meshName m) _meshVar setActiveObject ?sceneE var -- don't know how to determine whether we are in editmode already (seems to be determined at random for new objects...), so try/catch ln "try:" indent $ do normals_make_consistent ln "except RuntimeError:" indent $ do editmode_toggle normals_make_consistent editmode_toggle
536
false
true
0
10
194
126
55
71
null
null
haroldcarr/juno
z-no-longer-used/src/Hop/Apps/Juno/Ledger.hs
bsd-3-clause
beneficiaryAcctFreetext :: SWIFT -> Text beneficiaryAcctFreetext s = s ^. sCode59a . bcDetails
94
beneficiaryAcctFreetext :: SWIFT -> Text beneficiaryAcctFreetext s = s ^. sCode59a . bcDetails
94
beneficiaryAcctFreetext s = s ^. sCode59a . bcDetails
53
false
true
0
6
12
26
13
13
null
null
josefs/sbv
Data/SBV/Examples/BitPrecise/PrefixSum.hs
bsd-3-clause
lf (zero, f) pl = zipPL (zipWith f (rsh lfpq) p) lfpq where (p, q) = unzipPL pl pq = zipWith f p q lfpq = lf (zero, f) pq rsh xs = zero : init xs ---------------------------------------------------------------------- -- * Sample proofs for concrete operators ---------------------------------------------------------------------- -- | Correctness theorem, for a powerlist of given size, an associative operator, and its left-unit element.
477
lf (zero, f) pl = zipPL (zipWith f (rsh lfpq) p) lfpq where (p, q) = unzipPL pl pq = zipWith f p q lfpq = lf (zero, f) pq rsh xs = zero : init xs ---------------------------------------------------------------------- -- * Sample proofs for concrete operators ---------------------------------------------------------------------- -- | Correctness theorem, for a powerlist of given size, an associative operator, and its left-unit element.
477
lf (zero, f) pl = zipPL (zipWith f (rsh lfpq) p) lfpq where (p, q) = unzipPL pl pq = zipWith f p q lfpq = lf (zero, f) pq rsh xs = zero : init xs ---------------------------------------------------------------------- -- * Sample proofs for concrete operators ---------------------------------------------------------------------- -- | Correctness theorem, for a powerlist of given size, an associative operator, and its left-unit element.
477
false
false
6
9
101
122
54
68
null
null
ChrisPenner/rasa
rasa-ext-vim/src/Rasa/Ext/Vim.hs
gpl-3.0
normal [Keypress 'r' [],Keypress c []] = delete >> insertText (Y.singleton c)
77
normal [Keypress 'r' [],Keypress c []] = delete >> insertText (Y.singleton c)
77
normal [Keypress 'r' [],Keypress c []] = delete >> insertText (Y.singleton c)
77
false
false
0
9
11
44
21
23
null
null
haroldcarr/learn-haskell-coq-ml-etc
haskell/playpen/hcpn/src/NetEdit.hs
unlicense
addNode 'p' vContext pos = do nId <- newUnique context@Context{vNet=vNet} <- varGet vContext nodeVar <- newMVar $ mkPlace nId "" "()" "" pos varUpdate vNet $ \n->n{places =nodeVar:(places n)} updateHistory vContext ((AddNodePlace nodeVar):) return () -- add an arc between a place and a transition
311
addNode 'p' vContext pos = do nId <- newUnique context@Context{vNet=vNet} <- varGet vContext nodeVar <- newMVar $ mkPlace nId "" "()" "" pos varUpdate vNet $ \n->n{places =nodeVar:(places n)} updateHistory vContext ((AddNodePlace nodeVar):) return () -- add an arc between a place and a transition
311
addNode 'p' vContext pos = do nId <- newUnique context@Context{vNet=vNet} <- varGet vContext nodeVar <- newMVar $ mkPlace nId "" "()" "" pos varUpdate vNet $ \n->n{places =nodeVar:(places n)} updateHistory vContext ((AddNodePlace nodeVar):) return () -- add an arc between a place and a transition
311
false
false
0
13
58
124
60
64
null
null
urbanslug/ghc
compiler/utils/Digraph.hs
bsd-3-clause
findCycle :: forall payload key. Ord key => [Node key payload] -- The nodes. The dependencies can -- contain extra keys, which are ignored -> Maybe [payload] -- A cycle, starting with node -- so each depends on the next findCycle graph = go Set.empty (new_work root_deps []) [] where env :: Map.Map key (Node key payload) env = Map.fromList [ (key, node) | node@(_, key, _) <- graph ] -- Find the node with fewest dependencies among the SCC modules -- This is just a heuristic to find some plausible root module root :: Node key payload root = fst (minWith snd [ (node, count (`Map.member` env) deps) | node@(_,_,deps) <- graph ]) (root_payload,root_key,root_deps) = root -- 'go' implements Dijkstra's algorithm, more or less go :: Set.Set key -- Visited -> [WorkItem key payload] -- Work list, items length n -> [WorkItem key payload] -- Work list, items length n+1 -> Maybe [payload] -- Returned cycle -- Invariant: in a call (go visited ps qs), -- visited = union (map tail (ps ++ qs)) go _ [] [] = Nothing -- No cycles go visited [] qs = go visited qs [] go visited (((payload,key,deps), path) : ps) qs | key == root_key = Just (root_payload : reverse path) | key `Set.member` visited = go visited ps qs | key `Map.notMember` env = go visited ps qs | otherwise = go (Set.insert key visited) ps (new_qs ++ qs) where new_qs = new_work deps (payload : path) new_work :: [key] -> [payload] -> [WorkItem key payload] new_work deps path = [ (n, path) | Just n <- map (`Map.lookup` env) deps ] {- ************************************************************************ * * * Strongly Connected Component wrappers for Graph * * ************************************************************************ Note: the components are returned topologically sorted: later components depend on earlier ones, but not vice versa i.e. later components only have edges going from them to earlier ones. -}
2,425
findCycle :: forall payload key. Ord key => [Node key payload] -- The nodes. The dependencies can -- contain extra keys, which are ignored -> Maybe [payload] findCycle graph = go Set.empty (new_work root_deps []) [] where env :: Map.Map key (Node key payload) env = Map.fromList [ (key, node) | node@(_, key, _) <- graph ] -- Find the node with fewest dependencies among the SCC modules -- This is just a heuristic to find some plausible root module root :: Node key payload root = fst (minWith snd [ (node, count (`Map.member` env) deps) | node@(_,_,deps) <- graph ]) (root_payload,root_key,root_deps) = root -- 'go' implements Dijkstra's algorithm, more or less go :: Set.Set key -- Visited -> [WorkItem key payload] -- Work list, items length n -> [WorkItem key payload] -- Work list, items length n+1 -> Maybe [payload] -- Returned cycle -- Invariant: in a call (go visited ps qs), -- visited = union (map tail (ps ++ qs)) go _ [] [] = Nothing -- No cycles go visited [] qs = go visited qs [] go visited (((payload,key,deps), path) : ps) qs | key == root_key = Just (root_payload : reverse path) | key `Set.member` visited = go visited ps qs | key `Map.notMember` env = go visited ps qs | otherwise = go (Set.insert key visited) ps (new_qs ++ qs) where new_qs = new_work deps (payload : path) new_work :: [key] -> [payload] -> [WorkItem key payload] new_work deps path = [ (n, path) | Just n <- map (`Map.lookup` env) deps ] {- ************************************************************************ * * * Strongly Connected Component wrappers for Graph * * ************************************************************************ Note: the components are returned topologically sorted: later components depend on earlier ones, but not vice versa i.e. later components only have edges going from them to earlier ones. -}
2,320
findCycle graph = go Set.empty (new_work root_deps []) [] where env :: Map.Map key (Node key payload) env = Map.fromList [ (key, node) | node@(_, key, _) <- graph ] -- Find the node with fewest dependencies among the SCC modules -- This is just a heuristic to find some plausible root module root :: Node key payload root = fst (minWith snd [ (node, count (`Map.member` env) deps) | node@(_,_,deps) <- graph ]) (root_payload,root_key,root_deps) = root -- 'go' implements Dijkstra's algorithm, more or less go :: Set.Set key -- Visited -> [WorkItem key payload] -- Work list, items length n -> [WorkItem key payload] -- Work list, items length n+1 -> Maybe [payload] -- Returned cycle -- Invariant: in a call (go visited ps qs), -- visited = union (map tail (ps ++ qs)) go _ [] [] = Nothing -- No cycles go visited [] qs = go visited qs [] go visited (((payload,key,deps), path) : ps) qs | key == root_key = Just (root_payload : reverse path) | key `Set.member` visited = go visited ps qs | key `Map.notMember` env = go visited ps qs | otherwise = go (Set.insert key visited) ps (new_qs ++ qs) where new_qs = new_work deps (payload : path) new_work :: [key] -> [payload] -> [WorkItem key payload] new_work deps path = [ (n, path) | Just n <- map (`Map.lookup` env) deps ] {- ************************************************************************ * * * Strongly Connected Component wrappers for Graph * * ************************************************************************ Note: the components are returned topologically sorted: later components depend on earlier ones, but not vice versa i.e. later components only have edges going from them to earlier ones. -}
2,101
true
true
3
12
853
557
294
263
null
null
chemist/highlighter
src/Text/Highlighter/Lexers/Groff.hs
bsd-3-clause
textline' :: TokenMatcher textline' = [ anyOf escapes' , tok "[^\\\\\\n]+" (Arbitrary "Text") , tokNext "\\n" (Arbitrary "Text") Pop ]
150
textline' :: TokenMatcher textline' = [ anyOf escapes' , tok "[^\\\\\\n]+" (Arbitrary "Text") , tokNext "\\n" (Arbitrary "Text") Pop ]
150
textline' = [ anyOf escapes' , tok "[^\\\\\\n]+" (Arbitrary "Text") , tokNext "\\n" (Arbitrary "Text") Pop ]
124
false
true
0
9
35
54
25
29
null
null
nevrenato/Hets_Fork
Static/ArchDiagram.hs
gpl-2.0
getSigFromDiag :: DiagNodeSig -> NodeSig getSigFromDiag (Diag_node_sig _ ns) = ns
81
getSigFromDiag :: DiagNodeSig -> NodeSig getSigFromDiag (Diag_node_sig _ ns) = ns
81
getSigFromDiag (Diag_node_sig _ ns) = ns
40
false
true
0
7
10
26
13
13
null
null
kvelicka/Fizz
Viewer.hs
lgpl-2.1
volume = (from4 35 G) :> (Volume vis5D)
48
volume = (from4 35 G) :> (Volume vis5D)
48
volume = (from4 35 G) :> (Volume vis5D)
48
false
false
0
7
16
24
12
12
null
null
diku-dk/futhark
src/Futhark/Optimise/Simplify/Rep.hs
isc
mkWiseLetStm :: (ASTRep rep, CanBeWise (Op rep)) => Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp (Wise rep) -> Stm (Wise rep) mkWiseLetStm pat (StmAux cs attrs dec) e = let pat' = addWisdomToPat pat e in Let pat' (StmAux cs attrs $ mkWiseExpDec pat' dec e) e
275
mkWiseLetStm :: (ASTRep rep, CanBeWise (Op rep)) => Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp (Wise rep) -> Stm (Wise rep) mkWiseLetStm pat (StmAux cs attrs dec) e = let pat' = addWisdomToPat pat e in Let pat' (StmAux cs attrs $ mkWiseExpDec pat' dec e) e
275
mkWiseLetStm pat (StmAux cs attrs dec) e = let pat' = addWisdomToPat pat e in Let pat' (StmAux cs attrs $ mkWiseExpDec pat' dec e) e
137
false
true
0
12
63
145
67
78
null
null
jasonzoladz/persistent
persistent/Database/Persist/Sql/Orphan/PersistStore.hs
mit
toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record toSqlKey = fromBackendKey . SqlBackendKey
107
toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record toSqlKey = fromBackendKey . SqlBackendKey
107
toSqlKey = fromBackendKey . SqlBackendKey
41
false
true
0
7
14
31
15
16
null
null
cabrera/hdbc-postgresql
testsrc/Testbasics.hs
bsd-3-clause
tests = TestList [ TestLabel "openClosedb" openClosedb, TestLabel "multiFinish" multiFinish, TestLabel "basicQueries" basicQueries, TestLabel "createTable" createTable, TestLabel "runReplace" runReplace, TestLabel "executeReplace" executeReplace, TestLabel "executeMany" testExecuteMany, TestLabel "fetchAllRows" testFetchAllRows, TestLabel "fetchAllRows'" testFetchAllRows', TestLabel "basicTransactions" basicTransactions, TestLabel "withTransaction" testWithTransaction, TestLabel "dropTable" dropTable ]
632
tests = TestList [ TestLabel "openClosedb" openClosedb, TestLabel "multiFinish" multiFinish, TestLabel "basicQueries" basicQueries, TestLabel "createTable" createTable, TestLabel "runReplace" runReplace, TestLabel "executeReplace" executeReplace, TestLabel "executeMany" testExecuteMany, TestLabel "fetchAllRows" testFetchAllRows, TestLabel "fetchAllRows'" testFetchAllRows', TestLabel "basicTransactions" basicTransactions, TestLabel "withTransaction" testWithTransaction, TestLabel "dropTable" dropTable ]
632
tests = TestList [ TestLabel "openClosedb" openClosedb, TestLabel "multiFinish" multiFinish, TestLabel "basicQueries" basicQueries, TestLabel "createTable" createTable, TestLabel "runReplace" runReplace, TestLabel "executeReplace" executeReplace, TestLabel "executeMany" testExecuteMany, TestLabel "fetchAllRows" testFetchAllRows, TestLabel "fetchAllRows'" testFetchAllRows', TestLabel "basicTransactions" basicTransactions, TestLabel "withTransaction" testWithTransaction, TestLabel "dropTable" dropTable ]
632
false
false
0
7
165
105
52
53
null
null
thoughtpolice/vacuum
src/GHC/Vacuum/Internal.hs
lgpl-3.0
byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7 :: (Integral w, Bits w) => w -> Word8 byte0 w = fromIntegral w
120
byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7 :: (Integral w, Bits w) => w -> Word8 byte0 w = fromIntegral w
120
byte0 w = fromIntegral w
24
false
true
5
6
24
61
32
29
null
null
Oblosys/webviews
src/exec/WebForms/Main.hs
mit
mkTableView :: String -> Bool -> Bool -> Bool -> [[UntypedWebView Database]] -> WebViewM Database (WV TableView) mkTableView classTag border topHeader leftHeader rows = mkWebView $ \vid _ -> do { return $ TableView classTag border topHeader leftHeader rows }
271
mkTableView :: String -> Bool -> Bool -> Bool -> [[UntypedWebView Database]] -> WebViewM Database (WV TableView) mkTableView classTag border topHeader leftHeader rows = mkWebView $ \vid _ -> do { return $ TableView classTag border topHeader leftHeader rows }
271
mkTableView classTag border topHeader leftHeader rows = mkWebView $ \vid _ -> do { return $ TableView classTag border topHeader leftHeader rows }
158
false
true
0
12
52
93
47
46
null
null
mariefarrell/Hets
Temporal/Mu.hs
gpl-2.0
nnfS (Snot (Snot phi )) = nnfS phi
34
nnfS (Snot (Snot phi )) = nnfS phi
34
nnfS (Snot (Snot phi )) = nnfS phi
34
false
false
0
9
7
24
11
13
null
null
fmapfmapfmap/amazonka
amazonka-ses/gen/Network/AWS/SES/ListIdentities.hs
mpl-2.0
-- | Creates a value of 'ListIdentities' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'liIdentityType' -- -- * 'liNextToken' -- -- * 'liMaxItems' listIdentities :: ListIdentities listIdentities = ListIdentities' { _liIdentityType = Nothing , _liNextToken = Nothing , _liMaxItems = Nothing }
402
listIdentities :: ListIdentities listIdentities = ListIdentities' { _liIdentityType = Nothing , _liNextToken = Nothing , _liMaxItems = Nothing }
168
listIdentities = ListIdentities' { _liIdentityType = Nothing , _liNextToken = Nothing , _liMaxItems = Nothing }
131
true
true
0
7
84
50
30
20
null
null
brendanhay/gogol
gogol-dataflow/gen/Network/Google/Resource/Dataflow/Projects/Jobs/GetMetrics.hs
mpl-2.0
-- | OAuth access token. pjgmAccessToken :: Lens' ProjectsJobsGetMetrics (Maybe Text) pjgmAccessToken = lens _pjgmAccessToken (\ s a -> s{_pjgmAccessToken = a})
168
pjgmAccessToken :: Lens' ProjectsJobsGetMetrics (Maybe Text) pjgmAccessToken = lens _pjgmAccessToken (\ s a -> s{_pjgmAccessToken = a})
143
pjgmAccessToken = lens _pjgmAccessToken (\ s a -> s{_pjgmAccessToken = a})
82
true
true
0
8
29
49
25
24
null
null
synsem/texhs
app/texhs.hs
gpl-3.0
parseBib :: FilePath -> IO (Maybe BibDB) parseBib bibfile = do bibinfo <- fromBibTeXFile bibfile bibfile case bibinfo of Left errmsg -> warn "Warning: cannot read bib file." *> warn errmsg *> return Nothing Right db -> return (Just db)
265
parseBib :: FilePath -> IO (Maybe BibDB) parseBib bibfile = do bibinfo <- fromBibTeXFile bibfile bibfile case bibinfo of Left errmsg -> warn "Warning: cannot read bib file." *> warn errmsg *> return Nothing Right db -> return (Just db)
265
parseBib bibfile = do bibinfo <- fromBibTeXFile bibfile bibfile case bibinfo of Left errmsg -> warn "Warning: cannot read bib file." *> warn errmsg *> return Nothing Right db -> return (Just db)
224
false
true
0
13
69
95
41
54
null
null
romanb/amazonka
amazonka-elasticache/gen/Network/AWS/ElastiCache/Types.hs
mpl-2.0
-- | The offering identifier. rcnReservedCacheNodesOfferingId :: Lens' ReservedCacheNode (Maybe Text) rcnReservedCacheNodesOfferingId = lens _rcnReservedCacheNodesOfferingId (\s a -> s { _rcnReservedCacheNodesOfferingId = a })
238
rcnReservedCacheNodesOfferingId :: Lens' ReservedCacheNode (Maybe Text) rcnReservedCacheNodesOfferingId = lens _rcnReservedCacheNodesOfferingId (\s a -> s { _rcnReservedCacheNodesOfferingId = a })
208
rcnReservedCacheNodesOfferingId = lens _rcnReservedCacheNodesOfferingId (\s a -> s { _rcnReservedCacheNodesOfferingId = a })
136
true
true
0
8
35
47
25
22
null
null
yav/haskell-lexer
generator/src/Spec/HaskellLexicalSyntax.hs
mit
-- aa = a . acs
15
aa = a . acs
12
aa = a . acs
12
true
false
2
5
5
16
6
10
null
null
paulbarbu/ePseudocode
src/EPseudocode/Evaluator.hs
bsd-3-clause
evalBinExpr _ (BinExpr Or (Float _) (Int _)) = throwError "Or is invalid on Float and Int"
90
evalBinExpr _ (BinExpr Or (Float _) (Int _)) = throwError "Or is invalid on Float and Int"
90
evalBinExpr _ (BinExpr Or (Float _) (Int _)) = throwError "Or is invalid on Float and Int"
90
false
false
0
9
16
36
17
19
null
null
ancientlanguage/haskell-analysis
prepare/src/Prepare/Decompose.hs
mit
decomposeChar '\x0450' = "\x0435\x0300"
39
decomposeChar '\x0450' = "\x0435\x0300"
39
decomposeChar '\x0450' = "\x0435\x0300"
39
false
false
1
5
3
13
4
9
null
null
pparkkin/eta
compiler/ETA/Prelude/PrimOp.hs
bsd-3-clause
tagOf_PrimOp IndexByteArrayOp_Word16 = _ILIT(194)
49
tagOf_PrimOp IndexByteArrayOp_Word16 = _ILIT(194)
49
tagOf_PrimOp IndexByteArrayOp_Word16 = _ILIT(194)
49
false
false
0
6
3
15
7
8
null
null
vdweegen/UvA-Software_Testing
Lab5/Final/Lecture5'.hs
gpl-3.0
prune :: (Row,Column,Value) -> [Constraint] -> [Constraint] prune _ [] = []
75
prune :: (Row,Column,Value) -> [Constraint] -> [Constraint] prune _ [] = []
75
prune _ [] = []
15
false
true
0
9
11
49
25
24
null
null
spechub/Hets
CSL/Keywords.hs
gpl-2.0
whenS :: String whenS = "when"
30
whenS :: String whenS = "when"
30
whenS = "when"
14
false
true
0
6
5
18
7
11
null
null
jfischoff/LambdaPrettyQuote
src/Language/Lambda/SimplyTyped/Arbitrary.hs
bsd-3-clause
uniq_sym :: (Eq a, Eq s) => EnvGen a s c s uniq_sym = do s_gen <- asks sel2 env <- get_env lift $ suchThat s_gen ( `notElem` (map fst env))
151
uniq_sym :: (Eq a, Eq s) => EnvGen a s c s uniq_sym = do s_gen <- asks sel2 env <- get_env lift $ suchThat s_gen ( `notElem` (map fst env))
151
uniq_sym = do s_gen <- asks sel2 env <- get_env lift $ suchThat s_gen ( `notElem` (map fst env))
108
false
true
0
11
42
78
39
39
null
null
keera-studios/hsQt
Qtc/Enums/Gui/QImage.hs
bsd-2-clause
eQImageFormat_ARGB8555_Premultiplied :: QImageFormat eQImageFormat_ARGB8555_Premultiplied = ieQImageFormat $ 12
113
eQImageFormat_ARGB8555_Premultiplied :: QImageFormat eQImageFormat_ARGB8555_Premultiplied = ieQImageFormat $ 12
113
eQImageFormat_ARGB8555_Premultiplied = ieQImageFormat $ 12
60
false
true
0
6
9
18
8
10
null
null
brendanhay/gogol
gogol-sqladmin/gen/Network/Google/Resource/SQL/SSLCerts/CreateEphemeral.hs
mpl-2.0
-- | Upload protocol for media (e.g. \"raw\", \"multipart\"). scceUploadProtocol :: Lens' SSLCertsCreateEphemeral (Maybe Text) scceUploadProtocol = lens _scceUploadProtocol (\ s a -> s{_scceUploadProtocol = a})
218
scceUploadProtocol :: Lens' SSLCertsCreateEphemeral (Maybe Text) scceUploadProtocol = lens _scceUploadProtocol (\ s a -> s{_scceUploadProtocol = a})
156
scceUploadProtocol = lens _scceUploadProtocol (\ s a -> s{_scceUploadProtocol = a})
91
true
true
1
9
33
51
25
26
null
null
acowley/language-c
src/Language/C/Analysis/Export.hs
bsd-3-clause
exportMemberDecl (MemberDecl vardecl bitfieldsz node_info) = let (specs,declarator) = exportVarDecl vardecl in CDecl specs [(Just declarator, Nothing, bitfieldsz)] node_info
182
exportMemberDecl (MemberDecl vardecl bitfieldsz node_info) = let (specs,declarator) = exportVarDecl vardecl in CDecl specs [(Just declarator, Nothing, bitfieldsz)] node_info
182
exportMemberDecl (MemberDecl vardecl bitfieldsz node_info) = let (specs,declarator) = exportVarDecl vardecl in CDecl specs [(Just declarator, Nothing, bitfieldsz)] node_info
182
false
false
0
9
27
65
31
34
null
null
urbanslug/ghc
testsuite/tests/typecheck/should_compile/T10195.hs
bsd-3-clause
getDict :: a -> Dict (Num a) getDict _ = undefined
50
getDict :: a -> Dict (Num a) getDict _ = undefined
50
getDict _ = undefined
21
false
true
0
8
10
27
13
14
null
null
Persi/shellcheck
ShellCheck/Analytics.hs
gpl-3.0
prop_checkSetAssignment1 = verify checkSetAssignment "set foo 42"
65
prop_checkSetAssignment1 = verify checkSetAssignment "set foo 42"
65
prop_checkSetAssignment1 = verify checkSetAssignment "set foo 42"
65
false
false
0
5
6
11
5
6
null
null
thielema/accelerate-fft
Data/Array/Accelerate/Math/FFT.hs
bsd-3-clause
fftDITLoop :: forall sh e. (Slice sh, Shape sh, IsFloating e, Elt e) => Exp e -> Acc (Array (sh:.Int) (Complex e)) -> Acc (Array (sh:.Int) (Complex e)) fftDITLoop sign = flip A.slice (A.lift $ A.Any :. (0::Int) :. A.All) . A.awhile (\x -> A.unit $ (A.indexHead $ A.indexTail $ A.shape x) >* 1) (ditStep sign) . A.awhile (\x -> A.unit $ (A.indexHead $ A.shape x) >* 1) twist . A.replicate (A.lift $ A.Any :. (1::Int) :. A.All)
482
fftDITLoop :: forall sh e. (Slice sh, Shape sh, IsFloating e, Elt e) => Exp e -> Acc (Array (sh:.Int) (Complex e)) -> Acc (Array (sh:.Int) (Complex e)) fftDITLoop sign = flip A.slice (A.lift $ A.Any :. (0::Int) :. A.All) . A.awhile (\x -> A.unit $ (A.indexHead $ A.indexTail $ A.shape x) >* 1) (ditStep sign) . A.awhile (\x -> A.unit $ (A.indexHead $ A.shape x) >* 1) twist . A.replicate (A.lift $ A.Any :. (1::Int) :. A.All)
482
fftDITLoop sign = flip A.slice (A.lift $ A.Any :. (0::Int) :. A.All) . A.awhile (\x -> A.unit $ (A.indexHead $ A.indexTail $ A.shape x) >* 1) (ditStep sign) . A.awhile (\x -> A.unit $ (A.indexHead $ A.shape x) >* 1) twist . A.replicate (A.lift $ A.Any :. (1::Int) :. A.All)
318
false
true
3
14
134
281
141
140
null
null
NightRa/Idris-dev
src/Idris/AbsSyntaxTree.hs
bsd-3-clause
mapPTermFC f g (PType fc) = PType (f fc)
40
mapPTermFC f g (PType fc) = PType (f fc)
40
mapPTermFC f g (PType fc) = PType (f fc)
40
false
false
0
7
8
28
13
15
null
null
beni55/ghcjs
src/Compiler/Program.hs
mit
mkPreStartupMode :: PreStartupMode -> Mode mkPreStartupMode = Left
66
mkPreStartupMode :: PreStartupMode -> Mode mkPreStartupMode = Left
66
mkPreStartupMode = Left
23
false
true
0
5
7
15
8
7
null
null
twittner/redis-resp
src/Data/Redis/Resp.hs
mpl-2.0
nullBulk = byteString "$-1\r\n"
32
nullBulk = byteString "$-1\r\n"
32
nullBulk = byteString "$-1\r\n"
32
false
false
0
5
4
9
4
5
null
null
jbaum98/graphics
bench/Bench.hs
bsd-3-clause
benchPure :: NFData a => (Point -> a) -> Coord -> Benchmark benchPure f size = bench (showPair point) . nf f $ point where point = pure size
156
benchPure :: NFData a => (Point -> a) -> Coord -> Benchmark benchPure f size = bench (showPair point) . nf f $ point where point = pure size
156
benchPure f size = bench (showPair point) . nf f $ point where point = pure size
86
false
true
1
9
44
78
34
44
null
null
BlackBrane/ansigraph
src/System/Console/Ansigraph/Examples.hs
mit
-- | Display an animation of the complex wave /z(x,t) = exp(ix - it)/ in some units. waveDemoComplex :: IO () waveDemoComplex = animate waves
141
waveDemoComplex :: IO () waveDemoComplex = animate waves
56
waveDemoComplex = animate waves
31
true
true
0
6
24
20
10
10
null
null
ademinn/JavaWithClasses
src/Checker.hs
bsd-3-clause
checkUnaryOp :: Expression -> CheckerError MethodType checkUnaryOp e = do et <- checkReturnExpression e checkNumericType et
131
checkUnaryOp :: Expression -> CheckerError MethodType checkUnaryOp e = do et <- checkReturnExpression e checkNumericType et
131
checkUnaryOp e = do et <- checkReturnExpression e checkNumericType et
77
false
true
0
8
23
37
16
21
null
null
mzini/TcT
source/Tct/Utils/Ask.hs
gpl-3.0
completeFromList :: MonadException m => [String] -> String -> m [Completion] completeFromList lst str = return [simpleCompletion s | s <- lst, str `isPrefixOf` s]
162
completeFromList :: MonadException m => [String] -> String -> m [Completion] completeFromList lst str = return [simpleCompletion s | s <- lst, str `isPrefixOf` s]
162
completeFromList lst str = return [simpleCompletion s | s <- lst, str `isPrefixOf` s]
85
false
true
0
9
24
67
34
33
null
null
dgvncsz0f/sssfs
src/SSSFS/Storage/RedisStorage.hs
gpl-3.0
expectOk :: Reply () -> () expectOk ROk = ()
44
expectOk :: Reply () -> () expectOk ROk = ()
44
expectOk ROk = ()
17
false
true
0
8
9
33
14
19
null
null
brendanhay/gogol
gogol-cloudfunctions/gen/Network/Google/CloudFunctions/Types/Product.hs
mpl-2.0
-- | The friendly name for this location, typically a nearby city name. For -- example, \"Tokyo\". lDisplayName :: Lens' Location (Maybe Text) lDisplayName = lens _lDisplayName (\ s a -> s{_lDisplayName = a})
210
lDisplayName :: Lens' Location (Maybe Text) lDisplayName = lens _lDisplayName (\ s a -> s{_lDisplayName = a})
111
lDisplayName = lens _lDisplayName (\ s a -> s{_lDisplayName = a})
67
true
true
0
9
35
49
26
23
null
null
nau/lasca-compiler
src/lib/Lasca/Codegen.hs
bsd-3-clause
constInt32 i = C.Int 32 (toInteger i)
37
constInt32 i = C.Int 32 (toInteger i)
37
constInt32 i = C.Int 32 (toInteger i)
37
false
false
0
7
6
22
10
12
null
null
dsaenztagarro/haskellbook
src/chapter8/Exercises.hs
bsd-3-clause
multiply :: (Integral a) => a -> a -> a multiply x y = go x y 0 where go _ 0 memo = memo go x' y' memo = go x' (y' - 1) (memo + x')
141
multiply :: (Integral a) => a -> a -> a multiply x y = go x y 0 where go _ 0 memo = memo go x' y' memo = go x' (y' - 1) (memo + x')
141
multiply x y = go x y 0 where go _ 0 memo = memo go x' y' memo = go x' (y' - 1) (memo + x')
101
false
true
0
7
47
92
45
47
null
null
dahlia/nirum
src/Nirum/Targets/Docs.hs
gpl-3.0
showKind :: TD.TypeDeclaration -> T.Text showKind TD.ServiceDeclaration {} = "service"
86
showKind :: TD.TypeDeclaration -> T.Text showKind TD.ServiceDeclaration {} = "service"
86
showKind TD.ServiceDeclaration {} = "service"
45
false
true
0
7
9
28
14
14
null
null
vios-fish/CompetitiveProgramming
ProjectEuler/problem001.hs
mit
answer = let n = 1000-1 in sum $ union [3,3*2 .. n] [5,5*2 .. n]
64
answer = let n = 1000-1 in sum $ union [3,3*2 .. n] [5,5*2 .. n]
64
answer = let n = 1000-1 in sum $ union [3,3*2 .. n] [5,5*2 .. n]
64
false
false
1
10
15
59
30
29
null
null
ward/halendar
src/Main.hs
gpl-3.0
handleCalendarMonth :: Integer -> Int -> Handler App (AuthManager App) () handleCalendarMonth year month = do let start = UTCTime (fromGregorian year month 1) 0 let end = UTCTime (fromGregorian year month (gregorianMonthLength year month)) 86401 let (prevyear, prevmonth, _) = toGregorian . addGregorianMonthsClip (-1) $ fromGregorian year month 1 let (nextyear, nextmonth, _) = toGregorian . addGregorianMonthsClip 1 $ fromGregorian year month 1 events <- withTop db $ getEventsForRange start end renderWithSplices "calendar/month" $ do "events" ## renderEvents events "year" ## toTextSplice year "month" ## toTextSplice month "prevyear" ## toTextSplice prevyear "prevmonth" ## toTextSplice prevmonth "nextyear" ## toTextSplice nextyear "nextmonth" ## toTextSplice nextmonth
869
handleCalendarMonth :: Integer -> Int -> Handler App (AuthManager App) () handleCalendarMonth year month = do let start = UTCTime (fromGregorian year month 1) 0 let end = UTCTime (fromGregorian year month (gregorianMonthLength year month)) 86401 let (prevyear, prevmonth, _) = toGregorian . addGregorianMonthsClip (-1) $ fromGregorian year month 1 let (nextyear, nextmonth, _) = toGregorian . addGregorianMonthsClip 1 $ fromGregorian year month 1 events <- withTop db $ getEventsForRange start end renderWithSplices "calendar/month" $ do "events" ## renderEvents events "year" ## toTextSplice year "month" ## toTextSplice month "prevyear" ## toTextSplice prevyear "prevmonth" ## toTextSplice prevmonth "nextyear" ## toTextSplice nextyear "nextmonth" ## toTextSplice nextmonth
869
handleCalendarMonth year month = do let start = UTCTime (fromGregorian year month 1) 0 let end = UTCTime (fromGregorian year month (gregorianMonthLength year month)) 86401 let (prevyear, prevmonth, _) = toGregorian . addGregorianMonthsClip (-1) $ fromGregorian year month 1 let (nextyear, nextmonth, _) = toGregorian . addGregorianMonthsClip 1 $ fromGregorian year month 1 events <- withTop db $ getEventsForRange start end renderWithSplices "calendar/month" $ do "events" ## renderEvents events "year" ## toTextSplice year "month" ## toTextSplice month "prevyear" ## toTextSplice prevyear "prevmonth" ## toTextSplice prevmonth "nextyear" ## toTextSplice nextyear "nextmonth" ## toTextSplice nextmonth
795
false
true
0
14
197
278
125
153
null
null
Cadynum/tremulous-query
Network/Tremulous/Protocol.hs
gpl-3.0
parsePlayers (Just p) xs = zipWithM parsePlayer (parseP p ++ repeat Unknown) xs
79
parsePlayers (Just p) xs = zipWithM parsePlayer (parseP p ++ repeat Unknown) xs
79
parsePlayers (Just p) xs = zipWithM parsePlayer (parseP p ++ repeat Unknown) xs
79
false
false
0
8
12
38
17
21
null
null
leptonyu/mint
corn/src/Base/Import.hs
bsd-3-clause
_hex = ['0'..'9'] <> ['a'..'f']
31
_hex = ['0'..'9'] <> ['a'..'f']
31
_hex = ['0'..'9'] <> ['a'..'f']
31
false
false
3
6
4
25
11
14
null
null
nh2/haskell-socket-sctp
tests/SendReceiveMessage.hs
mit
main :: IO () main = do server <- socket `onException` p 0 :: IO (Socket Inet SequentialPacket SCTP) client <- socket `onException` p 1 :: IO (Socket Inet SequentialPacket SCTP) bind server addr `onException` p 3 listen server 5 `onException` p 4 connect client addr `onException` p 5 setSocketOption server (mempty { dataIOEvent = True }) `onException` p 6 SCTP.sendMessage client "hallo" addr ( 2342 :: PayloadProtocolIdentifier ) ( mempty :: MessageFlags ) ( 2 :: StreamNumber ) ( 3 :: TimeToLive ) ( 4 :: Context ) `onException` p 7 (msg, adr, sinfo, flags) <- SCTP.receiveMessage server 4096 mempty `onException` p 8 when (sinfoPayloadProtocolIdentifier sinfo /= 2342) (e 9) when (sinfoStreamNumber sinfo /= 2) (e 10) when (msg /= "hallo") (e 11) when (flags /= msgEndOfRecord) (e 12)
1,001
main :: IO () main = do server <- socket `onException` p 0 :: IO (Socket Inet SequentialPacket SCTP) client <- socket `onException` p 1 :: IO (Socket Inet SequentialPacket SCTP) bind server addr `onException` p 3 listen server 5 `onException` p 4 connect client addr `onException` p 5 setSocketOption server (mempty { dataIOEvent = True }) `onException` p 6 SCTP.sendMessage client "hallo" addr ( 2342 :: PayloadProtocolIdentifier ) ( mempty :: MessageFlags ) ( 2 :: StreamNumber ) ( 3 :: TimeToLive ) ( 4 :: Context ) `onException` p 7 (msg, adr, sinfo, flags) <- SCTP.receiveMessage server 4096 mempty `onException` p 8 when (sinfoPayloadProtocolIdentifier sinfo /= 2342) (e 9) when (sinfoStreamNumber sinfo /= 2) (e 10) when (msg /= "hallo") (e 11) when (flags /= msgEndOfRecord) (e 12)
1,001
main = do server <- socket `onException` p 0 :: IO (Socket Inet SequentialPacket SCTP) client <- socket `onException` p 1 :: IO (Socket Inet SequentialPacket SCTP) bind server addr `onException` p 3 listen server 5 `onException` p 4 connect client addr `onException` p 5 setSocketOption server (mempty { dataIOEvent = True }) `onException` p 6 SCTP.sendMessage client "hallo" addr ( 2342 :: PayloadProtocolIdentifier ) ( mempty :: MessageFlags ) ( 2 :: StreamNumber ) ( 3 :: TimeToLive ) ( 4 :: Context ) `onException` p 7 (msg, adr, sinfo, flags) <- SCTP.receiveMessage server 4096 mempty `onException` p 8 when (sinfoPayloadProtocolIdentifier sinfo /= 2342) (e 9) when (sinfoStreamNumber sinfo /= 2) (e 10) when (msg /= "hallo") (e 11) when (flags /= msgEndOfRecord) (e 12)
987
false
true
0
12
341
353
177
176
null
null
Soostone/uri-bytestring
src/URI/ByteString/Internal.hs
bsd-3-clause
removeDotSegments :: ByteString -> ByteString removeDotSegments path = mconcat (rl2L (go path (RL []))) where go inBuf outBuf -- A. If the input buffer begins with prefix of ../ or ./ then -- remove the prefix from the input buffer | BS8.isPrefixOf "../" inBuf = go (BS8.drop 3 inBuf) outBuf | BS8.isPrefixOf "./" inBuf = go (BS8.drop 2 inBuf) outBuf -- B. If the input buffer begins with a prefix of "/./" or "/.", -- where "." is a complete path segment, then replace that -- prefix with "/" in the input buffer. TODO: I think "a -- complete path segment" means its the whole thing? | BS.isPrefixOf "/./" inBuf = go (BS8.drop 2 inBuf) outBuf | inBuf == "/." = go "/" outBuf -- C. If the input buffer begins with a prefix of "/../" or -- "/..", where ".." is a complete path segment, then replace -- that prefix with "/" in the input buffer and remove the last -- segment and its preceding "/" (if any) from the output buffer | BS.isPrefixOf "/../" inBuf = go (BS8.drop 3 inBuf) (unsnoc (unsnoc outBuf)) | inBuf == "/.." = go "/" (unsnoc (unsnoc outBuf)) -- D. If the input buffer consists only of "." or "..", then -- remove that from the input buffer | inBuf == "." = go mempty outBuf | inBuf == ".." = go mempty outBuf -- E. Move the first path segment in the input buffer to the end -- of the output buffer, including the initial "/" character (if -- any) and any subsequent characters up to, but not including, -- the next "/" character or the end of the input buffer. | otherwise = case BS8.uncons inBuf of Just ('/', rest) -> let (thisSeg, inBuf') = BS8.span (/= '/') rest in go inBuf' (outBuf |> "/" |> thisSeg) Just (_, _) -> let (thisSeg, inBuf') = BS8.span (/= '/') inBuf in go inBuf' (outBuf |> thisSeg) Nothing -> outBuf ------------------------------------------------------------------------------- -- | Like 'serializeURI', with conversion into a strict 'ByteString'.
2,206
removeDotSegments :: ByteString -> ByteString removeDotSegments path = mconcat (rl2L (go path (RL []))) where go inBuf outBuf -- A. If the input buffer begins with prefix of ../ or ./ then -- remove the prefix from the input buffer | BS8.isPrefixOf "../" inBuf = go (BS8.drop 3 inBuf) outBuf | BS8.isPrefixOf "./" inBuf = go (BS8.drop 2 inBuf) outBuf -- B. If the input buffer begins with a prefix of "/./" or "/.", -- where "." is a complete path segment, then replace that -- prefix with "/" in the input buffer. TODO: I think "a -- complete path segment" means its the whole thing? | BS.isPrefixOf "/./" inBuf = go (BS8.drop 2 inBuf) outBuf | inBuf == "/." = go "/" outBuf -- C. If the input buffer begins with a prefix of "/../" or -- "/..", where ".." is a complete path segment, then replace -- that prefix with "/" in the input buffer and remove the last -- segment and its preceding "/" (if any) from the output buffer | BS.isPrefixOf "/../" inBuf = go (BS8.drop 3 inBuf) (unsnoc (unsnoc outBuf)) | inBuf == "/.." = go "/" (unsnoc (unsnoc outBuf)) -- D. If the input buffer consists only of "." or "..", then -- remove that from the input buffer | inBuf == "." = go mempty outBuf | inBuf == ".." = go mempty outBuf -- E. Move the first path segment in the input buffer to the end -- of the output buffer, including the initial "/" character (if -- any) and any subsequent characters up to, but not including, -- the next "/" character or the end of the input buffer. | otherwise = case BS8.uncons inBuf of Just ('/', rest) -> let (thisSeg, inBuf') = BS8.span (/= '/') rest in go inBuf' (outBuf |> "/" |> thisSeg) Just (_, _) -> let (thisSeg, inBuf') = BS8.span (/= '/') inBuf in go inBuf' (outBuf |> thisSeg) Nothing -> outBuf ------------------------------------------------------------------------------- -- | Like 'serializeURI', with conversion into a strict 'ByteString'.
2,206
removeDotSegments path = mconcat (rl2L (go path (RL []))) where go inBuf outBuf -- A. If the input buffer begins with prefix of ../ or ./ then -- remove the prefix from the input buffer | BS8.isPrefixOf "../" inBuf = go (BS8.drop 3 inBuf) outBuf | BS8.isPrefixOf "./" inBuf = go (BS8.drop 2 inBuf) outBuf -- B. If the input buffer begins with a prefix of "/./" or "/.", -- where "." is a complete path segment, then replace that -- prefix with "/" in the input buffer. TODO: I think "a -- complete path segment" means its the whole thing? | BS.isPrefixOf "/./" inBuf = go (BS8.drop 2 inBuf) outBuf | inBuf == "/." = go "/" outBuf -- C. If the input buffer begins with a prefix of "/../" or -- "/..", where ".." is a complete path segment, then replace -- that prefix with "/" in the input buffer and remove the last -- segment and its preceding "/" (if any) from the output buffer | BS.isPrefixOf "/../" inBuf = go (BS8.drop 3 inBuf) (unsnoc (unsnoc outBuf)) | inBuf == "/.." = go "/" (unsnoc (unsnoc outBuf)) -- D. If the input buffer consists only of "." or "..", then -- remove that from the input buffer | inBuf == "." = go mempty outBuf | inBuf == ".." = go mempty outBuf -- E. Move the first path segment in the input buffer to the end -- of the output buffer, including the initial "/" character (if -- any) and any subsequent characters up to, but not including, -- the next "/" character or the end of the input buffer. | otherwise = case BS8.uncons inBuf of Just ('/', rest) -> let (thisSeg, inBuf') = BS8.span (/= '/') rest in go inBuf' (outBuf |> "/" |> thisSeg) Just (_, _) -> let (thisSeg, inBuf') = BS8.span (/= '/') inBuf in go inBuf' (outBuf |> thisSeg) Nothing -> outBuf ------------------------------------------------------------------------------- -- | Like 'serializeURI', with conversion into a strict 'ByteString'.
2,160
false
true
0
14
659
430
214
216
null
null
narumij/matrix-as-xyz
src/Data/Matrix/AsXYZ/ParseXYZ.hs
bsd-3-clause
-- | Jones-Faithful notation parser -- -- >>> parse (equivalentPositions integral) "" "x+1,y+2,z+3" -- Right [[1,0,0,1],[0,1,0,2],[0,0,1,3]] equivalentPositions :: Num a =>               ReadNum a -- ^ ratio or floating or integral              -> CharParser () [[a]] equivalentPositions = components xyz
304
equivalentPositions :: Num a =>               ReadNum a -- ^ ratio or floating or integral              -> CharParser () [[a]] equivalentPositions = components xyz
163
equivalentPositions :: Num a =>               ReadNum a -- ^ ratio or floating or integral              -> CharParser () [[a]] equivalentPositions = components xyz
163
true
false
0
10
64
48
25
23
null
null
geophf/1HaskellADay
exercises/HAD/Y2017/M11/D01/Exercise.hs
mit
{-- Once you've done that, scan the repository here for special characters. Are there any diffs? What are they? If there are new special characters you've encountered, add them to the memoizing table (hint: triageMT) n.b.: since we are not 'mapping back' from ASCII to the special characters, the readIndex table in the MemoizingTable can be ignored. --} repository :: FilePath repository = "Y2017/M11/D01/NYTOnline_08-29-17_09-05-17_pt3a.txt.gz"
450
repository :: FilePath repository = "Y2017/M11/D01/NYTOnline_08-29-17_09-05-17_pt3a.txt.gz"
91
repository = "Y2017/M11/D01/NYTOnline_08-29-17_09-05-17_pt3a.txt.gz"
68
true
true
0
4
67
12
7
5
null
null
jamesdarcy/DicomH
src/Data/Dicom/Jpeg2000.hs
bsd-3-clause
-- ROI present flag j2K_RSIZ_ROI :: Word16 j2K_RSIZ_ROI = 0x0002
64
j2K_RSIZ_ROI :: Word16 j2K_RSIZ_ROI = 0x0002
44
j2K_RSIZ_ROI = 0x0002
21
true
true
0
4
9
12
7
5
null
null
herngyi/hmol
Geometry.hs
gpl-3.0
convexHull [hp1,hp2] = ConvexHull [hp1,hp2] [(hp1,hp2)] []
58
convexHull [hp1,hp2] = ConvexHull [hp1,hp2] [(hp1,hp2)] []
58
convexHull [hp1,hp2] = ConvexHull [hp1,hp2] [(hp1,hp2)] []
58
false
false
0
7
6
40
22
18
null
null
sdiehl/ghc
compiler/GHC/StgToCmm/Monad.hs
bsd-3-clause
emitProcWithStackFrame conv mb_info lbl stk_args args (graph, tscope) True -- do layout = do { dflags <- getDynFlags ; let (offset, live, entry) = mkCallEntry dflags conv args stk_args graph' = entry CmmGraph.<*> graph ; emitProc mb_info lbl live (graph', tscope) offset True }
326
emitProcWithStackFrame conv mb_info lbl stk_args args (graph, tscope) True -- do layout = do { dflags <- getDynFlags ; let (offset, live, entry) = mkCallEntry dflags conv args stk_args graph' = entry CmmGraph.<*> graph ; emitProc mb_info lbl live (graph', tscope) offset True }
326
emitProcWithStackFrame conv mb_info lbl stk_args args (graph, tscope) True -- do layout = do { dflags <- getDynFlags ; let (offset, live, entry) = mkCallEntry dflags conv args stk_args graph' = entry CmmGraph.<*> graph ; emitProc mb_info lbl live (graph', tscope) offset True }
326
false
false
0
10
92
100
53
47
null
null
netogallo/MoCap
Data/MotionCapture/AMC/ASFExporter.hs
bsd-3-clause
writeBoneDataSections :: Handle -> AsfFile -> IO () writeBoneDataSections h asf = do hPutStrLn h ":bonedata" mapM_ writeBoneDataSection $ boneDataSections asf where writeBoneDataSection x = do hPutStrLn h "begin" hPutStr h "id " hPutStrLn h $ show $ boneId x hPutStr h "name " hPutStrLn h $ boneName x hPutStr h "direction " hPutStrLn h $ show3DCoord $ boneDirection x hPutStr h "length " hPrintf h "%f\n" $ boneLength x hPutStr h "axis " hPutStrLn h $ show3DCoord (fst $ boneAxis x) ++ " " ++ showAxis (snd $ boneAxis x) writeDof $ boneDof x writeLimits $ boneLimits x hPutStrLn h "end" where writeDof (Just xs) = do hPutStr h "dof " hPutStrLn h $ concat . intersperse " " . map ((map toLower) . show) $ xs writeDof Nothing = return () writeLimits (Just xs) = do hPutStr h "limits " hPutStrLn h $ concat . intersperse " " . map ((\x -> "(" ++ x ++ ")") . show2DCoord) $ xs writeLimits Nothing = return ()
1,158
writeBoneDataSections :: Handle -> AsfFile -> IO () writeBoneDataSections h asf = do hPutStrLn h ":bonedata" mapM_ writeBoneDataSection $ boneDataSections asf where writeBoneDataSection x = do hPutStrLn h "begin" hPutStr h "id " hPutStrLn h $ show $ boneId x hPutStr h "name " hPutStrLn h $ boneName x hPutStr h "direction " hPutStrLn h $ show3DCoord $ boneDirection x hPutStr h "length " hPrintf h "%f\n" $ boneLength x hPutStr h "axis " hPutStrLn h $ show3DCoord (fst $ boneAxis x) ++ " " ++ showAxis (snd $ boneAxis x) writeDof $ boneDof x writeLimits $ boneLimits x hPutStrLn h "end" where writeDof (Just xs) = do hPutStr h "dof " hPutStrLn h $ concat . intersperse " " . map ((map toLower) . show) $ xs writeDof Nothing = return () writeLimits (Just xs) = do hPutStr h "limits " hPutStrLn h $ concat . intersperse " " . map ((\x -> "(" ++ x ++ ")") . show2DCoord) $ xs writeLimits Nothing = return ()
1,158
writeBoneDataSections h asf = do hPutStrLn h ":bonedata" mapM_ writeBoneDataSection $ boneDataSections asf where writeBoneDataSection x = do hPutStrLn h "begin" hPutStr h "id " hPutStrLn h $ show $ boneId x hPutStr h "name " hPutStrLn h $ boneName x hPutStr h "direction " hPutStrLn h $ show3DCoord $ boneDirection x hPutStr h "length " hPrintf h "%f\n" $ boneLength x hPutStr h "axis " hPutStrLn h $ show3DCoord (fst $ boneAxis x) ++ " " ++ showAxis (snd $ boneAxis x) writeDof $ boneDof x writeLimits $ boneLimits x hPutStrLn h "end" where writeDof (Just xs) = do hPutStr h "dof " hPutStrLn h $ concat . intersperse " " . map ((map toLower) . show) $ xs writeDof Nothing = return () writeLimits (Just xs) = do hPutStr h "limits " hPutStrLn h $ concat . intersperse " " . map ((\x -> "(" ++ x ++ ")") . show2DCoord) $ xs writeLimits Nothing = return ()
1,106
false
true
0
17
420
406
178
228
null
null
rfranek/duckling
Duckling/Time/RO/Rules.hs
bsd-3-clause
ruleDurationDeAcum :: Rule ruleDurationDeAcum = Rule { name = "<duration> de acum" , pattern = [ dimension Duration , regex "de (acum|azi)" ] , prod = \tokens -> case tokens of (Token Duration dd:_) -> tt $ inDuration dd _ -> Nothing }
267
ruleDurationDeAcum :: Rule ruleDurationDeAcum = Rule { name = "<duration> de acum" , pattern = [ dimension Duration , regex "de (acum|azi)" ] , prod = \tokens -> case tokens of (Token Duration dd:_) -> tt $ inDuration dd _ -> Nothing }
267
ruleDurationDeAcum = Rule { name = "<duration> de acum" , pattern = [ dimension Duration , regex "de (acum|azi)" ] , prod = \tokens -> case tokens of (Token Duration dd:_) -> tt $ inDuration dd _ -> Nothing }
240
false
true
0
14
74
87
46
41
null
null
forsyde/forsyde-shallow
src/ForSyDe/Shallow/MoC/Untimed.hs
bsd-3-clause
zipWithU _ _ _ _ NullS = NullS
34
zipWithU _ _ _ _ NullS = NullS
34
zipWithU _ _ _ _ NullS = NullS
34
false
false
0
5
11
17
8
9
null
null
zudov/purescript-inspection
src/Inspection/API/Types.hs
bsd-3-clause
toServantErr :: AppError -> ServantErr toServantErr err = ServantErr { errHTTPCode = toHTTPCode err , errReasonPhrase = show err , errBody = encode $ object [ "error" .= err ] , errHeaders = [] }
217
toServantErr :: AppError -> ServantErr toServantErr err = ServantErr { errHTTPCode = toHTTPCode err , errReasonPhrase = show err , errBody = encode $ object [ "error" .= err ] , errHeaders = [] }
217
toServantErr err = ServantErr { errHTTPCode = toHTTPCode err , errReasonPhrase = show err , errBody = encode $ object [ "error" .= err ] , errHeaders = [] }
178
false
true
0
10
56
66
36
30
null
null
mzero/plush
src/Plush/Run/TestExec.hs
apache-2.0
openFDesc :: FDesc -> TestExec Fd openFDesc fdesc = do s <- lift get let fd = freeDesc 0 $ tsFDescs s lift $ put s { tsFDescs = I.insert fd fdesc $ tsFDescs s} return $ fromIntegral fd where freeDesc fd fds = if I.member fd fds then freeDesc (fd + 1) fds else fd
284
openFDesc :: FDesc -> TestExec Fd openFDesc fdesc = do s <- lift get let fd = freeDesc 0 $ tsFDescs s lift $ put s { tsFDescs = I.insert fd fdesc $ tsFDescs s} return $ fromIntegral fd where freeDesc fd fds = if I.member fd fds then freeDesc (fd + 1) fds else fd
284
openFDesc fdesc = do s <- lift get let fd = freeDesc 0 $ tsFDescs s lift $ put s { tsFDescs = I.insert fd fdesc $ tsFDescs s} return $ fromIntegral fd where freeDesc fd fds = if I.member fd fds then freeDesc (fd + 1) fds else fd
250
false
true
1
13
77
141
62
79
null
null
jgonggrijp/net-prove
src/LG/Unfold.hs
bsd-3-clause
getUnfoldInfoC f@(P (b:<×>:a)) mainId idCounter = (mainTerm, operatorLink, aNodes, bNodes, bCount) where firstId = idCounter+0 mainId = idCounter+1 -- Terms, derived from node ids mainTerm = Va (V' aVar :<×> V' bVar) aVar = Variable (show aId) bVar = Variable (show bId) aTerm = Va aVar bTerm :: NodeTerm bTerm = Va bVar -- Operator link link =[Active aId, Active bId] :○: [MainT (mainId)] operatorLink = Just link (aId, aNodes, aCount) = unfoldConclusion' a aTerm operatorLink (idCounter+2) (bId, bNodes, bCount) = unfoldConclusion' b bTerm operatorLink aCount -- R\
780
getUnfoldInfoC f@(P (b:<×>:a)) mainId idCounter = (mainTerm, operatorLink, aNodes, bNodes, bCount) where firstId = idCounter+0 mainId = idCounter+1 -- Terms, derived from node ids mainTerm = Va (V' aVar :<×> V' bVar) aVar = Variable (show aId) bVar = Variable (show bId) aTerm = Va aVar bTerm :: NodeTerm bTerm = Va bVar -- Operator link link =[Active aId, Active bId] :○: [MainT (mainId)] operatorLink = Just link (aId, aNodes, aCount) = unfoldConclusion' a aTerm operatorLink (idCounter+2) (bId, bNodes, bCount) = unfoldConclusion' b bTerm operatorLink aCount -- R\
780
getUnfoldInfoC f@(P (b:<×>:a)) mainId idCounter = (mainTerm, operatorLink, aNodes, bNodes, bCount) where firstId = idCounter+0 mainId = idCounter+1 -- Terms, derived from node ids mainTerm = Va (V' aVar :<×> V' bVar) aVar = Variable (show aId) bVar = Variable (show bId) aTerm = Va aVar bTerm :: NodeTerm bTerm = Va bVar -- Operator link link =[Active aId, Active bId] :○: [MainT (mainId)] operatorLink = Just link (aId, aNodes, aCount) = unfoldConclusion' a aTerm operatorLink (idCounter+2) (bId, bNodes, bCount) = unfoldConclusion' b bTerm operatorLink aCount -- R\
780
false
false
0
10
300
230
124
106
null
null
NicolasDP/hitolite
GitBunker/HitoliteDB.hs
bsd-3-clause
showListGroupe = do listGroupe <- listHitoliteGroupe Prelude.mapM_ showAGroupe listGroupe where showAGroupe ent = let u = entityVal ent uk = unKey $ entityKey ent in Prelude.putStrLn $ "id(" ++ (show uk) ++ ") " ++ "groupe(" ++ (BS.unpack $ groupeName u) ++ ") " ++ "owner(" ++ (show $ unKey $ groupeOwner u) ++ ")"
440
showListGroupe = do listGroupe <- listHitoliteGroupe Prelude.mapM_ showAGroupe listGroupe where showAGroupe ent = let u = entityVal ent uk = unKey $ entityKey ent in Prelude.putStrLn $ "id(" ++ (show uk) ++ ") " ++ "groupe(" ++ (BS.unpack $ groupeName u) ++ ") " ++ "owner(" ++ (show $ unKey $ groupeOwner u) ++ ")"
440
showListGroupe = do listGroupe <- listHitoliteGroupe Prelude.mapM_ showAGroupe listGroupe where showAGroupe ent = let u = entityVal ent uk = unKey $ entityKey ent in Prelude.putStrLn $ "id(" ++ (show uk) ++ ") " ++ "groupe(" ++ (BS.unpack $ groupeName u) ++ ") " ++ "owner(" ++ (show $ unKey $ groupeOwner u) ++ ")"
440
false
false
0
16
179
129
62
67
null
null
DanielG/cabal-helper
src/CabalHelper/Compiletime/Compat/Parsec.hs
apache-2.0
absorbParsecFailure :: String -> Either String a -> a absorbParsecFailure _ (Right x) = x
89
absorbParsecFailure :: String -> Either String a -> a absorbParsecFailure _ (Right x) = x
89
absorbParsecFailure _ (Right x) = x
35
false
true
0
10
14
41
18
23
null
null
bcorrigan/PipeFeed
src/Util.hs
gpl-3.0
isLeft _ = False
23
isLeft _ = False
23
isLeft _ = False
23
false
false
0
5
10
9
4
5
null
null
carletes/monad-transformers
Transformers.hs
bsd-3-clause
eval2 env (Var n) = case Map.lookup n env of Nothing -> throwError ("Unbound variable: " ++ n) Just val -> return val
177
eval2 env (Var n) = case Map.lookup n env of Nothing -> throwError ("Unbound variable: " ++ n) Just val -> return val
177
eval2 env (Var n) = case Map.lookup n env of Nothing -> throwError ("Unbound variable: " ++ n) Just val -> return val
177
false
false
0
10
82
58
26
32
null
null
yamadapc/hpack-convert
src/Hpack/Config.hs
mit
convertSingletons "copyright" (Array a) = convertSingleton a
60
convertSingletons "copyright" (Array a) = convertSingleton a
60
convertSingletons "copyright" (Array a) = convertSingleton a
60
false
false
0
7
6
20
9
11
null
null
haskell/haddock
haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
bsd-2-clause
ppTyVars :: RenderableBndrFlag flag => Unicode -> Qualification -> [LHsTyVarBndr flag DocNameI] -> [Html] ppTyVars unicode qual tvs = map (ppHsTyVarBndr unicode qual . unLoc) tvs
180
ppTyVars :: RenderableBndrFlag flag => Unicode -> Qualification -> [LHsTyVarBndr flag DocNameI] -> [Html] ppTyVars unicode qual tvs = map (ppHsTyVarBndr unicode qual . unLoc) tvs
180
ppTyVars unicode qual tvs = map (ppHsTyVarBndr unicode qual . unLoc) tvs
72
false
true
0
11
27
70
33
37
null
null
yuki-takeichi/JavaStaticAnalyzer
Language/Java/StaticAnalyzer/ExpressionParser.hs
mit
accessLevel :: Parser (Maybe AccessLevel) accessLevel = liftM (liftM makeAccessLevel) $ optionMaybe $ choice [string "public", string "protected", string "private"] where makeAccessLevel "public" = Public makeAccessLevel "protected" = Protected makeAccessLevel "private" = Private makeAccessLevel _ = error "never reach here"
343
accessLevel :: Parser (Maybe AccessLevel) accessLevel = liftM (liftM makeAccessLevel) $ optionMaybe $ choice [string "public", string "protected", string "private"] where makeAccessLevel "public" = Public makeAccessLevel "protected" = Protected makeAccessLevel "private" = Private makeAccessLevel _ = error "never reach here"
343
accessLevel = liftM (liftM makeAccessLevel) $ optionMaybe $ choice [string "public", string "protected", string "private"] where makeAccessLevel "public" = Public makeAccessLevel "protected" = Protected makeAccessLevel "private" = Private makeAccessLevel _ = error "never reach here"
301
false
true
1
9
57
99
46
53
null
null
pap/postgrest
src/PostgREST/PgQuery.hs
mit
withCount :: StatementT withCount s = s { B.stmtTemplate = "pg_catalog.count(t), " <> B.stmtTemplate s }
104
withCount :: StatementT withCount s = s { B.stmtTemplate = "pg_catalog.count(t), " <> B.stmtTemplate s }
104
withCount s = s { B.stmtTemplate = "pg_catalog.count(t), " <> B.stmtTemplate s }
80
false
true
0
9
15
33
17
16
null
null
GaloisInc/halvm-ghc
compiler/types/Type.hs
bsd-3-clause
-- | Is this a symbol literal. We also look through type synonyms. isStrLitTy :: Type -> Maybe FastString isStrLitTy ty | Just ty1 <- coreView ty = isStrLitTy ty1
162
isStrLitTy :: Type -> Maybe FastString isStrLitTy ty | Just ty1 <- coreView ty = isStrLitTy ty1
95
isStrLitTy ty | Just ty1 <- coreView ty = isStrLitTy ty1
56
true
true
0
9
29
45
19
26
null
null
ribag/ganeti-experiments
src/Ganeti/UDSServer.hs
gpl-2.0
prepareMsg (Ok result) = (True, result)
39
prepareMsg (Ok result) = (True, result)
39
prepareMsg (Ok result) = (True, result)
39
false
false
0
7
5
21
11
10
null
null
twopoint718/haifa
src/Utils.hs
gpl-2.0
dimInc2 :: [Int] -> [Int] -> [[Int]] dimInc2 [x] [y] = map (\x -> [x]) [x..y]
77
dimInc2 :: [Int] -> [Int] -> [[Int]] dimInc2 [x] [y] = map (\x -> [x]) [x..y]
77
dimInc2 [x] [y] = map (\x -> [x]) [x..y]
40
false
true
0
8
15
63
36
27
null
null
brendanhay/gogol
gogol-pubsub/gen/Network/Google/Resource/PubSub/Projects/Subscriptions/ModifyPushConfig.hs
mpl-2.0
-- | Legacy upload protocol for media (e.g. \"media\", \"multipart\"). psmpcUploadType :: Lens' ProjectsSubscriptionsModifyPushConfig (Maybe Text) psmpcUploadType = lens _psmpcUploadType (\ s a -> s{_psmpcUploadType = a})
229
psmpcUploadType :: Lens' ProjectsSubscriptionsModifyPushConfig (Maybe Text) psmpcUploadType = lens _psmpcUploadType (\ s a -> s{_psmpcUploadType = a})
158
psmpcUploadType = lens _psmpcUploadType (\ s a -> s{_psmpcUploadType = a})
82
true
true
0
8
34
49
25
24
null
null
Ragnaroek/orwell
src/Orwell/Analyse.hs
gpl-3.0
filterTypeNoTest :: CommitType -> CommitStat -> Bool filterTypeNoTest t s = (classify c) == t && (commitTestFiles c) == [] && (commitCodeFiles c) /= [] where c = (commit s)
176
filterTypeNoTest :: CommitType -> CommitStat -> Bool filterTypeNoTest t s = (classify c) == t && (commitTestFiles c) == [] && (commitCodeFiles c) /= [] where c = (commit s)
176
filterTypeNoTest t s = (classify c) == t && (commitTestFiles c) == [] && (commitCodeFiles c) /= [] where c = (commit s)
123
false
true
0
11
33
80
40
40
null
null
bitemyapp/morfette
src/GramLab/Morfette/Evaluation.hs
bsd-2-clause
sentenceAccuracy :: [[Token]] -> [[Token]] -> Maybe [[Token]] -> Accuracy sentenceAccuracy xs ys bl = accuracy (map,map,map) (map (map tokToPair) xs) (map (map tokToPair) ys) (fmap (map (map tokToPair)) bl)
310
sentenceAccuracy :: [[Token]] -> [[Token]] -> Maybe [[Token]] -> Accuracy sentenceAccuracy xs ys bl = accuracy (map,map,map) (map (map tokToPair) xs) (map (map tokToPair) ys) (fmap (map (map tokToPair)) bl)
310
sentenceAccuracy xs ys bl = accuracy (map,map,map) (map (map tokToPair) xs) (map (map tokToPair) ys) (fmap (map (map tokToPair)) bl)
236
false
true
0
11
133
117
62
55
null
null
AndreasPK/stack
src/Stack/Options/GhcBuildParser.hs
bsd-3-clause
-- | GHC build parser ghcBuildParser :: Bool -> Parser CompilerBuild ghcBuildParser hide = option readGHCBuild (long "ghc-build" <> metavar "BUILD" <> help "Specialized GHC build, e.g. 'gmp4' or 'standard' (usually auto-detected)" <> hideMods hide ) where readGHCBuild = do s <- readerAsk case parseCompilerBuild s of Left e -> readerError (show e) Right v -> return v
473
ghcBuildParser :: Bool -> Parser CompilerBuild ghcBuildParser hide = option readGHCBuild (long "ghc-build" <> metavar "BUILD" <> help "Specialized GHC build, e.g. 'gmp4' or 'standard' (usually auto-detected)" <> hideMods hide ) where readGHCBuild = do s <- readerAsk case parseCompilerBuild s of Left e -> readerError (show e) Right v -> return v
451
ghcBuildParser hide = option readGHCBuild (long "ghc-build" <> metavar "BUILD" <> help "Specialized GHC build, e.g. 'gmp4' or 'standard' (usually auto-detected)" <> hideMods hide ) where readGHCBuild = do s <- readerAsk case parseCompilerBuild s of Left e -> readerError (show e) Right v -> return v
404
true
true
0
12
162
109
49
60
null
null
davedissian/hackcambridge2016
Main.hs
mit
scaleMatrix :: GLfloat -> GLfloat -> GLfloat -> M44 GLfloat scaleMatrix x y z = V4 (V4 x 0 0 0) (V4 0 y 0 0) (V4 0 0 z 0) (V4 0 0 0 1)
134
scaleMatrix :: GLfloat -> GLfloat -> GLfloat -> M44 GLfloat scaleMatrix x y z = V4 (V4 x 0 0 0) (V4 0 y 0 0) (V4 0 0 z 0) (V4 0 0 0 1)
134
scaleMatrix x y z = V4 (V4 x 0 0 0) (V4 0 y 0 0) (V4 0 0 z 0) (V4 0 0 0 1)
74
false
true
0
8
35
90
44
46
null
null
jsavatgy/hatupist
code/readFile.hs
gpl-2.0
untilLen (t:ts) s n | s+x<n || s==0 = t : untilLen ts (s+x) n | otherwise = [] where x = length t + 1
116
untilLen (t:ts) s n | s+x<n || s==0 = t : untilLen ts (s+x) n | otherwise = [] where x = length t + 1
116
untilLen (t:ts) s n | s+x<n || s==0 = t : untilLen ts (s+x) n | otherwise = [] where x = length t + 1
116
false
false
5
11
40
99
43
56
null
null
spl/digits
src/Test/EnumInt.hs
bsd-3-clause
-------------------------------------------------------------------------------- iso :: Test iso = "iso" ~: [ qc (undefined :: Int8) Prop.iso , qc (undefined :: Int16) Prop.iso , qc (undefined :: Int32) Prop.iso , qc (undefined :: Int64) Prop.iso , qc (undefined :: Word) Prop.iso , qc (undefined :: Word8) Prop.iso , qc (undefined :: Word16) Prop.iso , qc (undefined :: Word32) Prop.iso , qc (undefined :: Word64) Prop.iso , qc (undefined :: Integer) Prop.iso ] where qc :: (Show n, Data n, Arbitrary n, Testable prop) => n -> (n -> n -> prop) -> Test qc x p = dataTypeNameOf x ~|: p
658
iso :: Test iso = "iso" ~: [ qc (undefined :: Int8) Prop.iso , qc (undefined :: Int16) Prop.iso , qc (undefined :: Int32) Prop.iso , qc (undefined :: Int64) Prop.iso , qc (undefined :: Word) Prop.iso , qc (undefined :: Word8) Prop.iso , qc (undefined :: Word16) Prop.iso , qc (undefined :: Word32) Prop.iso , qc (undefined :: Word64) Prop.iso , qc (undefined :: Integer) Prop.iso ] where qc :: (Show n, Data n, Arbitrary n, Testable prop) => n -> (n -> n -> prop) -> Test qc x p = dataTypeNameOf x ~|: p
576
iso = "iso" ~: [ qc (undefined :: Int8) Prop.iso , qc (undefined :: Int16) Prop.iso , qc (undefined :: Int32) Prop.iso , qc (undefined :: Int64) Prop.iso , qc (undefined :: Word) Prop.iso , qc (undefined :: Word8) Prop.iso , qc (undefined :: Word16) Prop.iso , qc (undefined :: Word32) Prop.iso , qc (undefined :: Word64) Prop.iso , qc (undefined :: Integer) Prop.iso ] where qc :: (Show n, Data n, Arbitrary n, Testable prop) => n -> (n -> n -> prop) -> Test qc x p = dataTypeNameOf x ~|: p
564
true
true
2
11
171
260
137
123
null
null
dimara/ganeti
src/Ganeti/Constants.hs
bsd-2-clause
-- * Confd node role confdNodeRoleMaster :: Int confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
110
confdNodeRoleMaster :: Int confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
88
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
61
true
true
0
6
12
23
10
13
null
null
josefs/feldspar-opencv
Feldspar/OpenCV.hs
mit
setArr_ :: IplImage -> Data [Word8] -> Data IntN -> Program () setArr_ i d s = do arr <- unsafeThawArr d callProc "cvSetData" [objArg (unImg i) ,arrArg arr ,valArg s ]
243
setArr_ :: IplImage -> Data [Word8] -> Data IntN -> Program () setArr_ i d s = do arr <- unsafeThawArr d callProc "cvSetData" [objArg (unImg i) ,arrArg arr ,valArg s ]
243
setArr_ i d s = do arr <- unsafeThawArr d callProc "cvSetData" [objArg (unImg i) ,arrArg arr ,valArg s ]
180
false
true
0
12
107
91
41
50
null
null
stefan-hoeck/labeled-graph
Data/Graph/Simple/Query/Dfs.hs
bsd-3-clause
-- | Returns a list of vertices reachable from a given vertex -- in depth first order. The list starts with the vertex -- provided. reachable ∷ Graph → Vertex → [Vertex] reachable g v = head $ dfs g [v]
206
reachable ∷ Graph → Vertex → [Vertex] reachable g v = head $ dfs g [v]
70
reachable g v = head $ dfs g [v]
32
true
true
2
9
44
48
24
24
null
null
facebookincubator/duckling
Duckling/Numeral/ES/ES/Rules.hs
bsd-3-clause
rulesBackwardCompatible :: [Rule] rulesBackwardCompatible = [ ruleDecimalNumeral , ruleDecimalWithThousandsSeparator , ruleIntegerWithThousandsSeparator ]
162
rulesBackwardCompatible :: [Rule] rulesBackwardCompatible = [ ruleDecimalNumeral , ruleDecimalWithThousandsSeparator , ruleIntegerWithThousandsSeparator ]
162
rulesBackwardCompatible = [ ruleDecimalNumeral , ruleDecimalWithThousandsSeparator , ruleIntegerWithThousandsSeparator ]
128
false
true
0
5
19
23
14
9
null
null
mrd/camfort
tests/Camfort/Specification/StencilsSpec.hs
apache-2.0
test2DSpecVariation a b (input, expectation) = it ("format=" ++ show input) $ -- Test inference indicesToSpec' ["i", "j"] [a, b] (map fromFormatToIx input) `shouldBe` Just expectedSpec where expectedSpec = Specification expectation fromFormatToIx [ri,rj] = [ offsetToIx "i" ri, offsetToIx "j" rj ]
335
test2DSpecVariation a b (input, expectation) = it ("format=" ++ show input) $ -- Test inference indicesToSpec' ["i", "j"] [a, b] (map fromFormatToIx input) `shouldBe` Just expectedSpec where expectedSpec = Specification expectation fromFormatToIx [ri,rj] = [ offsetToIx "i" ri, offsetToIx "j" rj ]
335
test2DSpecVariation a b (input, expectation) = it ("format=" ++ show input) $ -- Test inference indicesToSpec' ["i", "j"] [a, b] (map fromFormatToIx input) `shouldBe` Just expectedSpec where expectedSpec = Specification expectation fromFormatToIx [ri,rj] = [ offsetToIx "i" ri, offsetToIx "j" rj ]
335
false
false
1
10
79
114
60
54
null
null
GaloisInc/verification-game
web-prover/src/Prove.hs
bsd-3-clause
altErgoProver :: ProverOpts altErgoProver = mkProver PAltErgo True
66
altErgoProver :: ProverOpts altErgoProver = mkProver PAltErgo True
66
altErgoProver = mkProver PAltErgo True
38
false
true
0
6
7
22
9
13
null
null
ezyang/ghc
compiler/types/TyCoRep.hs
bsd-3-clause
noFreeVarsOfCo (FunCo _ c1 c2) = noFreeVarsOfCo c1 && noFreeVarsOfCo c2
78
noFreeVarsOfCo (FunCo _ c1 c2) = noFreeVarsOfCo c1 && noFreeVarsOfCo c2
78
noFreeVarsOfCo (FunCo _ c1 c2) = noFreeVarsOfCo c1 && noFreeVarsOfCo c2
78
false
false
0
6
17
30
13
17
null
null
bitemyapp/amqp
Tools/Builder.hs
bsd-3-clause
fieldType domainMap (DomainField _ domain) = fromJust $ M.lookup domain domainMap
81
fieldType domainMap (DomainField _ domain) = fromJust $ M.lookup domain domainMap
81
fieldType domainMap (DomainField _ domain) = fromJust $ M.lookup domain domainMap
81
false
false
0
7
10
30
14
16
null
null
tphyahoo/gititpt
Network/Gitit/Framework.hs
gpl-2.0
calculateWikiBase :: String -> String -> Maybe String calculateWikiBase path' uri' = let revpaths = reverse . filter (not . null) $ splitOn '/' path' revuris = reverse . filter (not . null) $ splitOn '/' uri' in if revpaths `isPrefixOf` revuris then let revbase = drop (length revpaths) revuris -- a path like _feed is not part of the base... revbase' = case revbase of (x:xs) | startsWithUnderscore x -> xs xs -> xs base' = intercalate "/" $ reverse revbase' in Just $ if null base' then "" else '/' : base' else Nothing
711
calculateWikiBase :: String -> String -> Maybe String calculateWikiBase path' uri' = let revpaths = reverse . filter (not . null) $ splitOn '/' path' revuris = reverse . filter (not . null) $ splitOn '/' uri' in if revpaths `isPrefixOf` revuris then let revbase = drop (length revpaths) revuris -- a path like _feed is not part of the base... revbase' = case revbase of (x:xs) | startsWithUnderscore x -> xs xs -> xs base' = intercalate "/" $ reverse revbase' in Just $ if null base' then "" else '/' : base' else Nothing
711
calculateWikiBase path' uri' = let revpaths = reverse . filter (not . null) $ splitOn '/' path' revuris = reverse . filter (not . null) $ splitOn '/' uri' in if revpaths `isPrefixOf` revuris then let revbase = drop (length revpaths) revuris -- a path like _feed is not part of the base... revbase' = case revbase of (x:xs) | startsWithUnderscore x -> xs xs -> xs base' = intercalate "/" $ reverse revbase' in Just $ if null base' then "" else '/' : base' else Nothing
657
false
true
0
18
285
197
98
99
null
null
olorin/amazonka
amazonka-dynamodb/gen/Network/AWS/DynamoDB/PutItem.hs
mpl-2.0
-- | Creates a value of 'PutItemResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'pirsItemCollectionMetrics' -- -- * 'pirsConsumedCapacity' -- -- * 'pirsAttributes' -- -- * 'pirsResponseStatus' putItemResponse :: Int -- ^ 'pirsResponseStatus' -> PutItemResponse putItemResponse pResponseStatus_ = PutItemResponse' { _pirsItemCollectionMetrics = Nothing , _pirsConsumedCapacity = Nothing , _pirsAttributes = Nothing , _pirsResponseStatus = pResponseStatus_ }
583
putItemResponse :: Int -- ^ 'pirsResponseStatus' -> PutItemResponse putItemResponse pResponseStatus_ = PutItemResponse' { _pirsItemCollectionMetrics = Nothing , _pirsConsumedCapacity = Nothing , _pirsAttributes = Nothing , _pirsResponseStatus = pResponseStatus_ }
295
putItemResponse pResponseStatus_ = PutItemResponse' { _pirsItemCollectionMetrics = Nothing , _pirsConsumedCapacity = Nothing , _pirsAttributes = Nothing , _pirsResponseStatus = pResponseStatus_ }
219
true
true
0
7
106
65
40
25
null
null
josefs/sbv
Data/SBV/Core/Data.hs
bsd-3-clause
-- | Not-A-Number for 'Double' and 'Float'. Surprisingly, Haskell -- Prelude doesn't have this value defined, so we provide it here. nan :: Floating a => a nan = 0/0
165
nan :: Floating a => a nan = 0/0
32
nan = 0/0
9
true
true
2
7
29
33
14
19
null
null
bgamari/text
src/Data/Text/Lazy.hs
bsd-2-clause
-- | /O(n)/ Convert a string to upper case, using simple case -- conversion. Subject to fusion. -- -- The result string may be longer than the input string. For -- instance, the German eszett (U+00DF) maps to the two-letter -- sequence SS. toUpper :: Text -> Text toUpper t = unstream (S.toUpper (stream t))
309
toUpper :: Text -> Text toUpper t = unstream (S.toUpper (stream t))
67
toUpper t = unstream (S.toUpper (stream t))
43
true
true
0
9
56
41
23
18
null
null
ankhers/openRTB-hs
spec/OpenRTB/Types/BidResponse/SeatBidSpec.hs
bsd-3-clause
spec :: Spec spec = describe "Bid" $ do context "JSON" $ do it "should convert back and fourth" $ property $ do \b -> (decode . encode) b == Just (b :: SeatBid)
172
spec :: Spec spec = describe "Bid" $ do context "JSON" $ do it "should convert back and fourth" $ property $ do \b -> (decode . encode) b == Just (b :: SeatBid)
172
spec = describe "Bid" $ do context "JSON" $ do it "should convert back and fourth" $ property $ do \b -> (decode . encode) b == Just (b :: SeatBid)
159
false
true
2
18
45
81
36
45
null
null
frontrowed/stratosphere
library-gen/Stratosphere/Resources/EC2VPC.hs
mit
-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html#cfn-aws-ec2-vpc-instancetenancy ecvpcInstanceTenancy :: Lens' EC2VPC (Maybe (Val Text)) ecvpcInstanceTenancy = lens _eC2VPCInstanceTenancy (\s a -> s { _eC2VPCInstanceTenancy = a })
274
ecvpcInstanceTenancy :: Lens' EC2VPC (Maybe (Val Text)) ecvpcInstanceTenancy = lens _eC2VPCInstanceTenancy (\s a -> s { _eC2VPCInstanceTenancy = a })
149
ecvpcInstanceTenancy = lens _eC2VPCInstanceTenancy (\s a -> s { _eC2VPCInstanceTenancy = a })
93
true
true
1
9
22
55
28
27
null
null
mariefarrell/Hets
OMDoc/XmlInterface.hs
gpl-2.0
xmlToAssignment :: Element -> Result (OMName, OMImage) xmlToAssignment e | elName e == el_open = let musthave = missingMaybe "Open" nm = musthave "name" $ findAttr at_name e alias = musthave "as" $ findAttr at_as e in return (readOMName nm, Left alias) | elName e == el_conass = let musthave = missingMaybe "Conass" nm = musthave "name" $ findAttr at_name e in do omel <- omelementFromOmobj e return (readOMName nm, Right $ musthave "OMOBJ element" omel) | otherwise = fail $ oneOfMsg e [el_conass, el_open]
607
xmlToAssignment :: Element -> Result (OMName, OMImage) xmlToAssignment e | elName e == el_open = let musthave = missingMaybe "Open" nm = musthave "name" $ findAttr at_name e alias = musthave "as" $ findAttr at_as e in return (readOMName nm, Left alias) | elName e == el_conass = let musthave = missingMaybe "Conass" nm = musthave "name" $ findAttr at_name e in do omel <- omelementFromOmobj e return (readOMName nm, Right $ musthave "OMOBJ element" omel) | otherwise = fail $ oneOfMsg e [el_conass, el_open]
607
xmlToAssignment e | elName e == el_open = let musthave = missingMaybe "Open" nm = musthave "name" $ findAttr at_name e alias = musthave "as" $ findAttr at_as e in return (readOMName nm, Left alias) | elName e == el_conass = let musthave = missingMaybe "Conass" nm = musthave "name" $ findAttr at_name e in do omel <- omelementFromOmobj e return (readOMName nm, Right $ musthave "OMOBJ element" omel) | otherwise = fail $ oneOfMsg e [el_conass, el_open]
552
false
true
0
14
184
211
97
114
null
null
diku-dk/futhark
src/Futhark/IR/Primitive.hs
isc
doUnOp Complement {} (IntValue v) = Just $ IntValue $ doComplement v
68
doUnOp Complement {} (IntValue v) = Just $ IntValue $ doComplement v
68
doUnOp Complement {} (IntValue v) = Just $ IntValue $ doComplement v
68
false
false
0
7
11
32
15
17
null
null
Sgoettschkes/learning
haskell/ProjectEuler/Helpers/Primes.hs
mit
primeFactors n | n == 1 = [1] | otherwise = go n primeNumbers where go num all@(x:xs) | x*x > num = [num] | num `rem` x == 0 = x : go (num `quot` x) all | otherwise = go num xs
233
primeFactors n | n == 1 = [1] | otherwise = go n primeNumbers where go num all@(x:xs) | x*x > num = [num] | num `rem` x == 0 = x : go (num `quot` x) all | otherwise = go num xs
233
primeFactors n | n == 1 = [1] | otherwise = go n primeNumbers where go num all@(x:xs) | x*x > num = [num] | num `rem` x == 0 = x : go (num `quot` x) all | otherwise = go num xs
233
false
false
1
9
100
124
62
62
null
null
hvr/multi-ghc-travis
src/HaskellCI/Bash/Template.hs
bsd-3-clause
-- To generate: -- -- :m *HaskellCI.Bash.Template -- Zinza.parseAndCompileModuleIO (Zinza.simpleConfig "Module" [] :: Zinza.ModuleConfig Z) "haskell-ci.sh.zinza" >>= putStr render :: Z -> String render z_root = execWriter $ do tell "#!/bin/bash\n" tell "# shellcheck disable=SC2086,SC2016,SC2046\n" tell "# REGENDATA " tell (zRegendata z_root) tell "\n" tell "\n" tell "set -o pipefail\n" tell "\n" tell "# Mode\n" tell "##############################################################################\n" tell "\n" tell "if [ \"$1\" = \"indocker\" ]; then\n" tell " INDOCKER=true\n" tell " shift\n" tell "else\n" tell " INDOCKER=false\n" tell "fi\n" tell "\n" tell "# Run configuration\n" tell "##############################################################################\n" tell "\n" tell "CFG_CABAL_STORE_CACHE=\"\"\n" tell "CFG_CABAL_REPO_CACHE=\"\"\n" tell "CFG_JOBS=\"" tell (zUnwords z_root (zJobs z_root)) tell "\"\n" tell "CFG_CABAL_UPDATE=false\n" tell "\n" tell "SCRIPT_NAME=$(basename \"$0\")\n" tell "START_TIME=\"$(date +'%s')\"\n" tell "\n" tell "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}\n" tell "\n" tell "# Job configuration\n" tell "##############################################################################\n" tell "\n" tell "GHC_VERSION=\"non-existing\"\n" tell "CABAL_VERSION=3.2\n" tell "HEADHACKAGE=false\n" tell "\n" tell "# Locale\n" tell "##############################################################################\n" tell "\n" tell "export LC_ALL=C.UTF-8\n" tell "\n" tell "# Utilities\n" tell "##############################################################################\n" tell "\n" tell "SGR_RED='\\033[1;31m'\n" tell "SGR_GREEN='\\033[1;32m'\n" tell "SGR_BLUE='\\033[1;34m'\n" tell "SGR_CYAN='\\033[1;96m'\n" tell "SGR_RESET='\\033[0m' # No Color\n" tell "\n" tell "put_info() {\n" tell " printf \"$SGR_CYAN%s$SGR_RESET\\n\" \"### $*\"\n" tell "}\n" tell "\n" tell "put_error() {\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! $*\"\n" tell "}\n" tell "\n" tell "run_cmd() {\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " if $INDOCKER; then\n" tell " PROMPT=\"$(pwd) >>>\"\n" tell " else\n" tell " PROMPT=\">>>\"\n" tell " fi\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell "\n" tell " local start_time end_time cmd_duration total_duration\n" tell " start_time=$(date +'%s')\n" tell "\n" tell " \"$@\"\n" tell " local RET=$?\n" tell "\n" tell " end_time=$(date +'%s')\n" tell " cmd_duration=$((end_time - start_time))\n" tell " total_duration=$((end_time - START_TIME))\n" tell "\n" tell " cmd_min=$((cmd_duration / 60))\n" tell " cmd_sec=$((cmd_duration % 60))\n" tell "\n" tell " total_min=$((total_duration / 60))\n" tell " total_sec=$((total_duration % 60))\n" tell "\n" tell " if [ $RET -eq 0 ]; then\n" tell " printf \"$SGR_GREEN%s$SGR_RESET (%dm%02ds; %dm%02ds)\\n\" \"<<< $PRETTYCMD\" \"$cmd_min\" \"$cmd_sec\" \"$total_min\" \"$total_sec\"\n" tell " else\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! $PRETTYCMD\"\n" tell " exit 1\n" tell " fi\n" tell "}\n" tell "\n" tell "run_cmd_if() {\n" tell " local COND=$1\n" tell " shift\n" tell "\n" tell " if [ $COND -eq 1 ]; then\n" tell " run_cmd \"$@\"\n" tell " else\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " PROMPT=\"$(pwd) (skipping) >>>\"\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell " fi\n" tell "}\n" tell "\n" tell "run_cmd_unchecked() {\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " if $INDOCKER; then\n" tell " PROMPT=\"$(pwd) >>>\"\n" tell " else\n" tell " PROMPT=\">>>\"\n" tell " fi\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell "\n" tell " local start_time end_time cmd_duration total_duration cmd_min cmd_sec total_min total_sec\n" tell " start_time=$(date +'%s')\n" tell "\n" tell " \"$@\"\n" tell "\n" tell " end_time=$(date +'%s')\n" tell " cmd_duration=$((end_time - start_time))\n" tell " total_duration=$((end_time - START_TIME))\n" tell "\n" tell " cmd_min=$((cmd_duration / 60))\n" tell " cmd_sec=$((cmd_duration % 60))\n" tell "\n" tell " total_min=$((total_duration / 60))\n" tell " total_sec=$((total_duration % 60))\n" tell "\n" tell " printf \"$SGR_GREEN%s$SGR_RESET (%dm%02ds; %dm%02ds)\\n\" \"<<< $PRETTYCMD\" \"$cmd_min\" \"$cmd_sec\" \"$total_min\" \"$total_sec\"\n" tell "}\n" tell "\n" tell "change_dir() {\n" tell " local DIR=$1\n" tell " if [ -d \"$DIR\" ]; then\n" tell " printf \"$SGR_BLUE%s$SGR_RESET\\n\" \"change directory to $DIR\"\n" tell " cd \"$DIR\" || exit 1\n" tell " else\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! cd $DIR\"\n" tell " exit 1\n" tell " fi\n" tell "}\n" tell "\n" tell "change_dir_if() {\n" tell " local COND=$1\n" tell " local DIR=$2\n" tell "\n" tell " if [ $COND -ne 0 ]; then\n" tell " change_dir \"$DIR\"\n" tell " fi\n" tell "}\n" tell "\n" tell "echo_to() {\n" tell " local DEST=$1\n" tell " local CONTENTS=$2\n" tell "\n" tell " echo \"$CONTENTS\" >> \"$DEST\"\n" tell "}\n" tell "\n" tell "echo_if_to() {\n" tell " local COND=$1\n" tell " local DEST=$2\n" tell " local CONTENTS=$3\n" tell "\n" tell " if [ $COND -ne 0 ]; then\n" tell " echo_to \"$DEST\" \"$CONTENTS\"\n" tell " fi\n" tell "}\n" tell "\n" tell "install_cabalplan() {\n" tell " put_info \"installing cabal-plan\"\n" tell "\n" tell " if [ ! -e $CABAL_REPOCACHE/downloads/cabal-plan ]; then\n" tell " curl -L https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > /tmp/cabal-plan.xz || exit 1\n" tell " (cd /tmp && echo \"de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz\" | sha256sum -c -)|| exit 1\n" tell " mkdir -p $CABAL_REPOCACHE/downloads\n" tell " xz -d < /tmp/cabal-plan.xz > $CABAL_REPOCACHE/downloads/cabal-plan || exit 1\n" tell " chmod a+x $CABAL_REPOCACHE/downloads/cabal-plan || exit 1\n" tell " fi\n" tell "\n" tell " mkdir -p $CABAL_DIR/bin || exit 1\n" tell " ln -s $CABAL_REPOCACHE/downloads/cabal-plan $CABAL_DIR/bin/cabal-plan || exit 1\n" tell "}\n" tell "\n" tell "# Help\n" tell "##############################################################################\n" tell "\n" tell "show_usage() {\n" tell "cat <<EOF\n" tell "./haskell-ci.sh - build & test\n" tell "\n" tell "Usage: ./haskell-ci.sh [options]\n" tell " A script to run automated checks locally (using Docker)\n" tell "\n" tell "Available options:\n" tell " --jobs JOBS Jobs to run (default: $CFG_JOBS)\n" tell " --cabal-store-cache PATH Directory to use for cabal-store-cache\n" tell " --cabal-repo-cache PATH Directory to use for cabal-repo-cache\n" tell " --skip-cabal-update Skip cabal update (useful with --cabal-repo-cache)\n" tell " --no-skip-cabal-update\n" tell " --help Print this message\n" tell "\n" tell "EOF\n" tell "}\n" tell "\n" tell "# getopt\n" tell "#######################################################################\n" tell "\n" tell "process_cli_options() {\n" tell " while [ $# -gt 0 ]; do\n" tell " arg=$1\n" tell " case $arg in\n" tell " --help)\n" tell " show_usage\n" tell " exit\n" tell " ;;\n" tell " --jobs)\n" tell " CFG_JOBS=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-store-cache)\n" tell " CFG_CABAL_STORE_CACHE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-repo-cache)\n" tell " CFG_CABAL_REPO_CACHE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --skip-cabal-update)\n" tell " CFG_CABAL_UPDATE=false\n" tell " shift\n" tell " ;;\n" tell " --no-skip-cabal-update)\n" tell " CFG_CABAL_UPDATE=true\n" tell " shift\n" tell " ;;\n" tell " *)\n" tell " echo \"Unknown option $arg\"\n" tell " exit 1\n" tell " esac\n" tell " done\n" tell "}\n" tell "\n" tell "process_indocker_options () {\n" tell " while [ $# -gt 0 ]; do\n" tell " arg=$1\n" tell "\n" tell " case $arg in\n" tell " --ghc-version)\n" tell " GHC_VERSION=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-version)\n" tell " CABAL_VERSION=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --start-time)\n" tell " START_TIME=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-update)\n" tell " CABAL_UPDATE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " *)\n" tell " echo \"Unknown option $arg\"\n" tell " exit 1\n" tell " esac\n" tell " done\n" tell "}\n" tell "\n" tell "if $INDOCKER; then\n" tell " process_indocker_options \"$@\"\n" tell "\n" tell "else\n" tell " if [ -f \"$XDG_CONFIG_HOME/haskell-ci/bash.config\" ]; then\n" tell " process_cli_options $(cat \"$XDG_CONFIG_HOME/haskell-ci/bash.config\")\n" tell " fi\n" tell "\n" tell " process_cli_options \"$@\"\n" tell "\n" tell " put_info \"jobs: $CFG_JOBS\"\n" tell " put_info \"cabal-store-cache: $CFG_CABAL_STORE_CACHE\"\n" tell " put_info \"cabal-repo-cache: $CFG_CABAL_REPO_CACHE\"\n" tell " put_info \"cabal-update: $CFG_CABAL_UPDATE\"\n" tell "fi\n" tell "\n" tell "# Constants\n" tell "##############################################################################\n" tell "\n" tell "SRCDIR=/hsci/src\n" tell "BUILDDIR=/hsci/build\n" tell "CABAL_DIR=\"$BUILDDIR/cabal\"\n" tell "CABAL_REPOCACHE=/hsci/cabal-repocache\n" tell "CABAL_STOREDIR=/hsci/store\n" tell "\n" tell "# Docker invoke\n" tell "##############################################################################\n" tell "\n" tell "# if cache directory is specified, use it.\n" tell "# Otherwise use another tmpfs host\n" tell "if [ -z \"$CFG_CABAL_STORE_CACHE\" ]; then\n" tell " CABALSTOREARG=\"--tmpfs $CABAL_STOREDIR:exec\"\n" tell "else\n" tell " CABALSTOREARG=\"--volume $CFG_CABAL_STORE_CACHE:$CABAL_STOREDIR\"\n" tell "fi\n" tell "\n" tell "if [ -z \"$CFG_CABAL_REPO_CACHE\" ]; then\n" tell " CABALREPOARG=\"--tmpfs $CABAL_REPOCACHE:exec\"\n" tell "else\n" tell " CABALREPOARG=\"--volume $CFG_CABAL_REPO_CACHE:$CABAL_REPOCACHE\"\n" tell "fi\n" tell "\n" tell "echo_docker_cmd() {\n" tell " local GHCVER=$1\n" tell "\n" tell " # TODO: mount /hsci/src:ro (readonly)\n" tell " echo docker run \\\n" tell " --tty \\\n" tell " --interactive \\\n" tell " --rm \\\n" tell " --label haskell-ci \\\n" tell " --volume \"$(pwd):/hsci/src\" \\\n" tell " $CABALSTOREARG \\\n" tell " $CABALREPOARG \\\n" tell " --tmpfs /tmp:exec \\\n" tell " --tmpfs /hsci/build:exec \\\n" tell " --workdir /hsci/build \\\n" tell " \"phadej/ghc:$GHCVER-bionic\" \\\n" tell " \"/bin/bash\" \"/hsci/src/$SCRIPT_NAME\" indocker \\\n" tell " --ghc-version \"$GHCVER\" \\\n" tell " --cabal-update \"$CFG_CABAL_UPDATE\" \\\n" tell " --start-time \"$START_TIME\"\n" tell "}\n" tell "\n" tell "# if we are not in docker, loop through jobs\n" tell "if ! $INDOCKER; then\n" tell " for JOB in $CFG_JOBS; do\n" tell " put_info \"Running in docker: $JOB\"\n" tell " run_cmd $(echo_docker_cmd \"$JOB\")\n" tell " done\n" tell "\n" tell " run_cmd echo \"ALL OK\"\n" tell " exit 0\n" tell "fi\n" tell "\n" tell "# Otherwise we are in docker, and the rest of script executes\n" tell "put_info \"In docker\"\n" tell "\n" tell "# Environment\n" tell "##############################################################################\n" tell "\n" tell "GHCDIR=/opt/ghc/$GHC_VERSION\n" tell "\n" tell "HC=$GHCDIR/bin/ghc\n" tell "HCPKG=$GHCDIR/bin/ghc-pkg\n" tell "HADDOCK=$GHCDIR/bin/haddock\n" tell "\n" tell "CABAL=/opt/cabal/$CABAL_VERSION/bin/cabal\n" tell "\n" tell "CABAL=\"$CABAL -vnormal+nowrap\"\n" tell "\n" tell "export CABAL_DIR\n" tell "export CABAL_CONFIG=\"$BUILDDIR/cabal/config\"\n" tell "\n" tell "PATH=\"$CABAL_DIR/bin:$PATH\"\n" tell "\n" tell "# HCNUMVER\n" tell "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')\n" tell "GHCJSARITH=0\n" tell "\n" tell "put_info \"HCNUMVER: $HCNUMVER\"\n" tell "\n" tell "# Args for shorter/nicer commands\n" tell "if [ " tell (zTestsCond z_root) tell " -ne 0 ] ; then ARG_TESTS=--enable-tests; else ARG_TESTS=--disable-tests; fi\n" tell "if [ " tell (zBenchCond z_root) tell " -ne 0 ] ; then ARG_BENCH=--enable-benchmarks; else ARG_BENCH=--disable-benchmarks; fi\n" tell "ARG_COMPILER=\"--ghc --with-compiler=$HC\"\n" tell "\n" tell "put_info \"tests/benchmarks: $ARG_TESTS $ARG_BENCH\"\n" tell "\n" tell "# Apt dependencies\n" tell "##############################################################################\n" tell "\n" if (zNotNull z_root (zApt z_root)) then do tell "run_cmd apt-get update\n" tell "run_cmd apt-get install -y --no-install-recommends " tell (zUnwords z_root (zApt z_root)) tell "\n" return () else do return () tell "\n" tell "# Cabal config\n" tell "##############################################################################\n" tell "\n" tell "mkdir -p $BUILDDIR/cabal\n" tell "\n" tell "cat > $BUILDDIR/cabal/config <<EOF\n" tell "remote-build-reporting: anonymous\n" tell "write-ghc-environment-files: always\n" tell "remote-repo-cache: $CABAL_REPOCACHE\n" tell "logs-dir: $CABAL_DIR/logs\n" tell "world-file: $CABAL_DIR/world\n" tell "extra-prog-path: $CABAL_DIR/bin\n" tell "symlink-bindir: $CABAL_DIR/bin\n" tell "installdir: $CABAL_DIR/bin\n" tell "build-summary: $CABAL_DIR/logs/build.log\n" tell "store-dir: $CABAL_STOREDIR\n" tell "install-dirs user\n" tell " prefix: $CABAL_DIR\n" tell "repository hackage.haskell.org\n" tell " url: http://hackage.haskell.org/\n" tell "EOF\n" tell "\n" tell "if $HEADHACKAGE; then\n" tell " put_error \"head.hackage is not implemented\"\n" tell " exit 1\n" tell "fi\n" tell "\n" tell "run_cmd cat \"$BUILDDIR/cabal/config\"\n" tell "\n" tell "# Version\n" tell "##############################################################################\n" tell "\n" tell "put_info \"Versions\"\n" tell "run_cmd $HC --version\n" tell "run_cmd_unchecked $HC --print-project-git-commit-id\n" tell "run_cmd $CABAL --version\n" tell "\n" tell "# Build script\n" tell "##############################################################################\n" tell "\n" tell "# update cabal index\n" tell "if $CABAL_UPDATE; then\n" tell " put_info \"Updating Hackage index\"\n" tell " run_cmd $CABAL v2-update -v\n" tell "fi\n" tell "\n" tell "# install cabal-plan\n" tell "install_cabalplan\n" tell "run_cmd cabal-plan --version\n" tell "\n" forM_ (zBlocks z_root) $ \z_var0_block -> do tell z_var0_block tell "\n" tell "\n" tell "# Done\n" tell "run_cmd echo OK\n"
16,800
render :: Z -> String render z_root = execWriter $ do tell "#!/bin/bash\n" tell "# shellcheck disable=SC2086,SC2016,SC2046\n" tell "# REGENDATA " tell (zRegendata z_root) tell "\n" tell "\n" tell "set -o pipefail\n" tell "\n" tell "# Mode\n" tell "##############################################################################\n" tell "\n" tell "if [ \"$1\" = \"indocker\" ]; then\n" tell " INDOCKER=true\n" tell " shift\n" tell "else\n" tell " INDOCKER=false\n" tell "fi\n" tell "\n" tell "# Run configuration\n" tell "##############################################################################\n" tell "\n" tell "CFG_CABAL_STORE_CACHE=\"\"\n" tell "CFG_CABAL_REPO_CACHE=\"\"\n" tell "CFG_JOBS=\"" tell (zUnwords z_root (zJobs z_root)) tell "\"\n" tell "CFG_CABAL_UPDATE=false\n" tell "\n" tell "SCRIPT_NAME=$(basename \"$0\")\n" tell "START_TIME=\"$(date +'%s')\"\n" tell "\n" tell "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}\n" tell "\n" tell "# Job configuration\n" tell "##############################################################################\n" tell "\n" tell "GHC_VERSION=\"non-existing\"\n" tell "CABAL_VERSION=3.2\n" tell "HEADHACKAGE=false\n" tell "\n" tell "# Locale\n" tell "##############################################################################\n" tell "\n" tell "export LC_ALL=C.UTF-8\n" tell "\n" tell "# Utilities\n" tell "##############################################################################\n" tell "\n" tell "SGR_RED='\\033[1;31m'\n" tell "SGR_GREEN='\\033[1;32m'\n" tell "SGR_BLUE='\\033[1;34m'\n" tell "SGR_CYAN='\\033[1;96m'\n" tell "SGR_RESET='\\033[0m' # No Color\n" tell "\n" tell "put_info() {\n" tell " printf \"$SGR_CYAN%s$SGR_RESET\\n\" \"### $*\"\n" tell "}\n" tell "\n" tell "put_error() {\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! $*\"\n" tell "}\n" tell "\n" tell "run_cmd() {\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " if $INDOCKER; then\n" tell " PROMPT=\"$(pwd) >>>\"\n" tell " else\n" tell " PROMPT=\">>>\"\n" tell " fi\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell "\n" tell " local start_time end_time cmd_duration total_duration\n" tell " start_time=$(date +'%s')\n" tell "\n" tell " \"$@\"\n" tell " local RET=$?\n" tell "\n" tell " end_time=$(date +'%s')\n" tell " cmd_duration=$((end_time - start_time))\n" tell " total_duration=$((end_time - START_TIME))\n" tell "\n" tell " cmd_min=$((cmd_duration / 60))\n" tell " cmd_sec=$((cmd_duration % 60))\n" tell "\n" tell " total_min=$((total_duration / 60))\n" tell " total_sec=$((total_duration % 60))\n" tell "\n" tell " if [ $RET -eq 0 ]; then\n" tell " printf \"$SGR_GREEN%s$SGR_RESET (%dm%02ds; %dm%02ds)\\n\" \"<<< $PRETTYCMD\" \"$cmd_min\" \"$cmd_sec\" \"$total_min\" \"$total_sec\"\n" tell " else\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! $PRETTYCMD\"\n" tell " exit 1\n" tell " fi\n" tell "}\n" tell "\n" tell "run_cmd_if() {\n" tell " local COND=$1\n" tell " shift\n" tell "\n" tell " if [ $COND -eq 1 ]; then\n" tell " run_cmd \"$@\"\n" tell " else\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " PROMPT=\"$(pwd) (skipping) >>>\"\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell " fi\n" tell "}\n" tell "\n" tell "run_cmd_unchecked() {\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " if $INDOCKER; then\n" tell " PROMPT=\"$(pwd) >>>\"\n" tell " else\n" tell " PROMPT=\">>>\"\n" tell " fi\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell "\n" tell " local start_time end_time cmd_duration total_duration cmd_min cmd_sec total_min total_sec\n" tell " start_time=$(date +'%s')\n" tell "\n" tell " \"$@\"\n" tell "\n" tell " end_time=$(date +'%s')\n" tell " cmd_duration=$((end_time - start_time))\n" tell " total_duration=$((end_time - START_TIME))\n" tell "\n" tell " cmd_min=$((cmd_duration / 60))\n" tell " cmd_sec=$((cmd_duration % 60))\n" tell "\n" tell " total_min=$((total_duration / 60))\n" tell " total_sec=$((total_duration % 60))\n" tell "\n" tell " printf \"$SGR_GREEN%s$SGR_RESET (%dm%02ds; %dm%02ds)\\n\" \"<<< $PRETTYCMD\" \"$cmd_min\" \"$cmd_sec\" \"$total_min\" \"$total_sec\"\n" tell "}\n" tell "\n" tell "change_dir() {\n" tell " local DIR=$1\n" tell " if [ -d \"$DIR\" ]; then\n" tell " printf \"$SGR_BLUE%s$SGR_RESET\\n\" \"change directory to $DIR\"\n" tell " cd \"$DIR\" || exit 1\n" tell " else\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! cd $DIR\"\n" tell " exit 1\n" tell " fi\n" tell "}\n" tell "\n" tell "change_dir_if() {\n" tell " local COND=$1\n" tell " local DIR=$2\n" tell "\n" tell " if [ $COND -ne 0 ]; then\n" tell " change_dir \"$DIR\"\n" tell " fi\n" tell "}\n" tell "\n" tell "echo_to() {\n" tell " local DEST=$1\n" tell " local CONTENTS=$2\n" tell "\n" tell " echo \"$CONTENTS\" >> \"$DEST\"\n" tell "}\n" tell "\n" tell "echo_if_to() {\n" tell " local COND=$1\n" tell " local DEST=$2\n" tell " local CONTENTS=$3\n" tell "\n" tell " if [ $COND -ne 0 ]; then\n" tell " echo_to \"$DEST\" \"$CONTENTS\"\n" tell " fi\n" tell "}\n" tell "\n" tell "install_cabalplan() {\n" tell " put_info \"installing cabal-plan\"\n" tell "\n" tell " if [ ! -e $CABAL_REPOCACHE/downloads/cabal-plan ]; then\n" tell " curl -L https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > /tmp/cabal-plan.xz || exit 1\n" tell " (cd /tmp && echo \"de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz\" | sha256sum -c -)|| exit 1\n" tell " mkdir -p $CABAL_REPOCACHE/downloads\n" tell " xz -d < /tmp/cabal-plan.xz > $CABAL_REPOCACHE/downloads/cabal-plan || exit 1\n" tell " chmod a+x $CABAL_REPOCACHE/downloads/cabal-plan || exit 1\n" tell " fi\n" tell "\n" tell " mkdir -p $CABAL_DIR/bin || exit 1\n" tell " ln -s $CABAL_REPOCACHE/downloads/cabal-plan $CABAL_DIR/bin/cabal-plan || exit 1\n" tell "}\n" tell "\n" tell "# Help\n" tell "##############################################################################\n" tell "\n" tell "show_usage() {\n" tell "cat <<EOF\n" tell "./haskell-ci.sh - build & test\n" tell "\n" tell "Usage: ./haskell-ci.sh [options]\n" tell " A script to run automated checks locally (using Docker)\n" tell "\n" tell "Available options:\n" tell " --jobs JOBS Jobs to run (default: $CFG_JOBS)\n" tell " --cabal-store-cache PATH Directory to use for cabal-store-cache\n" tell " --cabal-repo-cache PATH Directory to use for cabal-repo-cache\n" tell " --skip-cabal-update Skip cabal update (useful with --cabal-repo-cache)\n" tell " --no-skip-cabal-update\n" tell " --help Print this message\n" tell "\n" tell "EOF\n" tell "}\n" tell "\n" tell "# getopt\n" tell "#######################################################################\n" tell "\n" tell "process_cli_options() {\n" tell " while [ $# -gt 0 ]; do\n" tell " arg=$1\n" tell " case $arg in\n" tell " --help)\n" tell " show_usage\n" tell " exit\n" tell " ;;\n" tell " --jobs)\n" tell " CFG_JOBS=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-store-cache)\n" tell " CFG_CABAL_STORE_CACHE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-repo-cache)\n" tell " CFG_CABAL_REPO_CACHE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --skip-cabal-update)\n" tell " CFG_CABAL_UPDATE=false\n" tell " shift\n" tell " ;;\n" tell " --no-skip-cabal-update)\n" tell " CFG_CABAL_UPDATE=true\n" tell " shift\n" tell " ;;\n" tell " *)\n" tell " echo \"Unknown option $arg\"\n" tell " exit 1\n" tell " esac\n" tell " done\n" tell "}\n" tell "\n" tell "process_indocker_options () {\n" tell " while [ $# -gt 0 ]; do\n" tell " arg=$1\n" tell "\n" tell " case $arg in\n" tell " --ghc-version)\n" tell " GHC_VERSION=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-version)\n" tell " CABAL_VERSION=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --start-time)\n" tell " START_TIME=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-update)\n" tell " CABAL_UPDATE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " *)\n" tell " echo \"Unknown option $arg\"\n" tell " exit 1\n" tell " esac\n" tell " done\n" tell "}\n" tell "\n" tell "if $INDOCKER; then\n" tell " process_indocker_options \"$@\"\n" tell "\n" tell "else\n" tell " if [ -f \"$XDG_CONFIG_HOME/haskell-ci/bash.config\" ]; then\n" tell " process_cli_options $(cat \"$XDG_CONFIG_HOME/haskell-ci/bash.config\")\n" tell " fi\n" tell "\n" tell " process_cli_options \"$@\"\n" tell "\n" tell " put_info \"jobs: $CFG_JOBS\"\n" tell " put_info \"cabal-store-cache: $CFG_CABAL_STORE_CACHE\"\n" tell " put_info \"cabal-repo-cache: $CFG_CABAL_REPO_CACHE\"\n" tell " put_info \"cabal-update: $CFG_CABAL_UPDATE\"\n" tell "fi\n" tell "\n" tell "# Constants\n" tell "##############################################################################\n" tell "\n" tell "SRCDIR=/hsci/src\n" tell "BUILDDIR=/hsci/build\n" tell "CABAL_DIR=\"$BUILDDIR/cabal\"\n" tell "CABAL_REPOCACHE=/hsci/cabal-repocache\n" tell "CABAL_STOREDIR=/hsci/store\n" tell "\n" tell "# Docker invoke\n" tell "##############################################################################\n" tell "\n" tell "# if cache directory is specified, use it.\n" tell "# Otherwise use another tmpfs host\n" tell "if [ -z \"$CFG_CABAL_STORE_CACHE\" ]; then\n" tell " CABALSTOREARG=\"--tmpfs $CABAL_STOREDIR:exec\"\n" tell "else\n" tell " CABALSTOREARG=\"--volume $CFG_CABAL_STORE_CACHE:$CABAL_STOREDIR\"\n" tell "fi\n" tell "\n" tell "if [ -z \"$CFG_CABAL_REPO_CACHE\" ]; then\n" tell " CABALREPOARG=\"--tmpfs $CABAL_REPOCACHE:exec\"\n" tell "else\n" tell " CABALREPOARG=\"--volume $CFG_CABAL_REPO_CACHE:$CABAL_REPOCACHE\"\n" tell "fi\n" tell "\n" tell "echo_docker_cmd() {\n" tell " local GHCVER=$1\n" tell "\n" tell " # TODO: mount /hsci/src:ro (readonly)\n" tell " echo docker run \\\n" tell " --tty \\\n" tell " --interactive \\\n" tell " --rm \\\n" tell " --label haskell-ci \\\n" tell " --volume \"$(pwd):/hsci/src\" \\\n" tell " $CABALSTOREARG \\\n" tell " $CABALREPOARG \\\n" tell " --tmpfs /tmp:exec \\\n" tell " --tmpfs /hsci/build:exec \\\n" tell " --workdir /hsci/build \\\n" tell " \"phadej/ghc:$GHCVER-bionic\" \\\n" tell " \"/bin/bash\" \"/hsci/src/$SCRIPT_NAME\" indocker \\\n" tell " --ghc-version \"$GHCVER\" \\\n" tell " --cabal-update \"$CFG_CABAL_UPDATE\" \\\n" tell " --start-time \"$START_TIME\"\n" tell "}\n" tell "\n" tell "# if we are not in docker, loop through jobs\n" tell "if ! $INDOCKER; then\n" tell " for JOB in $CFG_JOBS; do\n" tell " put_info \"Running in docker: $JOB\"\n" tell " run_cmd $(echo_docker_cmd \"$JOB\")\n" tell " done\n" tell "\n" tell " run_cmd echo \"ALL OK\"\n" tell " exit 0\n" tell "fi\n" tell "\n" tell "# Otherwise we are in docker, and the rest of script executes\n" tell "put_info \"In docker\"\n" tell "\n" tell "# Environment\n" tell "##############################################################################\n" tell "\n" tell "GHCDIR=/opt/ghc/$GHC_VERSION\n" tell "\n" tell "HC=$GHCDIR/bin/ghc\n" tell "HCPKG=$GHCDIR/bin/ghc-pkg\n" tell "HADDOCK=$GHCDIR/bin/haddock\n" tell "\n" tell "CABAL=/opt/cabal/$CABAL_VERSION/bin/cabal\n" tell "\n" tell "CABAL=\"$CABAL -vnormal+nowrap\"\n" tell "\n" tell "export CABAL_DIR\n" tell "export CABAL_CONFIG=\"$BUILDDIR/cabal/config\"\n" tell "\n" tell "PATH=\"$CABAL_DIR/bin:$PATH\"\n" tell "\n" tell "# HCNUMVER\n" tell "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')\n" tell "GHCJSARITH=0\n" tell "\n" tell "put_info \"HCNUMVER: $HCNUMVER\"\n" tell "\n" tell "# Args for shorter/nicer commands\n" tell "if [ " tell (zTestsCond z_root) tell " -ne 0 ] ; then ARG_TESTS=--enable-tests; else ARG_TESTS=--disable-tests; fi\n" tell "if [ " tell (zBenchCond z_root) tell " -ne 0 ] ; then ARG_BENCH=--enable-benchmarks; else ARG_BENCH=--disable-benchmarks; fi\n" tell "ARG_COMPILER=\"--ghc --with-compiler=$HC\"\n" tell "\n" tell "put_info \"tests/benchmarks: $ARG_TESTS $ARG_BENCH\"\n" tell "\n" tell "# Apt dependencies\n" tell "##############################################################################\n" tell "\n" if (zNotNull z_root (zApt z_root)) then do tell "run_cmd apt-get update\n" tell "run_cmd apt-get install -y --no-install-recommends " tell (zUnwords z_root (zApt z_root)) tell "\n" return () else do return () tell "\n" tell "# Cabal config\n" tell "##############################################################################\n" tell "\n" tell "mkdir -p $BUILDDIR/cabal\n" tell "\n" tell "cat > $BUILDDIR/cabal/config <<EOF\n" tell "remote-build-reporting: anonymous\n" tell "write-ghc-environment-files: always\n" tell "remote-repo-cache: $CABAL_REPOCACHE\n" tell "logs-dir: $CABAL_DIR/logs\n" tell "world-file: $CABAL_DIR/world\n" tell "extra-prog-path: $CABAL_DIR/bin\n" tell "symlink-bindir: $CABAL_DIR/bin\n" tell "installdir: $CABAL_DIR/bin\n" tell "build-summary: $CABAL_DIR/logs/build.log\n" tell "store-dir: $CABAL_STOREDIR\n" tell "install-dirs user\n" tell " prefix: $CABAL_DIR\n" tell "repository hackage.haskell.org\n" tell " url: http://hackage.haskell.org/\n" tell "EOF\n" tell "\n" tell "if $HEADHACKAGE; then\n" tell " put_error \"head.hackage is not implemented\"\n" tell " exit 1\n" tell "fi\n" tell "\n" tell "run_cmd cat \"$BUILDDIR/cabal/config\"\n" tell "\n" tell "# Version\n" tell "##############################################################################\n" tell "\n" tell "put_info \"Versions\"\n" tell "run_cmd $HC --version\n" tell "run_cmd_unchecked $HC --print-project-git-commit-id\n" tell "run_cmd $CABAL --version\n" tell "\n" tell "# Build script\n" tell "##############################################################################\n" tell "\n" tell "# update cabal index\n" tell "if $CABAL_UPDATE; then\n" tell " put_info \"Updating Hackage index\"\n" tell " run_cmd $CABAL v2-update -v\n" tell "fi\n" tell "\n" tell "# install cabal-plan\n" tell "install_cabalplan\n" tell "run_cmd cabal-plan --version\n" tell "\n" forM_ (zBlocks z_root) $ \z_var0_block -> do tell z_var0_block tell "\n" tell "\n" tell "# Done\n" tell "run_cmd echo OK\n"
16,626
render z_root = execWriter $ do tell "#!/bin/bash\n" tell "# shellcheck disable=SC2086,SC2016,SC2046\n" tell "# REGENDATA " tell (zRegendata z_root) tell "\n" tell "\n" tell "set -o pipefail\n" tell "\n" tell "# Mode\n" tell "##############################################################################\n" tell "\n" tell "if [ \"$1\" = \"indocker\" ]; then\n" tell " INDOCKER=true\n" tell " shift\n" tell "else\n" tell " INDOCKER=false\n" tell "fi\n" tell "\n" tell "# Run configuration\n" tell "##############################################################################\n" tell "\n" tell "CFG_CABAL_STORE_CACHE=\"\"\n" tell "CFG_CABAL_REPO_CACHE=\"\"\n" tell "CFG_JOBS=\"" tell (zUnwords z_root (zJobs z_root)) tell "\"\n" tell "CFG_CABAL_UPDATE=false\n" tell "\n" tell "SCRIPT_NAME=$(basename \"$0\")\n" tell "START_TIME=\"$(date +'%s')\"\n" tell "\n" tell "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}\n" tell "\n" tell "# Job configuration\n" tell "##############################################################################\n" tell "\n" tell "GHC_VERSION=\"non-existing\"\n" tell "CABAL_VERSION=3.2\n" tell "HEADHACKAGE=false\n" tell "\n" tell "# Locale\n" tell "##############################################################################\n" tell "\n" tell "export LC_ALL=C.UTF-8\n" tell "\n" tell "# Utilities\n" tell "##############################################################################\n" tell "\n" tell "SGR_RED='\\033[1;31m'\n" tell "SGR_GREEN='\\033[1;32m'\n" tell "SGR_BLUE='\\033[1;34m'\n" tell "SGR_CYAN='\\033[1;96m'\n" tell "SGR_RESET='\\033[0m' # No Color\n" tell "\n" tell "put_info() {\n" tell " printf \"$SGR_CYAN%s$SGR_RESET\\n\" \"### $*\"\n" tell "}\n" tell "\n" tell "put_error() {\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! $*\"\n" tell "}\n" tell "\n" tell "run_cmd() {\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " if $INDOCKER; then\n" tell " PROMPT=\"$(pwd) >>>\"\n" tell " else\n" tell " PROMPT=\">>>\"\n" tell " fi\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell "\n" tell " local start_time end_time cmd_duration total_duration\n" tell " start_time=$(date +'%s')\n" tell "\n" tell " \"$@\"\n" tell " local RET=$?\n" tell "\n" tell " end_time=$(date +'%s')\n" tell " cmd_duration=$((end_time - start_time))\n" tell " total_duration=$((end_time - START_TIME))\n" tell "\n" tell " cmd_min=$((cmd_duration / 60))\n" tell " cmd_sec=$((cmd_duration % 60))\n" tell "\n" tell " total_min=$((total_duration / 60))\n" tell " total_sec=$((total_duration % 60))\n" tell "\n" tell " if [ $RET -eq 0 ]; then\n" tell " printf \"$SGR_GREEN%s$SGR_RESET (%dm%02ds; %dm%02ds)\\n\" \"<<< $PRETTYCMD\" \"$cmd_min\" \"$cmd_sec\" \"$total_min\" \"$total_sec\"\n" tell " else\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! $PRETTYCMD\"\n" tell " exit 1\n" tell " fi\n" tell "}\n" tell "\n" tell "run_cmd_if() {\n" tell " local COND=$1\n" tell " shift\n" tell "\n" tell " if [ $COND -eq 1 ]; then\n" tell " run_cmd \"$@\"\n" tell " else\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " PROMPT=\"$(pwd) (skipping) >>>\"\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell " fi\n" tell "}\n" tell "\n" tell "run_cmd_unchecked() {\n" tell " local PRETTYCMD=\"$*\"\n" tell " local PROMPT\n" tell " if $INDOCKER; then\n" tell " PROMPT=\"$(pwd) >>>\"\n" tell " else\n" tell " PROMPT=\">>>\"\n" tell " fi\n" tell "\n" tell " printf \"$SGR_BLUE%s %s$SGR_RESET\\n\" \"$PROMPT\" \"$PRETTYCMD\"\n" tell "\n" tell " local start_time end_time cmd_duration total_duration cmd_min cmd_sec total_min total_sec\n" tell " start_time=$(date +'%s')\n" tell "\n" tell " \"$@\"\n" tell "\n" tell " end_time=$(date +'%s')\n" tell " cmd_duration=$((end_time - start_time))\n" tell " total_duration=$((end_time - START_TIME))\n" tell "\n" tell " cmd_min=$((cmd_duration / 60))\n" tell " cmd_sec=$((cmd_duration % 60))\n" tell "\n" tell " total_min=$((total_duration / 60))\n" tell " total_sec=$((total_duration % 60))\n" tell "\n" tell " printf \"$SGR_GREEN%s$SGR_RESET (%dm%02ds; %dm%02ds)\\n\" \"<<< $PRETTYCMD\" \"$cmd_min\" \"$cmd_sec\" \"$total_min\" \"$total_sec\"\n" tell "}\n" tell "\n" tell "change_dir() {\n" tell " local DIR=$1\n" tell " if [ -d \"$DIR\" ]; then\n" tell " printf \"$SGR_BLUE%s$SGR_RESET\\n\" \"change directory to $DIR\"\n" tell " cd \"$DIR\" || exit 1\n" tell " else\n" tell " printf \"$SGR_RED%s$SGR_RESET\\n\" \"!!! cd $DIR\"\n" tell " exit 1\n" tell " fi\n" tell "}\n" tell "\n" tell "change_dir_if() {\n" tell " local COND=$1\n" tell " local DIR=$2\n" tell "\n" tell " if [ $COND -ne 0 ]; then\n" tell " change_dir \"$DIR\"\n" tell " fi\n" tell "}\n" tell "\n" tell "echo_to() {\n" tell " local DEST=$1\n" tell " local CONTENTS=$2\n" tell "\n" tell " echo \"$CONTENTS\" >> \"$DEST\"\n" tell "}\n" tell "\n" tell "echo_if_to() {\n" tell " local COND=$1\n" tell " local DEST=$2\n" tell " local CONTENTS=$3\n" tell "\n" tell " if [ $COND -ne 0 ]; then\n" tell " echo_to \"$DEST\" \"$CONTENTS\"\n" tell " fi\n" tell "}\n" tell "\n" tell "install_cabalplan() {\n" tell " put_info \"installing cabal-plan\"\n" tell "\n" tell " if [ ! -e $CABAL_REPOCACHE/downloads/cabal-plan ]; then\n" tell " curl -L https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > /tmp/cabal-plan.xz || exit 1\n" tell " (cd /tmp && echo \"de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz\" | sha256sum -c -)|| exit 1\n" tell " mkdir -p $CABAL_REPOCACHE/downloads\n" tell " xz -d < /tmp/cabal-plan.xz > $CABAL_REPOCACHE/downloads/cabal-plan || exit 1\n" tell " chmod a+x $CABAL_REPOCACHE/downloads/cabal-plan || exit 1\n" tell " fi\n" tell "\n" tell " mkdir -p $CABAL_DIR/bin || exit 1\n" tell " ln -s $CABAL_REPOCACHE/downloads/cabal-plan $CABAL_DIR/bin/cabal-plan || exit 1\n" tell "}\n" tell "\n" tell "# Help\n" tell "##############################################################################\n" tell "\n" tell "show_usage() {\n" tell "cat <<EOF\n" tell "./haskell-ci.sh - build & test\n" tell "\n" tell "Usage: ./haskell-ci.sh [options]\n" tell " A script to run automated checks locally (using Docker)\n" tell "\n" tell "Available options:\n" tell " --jobs JOBS Jobs to run (default: $CFG_JOBS)\n" tell " --cabal-store-cache PATH Directory to use for cabal-store-cache\n" tell " --cabal-repo-cache PATH Directory to use for cabal-repo-cache\n" tell " --skip-cabal-update Skip cabal update (useful with --cabal-repo-cache)\n" tell " --no-skip-cabal-update\n" tell " --help Print this message\n" tell "\n" tell "EOF\n" tell "}\n" tell "\n" tell "# getopt\n" tell "#######################################################################\n" tell "\n" tell "process_cli_options() {\n" tell " while [ $# -gt 0 ]; do\n" tell " arg=$1\n" tell " case $arg in\n" tell " --help)\n" tell " show_usage\n" tell " exit\n" tell " ;;\n" tell " --jobs)\n" tell " CFG_JOBS=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-store-cache)\n" tell " CFG_CABAL_STORE_CACHE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-repo-cache)\n" tell " CFG_CABAL_REPO_CACHE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --skip-cabal-update)\n" tell " CFG_CABAL_UPDATE=false\n" tell " shift\n" tell " ;;\n" tell " --no-skip-cabal-update)\n" tell " CFG_CABAL_UPDATE=true\n" tell " shift\n" tell " ;;\n" tell " *)\n" tell " echo \"Unknown option $arg\"\n" tell " exit 1\n" tell " esac\n" tell " done\n" tell "}\n" tell "\n" tell "process_indocker_options () {\n" tell " while [ $# -gt 0 ]; do\n" tell " arg=$1\n" tell "\n" tell " case $arg in\n" tell " --ghc-version)\n" tell " GHC_VERSION=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-version)\n" tell " CABAL_VERSION=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --start-time)\n" tell " START_TIME=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " --cabal-update)\n" tell " CABAL_UPDATE=$2\n" tell " shift\n" tell " shift\n" tell " ;;\n" tell " *)\n" tell " echo \"Unknown option $arg\"\n" tell " exit 1\n" tell " esac\n" tell " done\n" tell "}\n" tell "\n" tell "if $INDOCKER; then\n" tell " process_indocker_options \"$@\"\n" tell "\n" tell "else\n" tell " if [ -f \"$XDG_CONFIG_HOME/haskell-ci/bash.config\" ]; then\n" tell " process_cli_options $(cat \"$XDG_CONFIG_HOME/haskell-ci/bash.config\")\n" tell " fi\n" tell "\n" tell " process_cli_options \"$@\"\n" tell "\n" tell " put_info \"jobs: $CFG_JOBS\"\n" tell " put_info \"cabal-store-cache: $CFG_CABAL_STORE_CACHE\"\n" tell " put_info \"cabal-repo-cache: $CFG_CABAL_REPO_CACHE\"\n" tell " put_info \"cabal-update: $CFG_CABAL_UPDATE\"\n" tell "fi\n" tell "\n" tell "# Constants\n" tell "##############################################################################\n" tell "\n" tell "SRCDIR=/hsci/src\n" tell "BUILDDIR=/hsci/build\n" tell "CABAL_DIR=\"$BUILDDIR/cabal\"\n" tell "CABAL_REPOCACHE=/hsci/cabal-repocache\n" tell "CABAL_STOREDIR=/hsci/store\n" tell "\n" tell "# Docker invoke\n" tell "##############################################################################\n" tell "\n" tell "# if cache directory is specified, use it.\n" tell "# Otherwise use another tmpfs host\n" tell "if [ -z \"$CFG_CABAL_STORE_CACHE\" ]; then\n" tell " CABALSTOREARG=\"--tmpfs $CABAL_STOREDIR:exec\"\n" tell "else\n" tell " CABALSTOREARG=\"--volume $CFG_CABAL_STORE_CACHE:$CABAL_STOREDIR\"\n" tell "fi\n" tell "\n" tell "if [ -z \"$CFG_CABAL_REPO_CACHE\" ]; then\n" tell " CABALREPOARG=\"--tmpfs $CABAL_REPOCACHE:exec\"\n" tell "else\n" tell " CABALREPOARG=\"--volume $CFG_CABAL_REPO_CACHE:$CABAL_REPOCACHE\"\n" tell "fi\n" tell "\n" tell "echo_docker_cmd() {\n" tell " local GHCVER=$1\n" tell "\n" tell " # TODO: mount /hsci/src:ro (readonly)\n" tell " echo docker run \\\n" tell " --tty \\\n" tell " --interactive \\\n" tell " --rm \\\n" tell " --label haskell-ci \\\n" tell " --volume \"$(pwd):/hsci/src\" \\\n" tell " $CABALSTOREARG \\\n" tell " $CABALREPOARG \\\n" tell " --tmpfs /tmp:exec \\\n" tell " --tmpfs /hsci/build:exec \\\n" tell " --workdir /hsci/build \\\n" tell " \"phadej/ghc:$GHCVER-bionic\" \\\n" tell " \"/bin/bash\" \"/hsci/src/$SCRIPT_NAME\" indocker \\\n" tell " --ghc-version \"$GHCVER\" \\\n" tell " --cabal-update \"$CFG_CABAL_UPDATE\" \\\n" tell " --start-time \"$START_TIME\"\n" tell "}\n" tell "\n" tell "# if we are not in docker, loop through jobs\n" tell "if ! $INDOCKER; then\n" tell " for JOB in $CFG_JOBS; do\n" tell " put_info \"Running in docker: $JOB\"\n" tell " run_cmd $(echo_docker_cmd \"$JOB\")\n" tell " done\n" tell "\n" tell " run_cmd echo \"ALL OK\"\n" tell " exit 0\n" tell "fi\n" tell "\n" tell "# Otherwise we are in docker, and the rest of script executes\n" tell "put_info \"In docker\"\n" tell "\n" tell "# Environment\n" tell "##############################################################################\n" tell "\n" tell "GHCDIR=/opt/ghc/$GHC_VERSION\n" tell "\n" tell "HC=$GHCDIR/bin/ghc\n" tell "HCPKG=$GHCDIR/bin/ghc-pkg\n" tell "HADDOCK=$GHCDIR/bin/haddock\n" tell "\n" tell "CABAL=/opt/cabal/$CABAL_VERSION/bin/cabal\n" tell "\n" tell "CABAL=\"$CABAL -vnormal+nowrap\"\n" tell "\n" tell "export CABAL_DIR\n" tell "export CABAL_CONFIG=\"$BUILDDIR/cabal/config\"\n" tell "\n" tell "PATH=\"$CABAL_DIR/bin:$PATH\"\n" tell "\n" tell "# HCNUMVER\n" tell "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')\n" tell "GHCJSARITH=0\n" tell "\n" tell "put_info \"HCNUMVER: $HCNUMVER\"\n" tell "\n" tell "# Args for shorter/nicer commands\n" tell "if [ " tell (zTestsCond z_root) tell " -ne 0 ] ; then ARG_TESTS=--enable-tests; else ARG_TESTS=--disable-tests; fi\n" tell "if [ " tell (zBenchCond z_root) tell " -ne 0 ] ; then ARG_BENCH=--enable-benchmarks; else ARG_BENCH=--disable-benchmarks; fi\n" tell "ARG_COMPILER=\"--ghc --with-compiler=$HC\"\n" tell "\n" tell "put_info \"tests/benchmarks: $ARG_TESTS $ARG_BENCH\"\n" tell "\n" tell "# Apt dependencies\n" tell "##############################################################################\n" tell "\n" if (zNotNull z_root (zApt z_root)) then do tell "run_cmd apt-get update\n" tell "run_cmd apt-get install -y --no-install-recommends " tell (zUnwords z_root (zApt z_root)) tell "\n" return () else do return () tell "\n" tell "# Cabal config\n" tell "##############################################################################\n" tell "\n" tell "mkdir -p $BUILDDIR/cabal\n" tell "\n" tell "cat > $BUILDDIR/cabal/config <<EOF\n" tell "remote-build-reporting: anonymous\n" tell "write-ghc-environment-files: always\n" tell "remote-repo-cache: $CABAL_REPOCACHE\n" tell "logs-dir: $CABAL_DIR/logs\n" tell "world-file: $CABAL_DIR/world\n" tell "extra-prog-path: $CABAL_DIR/bin\n" tell "symlink-bindir: $CABAL_DIR/bin\n" tell "installdir: $CABAL_DIR/bin\n" tell "build-summary: $CABAL_DIR/logs/build.log\n" tell "store-dir: $CABAL_STOREDIR\n" tell "install-dirs user\n" tell " prefix: $CABAL_DIR\n" tell "repository hackage.haskell.org\n" tell " url: http://hackage.haskell.org/\n" tell "EOF\n" tell "\n" tell "if $HEADHACKAGE; then\n" tell " put_error \"head.hackage is not implemented\"\n" tell " exit 1\n" tell "fi\n" tell "\n" tell "run_cmd cat \"$BUILDDIR/cabal/config\"\n" tell "\n" tell "# Version\n" tell "##############################################################################\n" tell "\n" tell "put_info \"Versions\"\n" tell "run_cmd $HC --version\n" tell "run_cmd_unchecked $HC --print-project-git-commit-id\n" tell "run_cmd $CABAL --version\n" tell "\n" tell "# Build script\n" tell "##############################################################################\n" tell "\n" tell "# update cabal index\n" tell "if $CABAL_UPDATE; then\n" tell " put_info \"Updating Hackage index\"\n" tell " run_cmd $CABAL v2-update -v\n" tell "fi\n" tell "\n" tell "# install cabal-plan\n" tell "install_cabalplan\n" tell "run_cmd cabal-plan --version\n" tell "\n" forM_ (zBlocks z_root) $ \z_var0_block -> do tell z_var0_block tell "\n" tell "\n" tell "# Done\n" tell "run_cmd echo OK\n"
16,604
true
true
0
16
4,172
2,916
994
1,922
null
null