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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mlite/hLLVM | src/Llvm/Asm/Simplification.hs | bsd-3-clause | rnToplevel1 :: Toplevel -> (Toplevel, M.Map GlobalId LabelNumbers)
rnToplevel1 (ToplevelDefine (TlDefine fp bs)) =
let ((fp2, bs2), mys) = S.runState (do { fpa <- rnDefFunctionPrototype fp
; bsa <- S.mapM rnBlock bs
; return (fpa, bsa)
}
) (MyState 0 (show fp) St.empty St.empty St.empty St.empty)
labelNumbers = LabelNumbers (_implicitLabelNums mys) (_explicitLabelNums mys) (_explicitLabelDqNums mys)
in ((ToplevelDefine (TlDefine fp2 bs2)), M.insert (getGlobalId fp) labelNumbers M.empty) | 662 | rnToplevel1 :: Toplevel -> (Toplevel, M.Map GlobalId LabelNumbers)
rnToplevel1 (ToplevelDefine (TlDefine fp bs)) =
let ((fp2, bs2), mys) = S.runState (do { fpa <- rnDefFunctionPrototype fp
; bsa <- S.mapM rnBlock bs
; return (fpa, bsa)
}
) (MyState 0 (show fp) St.empty St.empty St.empty St.empty)
labelNumbers = LabelNumbers (_implicitLabelNums mys) (_explicitLabelNums mys) (_explicitLabelDqNums mys)
in ((ToplevelDefine (TlDefine fp2 bs2)), M.insert (getGlobalId fp) labelNumbers M.empty) | 662 | rnToplevel1 (ToplevelDefine (TlDefine fp bs)) =
let ((fp2, bs2), mys) = S.runState (do { fpa <- rnDefFunctionPrototype fp
; bsa <- S.mapM rnBlock bs
; return (fpa, bsa)
}
) (MyState 0 (show fp) St.empty St.empty St.empty St.empty)
labelNumbers = LabelNumbers (_implicitLabelNums mys) (_explicitLabelNums mys) (_explicitLabelDqNums mys)
in ((ToplevelDefine (TlDefine fp2 bs2)), M.insert (getGlobalId fp) labelNumbers M.empty) | 595 | false | true | 0 | 15 | 235 | 222 | 111 | 111 | null | null |
riwsky/wiwinwlh | src/parsec_operators.hs | mit | letin :: Parser Expr
letin = do
reserved "let"
x <- identifier
reservedOp "="
e1 <- expr
reserved "in"
e2 <- expr
return (Let x e1 e2) | 148 | letin :: Parser Expr
letin = do
reserved "let"
x <- identifier
reservedOp "="
e1 <- expr
reserved "in"
e2 <- expr
return (Let x e1 e2) | 148 | letin = do
reserved "let"
x <- identifier
reservedOp "="
e1 <- expr
reserved "in"
e2 <- expr
return (Let x e1 e2) | 127 | false | true | 0 | 10 | 40 | 75 | 30 | 45 | null | null |
m0ar/safe-streaming | src/Streaming/Prelude.hs | bsd-3-clause | -- {-| Streams the number of seconds from the beginning of action
--
-- Thus, to mark times of user input we might write something like:
--
-- >>> S.toList $ S.take 3 $ S.zip S.seconds S.stdinLn
-- a<Enter>
-- b<Enter>
-- c<Enter>
-- [(0.0,"a"),(1.088711,"b"),(3.7289649999999996,"c")] :> ()
--
-- To restrict user input to some number of seconds, we might write:
--
-- >>> S.toList $ S.map fst $ S.zip S.stdinLn $ S.takeWhile (< 3) S.seconds
-- one<Enter>
-- two<Enter>
-- three<Enter>
-- four<Enter>
-- five<Enter>
-- ["one","two","three","four","five"] :> ()
--
-- This of course does not interrupt an action that has already begun.
--
-- -}
--
-- seconds :: Stream (Of Double) IO r
-- seconds = do
-- e <- lift $ next preseconds
-- case e of
-- Left r -> return r
-- Right (t, rest) -> do
-- yield 0
-- map (subtract t) rest
-- where
-- preseconds :: Stream (Of Double) IO r
-- preseconds = do
-- utc <- liftIO getCurrentTime
-- map ((/1000000000) . nice utc) (repeatM getCurrentTime)
-- where
-- nice u u' = fromIntegral $ truncate (1000000000 * diffUTCTime u' u)
-- ---------------
-- sequence
-- ---------------
{-| Like the 'Data.List.sequence' but streaming. The result type is a
stream of a\'s, /but is not accumulated/; the effects of the elements
of the original stream are interleaved in the resulting stream. Compare:
> sequence :: Monad m => [m a] -> m [a]
> sequence :: Monad m => Stream (Of (m a)) m r -> Stream (Of a) m r
This obeys the rule
-}
sequence :: LMonad m => Stream (LOf (m a)) m r -> Stream (LOf a) m r
sequence (Return r) = Return r | 1,663 | sequence :: LMonad m => Stream (LOf (m a)) m r -> Stream (LOf a) m r
sequence (Return r) = Return r | 99 | sequence (Return r) = Return r | 30 | true | true | 0 | 11 | 390 | 109 | 74 | 35 | null | null |
lilac/ivy-web | src/Web/Ivy/Routes.hs | bsd-3-clause | parseUrl = parse | 16 | parseUrl = parse | 16 | parseUrl = parse | 16 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
bitemyapp/morfette | src/GramLab/Morfette/Features/Common.hs | bsd-2-clause | mapNum f (Num n) = Num (f n) | 28 | mapNum f (Num n) = Num (f n) | 28 | mapNum f (Num n) = Num (f n) | 28 | false | false | 0 | 6 | 7 | 28 | 12 | 16 | null | null |
lukasmartinelli/hadolint | test/DL3051.hs | gpl-3.0 | tests :: SpecWith ()
tests = do
let ?rulesConfig = Hadolint.Process.RulesConfig [] (Map.fromList [("emptylabel", Rule.RawText)]) False
describe "DL3051 - Label `<label>` is empty." $ do
it "not ok with label empty" $ do
ruleCatches "DL3051" "LABEL emptylabel=\"\""
onBuildRuleCatches "DL3051" "LABEL emptylabel=\"\""
it "ok with label not empty" $ do
ruleCatchesNot "DL3051" "LABEL emptylabel=\"foo\""
onBuildRuleCatchesNot "DL3051" "LABEL emptylabel=\"bar\""
it "ok with other label empty" $ do
ruleCatchesNot "DL3051" "LABEL other=\"\""
onBuildRuleCatchesNot "DL3051" "LABEL other=\"\"" | 640 | tests :: SpecWith ()
tests = do
let ?rulesConfig = Hadolint.Process.RulesConfig [] (Map.fromList [("emptylabel", Rule.RawText)]) False
describe "DL3051 - Label `<label>` is empty." $ do
it "not ok with label empty" $ do
ruleCatches "DL3051" "LABEL emptylabel=\"\""
onBuildRuleCatches "DL3051" "LABEL emptylabel=\"\""
it "ok with label not empty" $ do
ruleCatchesNot "DL3051" "LABEL emptylabel=\"foo\""
onBuildRuleCatchesNot "DL3051" "LABEL emptylabel=\"bar\""
it "ok with other label empty" $ do
ruleCatchesNot "DL3051" "LABEL other=\"\""
onBuildRuleCatchesNot "DL3051" "LABEL other=\"\"" | 640 | tests = do
let ?rulesConfig = Hadolint.Process.RulesConfig [] (Map.fromList [("emptylabel", Rule.RawText)]) False
describe "DL3051 - Label `<label>` is empty." $ do
it "not ok with label empty" $ do
ruleCatches "DL3051" "LABEL emptylabel=\"\""
onBuildRuleCatches "DL3051" "LABEL emptylabel=\"\""
it "ok with label not empty" $ do
ruleCatchesNot "DL3051" "LABEL emptylabel=\"foo\""
onBuildRuleCatchesNot "DL3051" "LABEL emptylabel=\"bar\""
it "ok with other label empty" $ do
ruleCatchesNot "DL3051" "LABEL other=\"\""
onBuildRuleCatchesNot "DL3051" "LABEL other=\"\"" | 619 | false | true | 1 | 15 | 124 | 148 | 63 | 85 | null | null |
Paow/encore | src/back/CodeGen/Type.hs | bsd-3-clause | encoreArgTTag (Embed _) = Nam "p" | 39 | encoreArgTTag (Embed _) = Nam "p" | 39 | encoreArgTTag (Embed _) = Nam "p" | 39 | false | false | 0 | 6 | 11 | 19 | 8 | 11 | null | null |
rethab/combinatorrent | src/Combinatorrent.hs | bsd-2-clause | GpgFingerprint _ ~= GpgFingerprint _ = True | 43 | GpgFingerprint _ ~= GpgFingerprint _ = True | 43 | GpgFingerprint _ ~= GpgFingerprint _ = True | 43 | false | false | 0 | 6 | 6 | 18 | 7 | 11 | null | null |
MattWis/smallEmail | smallEmail/gmailMonitor.hs | mit | mailList = Address Nothing "olinemailbot@gmail.com" | 51 | mailList = Address Nothing "olinemailbot@gmail.com" | 51 | mailList = Address Nothing "olinemailbot@gmail.com" | 51 | false | false | 1 | 5 | 4 | 15 | 5 | 10 | null | null |
tpsinnem/Idris-dev | src/Idris/IBC.hs | bsd-3-clause | writePkgIndex :: FilePath -> Idris ()
writePkgIndex f
= do i <- getIState
let imps = map (\ (x, y) -> (True, x)) $ idris_imported i
logIBC 1 $ "Writing package index " ++ show f ++ " including\n" ++
show (map snd imps)
resetNameIdx
let ibcf = initIBC { ibc_imports = imps }
idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
writeArchive f ibcf
logIBC 1 "Written")
(\c -> do logIBC 1 $ "Failed " ++ pshow i c)
return () | 572 | writePkgIndex :: FilePath -> Idris ()
writePkgIndex f
= do i <- getIState
let imps = map (\ (x, y) -> (True, x)) $ idris_imported i
logIBC 1 $ "Writing package index " ++ show f ++ " including\n" ++
show (map snd imps)
resetNameIdx
let ibcf = initIBC { ibc_imports = imps }
idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
writeArchive f ibcf
logIBC 1 "Written")
(\c -> do logIBC 1 $ "Failed " ++ pshow i c)
return () | 572 | writePkgIndex f
= do i <- getIState
let imps = map (\ (x, y) -> (True, x)) $ idris_imported i
logIBC 1 $ "Writing package index " ++ show f ++ " including\n" ++
show (map snd imps)
resetNameIdx
let ibcf = initIBC { ibc_imports = imps }
idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
writeArchive f ibcf
logIBC 1 "Written")
(\c -> do logIBC 1 $ "Failed " ++ pshow i c)
return () | 534 | false | true | 0 | 15 | 215 | 210 | 97 | 113 | null | null |
rybye/blog | src/Site.hs | mit | handleLogout :: Handler App (AuthManager App) ()
handleLogout = logout >> redirect "/" | 86 | handleLogout :: Handler App (AuthManager App) ()
handleLogout = logout >> redirect "/" | 86 | handleLogout = logout >> redirect "/" | 37 | false | true | 0 | 7 | 12 | 33 | 16 | 17 | null | null |
phischu/fragnix | tests/packages/scotty/Control.Concurrent.STM.TBQueue.hs | bsd-3-clause | newTBQueueIO :: Int -> IO (TBQueue a)
newTBQueueIO size = do
read <- newTVarIO []
write <- newTVarIO []
rsize <- newTVarIO 0
wsize <- newTVarIO size
return (TBQueue rsize read wsize write)
-- |Write a value to a 'TBQueue'; blocks if the queue is full. | 263 | newTBQueueIO :: Int -> IO (TBQueue a)
newTBQueueIO size = do
read <- newTVarIO []
write <- newTVarIO []
rsize <- newTVarIO 0
wsize <- newTVarIO size
return (TBQueue rsize read wsize write)
-- |Write a value to a 'TBQueue'; blocks if the queue is full. | 263 | newTBQueueIO size = do
read <- newTVarIO []
write <- newTVarIO []
rsize <- newTVarIO 0
wsize <- newTVarIO size
return (TBQueue rsize read wsize write)
-- |Write a value to a 'TBQueue'; blocks if the queue is full. | 225 | false | true | 0 | 9 | 57 | 90 | 40 | 50 | null | null |
ocharles/hackage-server | Distribution/Server/Framework/Resource.hs | bsd-3-clause | negotiateContent :: (FilterMonad Response m, ServerMonad m)
=> (Content, a) -> [(Content, a)] -> m (Content, a)
negotiateContent def available = do
when (length available > 1) $
setHeaderM "Vary" "Accept"
maccept <- getHeaderM "Accept"
case maccept of
Nothing -> return def
Just accept ->
return $ fromMaybe def $ listToMaybe $ catMaybes
[ simpleContentTypeMapping ct
>>= \f -> find (\x -> fst x == f) available
| let acceptable = parseContentAccept (BS.unpack accept)
, ct <- acceptable ]
where
-- This is rather a non-extensible hack
simpleContentTypeMapping ContentType {ctType, ctSubtype, ctParameters = []} =
case (ctType, ctSubtype) of
("text", "html") -> Just "html"
("text", "plain") -> Just "txt"
("application", "json") -> Just "json"
_ -> Nothing
simpleContentTypeMapping _ = Nothing
---------------------------------------------------------------------------- | 1,101 | negotiateContent :: (FilterMonad Response m, ServerMonad m)
=> (Content, a) -> [(Content, a)] -> m (Content, a)
negotiateContent def available = do
when (length available > 1) $
setHeaderM "Vary" "Accept"
maccept <- getHeaderM "Accept"
case maccept of
Nothing -> return def
Just accept ->
return $ fromMaybe def $ listToMaybe $ catMaybes
[ simpleContentTypeMapping ct
>>= \f -> find (\x -> fst x == f) available
| let acceptable = parseContentAccept (BS.unpack accept)
, ct <- acceptable ]
where
-- This is rather a non-extensible hack
simpleContentTypeMapping ContentType {ctType, ctSubtype, ctParameters = []} =
case (ctType, ctSubtype) of
("text", "html") -> Just "html"
("text", "plain") -> Just "txt"
("application", "json") -> Just "json"
_ -> Nothing
simpleContentTypeMapping _ = Nothing
---------------------------------------------------------------------------- | 1,101 | negotiateContent def available = do
when (length available > 1) $
setHeaderM "Vary" "Accept"
maccept <- getHeaderM "Accept"
case maccept of
Nothing -> return def
Just accept ->
return $ fromMaybe def $ listToMaybe $ catMaybes
[ simpleContentTypeMapping ct
>>= \f -> find (\x -> fst x == f) available
| let acceptable = parseContentAccept (BS.unpack accept)
, ct <- acceptable ]
where
-- This is rather a non-extensible hack
simpleContentTypeMapping ContentType {ctType, ctSubtype, ctParameters = []} =
case (ctType, ctSubtype) of
("text", "html") -> Just "html"
("text", "plain") -> Just "txt"
("application", "json") -> Just "json"
_ -> Nothing
simpleContentTypeMapping _ = Nothing
---------------------------------------------------------------------------- | 972 | false | true | 0 | 20 | 351 | 306 | 156 | 150 | null | null |
fhsjaagshs/niagra | src/Data/Niagra/Selector/Combinators.hs | mit | -- |Selects elements with a value outside a specified range.
outOfRange :: Selector
outOfRange = pseudoClass' "out-of-range" | 124 | outOfRange :: Selector
outOfRange = pseudoClass' "out-of-range" | 63 | outOfRange = pseudoClass' "out-of-range" | 40 | true | true | 0 | 5 | 16 | 15 | 8 | 7 | null | null |
ben-han-cn/hdns | Network/ZDNS/Types/RRset.hs | bsd-3-clause | getRdataDescriptor (UNKNOWNTYPE _) = [RBinary] | 46 | getRdataDescriptor (UNKNOWNTYPE _) = [RBinary] | 46 | getRdataDescriptor (UNKNOWNTYPE _) = [RBinary] | 46 | false | false | 0 | 7 | 4 | 18 | 9 | 9 | null | null |
narurien/ganeti-ceph | src/Ganeti/Query/Server.hs | gpl-2.0 | main :: MainFn () PrepResult
main _ _ (socket_path, server, cref) = do
initConfigReader id cref
let creader = readIORef cref
finally
(forever $ listener creader server)
(closeServer socket_path server) | 216 | main :: MainFn () PrepResult
main _ _ (socket_path, server, cref) = do
initConfigReader id cref
let creader = readIORef cref
finally
(forever $ listener creader server)
(closeServer socket_path server) | 216 | main _ _ (socket_path, server, cref) = do
initConfigReader id cref
let creader = readIORef cref
finally
(forever $ listener creader server)
(closeServer socket_path server) | 187 | false | true | 0 | 10 | 44 | 82 | 39 | 43 | null | null |
betaveros/bcodex | Text/Bcodex/Cx.hs | mit | showCxLeft (CxFrozen s) = [s] | 29 | showCxLeft (CxFrozen s) = [s] | 29 | showCxLeft (CxFrozen s) = [s] | 29 | false | false | 0 | 7 | 4 | 18 | 9 | 9 | null | null |
tjunier/mlgsc | test/TestIDTree.hs | mit | main = do
runTestTT tests | 28 | main = do
runTestTT tests | 28 | main = do
runTestTT tests | 28 | false | false | 1 | 8 | 7 | 16 | 5 | 11 | null | null |
iand675/uri-templater | test/Test.hs | mit | labelTests :: (Eq s, IsString s, Buildable s) => (s -> s -> Assertion) -> Assertion
labelTests (@?=) = do
[uri|X{.var:3}|] @?= "X.val"
[uri|X{.list}|] @?= "X.red,green,blue"
[uri|X{.list*}|] @?= "X.red.green.blue"
[uri|X{.keys}|] @?= "X.semi,%3B,dot,.,comma,%2C"
[uri|X{.keys*}|] @?= "X.semi=%3B.dot=..comma=%2C" | 322 | labelTests :: (Eq s, IsString s, Buildable s) => (s -> s -> Assertion) -> Assertion
labelTests (@?=) = do
[uri|X{.var:3}|] @?= "X.val"
[uri|X{.list}|] @?= "X.red,green,blue"
[uri|X{.list*}|] @?= "X.red.green.blue"
[uri|X{.keys}|] @?= "X.semi,%3B,dot,.,comma,%2C"
[uri|X{.keys*}|] @?= "X.semi=%3B.dot=..comma=%2C" | 322 | labelTests (@?=) = do
[uri|X{.var:3}|] @?= "X.val"
[uri|X{.list}|] @?= "X.red,green,blue"
[uri|X{.list*}|] @?= "X.red.green.blue"
[uri|X{.keys}|] @?= "X.semi,%3B,dot,.,comma,%2C"
[uri|X{.keys*}|] @?= "X.semi=%3B.dot=..comma=%2C" | 238 | false | true | 0 | 9 | 44 | 107 | 63 | 44 | null | null |
stu-smith/rendering-in-haskell | src/experiment05/Light.hs | mit | green :: Light
green =
Light 0.0 1.0 0.0 | 44 | green :: Light
green =
Light 0.0 1.0 0.0 | 44 | green =
Light 0.0 1.0 0.0 | 29 | false | true | 0 | 5 | 12 | 18 | 9 | 9 | null | null |
forked-upstream-packages-for-ghcjs/ghc | compiler/codeGen/StgCmmPrim.hs | bsd-3-clause | translateOp _ (VecAddOp WordVec n w) = Just (MO_V_Add n w) | 61 | translateOp _ (VecAddOp WordVec n w) = Just (MO_V_Add n w) | 61 | translateOp _ (VecAddOp WordVec n w) = Just (MO_V_Add n w) | 61 | false | false | 0 | 7 | 13 | 32 | 15 | 17 | null | null |
ezyang/ghc | libraries/base/Data/Semigroup/Internal.hs | bsd-3-clause | -- | This is a valid definition of 'stimes' for an idempotent 'Monoid'.
--
-- When @mappend x x = x@, this definition should be preferred, because it
-- works in /O(1)/ rather than /O(log n)/
stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a
stimesIdempotentMonoid n x = case compare n 0 of
LT -> errorWithoutStackTrace "stimesIdempotentMonoid: negative multiplier"
EQ -> mempty
GT -> x
-- | This is a valid definition of 'stimes' for a 'Monoid'.
--
-- Unlike the default definition of 'stimes', it is defined for 0
-- and so it should be preferred where possible. | 585 | stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a
stimesIdempotentMonoid n x = case compare n 0 of
LT -> errorWithoutStackTrace "stimesIdempotentMonoid: negative multiplier"
EQ -> mempty
GT -> x
-- | This is a valid definition of 'stimes' for a 'Monoid'.
--
-- Unlike the default definition of 'stimes', it is defined for 0
-- and so it should be preferred where possible. | 393 | stimesIdempotentMonoid n x = case compare n 0 of
LT -> errorWithoutStackTrace "stimesIdempotentMonoid: negative multiplier"
EQ -> mempty
GT -> x
-- | This is a valid definition of 'stimes' for a 'Monoid'.
--
-- Unlike the default definition of 'stimes', it is defined for 0
-- and so it should be preferred where possible. | 329 | true | true | 0 | 8 | 109 | 77 | 42 | 35 | null | null |
msakai/folkung | Haskell/Clausify.hs | mit | (l1,c1) /. (l2,c2) = (l1*c2+c1*l2,c1*c2) | 40 | (l1,c1) /. (l2,c2) = (l1*c2+c1*l2,c1*c2) | 40 | (l1,c1) /. (l2,c2) = (l1*c2+c1*l2,c1*c2) | 40 | false | false | 0 | 8 | 4 | 46 | 25 | 21 | null | null |
begriffs/hasql-postgres | library/Hasql/Postgres/ErrorCode.hs | mit | -- * Class 38 — External Routine Exception
-------------------------
external_routine_exception :: ErrorCode = "38000" | 145 | external_routine_exception :: ErrorCode = "38000" | 75 | external_routine_exception :: ErrorCode = "38000" | 75 | true | false | 0 | 5 | 40 | 13 | 7 | 6 | null | null |
urbanslug/ghc | compiler/cmm/CLabel.hs | bsd-3-clause | toEntryLbl l = pprPanic "toEntryLbl" (ppr l) | 44 | toEntryLbl l = pprPanic "toEntryLbl" (ppr l) | 44 | toEntryLbl l = pprPanic "toEntryLbl" (ppr l) | 44 | false | false | 0 | 7 | 6 | 20 | 9 | 11 | null | null |
vTurbine/ghc | utils/ghc-cabal/Main.hs | bsd-3-clause | generate :: FilePath -> FilePath -> String -> [String] -> IO ()
generate directory distdir dll0Modules config_args
= withCurrentDirectory directory
$ do let verbosity = normal
-- XXX We shouldn't just configure with the default flags
-- XXX And this, and thus the "getPersistBuildConfig distdir" below,
-- aren't going to work when the deps aren't built yet
withArgs (["configure", "--distdir", distdir, "--ipid", "$pkg-$version"] ++ config_args)
runDefaultMain
lbi <- getPersistBuildConfig distdir
let pd0 = localPkgDescr lbi
writePersistBuildConfig distdir lbi
hooked_bi <-
if (buildType pd0 == Just Configure) || (buildType pd0 == Just Custom)
then do
maybe_infoFile <- defaultHookedPackageDesc
case maybe_infoFile of
Nothing -> return emptyHookedBuildInfo
Just infoFile -> readHookedBuildInfo verbosity infoFile
else
return emptyHookedBuildInfo
let pd = updatePackageDescription hooked_bi pd0
-- generate Paths_<pkg>.hs and cabal-macros.h
withAllComponentsInBuildOrder pd lbi $ \_ clbi ->
writeAutogenFiles verbosity pd lbi clbi
-- generate inplace-pkg-config
withLibLBI pd lbi $ \lib clbi ->
do cwd <- getCurrentDirectory
let ipid = mkUnitId (display (packageId pd))
let installedPkgInfo = inplaceInstalledPackageInfo cwd distdir
pd (AbiHash "") lib lbi clbi
final_ipi = mangleIPI directory distdir lbi $ installedPkgInfo {
Installed.installedUnitId = ipid,
Installed.compatPackageKey = display (packageId pd),
Installed.haddockHTMLs = []
}
content = Installed.showInstalledPackageInfo final_ipi ++ "\n"
writeFileAtomic (distdir </> "inplace-pkg-config") (BS.pack $ toUTF8 content)
let
comp = compiler lbi
libBiModules lib = (libBuildInfo lib, libModules lib)
exeBiModules exe = (buildInfo exe, ModuleName.main : exeModules exe)
biModuless = (map libBiModules $ libraries pd)
++ (map exeBiModules $ executables pd)
buildableBiModuless = filter isBuildable biModuless
where isBuildable (bi', _) = buildable bi'
(bi, modules) = case buildableBiModuless of
[] -> error "No buildable component found"
[biModules] -> biModules
_ -> error ("XXX ghc-cabal can't handle " ++
"more than one buildinfo yet")
-- XXX Another Just...
Just ghcProg = lookupProgram ghcProgram (withPrograms lbi)
dep_pkgs = PackageIndex.topologicalOrder (packageHacks (installedPkgs lbi))
forDeps f = concatMap f dep_pkgs
-- copied from Distribution.Simple.PreProcess.ppHsc2Hs
packageHacks = case compilerFlavor (compiler lbi) of
GHC -> hackRtsPackage
_ -> id
-- We don't link in the actual Haskell libraries of our
-- dependencies, so the -u flags in the ldOptions of the rts
-- package mean linking fails on OS X (it's ld is a tad
-- stricter than gnu ld). Thus we remove the ldOptions for
-- GHC's rts package:
hackRtsPackage index =
case PackageIndex.lookupPackageName index (PackageName "rts") of
[(_,[rts])] ->
PackageIndex.insert rts{
Installed.ldOptions = [],
Installed.libraryDirs = filter (not . ("gcc-lib" `isSuffixOf`)) (Installed.libraryDirs rts)} index
-- GHC <= 6.12 had $topdir/gcc-lib in their
-- library-dirs for the rts package, which causes
-- problems when we try to use the in-tree mingw,
-- due to accidentally picking up the incompatible
-- libraries there. So we filter out gcc-lib from
-- the RTS's library-dirs here.
_ -> error "No (or multiple) ghc rts package is registered!!"
dep_ids = map snd (externalPackageDeps lbi)
deps = map display dep_ids
dep_direct = map (fromMaybe (error "ghc-cabal: dep_keys failed")
. PackageIndex.lookupUnitId
(installedPkgs lbi)
. fst)
. externalPackageDeps
$ lbi
dep_ipids = map (display . Installed.installedUnitId) dep_direct
depLibNames
| packageKeySupported comp = dep_ipids
| otherwise = deps
depNames = map (display . packageName) dep_ids
transitive_dep_ids = map Installed.sourcePackageId dep_pkgs
transitiveDeps = map display transitive_dep_ids
transitiveDepLibNames
| packageKeySupported comp = map fixupRtsLibName transitiveDeps
| otherwise = transitiveDeps
fixupRtsLibName "rts-1.0" = "rts"
fixupRtsLibName x = x
transitiveDepNames = map (display . packageName) transitive_dep_ids
libraryDirs = forDeps Installed.libraryDirs
-- The mkLibraryRelDir function is a bit of a hack.
-- Ideally it should be handled in the makefiles instead.
mkLibraryRelDir "rts" = "rts/dist/build"
mkLibraryRelDir "ghc" = "compiler/stage2/build"
mkLibraryRelDir "Cabal" = "libraries/Cabal/Cabal/dist-install/build"
mkLibraryRelDir l = "libraries/" ++ l ++ "/dist-install/build"
libraryRelDirs = map mkLibraryRelDir transitiveDepNames
wrappedIncludeDirs <- wrap $ forDeps Installed.includeDirs
wrappedLibraryDirs <- wrap libraryDirs
let variablePrefix = directory ++ '_':distdir
mods = map display modules
otherMods = map display (otherModules bi)
allMods = mods ++ otherMods
let xs = [variablePrefix ++ "_VERSION = " ++ display (pkgVersion (package pd)),
-- TODO: move inside withLibLBI
variablePrefix ++ "_COMPONENT_ID = " ++ localCompatPackageKey lbi,
variablePrefix ++ "_MODULES = " ++ unwords mods,
variablePrefix ++ "_HIDDEN_MODULES = " ++ unwords otherMods,
variablePrefix ++ "_SYNOPSIS =" ++ (unwords $ lines $ synopsis pd),
variablePrefix ++ "_HS_SRC_DIRS = " ++ unwords (hsSourceDirs bi),
variablePrefix ++ "_DEPS = " ++ unwords deps,
variablePrefix ++ "_DEP_IPIDS = " ++ unwords dep_ipids,
variablePrefix ++ "_DEP_NAMES = " ++ unwords depNames,
variablePrefix ++ "_DEP_COMPONENT_IDS = " ++ unwords depLibNames,
variablePrefix ++ "_TRANSITIVE_DEP_NAMES = " ++ unwords transitiveDepNames,
variablePrefix ++ "_TRANSITIVE_DEP_COMPONENT_IDS = " ++ unwords transitiveDepLibNames,
variablePrefix ++ "_INCLUDE_DIRS = " ++ unwords (includeDirs bi),
variablePrefix ++ "_INCLUDES = " ++ unwords (includes bi),
variablePrefix ++ "_INSTALL_INCLUDES = " ++ unwords (installIncludes bi),
variablePrefix ++ "_EXTRA_LIBRARIES = " ++ unwords (extraLibs bi),
variablePrefix ++ "_EXTRA_LIBDIRS = " ++ unwords (extraLibDirs bi),
variablePrefix ++ "_C_SRCS = " ++ unwords (cSources bi),
variablePrefix ++ "_CMM_SRCS := $(addprefix cbits/,$(notdir $(wildcard " ++ directory ++ "/cbits/*.cmm)))",
variablePrefix ++ "_DATA_FILES = " ++ unwords (dataFiles pd),
-- XXX This includes things it shouldn't, like:
-- -odir dist-bootstrapping/build
variablePrefix ++ "_HC_OPTS = " ++ escape (unwords
( programDefaultArgs ghcProg
++ hcOptions GHC bi
++ languageToFlags (compiler lbi) (defaultLanguage bi)
++ extensionsToFlags (compiler lbi) (usedExtensions bi)
++ programOverrideArgs ghcProg)),
variablePrefix ++ "_CC_OPTS = " ++ unwords (ccOptions bi),
variablePrefix ++ "_CPP_OPTS = " ++ unwords (cppOptions bi),
variablePrefix ++ "_LD_OPTS = " ++ unwords (ldOptions bi),
variablePrefix ++ "_DEP_INCLUDE_DIRS_SINGLE_QUOTED = " ++ unwords wrappedIncludeDirs,
variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions),
variablePrefix ++ "_DEP_LIB_DIRS_SINGLE_QUOTED = " ++ unwords wrappedLibraryDirs,
variablePrefix ++ "_DEP_LIB_DIRS_SEARCHPATH = " ++ mkSearchPath libraryDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS = " ++ unwords libraryRelDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS_SEARCHPATH = " ++ mkSearchPath libraryRelDirs,
variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries),
variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions),
variablePrefix ++ "_BUILD_GHCI_LIB = " ++ boolToYesNo (withGHCiLib lbi),
"",
-- Sometimes we need to modify the automatically-generated package-data.mk
-- bindings in a special way for the GHC build system, so allow that here:
"$(eval $(" ++ directory ++ "_PACKAGE_MAGIC))"
]
writeFile (distdir ++ "/package-data.mk") $ unlines xs
writeFileUtf8 (distdir ++ "/haddock-prologue.txt") $
if null (description pd) then synopsis pd
else description pd
unless (null dll0Modules) $
do let dll0Mods = words dll0Modules
dllMods = allMods \\ dll0Mods
dllModSets = map unwords [dll0Mods, dllMods]
writeFile (distdir ++ "/dll-split") $ unlines dllModSets
where
escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
wrap = mapM wrap1
wrap1 s
| null s = die ["Wrapping empty value"]
| '\'' `elem` s = die ["Single quote in value to be wrapped:", s]
-- We want to be able to assume things like <space><quote> is the
-- start of a value, so check there are no spaces in confusing
-- positions
| head s == ' ' = die ["Leading space in value to be wrapped:", s]
| last s == ' ' = die ["Trailing space in value to be wrapped:", s]
| otherwise = return ("\'" ++ s ++ "\'")
mkSearchPath = intercalate [searchPathSeparator]
boolToYesNo True = "YES"
boolToYesNo False = "NO"
-- | Version of 'writeFile' that always uses UTF8 encoding
writeFileUtf8 f txt = withFile f WriteMode $ \hdl -> do
hSetEncoding hdl utf8
hPutStr hdl txt | 11,359 | generate :: FilePath -> FilePath -> String -> [String] -> IO ()
generate directory distdir dll0Modules config_args
= withCurrentDirectory directory
$ do let verbosity = normal
-- XXX We shouldn't just configure with the default flags
-- XXX And this, and thus the "getPersistBuildConfig distdir" below,
-- aren't going to work when the deps aren't built yet
withArgs (["configure", "--distdir", distdir, "--ipid", "$pkg-$version"] ++ config_args)
runDefaultMain
lbi <- getPersistBuildConfig distdir
let pd0 = localPkgDescr lbi
writePersistBuildConfig distdir lbi
hooked_bi <-
if (buildType pd0 == Just Configure) || (buildType pd0 == Just Custom)
then do
maybe_infoFile <- defaultHookedPackageDesc
case maybe_infoFile of
Nothing -> return emptyHookedBuildInfo
Just infoFile -> readHookedBuildInfo verbosity infoFile
else
return emptyHookedBuildInfo
let pd = updatePackageDescription hooked_bi pd0
-- generate Paths_<pkg>.hs and cabal-macros.h
withAllComponentsInBuildOrder pd lbi $ \_ clbi ->
writeAutogenFiles verbosity pd lbi clbi
-- generate inplace-pkg-config
withLibLBI pd lbi $ \lib clbi ->
do cwd <- getCurrentDirectory
let ipid = mkUnitId (display (packageId pd))
let installedPkgInfo = inplaceInstalledPackageInfo cwd distdir
pd (AbiHash "") lib lbi clbi
final_ipi = mangleIPI directory distdir lbi $ installedPkgInfo {
Installed.installedUnitId = ipid,
Installed.compatPackageKey = display (packageId pd),
Installed.haddockHTMLs = []
}
content = Installed.showInstalledPackageInfo final_ipi ++ "\n"
writeFileAtomic (distdir </> "inplace-pkg-config") (BS.pack $ toUTF8 content)
let
comp = compiler lbi
libBiModules lib = (libBuildInfo lib, libModules lib)
exeBiModules exe = (buildInfo exe, ModuleName.main : exeModules exe)
biModuless = (map libBiModules $ libraries pd)
++ (map exeBiModules $ executables pd)
buildableBiModuless = filter isBuildable biModuless
where isBuildable (bi', _) = buildable bi'
(bi, modules) = case buildableBiModuless of
[] -> error "No buildable component found"
[biModules] -> biModules
_ -> error ("XXX ghc-cabal can't handle " ++
"more than one buildinfo yet")
-- XXX Another Just...
Just ghcProg = lookupProgram ghcProgram (withPrograms lbi)
dep_pkgs = PackageIndex.topologicalOrder (packageHacks (installedPkgs lbi))
forDeps f = concatMap f dep_pkgs
-- copied from Distribution.Simple.PreProcess.ppHsc2Hs
packageHacks = case compilerFlavor (compiler lbi) of
GHC -> hackRtsPackage
_ -> id
-- We don't link in the actual Haskell libraries of our
-- dependencies, so the -u flags in the ldOptions of the rts
-- package mean linking fails on OS X (it's ld is a tad
-- stricter than gnu ld). Thus we remove the ldOptions for
-- GHC's rts package:
hackRtsPackage index =
case PackageIndex.lookupPackageName index (PackageName "rts") of
[(_,[rts])] ->
PackageIndex.insert rts{
Installed.ldOptions = [],
Installed.libraryDirs = filter (not . ("gcc-lib" `isSuffixOf`)) (Installed.libraryDirs rts)} index
-- GHC <= 6.12 had $topdir/gcc-lib in their
-- library-dirs for the rts package, which causes
-- problems when we try to use the in-tree mingw,
-- due to accidentally picking up the incompatible
-- libraries there. So we filter out gcc-lib from
-- the RTS's library-dirs here.
_ -> error "No (or multiple) ghc rts package is registered!!"
dep_ids = map snd (externalPackageDeps lbi)
deps = map display dep_ids
dep_direct = map (fromMaybe (error "ghc-cabal: dep_keys failed")
. PackageIndex.lookupUnitId
(installedPkgs lbi)
. fst)
. externalPackageDeps
$ lbi
dep_ipids = map (display . Installed.installedUnitId) dep_direct
depLibNames
| packageKeySupported comp = dep_ipids
| otherwise = deps
depNames = map (display . packageName) dep_ids
transitive_dep_ids = map Installed.sourcePackageId dep_pkgs
transitiveDeps = map display transitive_dep_ids
transitiveDepLibNames
| packageKeySupported comp = map fixupRtsLibName transitiveDeps
| otherwise = transitiveDeps
fixupRtsLibName "rts-1.0" = "rts"
fixupRtsLibName x = x
transitiveDepNames = map (display . packageName) transitive_dep_ids
libraryDirs = forDeps Installed.libraryDirs
-- The mkLibraryRelDir function is a bit of a hack.
-- Ideally it should be handled in the makefiles instead.
mkLibraryRelDir "rts" = "rts/dist/build"
mkLibraryRelDir "ghc" = "compiler/stage2/build"
mkLibraryRelDir "Cabal" = "libraries/Cabal/Cabal/dist-install/build"
mkLibraryRelDir l = "libraries/" ++ l ++ "/dist-install/build"
libraryRelDirs = map mkLibraryRelDir transitiveDepNames
wrappedIncludeDirs <- wrap $ forDeps Installed.includeDirs
wrappedLibraryDirs <- wrap libraryDirs
let variablePrefix = directory ++ '_':distdir
mods = map display modules
otherMods = map display (otherModules bi)
allMods = mods ++ otherMods
let xs = [variablePrefix ++ "_VERSION = " ++ display (pkgVersion (package pd)),
-- TODO: move inside withLibLBI
variablePrefix ++ "_COMPONENT_ID = " ++ localCompatPackageKey lbi,
variablePrefix ++ "_MODULES = " ++ unwords mods,
variablePrefix ++ "_HIDDEN_MODULES = " ++ unwords otherMods,
variablePrefix ++ "_SYNOPSIS =" ++ (unwords $ lines $ synopsis pd),
variablePrefix ++ "_HS_SRC_DIRS = " ++ unwords (hsSourceDirs bi),
variablePrefix ++ "_DEPS = " ++ unwords deps,
variablePrefix ++ "_DEP_IPIDS = " ++ unwords dep_ipids,
variablePrefix ++ "_DEP_NAMES = " ++ unwords depNames,
variablePrefix ++ "_DEP_COMPONENT_IDS = " ++ unwords depLibNames,
variablePrefix ++ "_TRANSITIVE_DEP_NAMES = " ++ unwords transitiveDepNames,
variablePrefix ++ "_TRANSITIVE_DEP_COMPONENT_IDS = " ++ unwords transitiveDepLibNames,
variablePrefix ++ "_INCLUDE_DIRS = " ++ unwords (includeDirs bi),
variablePrefix ++ "_INCLUDES = " ++ unwords (includes bi),
variablePrefix ++ "_INSTALL_INCLUDES = " ++ unwords (installIncludes bi),
variablePrefix ++ "_EXTRA_LIBRARIES = " ++ unwords (extraLibs bi),
variablePrefix ++ "_EXTRA_LIBDIRS = " ++ unwords (extraLibDirs bi),
variablePrefix ++ "_C_SRCS = " ++ unwords (cSources bi),
variablePrefix ++ "_CMM_SRCS := $(addprefix cbits/,$(notdir $(wildcard " ++ directory ++ "/cbits/*.cmm)))",
variablePrefix ++ "_DATA_FILES = " ++ unwords (dataFiles pd),
-- XXX This includes things it shouldn't, like:
-- -odir dist-bootstrapping/build
variablePrefix ++ "_HC_OPTS = " ++ escape (unwords
( programDefaultArgs ghcProg
++ hcOptions GHC bi
++ languageToFlags (compiler lbi) (defaultLanguage bi)
++ extensionsToFlags (compiler lbi) (usedExtensions bi)
++ programOverrideArgs ghcProg)),
variablePrefix ++ "_CC_OPTS = " ++ unwords (ccOptions bi),
variablePrefix ++ "_CPP_OPTS = " ++ unwords (cppOptions bi),
variablePrefix ++ "_LD_OPTS = " ++ unwords (ldOptions bi),
variablePrefix ++ "_DEP_INCLUDE_DIRS_SINGLE_QUOTED = " ++ unwords wrappedIncludeDirs,
variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions),
variablePrefix ++ "_DEP_LIB_DIRS_SINGLE_QUOTED = " ++ unwords wrappedLibraryDirs,
variablePrefix ++ "_DEP_LIB_DIRS_SEARCHPATH = " ++ mkSearchPath libraryDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS = " ++ unwords libraryRelDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS_SEARCHPATH = " ++ mkSearchPath libraryRelDirs,
variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries),
variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions),
variablePrefix ++ "_BUILD_GHCI_LIB = " ++ boolToYesNo (withGHCiLib lbi),
"",
-- Sometimes we need to modify the automatically-generated package-data.mk
-- bindings in a special way for the GHC build system, so allow that here:
"$(eval $(" ++ directory ++ "_PACKAGE_MAGIC))"
]
writeFile (distdir ++ "/package-data.mk") $ unlines xs
writeFileUtf8 (distdir ++ "/haddock-prologue.txt") $
if null (description pd) then synopsis pd
else description pd
unless (null dll0Modules) $
do let dll0Mods = words dll0Modules
dllMods = allMods \\ dll0Mods
dllModSets = map unwords [dll0Mods, dllMods]
writeFile (distdir ++ "/dll-split") $ unlines dllModSets
where
escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
wrap = mapM wrap1
wrap1 s
| null s = die ["Wrapping empty value"]
| '\'' `elem` s = die ["Single quote in value to be wrapped:", s]
-- We want to be able to assume things like <space><quote> is the
-- start of a value, so check there are no spaces in confusing
-- positions
| head s == ' ' = die ["Leading space in value to be wrapped:", s]
| last s == ' ' = die ["Trailing space in value to be wrapped:", s]
| otherwise = return ("\'" ++ s ++ "\'")
mkSearchPath = intercalate [searchPathSeparator]
boolToYesNo True = "YES"
boolToYesNo False = "NO"
-- | Version of 'writeFile' that always uses UTF8 encoding
writeFileUtf8 f txt = withFile f WriteMode $ \hdl -> do
hSetEncoding hdl utf8
hPutStr hdl txt | 11,359 | generate directory distdir dll0Modules config_args
= withCurrentDirectory directory
$ do let verbosity = normal
-- XXX We shouldn't just configure with the default flags
-- XXX And this, and thus the "getPersistBuildConfig distdir" below,
-- aren't going to work when the deps aren't built yet
withArgs (["configure", "--distdir", distdir, "--ipid", "$pkg-$version"] ++ config_args)
runDefaultMain
lbi <- getPersistBuildConfig distdir
let pd0 = localPkgDescr lbi
writePersistBuildConfig distdir lbi
hooked_bi <-
if (buildType pd0 == Just Configure) || (buildType pd0 == Just Custom)
then do
maybe_infoFile <- defaultHookedPackageDesc
case maybe_infoFile of
Nothing -> return emptyHookedBuildInfo
Just infoFile -> readHookedBuildInfo verbosity infoFile
else
return emptyHookedBuildInfo
let pd = updatePackageDescription hooked_bi pd0
-- generate Paths_<pkg>.hs and cabal-macros.h
withAllComponentsInBuildOrder pd lbi $ \_ clbi ->
writeAutogenFiles verbosity pd lbi clbi
-- generate inplace-pkg-config
withLibLBI pd lbi $ \lib clbi ->
do cwd <- getCurrentDirectory
let ipid = mkUnitId (display (packageId pd))
let installedPkgInfo = inplaceInstalledPackageInfo cwd distdir
pd (AbiHash "") lib lbi clbi
final_ipi = mangleIPI directory distdir lbi $ installedPkgInfo {
Installed.installedUnitId = ipid,
Installed.compatPackageKey = display (packageId pd),
Installed.haddockHTMLs = []
}
content = Installed.showInstalledPackageInfo final_ipi ++ "\n"
writeFileAtomic (distdir </> "inplace-pkg-config") (BS.pack $ toUTF8 content)
let
comp = compiler lbi
libBiModules lib = (libBuildInfo lib, libModules lib)
exeBiModules exe = (buildInfo exe, ModuleName.main : exeModules exe)
biModuless = (map libBiModules $ libraries pd)
++ (map exeBiModules $ executables pd)
buildableBiModuless = filter isBuildable biModuless
where isBuildable (bi', _) = buildable bi'
(bi, modules) = case buildableBiModuless of
[] -> error "No buildable component found"
[biModules] -> biModules
_ -> error ("XXX ghc-cabal can't handle " ++
"more than one buildinfo yet")
-- XXX Another Just...
Just ghcProg = lookupProgram ghcProgram (withPrograms lbi)
dep_pkgs = PackageIndex.topologicalOrder (packageHacks (installedPkgs lbi))
forDeps f = concatMap f dep_pkgs
-- copied from Distribution.Simple.PreProcess.ppHsc2Hs
packageHacks = case compilerFlavor (compiler lbi) of
GHC -> hackRtsPackage
_ -> id
-- We don't link in the actual Haskell libraries of our
-- dependencies, so the -u flags in the ldOptions of the rts
-- package mean linking fails on OS X (it's ld is a tad
-- stricter than gnu ld). Thus we remove the ldOptions for
-- GHC's rts package:
hackRtsPackage index =
case PackageIndex.lookupPackageName index (PackageName "rts") of
[(_,[rts])] ->
PackageIndex.insert rts{
Installed.ldOptions = [],
Installed.libraryDirs = filter (not . ("gcc-lib" `isSuffixOf`)) (Installed.libraryDirs rts)} index
-- GHC <= 6.12 had $topdir/gcc-lib in their
-- library-dirs for the rts package, which causes
-- problems when we try to use the in-tree mingw,
-- due to accidentally picking up the incompatible
-- libraries there. So we filter out gcc-lib from
-- the RTS's library-dirs here.
_ -> error "No (or multiple) ghc rts package is registered!!"
dep_ids = map snd (externalPackageDeps lbi)
deps = map display dep_ids
dep_direct = map (fromMaybe (error "ghc-cabal: dep_keys failed")
. PackageIndex.lookupUnitId
(installedPkgs lbi)
. fst)
. externalPackageDeps
$ lbi
dep_ipids = map (display . Installed.installedUnitId) dep_direct
depLibNames
| packageKeySupported comp = dep_ipids
| otherwise = deps
depNames = map (display . packageName) dep_ids
transitive_dep_ids = map Installed.sourcePackageId dep_pkgs
transitiveDeps = map display transitive_dep_ids
transitiveDepLibNames
| packageKeySupported comp = map fixupRtsLibName transitiveDeps
| otherwise = transitiveDeps
fixupRtsLibName "rts-1.0" = "rts"
fixupRtsLibName x = x
transitiveDepNames = map (display . packageName) transitive_dep_ids
libraryDirs = forDeps Installed.libraryDirs
-- The mkLibraryRelDir function is a bit of a hack.
-- Ideally it should be handled in the makefiles instead.
mkLibraryRelDir "rts" = "rts/dist/build"
mkLibraryRelDir "ghc" = "compiler/stage2/build"
mkLibraryRelDir "Cabal" = "libraries/Cabal/Cabal/dist-install/build"
mkLibraryRelDir l = "libraries/" ++ l ++ "/dist-install/build"
libraryRelDirs = map mkLibraryRelDir transitiveDepNames
wrappedIncludeDirs <- wrap $ forDeps Installed.includeDirs
wrappedLibraryDirs <- wrap libraryDirs
let variablePrefix = directory ++ '_':distdir
mods = map display modules
otherMods = map display (otherModules bi)
allMods = mods ++ otherMods
let xs = [variablePrefix ++ "_VERSION = " ++ display (pkgVersion (package pd)),
-- TODO: move inside withLibLBI
variablePrefix ++ "_COMPONENT_ID = " ++ localCompatPackageKey lbi,
variablePrefix ++ "_MODULES = " ++ unwords mods,
variablePrefix ++ "_HIDDEN_MODULES = " ++ unwords otherMods,
variablePrefix ++ "_SYNOPSIS =" ++ (unwords $ lines $ synopsis pd),
variablePrefix ++ "_HS_SRC_DIRS = " ++ unwords (hsSourceDirs bi),
variablePrefix ++ "_DEPS = " ++ unwords deps,
variablePrefix ++ "_DEP_IPIDS = " ++ unwords dep_ipids,
variablePrefix ++ "_DEP_NAMES = " ++ unwords depNames,
variablePrefix ++ "_DEP_COMPONENT_IDS = " ++ unwords depLibNames,
variablePrefix ++ "_TRANSITIVE_DEP_NAMES = " ++ unwords transitiveDepNames,
variablePrefix ++ "_TRANSITIVE_DEP_COMPONENT_IDS = " ++ unwords transitiveDepLibNames,
variablePrefix ++ "_INCLUDE_DIRS = " ++ unwords (includeDirs bi),
variablePrefix ++ "_INCLUDES = " ++ unwords (includes bi),
variablePrefix ++ "_INSTALL_INCLUDES = " ++ unwords (installIncludes bi),
variablePrefix ++ "_EXTRA_LIBRARIES = " ++ unwords (extraLibs bi),
variablePrefix ++ "_EXTRA_LIBDIRS = " ++ unwords (extraLibDirs bi),
variablePrefix ++ "_C_SRCS = " ++ unwords (cSources bi),
variablePrefix ++ "_CMM_SRCS := $(addprefix cbits/,$(notdir $(wildcard " ++ directory ++ "/cbits/*.cmm)))",
variablePrefix ++ "_DATA_FILES = " ++ unwords (dataFiles pd),
-- XXX This includes things it shouldn't, like:
-- -odir dist-bootstrapping/build
variablePrefix ++ "_HC_OPTS = " ++ escape (unwords
( programDefaultArgs ghcProg
++ hcOptions GHC bi
++ languageToFlags (compiler lbi) (defaultLanguage bi)
++ extensionsToFlags (compiler lbi) (usedExtensions bi)
++ programOverrideArgs ghcProg)),
variablePrefix ++ "_CC_OPTS = " ++ unwords (ccOptions bi),
variablePrefix ++ "_CPP_OPTS = " ++ unwords (cppOptions bi),
variablePrefix ++ "_LD_OPTS = " ++ unwords (ldOptions bi),
variablePrefix ++ "_DEP_INCLUDE_DIRS_SINGLE_QUOTED = " ++ unwords wrappedIncludeDirs,
variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions),
variablePrefix ++ "_DEP_LIB_DIRS_SINGLE_QUOTED = " ++ unwords wrappedLibraryDirs,
variablePrefix ++ "_DEP_LIB_DIRS_SEARCHPATH = " ++ mkSearchPath libraryDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS = " ++ unwords libraryRelDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS_SEARCHPATH = " ++ mkSearchPath libraryRelDirs,
variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries),
variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions),
variablePrefix ++ "_BUILD_GHCI_LIB = " ++ boolToYesNo (withGHCiLib lbi),
"",
-- Sometimes we need to modify the automatically-generated package-data.mk
-- bindings in a special way for the GHC build system, so allow that here:
"$(eval $(" ++ directory ++ "_PACKAGE_MAGIC))"
]
writeFile (distdir ++ "/package-data.mk") $ unlines xs
writeFileUtf8 (distdir ++ "/haddock-prologue.txt") $
if null (description pd) then synopsis pd
else description pd
unless (null dll0Modules) $
do let dll0Mods = words dll0Modules
dllMods = allMods \\ dll0Mods
dllModSets = map unwords [dll0Mods, dllMods]
writeFile (distdir ++ "/dll-split") $ unlines dllModSets
where
escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
wrap = mapM wrap1
wrap1 s
| null s = die ["Wrapping empty value"]
| '\'' `elem` s = die ["Single quote in value to be wrapped:", s]
-- We want to be able to assume things like <space><quote> is the
-- start of a value, so check there are no spaces in confusing
-- positions
| head s == ' ' = die ["Leading space in value to be wrapped:", s]
| last s == ' ' = die ["Trailing space in value to be wrapped:", s]
| otherwise = return ("\'" ++ s ++ "\'")
mkSearchPath = intercalate [searchPathSeparator]
boolToYesNo True = "YES"
boolToYesNo False = "NO"
-- | Version of 'writeFile' that always uses UTF8 encoding
writeFileUtf8 f txt = withFile f WriteMode $ \hdl -> do
hSetEncoding hdl utf8
hPutStr hdl txt | 11,295 | false | true | 4 | 21 | 3,918 | 2,219 | 1,108 | 1,111 | null | null |
WSCU/JSEuterpea | Euterpea Examples/Random.hs | gpl-3.0 | voice11 = line(map voice1 rhythms1) | 35 | voice11 = line(map voice1 rhythms1) | 35 | voice11 = line(map voice1 rhythms1) | 35 | false | false | 0 | 7 | 4 | 17 | 8 | 9 | null | null |
zsol/hlogster | Carbon.hs | bsd-3-clause | sendToCarbon (key, value, time) handle = hPutStrLn handle (key ++ " " ++ value ++ " " ++ time) | 94 | sendToCarbon (key, value, time) handle = hPutStrLn handle (key ++ " " ++ value ++ " " ++ time) | 94 | sendToCarbon (key, value, time) handle = hPutStrLn handle (key ++ " " ++ value ++ " " ++ time) | 94 | false | false | 0 | 10 | 18 | 44 | 23 | 21 | null | null |
bergey/gooey | hello/src/Main.hs | bsd-3-clause | main :: IO ()
main = do
Just doc <- currentDocument
Just body <- getBody doc
setInnerHTML body $ Just "<p/>Hello World</p>" | 129 | main :: IO ()
main = do
Just doc <- currentDocument
Just body <- getBody doc
setInnerHTML body $ Just "<p/>Hello World</p>" | 129 | main = do
Just doc <- currentDocument
Just body <- getBody doc
setInnerHTML body $ Just "<p/>Hello World</p>" | 115 | false | true | 0 | 9 | 27 | 58 | 23 | 35 | null | null |
onponomarev/ganeti | src/Ganeti/Constants.hs | bsd-2-clause | -- | The default fixed timeout needed until the helper VM is finally
-- shutdown, for example, after installing the OS.
helperVmShutdown :: Int
helperVmShutdown = 2 * 60 * 60 | 174 | helperVmShutdown :: Int
helperVmShutdown = 2 * 60 * 60 | 54 | helperVmShutdown = 2 * 60 * 60 | 30 | true | true | 2 | 6 | 30 | 30 | 13 | 17 | null | null |
jyp/lp-diagrams | Graphics/Diagrams/Plot.hs | agpl-3.0 | lint :: Constant -> Expr -> Expr -> Expr
lint p origin target = (p*-(target-origin)) + origin | 93 | lint :: Constant -> Expr -> Expr -> Expr
lint p origin target = (p*-(target-origin)) + origin | 93 | lint p origin target = (p*-(target-origin)) + origin | 52 | false | true | 0 | 9 | 16 | 53 | 26 | 27 | null | null |
ihc/futhark | src/Futhark/Representation/AST/Attributes/Patterns.hs | isc | -- | Return a list of the 'Name's bound by the 'Pattern'.
patternNames :: PatternT attr -> [VName]
patternNames = map patElemName . patternElements | 147 | patternNames :: PatternT attr -> [VName]
patternNames = map patElemName . patternElements | 89 | patternNames = map patElemName . patternElements | 48 | true | true | 0 | 6 | 23 | 29 | 15 | 14 | null | null |
haskell-opengl/OpenGLRaw | src/Graphics/GL/Functions/F05.hs | bsd-3-clause | ptr_glCoverageOperationNV :: FunPtr (GLenum -> IO ())
ptr_glCoverageOperationNV = unsafePerformIO $ getCommand "glCoverageOperationNV" | 134 | ptr_glCoverageOperationNV :: FunPtr (GLenum -> IO ())
ptr_glCoverageOperationNV = unsafePerformIO $ getCommand "glCoverageOperationNV" | 134 | ptr_glCoverageOperationNV = unsafePerformIO $ getCommand "glCoverageOperationNV" | 80 | false | true | 0 | 9 | 12 | 33 | 16 | 17 | null | null |
upwawet/vision | src/Playtime.hs | gpl-3.0 | setupSeek :: (WithXMMS, WithPlaytime) => IO (ConnectId Adjustment)
setupSeek = adj `onValueChanged` do
modSeekCount (+ 1)
v <- adjustmentGetValue adj
playbackSeekMs xmms (round v) SeekSet >>* do
liftIO $ modSeekCount $ \n -> n - 1 | 241 | setupSeek :: (WithXMMS, WithPlaytime) => IO (ConnectId Adjustment)
setupSeek = adj `onValueChanged` do
modSeekCount (+ 1)
v <- adjustmentGetValue adj
playbackSeekMs xmms (round v) SeekSet >>* do
liftIO $ modSeekCount $ \n -> n - 1 | 241 | setupSeek = adj `onValueChanged` do
modSeekCount (+ 1)
v <- adjustmentGetValue adj
playbackSeekMs xmms (round v) SeekSet >>* do
liftIO $ modSeekCount $ \n -> n - 1 | 174 | false | true | 0 | 14 | 46 | 106 | 50 | 56 | null | null |
raptros/chatless-hs | src/Api/Queries/User.hs | bsd-3-clause | -- | the groundhog query.
userTopicsQuery :: Gh.PersistBackend m => Ur.User -> m [Tp.TopicRef]
userTopicsQuery user = Gh.project Tp.TopicCoord $ (Tp.TopicServerField Gh.==. Ur.userServer user) Gh.&&. (Tp.TopicUserField Gh.==. Ur.userId user) | 241 | userTopicsQuery :: Gh.PersistBackend m => Ur.User -> m [Tp.TopicRef]
userTopicsQuery user = Gh.project Tp.TopicCoord $ (Tp.TopicServerField Gh.==. Ur.userServer user) Gh.&&. (Tp.TopicUserField Gh.==. Ur.userId user) | 215 | userTopicsQuery user = Gh.project Tp.TopicCoord $ (Tp.TopicServerField Gh.==. Ur.userServer user) Gh.&&. (Tp.TopicUserField Gh.==. Ur.userId user) | 146 | true | true | 0 | 10 | 28 | 92 | 44 | 48 | null | null |
diku-kmc/kleenexlang | test/Tests/TestUtils.hs | mit | runTest :: TS.Test -> IO TS.Result
runTest (TS.Test t) = runTestInstance t | 74 | runTest :: TS.Test -> IO TS.Result
runTest (TS.Test t) = runTestInstance t | 74 | runTest (TS.Test t) = runTestInstance t | 39 | false | true | 0 | 8 | 11 | 36 | 17 | 19 | null | null |
Javran/Project-Euler | src/ProjectEuler/Problem105.hs | mit | compute :: T.Text -> Int
compute =
getSum
. foldMap (getSpecialSubsetSum . parseLine)
. lines
. T.unpack
where
parseLine raw = read ("[" <> raw <> "]") | 173 | compute :: T.Text -> Int
compute =
getSum
. foldMap (getSpecialSubsetSum . parseLine)
. lines
. T.unpack
where
parseLine raw = read ("[" <> raw <> "]") | 173 | compute =
getSum
. foldMap (getSpecialSubsetSum . parseLine)
. lines
. T.unpack
where
parseLine raw = read ("[" <> raw <> "]") | 148 | false | true | 4 | 8 | 48 | 79 | 34 | 45 | null | null |
plumlife/cabal | Cabal/Distribution/Simple/LocalBuildInfo.hs | bsd-3-clause | allComponentsInBuildOrder :: LocalBuildInfo
-> [(ComponentName, ComponentLocalBuildInfo)]
allComponentsInBuildOrder lbi =
componentsInBuildOrder lbi
[ cname | (cname, _, _) <- componentsConfigs lbi ] | 235 | allComponentsInBuildOrder :: LocalBuildInfo
-> [(ComponentName, ComponentLocalBuildInfo)]
allComponentsInBuildOrder lbi =
componentsInBuildOrder lbi
[ cname | (cname, _, _) <- componentsConfigs lbi ] | 235 | allComponentsInBuildOrder lbi =
componentsInBuildOrder lbi
[ cname | (cname, _, _) <- componentsConfigs lbi ] | 119 | false | true | 0 | 9 | 56 | 62 | 31 | 31 | null | null |
grodin/yacc | debug/src/main/haskell/generate-currencies.hs | apache-2.0 | displayCurrency :: Currency -> Text
displayCurrency c = T.replace codePin code . T.replace valuePin value
. T.replace namePin name $ line
where
code = cCode . curCode $ c
value = curValue c
name = curName c
codePin = "###"
valuePin = "@@@"
namePin = "¬¬¬" | 325 | displayCurrency :: Currency -> Text
displayCurrency c = T.replace codePin code . T.replace valuePin value
. T.replace namePin name $ line
where
code = cCode . curCode $ c
value = curValue c
name = curName c
codePin = "###"
valuePin = "@@@"
namePin = "¬¬¬" | 325 | displayCurrency c = T.replace codePin code . T.replace valuePin value
. T.replace namePin name $ line
where
code = cCode . curCode $ c
value = curValue c
name = curName c
codePin = "###"
valuePin = "@@@"
namePin = "¬¬¬" | 289 | false | true | 5 | 9 | 115 | 102 | 49 | 53 | null | null |
brendanhay/gogol | gogol-proximitybeacon/gen/Network/Google/Resource/ProximityBeacon/GetEidparams.hs | mpl-2.0 | -- | V1 error format.
geXgafv :: Lens' GetEidparams (Maybe Xgafv)
geXgafv = lens _geXgafv (\ s a -> s{_geXgafv = a}) | 116 | geXgafv :: Lens' GetEidparams (Maybe Xgafv)
geXgafv = lens _geXgafv (\ s a -> s{_geXgafv = a}) | 94 | geXgafv = lens _geXgafv (\ s a -> s{_geXgafv = a}) | 50 | true | true | 0 | 9 | 21 | 46 | 25 | 21 | null | null |
kristoff3r/importify | HLint.hs | mit | warn = (either (const (pure () )) f =<< m) ==> Universum.whenRightM m f | 72 | warn = (either (const (pure () )) f =<< m) ==> Universum.whenRightM m f | 72 | warn = (either (const (pure () )) f =<< m) ==> Universum.whenRightM m f | 72 | false | false | 0 | 13 | 14 | 43 | 21 | 22 | null | null |
shlevy/ghc | compiler/typecheck/TcDerivUtils.hs | bsd-3-clause | -- Side conditions (whether the datatype must have at least one constructor,
-- required language extensions, etc.) for using GHC's stock deriving
-- mechanism on certain classes (as opposed to classes that require
-- GeneralizedNewtypeDeriving or DeriveAnyClass). Returns Nothing for a
-- class for which stock deriving isn't possible.
sideConditions :: DerivContext -> Class -> Maybe Condition
sideConditions mtheta cls
| cls_key == eqClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == ordClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == showClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == readClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == enumClassKey = Just (cond_std `andCond` cond_isEnumeration)
| cls_key == ixClassKey = Just (cond_std `andCond` cond_enumOrProduct cls)
| cls_key == boundedClassKey = Just (cond_std `andCond` cond_enumOrProduct cls)
| cls_key == dataClassKey = Just (checkFlag LangExt.DeriveDataTypeable `andCond`
cond_vanilla `andCond`
cond_args cls)
| cls_key == functorClassKey = Just (checkFlag LangExt.DeriveFunctor `andCond`
cond_vanilla `andCond`
cond_functorOK True False)
| cls_key == foldableClassKey = Just (checkFlag LangExt.DeriveFoldable `andCond`
cond_vanilla `andCond`
cond_functorOK False True)
-- Functor/Fold/Trav works ok
-- for rank-n types
| cls_key == traversableClassKey = Just (checkFlag LangExt.DeriveTraversable `andCond`
cond_vanilla `andCond`
cond_functorOK False False)
| cls_key == genClassKey = Just (checkFlag LangExt.DeriveGeneric `andCond`
cond_vanilla `andCond`
cond_RepresentableOk)
| cls_key == gen1ClassKey = Just (checkFlag LangExt.DeriveGeneric `andCond`
cond_vanilla `andCond`
cond_Representable1Ok)
| cls_key == liftClassKey = Just (checkFlag LangExt.DeriveLift `andCond`
cond_vanilla `andCond`
cond_args cls)
| otherwise = Nothing
where
cls_key = getUnique cls
cond_std = cond_stdOK mtheta False -- Vanilla data constructors, at least one,
-- and monotype arguments
cond_vanilla = cond_stdOK mtheta True -- Vanilla data constructors but
-- allow no data cons or polytype arguments | 3,050 | sideConditions :: DerivContext -> Class -> Maybe Condition
sideConditions mtheta cls
| cls_key == eqClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == ordClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == showClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == readClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == enumClassKey = Just (cond_std `andCond` cond_isEnumeration)
| cls_key == ixClassKey = Just (cond_std `andCond` cond_enumOrProduct cls)
| cls_key == boundedClassKey = Just (cond_std `andCond` cond_enumOrProduct cls)
| cls_key == dataClassKey = Just (checkFlag LangExt.DeriveDataTypeable `andCond`
cond_vanilla `andCond`
cond_args cls)
| cls_key == functorClassKey = Just (checkFlag LangExt.DeriveFunctor `andCond`
cond_vanilla `andCond`
cond_functorOK True False)
| cls_key == foldableClassKey = Just (checkFlag LangExt.DeriveFoldable `andCond`
cond_vanilla `andCond`
cond_functorOK False True)
-- Functor/Fold/Trav works ok
-- for rank-n types
| cls_key == traversableClassKey = Just (checkFlag LangExt.DeriveTraversable `andCond`
cond_vanilla `andCond`
cond_functorOK False False)
| cls_key == genClassKey = Just (checkFlag LangExt.DeriveGeneric `andCond`
cond_vanilla `andCond`
cond_RepresentableOk)
| cls_key == gen1ClassKey = Just (checkFlag LangExt.DeriveGeneric `andCond`
cond_vanilla `andCond`
cond_Representable1Ok)
| cls_key == liftClassKey = Just (checkFlag LangExt.DeriveLift `andCond`
cond_vanilla `andCond`
cond_args cls)
| otherwise = Nothing
where
cls_key = getUnique cls
cond_std = cond_stdOK mtheta False -- Vanilla data constructors, at least one,
-- and monotype arguments
cond_vanilla = cond_stdOK mtheta True -- Vanilla data constructors but
-- allow no data cons or polytype arguments | 2,713 | sideConditions mtheta cls
| cls_key == eqClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == ordClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == showClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == readClassKey = Just (cond_std `andCond` cond_args cls)
| cls_key == enumClassKey = Just (cond_std `andCond` cond_isEnumeration)
| cls_key == ixClassKey = Just (cond_std `andCond` cond_enumOrProduct cls)
| cls_key == boundedClassKey = Just (cond_std `andCond` cond_enumOrProduct cls)
| cls_key == dataClassKey = Just (checkFlag LangExt.DeriveDataTypeable `andCond`
cond_vanilla `andCond`
cond_args cls)
| cls_key == functorClassKey = Just (checkFlag LangExt.DeriveFunctor `andCond`
cond_vanilla `andCond`
cond_functorOK True False)
| cls_key == foldableClassKey = Just (checkFlag LangExt.DeriveFoldable `andCond`
cond_vanilla `andCond`
cond_functorOK False True)
-- Functor/Fold/Trav works ok
-- for rank-n types
| cls_key == traversableClassKey = Just (checkFlag LangExt.DeriveTraversable `andCond`
cond_vanilla `andCond`
cond_functorOK False False)
| cls_key == genClassKey = Just (checkFlag LangExt.DeriveGeneric `andCond`
cond_vanilla `andCond`
cond_RepresentableOk)
| cls_key == gen1ClassKey = Just (checkFlag LangExt.DeriveGeneric `andCond`
cond_vanilla `andCond`
cond_Representable1Ok)
| cls_key == liftClassKey = Just (checkFlag LangExt.DeriveLift `andCond`
cond_vanilla `andCond`
cond_args cls)
| otherwise = Nothing
where
cls_key = getUnique cls
cond_std = cond_stdOK mtheta False -- Vanilla data constructors, at least one,
-- and monotype arguments
cond_vanilla = cond_stdOK mtheta True -- Vanilla data constructors but
-- allow no data cons or polytype arguments | 2,654 | true | true | 14 | 10 | 1,211 | 539 | 279 | 260 | null | null |
baig/review-md | critic.hs | bsd-3-clause | rejectChange (Deletion _ _ str) = Text str | 48 | rejectChange (Deletion _ _ str) = Text str | 48 | rejectChange (Deletion _ _ str) = Text str | 48 | false | false | 0 | 7 | 13 | 22 | 10 | 12 | null | null |
zeekay/lambdabot | Plugin/Free/Expr.hs | mit | exprSubst v e (EApp e1 e2)
= EApp (exprSubst v e e1) (exprSubst v e e2) | 76 | exprSubst v e (EApp e1 e2)
= EApp (exprSubst v e e1) (exprSubst v e e2) | 76 | exprSubst v e (EApp e1 e2)
= EApp (exprSubst v e e1) (exprSubst v e e2) | 76 | false | false | 0 | 6 | 20 | 50 | 22 | 28 | null | null |
cdepillabout/continuation-monad-test | src/Main.hs | gpl-2.0 | fibWithDoBad 1 = return 1 | 25 | fibWithDoBad 1 = return 1 | 25 | fibWithDoBad 1 = return 1 | 25 | false | false | 1 | 5 | 4 | 16 | 5 | 11 | null | null |
UCSD-PL/nano-js | Language/Nano/SSA/SSA.hs | bsd-3-clause | -- OTHER (Not handled)
ssaStmt s
= convertError "ssaStmt" s | 62 | ssaStmt s
= convertError "ssaStmt" s | 39 | ssaStmt s
= convertError "ssaStmt" s | 39 | true | false | 1 | 5 | 12 | 19 | 7 | 12 | null | null |
ktvoelker/cookie-jar | test/Util.hs | gpl-3.0 | runSession :: P.Rules -> Session a -> IO a
runSession = flip evalStateT . emptyJar . Just | 89 | runSession :: P.Rules -> Session a -> IO a
runSession = flip evalStateT . emptyJar . Just | 89 | runSession = flip evalStateT . emptyJar . Just | 46 | false | true | 0 | 7 | 16 | 38 | 18 | 20 | null | null |
brendanhay/gogol | gogol-bigquery/gen/Network/Google/BigQuery/Types/Product.hs | mpl-2.0 | -- | Creates a value of 'ModelDefinitionModelOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'mdmoModelType'
--
-- * 'mdmoLabels'
--
-- * 'mdmoLossType'
modelDefinitionModelOptions
:: ModelDefinitionModelOptions
modelDefinitionModelOptions =
ModelDefinitionModelOptions'
{_mdmoModelType = Nothing, _mdmoLabels = Nothing, _mdmoLossType = Nothing} | 449 | modelDefinitionModelOptions
:: ModelDefinitionModelOptions
modelDefinitionModelOptions =
ModelDefinitionModelOptions'
{_mdmoModelType = Nothing, _mdmoLabels = Nothing, _mdmoLossType = Nothing} | 202 | modelDefinitionModelOptions =
ModelDefinitionModelOptions'
{_mdmoModelType = Nothing, _mdmoLabels = Nothing, _mdmoLossType = Nothing} | 139 | true | true | 1 | 7 | 66 | 47 | 29 | 18 | null | null |
dbp/positionsites | src/Handler/Site.hs | bsd-3-clause | pageForm :: Site -> Maybe Page -> Form Text AppHandler Page
pageForm site p = mkPg <$> "flat" .: nonEmpty (text $ fmap (decodeUtf8 . pageFlat) p)
<*> "structured" .: nonEmpty (text $ fmap pageStructured p)
<*> "body" .: validateHtml (nonEmpty (text $ fmap pageBody p))
where mkPg f s b = case p of
Nothing -> Page (-1) (siteId site) (encodeUtf8 f) s b
Just pg -> pg { pageFlat = encodeUtf8 f, pageStructured = s, pageBody = b } | 521 | pageForm :: Site -> Maybe Page -> Form Text AppHandler Page
pageForm site p = mkPg <$> "flat" .: nonEmpty (text $ fmap (decodeUtf8 . pageFlat) p)
<*> "structured" .: nonEmpty (text $ fmap pageStructured p)
<*> "body" .: validateHtml (nonEmpty (text $ fmap pageBody p))
where mkPg f s b = case p of
Nothing -> Page (-1) (siteId site) (encodeUtf8 f) s b
Just pg -> pg { pageFlat = encodeUtf8 f, pageStructured = s, pageBody = b } | 521 | pageForm site p = mkPg <$> "flat" .: nonEmpty (text $ fmap (decodeUtf8 . pageFlat) p)
<*> "structured" .: nonEmpty (text $ fmap pageStructured p)
<*> "body" .: validateHtml (nonEmpty (text $ fmap pageBody p))
where mkPg f s b = case p of
Nothing -> Page (-1) (siteId site) (encodeUtf8 f) s b
Just pg -> pg { pageFlat = encodeUtf8 f, pageStructured = s, pageBody = b } | 461 | false | true | 0 | 15 | 174 | 200 | 100 | 100 | null | null |
jwiegley/ghc-release | libraries/Cabal/cabal-install/Distribution/Client/Targets.hs | gpl-3.0 | fetchPackageTarget :: Verbosity
-> PackageTarget (PackageLocation ())
-> IO (PackageTarget (PackageLocation FilePath))
fetchPackageTarget verbosity target = case target of
PackageTargetNamed n cs ut -> return (PackageTargetNamed n cs ut)
PackageTargetNamedFuzzy n cs ut -> return (PackageTargetNamedFuzzy n cs ut)
PackageTargetLocation location -> do
location' <- fetchPackage verbosity (fmap (const Nothing) location)
return (PackageTargetLocation location')
-- | Given a package target that has been fetched, read the .cabal file.
--
-- This only affects targets given by location, named targets are unaffected.
-- | 691 | fetchPackageTarget :: Verbosity
-> PackageTarget (PackageLocation ())
-> IO (PackageTarget (PackageLocation FilePath))
fetchPackageTarget verbosity target = case target of
PackageTargetNamed n cs ut -> return (PackageTargetNamed n cs ut)
PackageTargetNamedFuzzy n cs ut -> return (PackageTargetNamedFuzzy n cs ut)
PackageTargetLocation location -> do
location' <- fetchPackage verbosity (fmap (const Nothing) location)
return (PackageTargetLocation location')
-- | Given a package target that has been fetched, read the .cabal file.
--
-- This only affects targets given by location, named targets are unaffected.
-- | 691 | fetchPackageTarget verbosity target = case target of
PackageTargetNamed n cs ut -> return (PackageTargetNamed n cs ut)
PackageTargetNamedFuzzy n cs ut -> return (PackageTargetNamedFuzzy n cs ut)
PackageTargetLocation location -> do
location' <- fetchPackage verbosity (fmap (const Nothing) location)
return (PackageTargetLocation location')
-- | Given a package target that has been fetched, read the .cabal file.
--
-- This only affects targets given by location, named targets are unaffected.
-- | 534 | false | true | 0 | 15 | 156 | 157 | 75 | 82 | null | null |
buckie/juno | src/Juno/Consensus/Commit.hs | bsd-3-clause | logApplyLatency :: Monad m => Command -> Raft m ()
logApplyLatency (Command _ _ _ provenance) = case provenance of
NewMsg -> return ()
ReceivedMsg _digest _orig mReceivedAt -> case mReceivedAt of
Just (ReceivedAt arrived) -> do
now <- join $ view (rs.getTimestamp)
logMetric $ MetricApplyLatency $ fromIntegral $ interval arrived now
Nothing -> return () | 378 | logApplyLatency :: Monad m => Command -> Raft m ()
logApplyLatency (Command _ _ _ provenance) = case provenance of
NewMsg -> return ()
ReceivedMsg _digest _orig mReceivedAt -> case mReceivedAt of
Just (ReceivedAt arrived) -> do
now <- join $ view (rs.getTimestamp)
logMetric $ MetricApplyLatency $ fromIntegral $ interval arrived now
Nothing -> return () | 378 | logApplyLatency (Command _ _ _ provenance) = case provenance of
NewMsg -> return ()
ReceivedMsg _digest _orig mReceivedAt -> case mReceivedAt of
Just (ReceivedAt arrived) -> do
now <- join $ view (rs.getTimestamp)
logMetric $ MetricApplyLatency $ fromIntegral $ interval arrived now
Nothing -> return () | 327 | false | true | 0 | 17 | 79 | 145 | 67 | 78 | null | null |
leksah/yi | src/library/Yi/Syntax/Haskell.hs | gpl-2.0 | pForAll :: Parser TT (Exp TT)
pForAll = pKW [Reserved Forall]
(Bin <$> pVars <*> ppAtom [Operator "."]) | 113 | pForAll :: Parser TT (Exp TT)
pForAll = pKW [Reserved Forall]
(Bin <$> pVars <*> ppAtom [Operator "."]) | 113 | pForAll = pKW [Reserved Forall]
(Bin <$> pVars <*> ppAtom [Operator "."]) | 83 | false | true | 2 | 10 | 27 | 62 | 26 | 36 | null | null |
bos/text | tests/Tests/Properties/Builder.hs | bsd-2-clause | tb_hexadecimal_word32 (a::Word32) = tb_hex a | 44 | tb_hexadecimal_word32 (a::Word32) = tb_hex a | 44 | tb_hexadecimal_word32 (a::Word32) = tb_hex a | 44 | false | false | 0 | 7 | 4 | 19 | 9 | 10 | null | null |
AlexeyRaga/eta | compiler/ETA/Main/DynFlags.hs | bsd-3-clause | wayOptl _ WayProf = [] | 28 | wayOptl _ WayProf = [] | 28 | wayOptl _ WayProf = [] | 28 | false | false | 1 | 6 | 10 | 15 | 6 | 9 | null | null |
jfranklin9000/urbit | pkg/hs/urbit-king/lib/Urbit/Noun/TH.hs | mit | --------------------------------------------------------------------------------
vodToNoun :: Exp
vodToNoun = LamCaseE [] | 122 | vodToNoun :: Exp
vodToNoun = LamCaseE [] | 40 | vodToNoun = LamCaseE [] | 23 | true | true | 0 | 6 | 8 | 17 | 9 | 8 | null | null |
geophf/1HaskellADay | exercises/HAD/Y2017/M11/D17/Exercise.hs | mit | fetchKphr :: Connection -> Index -> IO [IxPhrase]
fetchKphr conn kind = undefined | 81 | fetchKphr :: Connection -> Index -> IO [IxPhrase]
fetchKphr conn kind = undefined | 81 | fetchKphr conn kind = undefined | 31 | false | true | 0 | 9 | 12 | 35 | 16 | 19 | null | null |
konn/hskk | cocoa/KeyFlags.hs | bsd-3-clause | isAlphabeticModifier :: Modifier -> Bool
isAlphabeticModifier a = compatible Shift a || compatible AlphaShift a | 111 | isAlphabeticModifier :: Modifier -> Bool
isAlphabeticModifier a = compatible Shift a || compatible AlphaShift a | 111 | isAlphabeticModifier a = compatible Shift a || compatible AlphaShift a | 70 | false | true | 0 | 7 | 14 | 38 | 16 | 22 | null | null |
spacekitteh/smcghc | compiler/main/DynFlags.hs | bsd-3-clause | addHaddockOpts f d = d{ haddockOptions = Just f} | 48 | addHaddockOpts f d = d{ haddockOptions = Just f} | 48 | addHaddockOpts f d = d{ haddockOptions = Just f} | 48 | false | false | 0 | 7 | 8 | 22 | 11 | 11 | null | null |
tommy-schmitz/haskell-faceted | Faceted/Internal.hs | apache-2.0 | -- | << pc ? x : y >> =====> pcF pc x y
pcF :: PC -> Faceted a -> Faceted a -> Faceted a
pcF [] x _ = x | 128 | pcF :: PC -> Faceted a -> Faceted a -> Faceted a
pcF [] x _ = x | 84 | pcF [] x _ = x | 35 | true | true | 0 | 8 | 56 | 42 | 20 | 22 | null | null |
axnion/playground | random/haskell/99questions/problem2.hs | mit | myButLast x = last (init x) | 27 | myButLast x = last (init x) | 27 | myButLast x = last (init x) | 27 | false | false | 0 | 7 | 5 | 18 | 8 | 10 | null | null |
michalt/ghc-comparisons-plugin | GhcPlugins/Comparisons/Pass.hs | bsd-3-clause | emptyWorkList :: Worklist
emptyWorkList = Wl [] [] [] | 53 | emptyWorkList :: Worklist
emptyWorkList = Wl [] [] [] | 53 | emptyWorkList = Wl [] [] [] | 27 | false | true | 0 | 6 | 8 | 24 | 12 | 12 | null | null |
dmp1ce/Haskell-Programming-Exercises | Chapter 3/Exercises: Scope - 4.hs | unlicense | r = d / 2 | 9 | r = d / 2 | 9 | r = d / 2 | 9 | false | false | 1 | 5 | 4 | 13 | 5 | 8 | null | null |
derkyjadex/tracks | Main.hs | mit | main :: IO ()
main = do
network <- readTracksFile "test.tracks"
services <- readServicesFile "test.services"
putStrLn $ writeTracksCommands network
signals <- atomically Signals.clear
forkIO $ startTrain "001" foxLine 1 services signals network
forkIO $ startTrain "002" foxLine 1 services signals network
forkIO $ startTrain "A01" newLine 1 services signals network
getLine
return () | 456 | main :: IO ()
main = do
network <- readTracksFile "test.tracks"
services <- readServicesFile "test.services"
putStrLn $ writeTracksCommands network
signals <- atomically Signals.clear
forkIO $ startTrain "001" foxLine 1 services signals network
forkIO $ startTrain "002" foxLine 1 services signals network
forkIO $ startTrain "A01" newLine 1 services signals network
getLine
return () | 456 | main = do
network <- readTracksFile "test.tracks"
services <- readServicesFile "test.services"
putStrLn $ writeTracksCommands network
signals <- atomically Signals.clear
forkIO $ startTrain "001" foxLine 1 services signals network
forkIO $ startTrain "002" foxLine 1 services signals network
forkIO $ startTrain "A01" newLine 1 services signals network
getLine
return () | 442 | false | true | 0 | 10 | 124 | 135 | 57 | 78 | null | null |
zaxtax/hakaru | haskell/Tests/RoundTrip.hs | bsd-3-clause | t7' = uniform_0_1 >>= \x -> unsafeSuperpose [(unsafeProb (x+one), dirac (x^(nat_ 2)))] | 87 | t7' = uniform_0_1 >>= \x -> unsafeSuperpose [(unsafeProb (x+one), dirac (x^(nat_ 2)))] | 87 | t7' = uniform_0_1 >>= \x -> unsafeSuperpose [(unsafeProb (x+one), dirac (x^(nat_ 2)))] | 87 | false | false | 3 | 13 | 12 | 58 | 29 | 29 | null | null |
DavidAlphaFox/ghc | libraries/containers/Data/IntSet/Base.hs | bsd-3-clause | null _ = False | 16 | null _ = False | 16 | null _ = False | 16 | false | false | 0 | 5 | 5 | 9 | 4 | 5 | null | null |
boj/garbage | src/NaiveGame3.hs | bsd-3-clause | entityBaseHealth :: EntityType -> Int
entityBaseHealth e = case e of
Zombie -> 50
Chicken -> 25
Exploder -> 75
TallCreepyThing -> 500 | 257 | entityBaseHealth :: EntityType -> Int
entityBaseHealth e = case e of
Zombie -> 50
Chicken -> 25
Exploder -> 75
TallCreepyThing -> 500 | 257 | entityBaseHealth e = case e of
Zombie -> 50
Chicken -> 25
Exploder -> 75
TallCreepyThing -> 500 | 219 | false | true | 0 | 8 | 146 | 52 | 24 | 28 | null | null |
fmapfmapfmap/amazonka | amazonka-rds/test/Test/AWS/Gen/RDS.hs | mpl-2.0 | testPromoteReadReplica :: PromoteReadReplica -> TestTree
testPromoteReadReplica = req
"PromoteReadReplica"
"fixture/PromoteReadReplica.yaml" | 148 | testPromoteReadReplica :: PromoteReadReplica -> TestTree
testPromoteReadReplica = req
"PromoteReadReplica"
"fixture/PromoteReadReplica.yaml" | 148 | testPromoteReadReplica = req
"PromoteReadReplica"
"fixture/PromoteReadReplica.yaml" | 91 | false | true | 0 | 5 | 17 | 20 | 10 | 10 | null | null |
jdve/xchat-plugin | src/Network/IRC/XChat/Examples/CountDown.hs | gpl-2.0 | parseInt :: Int -> String -> Int
parseInt acc [] = acc | 54 | parseInt :: Int -> String -> Int
parseInt acc [] = acc | 54 | parseInt acc [] = acc | 21 | false | true | 0 | 9 | 11 | 32 | 14 | 18 | null | null |
bitemyapp/github | samples/Issues/Milestones/ShowMilestones.hs | bsd-3-clause | formatDueOn (Just milestoneDate) = ", is due on " ++ dueOn milestoneDate | 72 | formatDueOn (Just milestoneDate) = ", is due on " ++ dueOn milestoneDate | 72 | formatDueOn (Just milestoneDate) = ", is due on " ++ dueOn milestoneDate | 72 | false | false | 0 | 7 | 11 | 22 | 10 | 12 | null | null |
clarkcb/xsearch | haskell/hssearch/src/HsSearch/FileUtil.hs | mit | getFileByteString :: FilePath -> IO (Either String B.ByteString)
getFileByteString f = handle (\(e :: IOException) -> return (Left (show e))) $
withFile f ReadMode $ \h -> do
hSetNewlineMode h universalNewlineMode
contents <- B.hGetContents h
return (Right contents) | 280 | getFileByteString :: FilePath -> IO (Either String B.ByteString)
getFileByteString f = handle (\(e :: IOException) -> return (Left (show e))) $
withFile f ReadMode $ \h -> do
hSetNewlineMode h universalNewlineMode
contents <- B.hGetContents h
return (Right contents) | 280 | getFileByteString f = handle (\(e :: IOException) -> return (Left (show e))) $
withFile f ReadMode $ \h -> do
hSetNewlineMode h universalNewlineMode
contents <- B.hGetContents h
return (Right contents) | 215 | false | true | 0 | 14 | 51 | 114 | 54 | 60 | null | null |
jdubrule/bond | compiler/src/Language/Bond/Parser.hs | mit | methodTypeUnary :: Parser MethodType
methodTypeUnary = (Unary <$> userStructRef) <?> "unary method type" | 104 | methodTypeUnary :: Parser MethodType
methodTypeUnary = (Unary <$> userStructRef) <?> "unary method type" | 104 | methodTypeUnary = (Unary <$> userStructRef) <?> "unary method type" | 67 | false | true | 0 | 7 | 12 | 25 | 13 | 12 | null | null |
poiuj/pfcc | src/Semant.hs | bsd-3-clause | throwTypeMismatch m@(TMethod _) t@(Type _) = throwTypeMismatch t m | 66 | throwTypeMismatch m@(TMethod _) t@(Type _) = throwTypeMismatch t m | 66 | throwTypeMismatch m@(TMethod _) t@(Type _) = throwTypeMismatch t m | 66 | false | false | 0 | 8 | 8 | 34 | 17 | 17 | null | null |
Heather/stack | src/Stack/Build/Source.hs | bsd-3-clause | getDefaultPackageConfig :: (MonadIO m, MonadReader env m, HasEnvConfig env)
=> m PackageConfig
getDefaultPackageConfig = do
econfig <- asks getEnvConfig
bconfig <- asks getBuildConfig
return PackageConfig
{ packageConfigEnableTests = False
, packageConfigEnableBenchmarks = False
, packageConfigFlags = M.empty
, packageConfigGhcOptions = []
, packageConfigCompilerVersion = envConfigCompilerVersion econfig
, packageConfigPlatform = configPlatform $ getConfig bconfig
}
-- | Get 'PackageConfig' for package given its name. | 560 | getDefaultPackageConfig :: (MonadIO m, MonadReader env m, HasEnvConfig env)
=> m PackageConfig
getDefaultPackageConfig = do
econfig <- asks getEnvConfig
bconfig <- asks getBuildConfig
return PackageConfig
{ packageConfigEnableTests = False
, packageConfigEnableBenchmarks = False
, packageConfigFlags = M.empty
, packageConfigGhcOptions = []
, packageConfigCompilerVersion = envConfigCompilerVersion econfig
, packageConfigPlatform = configPlatform $ getConfig bconfig
}
-- | Get 'PackageConfig' for package given its name. | 560 | getDefaultPackageConfig = do
econfig <- asks getEnvConfig
bconfig <- asks getBuildConfig
return PackageConfig
{ packageConfigEnableTests = False
, packageConfigEnableBenchmarks = False
, packageConfigFlags = M.empty
, packageConfigGhcOptions = []
, packageConfigCompilerVersion = envConfigCompilerVersion econfig
, packageConfigPlatform = configPlatform $ getConfig bconfig
}
-- | Get 'PackageConfig' for package given its name. | 463 | false | true | 0 | 11 | 99 | 116 | 61 | 55 | null | null |
apyrgio/snf-ganeti | src/Ganeti/Query/Common.hs | bsd-2-clause | -- | Ndparams optimised lookup map.
ndParamTypes :: Map.Map String FieldType
ndParamTypes = Map.map vTypeToQFT C.ndsParameterTypes | 130 | ndParamTypes :: Map.Map String FieldType
ndParamTypes = Map.map vTypeToQFT C.ndsParameterTypes | 94 | ndParamTypes = Map.map vTypeToQFT C.ndsParameterTypes | 53 | true | true | 1 | 6 | 15 | 31 | 14 | 17 | null | null |
ghcjs/jsaddle-dom | src/JSDOM/Generated/Plugin.hs | mit | -- | <https://developer.mozilla.org/en-US/docs/Web/API/Plugin.namedItem Mozilla Plugin.namedItem documentation>
namedItemUnsafe ::
(MonadDOM m, ToJSString name, HasCallStack) =>
Plugin -> name -> m MimeType
namedItemUnsafe self name
= liftDOM
(((self ! name) >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return) | 379 | namedItemUnsafe ::
(MonadDOM m, ToJSString name, HasCallStack) =>
Plugin -> name -> m MimeType
namedItemUnsafe self name
= liftDOM
(((self ! name) >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return) | 266 | namedItemUnsafe self name
= liftDOM
(((self ! name) >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return) | 137 | true | true | 0 | 11 | 88 | 84 | 43 | 41 | null | null |
davidhinkes/anarchy | src/Network/Anarchy/Client.hs | bsd-3-clause | getServerHostPort :: ClientOp HostPort
getServerHostPort = ClientOp f
where f ops = return (hostport ops) | 107 | getServerHostPort :: ClientOp HostPort
getServerHostPort = ClientOp f
where f ops = return (hostport ops) | 107 | getServerHostPort = ClientOp f
where f ops = return (hostport ops) | 68 | false | true | 1 | 7 | 16 | 46 | 18 | 28 | null | null |
Pnom/haskell-ast-pretty | Test/examples/Attributes.hs | mit | usedByEdges Color{} = True | 35 | usedByEdges Color{} = True | 35 | usedByEdges Color{} = True | 35 | false | false | 0 | 6 | 12 | 13 | 6 | 7 | null | null |
jdreaver/sum-type-boilerplate | library/SumTypes/TH.hs | mit | -- | This template haskell function creates a conversion function between two
-- sum types. It works by matching up constructors that share the same inner
-- type. Note that all types in the source sum type must be present in the
-- target sum type, or you will get an error.
--
-- > data MySum
-- > = MySumTypeA TypeA
-- > | MySumTypeB TypeB
-- > | MySumTypeC TypeC
-- >
-- > data OtherSum
-- > = OtherSumTypeA TypeA
-- > | OtherSumTypeB TypeB
-- >
-- > sumTypeConverter "otherSumToMySum" ''OtherSum ''MySum
--
-- This will producing the following code:
--
-- > otherSumToMySum :: OtherSum -> MySum
-- > otherSumToMySum (OtherSumTypeA typeA) = MySumTypeA typeA
-- > otherSumToMySum (OtherSumTypeB typeB) = MySumTypeB typeB
sumTypeConverter :: String -> Name -> Name -> Q [Dec]
sumTypeConverter functionName sourceType targetType = do
bothConstructors <- matchTypeConstructors sourceType targetType
let
funcName = mkName functionName
funcClauses <- mapM mkSerializeFunc bothConstructors
typeDecl <- [t| $(conT sourceType) -> $(conT targetType) |]
return
[ SigD funcName typeDecl
, FunD funcName funcClauses
]
-- | Similar to 'sumTypeConverter', except not all types in the source sum type
-- need to be present in the target sum type.
--
-- Note that this doesn't produce a partial function in the Haskell sense; you
-- won't get an 'error' with the generated function on any arguments. The word
-- partial is used mathematically to denote that not all types from the source
-- sum type are present in the target sum type.
--
-- > data MySum
-- > = MySumTypeA TypeA
-- > | MySumTypeB TypeB
-- > | MySumTypeC TypeC
-- >
-- > data OtherSum
-- > = OtherSumTypeA TypeA
-- > | OtherSumTypeB TypeB
-- >
-- > partialSumTypeConverter "mySumToOtherSum" ''MySum ''OtherSum
--
-- This will producing the following code:
--
-- > mySumToOtherSum :: MySum -> Maybe OtherSum
-- > mySumToOtherSum (MySumTypeA typeA) = Just $ OtherSumTypeA typeA
-- > mySumToOtherSum (MySumTypeB typeB) = Just $ OtherSumTypeB typeB
-- > mySumToOtherSum other = Nothing | 2,081 | sumTypeConverter :: String -> Name -> Name -> Q [Dec]
sumTypeConverter functionName sourceType targetType = do
bothConstructors <- matchTypeConstructors sourceType targetType
let
funcName = mkName functionName
funcClauses <- mapM mkSerializeFunc bothConstructors
typeDecl <- [t| $(conT sourceType) -> $(conT targetType) |]
return
[ SigD funcName typeDecl
, FunD funcName funcClauses
]
-- | Similar to 'sumTypeConverter', except not all types in the source sum type
-- need to be present in the target sum type.
--
-- Note that this doesn't produce a partial function in the Haskell sense; you
-- won't get an 'error' with the generated function on any arguments. The word
-- partial is used mathematically to denote that not all types from the source
-- sum type are present in the target sum type.
--
-- > data MySum
-- > = MySumTypeA TypeA
-- > | MySumTypeB TypeB
-- > | MySumTypeC TypeC
-- >
-- > data OtherSum
-- > = OtherSumTypeA TypeA
-- > | OtherSumTypeB TypeB
-- >
-- > partialSumTypeConverter "mySumToOtherSum" ''MySum ''OtherSum
--
-- This will producing the following code:
--
-- > mySumToOtherSum :: MySum -> Maybe OtherSum
-- > mySumToOtherSum (MySumTypeA typeA) = Just $ OtherSumTypeA typeA
-- > mySumToOtherSum (MySumTypeB typeB) = Just $ OtherSumTypeB typeB
-- > mySumToOtherSum other = Nothing | 1,347 | sumTypeConverter functionName sourceType targetType = do
bothConstructors <- matchTypeConstructors sourceType targetType
let
funcName = mkName functionName
funcClauses <- mapM mkSerializeFunc bothConstructors
typeDecl <- [t| $(conT sourceType) -> $(conT targetType) |]
return
[ SigD funcName typeDecl
, FunD funcName funcClauses
]
-- | Similar to 'sumTypeConverter', except not all types in the source sum type
-- need to be present in the target sum type.
--
-- Note that this doesn't produce a partial function in the Haskell sense; you
-- won't get an 'error' with the generated function on any arguments. The word
-- partial is used mathematically to denote that not all types from the source
-- sum type are present in the target sum type.
--
-- > data MySum
-- > = MySumTypeA TypeA
-- > | MySumTypeB TypeB
-- > | MySumTypeC TypeC
-- >
-- > data OtherSum
-- > = OtherSumTypeA TypeA
-- > | OtherSumTypeB TypeB
-- >
-- > partialSumTypeConverter "mySumToOtherSum" ''MySum ''OtherSum
--
-- This will producing the following code:
--
-- > mySumToOtherSum :: MySum -> Maybe OtherSum
-- > mySumToOtherSum (MySumTypeA typeA) = Just $ OtherSumTypeA typeA
-- > mySumToOtherSum (MySumTypeB typeB) = Just $ OtherSumTypeB typeB
-- > mySumToOtherSum other = Nothing | 1,293 | true | true | 0 | 10 | 388 | 151 | 96 | 55 | null | null |
f-me/snap-core | test/suite/Snap/Util/FileServe/Tests.hs | bsd-3-clause | cfgD = DirectoryConfig {
indexFiles = []
, indexGenerator = const pass
, dynamicHandlers = HashMap.fromList [ (".txt", printName) ]
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
} | 258 | cfgD = DirectoryConfig {
indexFiles = []
, indexGenerator = const pass
, dynamicHandlers = HashMap.fromList [ (".txt", printName) ]
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
} | 258 | cfgD = DirectoryConfig {
indexFiles = []
, indexGenerator = const pass
, dynamicHandlers = HashMap.fromList [ (".txt", printName) ]
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
} | 258 | false | false | 0 | 9 | 90 | 66 | 38 | 28 | null | null |
maxwelljoslyn/DnDMapAndEcon | RoadParser.hs | gpl-3.0 | parseRoad :: Parsec String () Road
parseRoad = do
char '['
coords <- sepBy parseCoord (char ',')
char ']'
return $ Road coords | 134 | parseRoad :: Parsec String () Road
parseRoad = do
char '['
coords <- sepBy parseCoord (char ',')
char ']'
return $ Road coords | 134 | parseRoad = do
char '['
coords <- sepBy parseCoord (char ',')
char ']'
return $ Road coords | 99 | false | true | 1 | 11 | 30 | 65 | 26 | 39 | null | null |
zc1036/Compiler-project | src/LIR.hs | gpl-3.0 | astToLIR state (P.TStringLiteral { P.tsrepr }) =
let (newstate, reg) = newreg state A.pointerSize True
in (newstate, (Just reg, [LoadStringPtr reg tsrepr])) | 164 | astToLIR state (P.TStringLiteral { P.tsrepr }) =
let (newstate, reg) = newreg state A.pointerSize True
in (newstate, (Just reg, [LoadStringPtr reg tsrepr])) | 164 | astToLIR state (P.TStringLiteral { P.tsrepr }) =
let (newstate, reg) = newreg state A.pointerSize True
in (newstate, (Just reg, [LoadStringPtr reg tsrepr])) | 164 | false | false | 0 | 10 | 29 | 74 | 38 | 36 | null | null |
mortum5/programming | haskell/ITMO-Course/hw1/src/TreePrinters.hs | mit | upEdge :: Int -> String
upEdge padding = nspaces padding ++ "|" | 63 | upEdge :: Int -> String
upEdge padding = nspaces padding ++ "|" | 63 | upEdge padding = nspaces padding ++ "|" | 39 | false | true | 2 | 7 | 11 | 32 | 13 | 19 | null | null |
jessica-taylor/quipp2 | src/Quipp/Interpreter.hs | mit | expFamForType (ConstTExpr "Bool") = boolValueExpFam | 51 | expFamForType (ConstTExpr "Bool") = boolValueExpFam | 51 | expFamForType (ConstTExpr "Bool") = boolValueExpFam | 51 | false | false | 0 | 7 | 4 | 15 | 7 | 8 | null | null |
CarstenKoenig/Countdown | src/web/CountdownGame/Views/Play.hs | mit | dataBind :: AttributeValue -> Attribute
dataBind = dataAttribute "bind" | 71 | dataBind :: AttributeValue -> Attribute
dataBind = dataAttribute "bind" | 71 | dataBind = dataAttribute "bind" | 31 | false | true | 0 | 5 | 8 | 18 | 9 | 9 | null | null |
mrb/tee-io | app/devel.hs | mit | main :: IO ()
main = develMain | 30 | main :: IO ()
main = develMain | 30 | main = develMain | 16 | false | true | 0 | 6 | 6 | 16 | 8 | 8 | null | null |
weso/shexkell | src/Shexkell/Text/Compact/ShexParser.hs | mit | inlineShapeOrRef :: ParserShex ShapeExpr
inlineShapeOrRef = inlineShapeDefinition <|>
ShapeRef <$> (char '@' *> shapeLabel) | 142 | inlineShapeOrRef :: ParserShex ShapeExpr
inlineShapeOrRef = inlineShapeDefinition <|>
ShapeRef <$> (char '@' *> shapeLabel) | 142 | inlineShapeOrRef = inlineShapeDefinition <|>
ShapeRef <$> (char '@' *> shapeLabel) | 101 | false | true | 0 | 8 | 32 | 32 | 16 | 16 | null | null |
ekmett/wxHaskell | wxcore/src/haskell/Graphics/UI/WXCore/Layout.hs | lgpl-2.1 | -- | (primitive) Create a 'Layout' from a 'Sizer' object.
sizer :: Sizer a -> Layout
sizer s
= XSizer optionsDefault (downcastSizer s) | 136 | sizer :: Sizer a -> Layout
sizer s
= XSizer optionsDefault (downcastSizer s) | 78 | sizer s
= XSizer optionsDefault (downcastSizer s) | 51 | true | true | 0 | 7 | 24 | 40 | 17 | 23 | null | null |
fmapfmapfmap/amazonka | amazonka-autoscaling/gen/Network/AWS/AutoScaling/Types/Product.hs | mpl-2.0 | -- | The granularity of the metric. The only valid value is '1Minute'.
emGranularity :: Lens' EnabledMetric (Maybe Text)
emGranularity = lens _emGranularity (\ s a -> s{_emGranularity = a}) | 189 | emGranularity :: Lens' EnabledMetric (Maybe Text)
emGranularity = lens _emGranularity (\ s a -> s{_emGranularity = a}) | 118 | emGranularity = lens _emGranularity (\ s a -> s{_emGranularity = a}) | 68 | true | true | 1 | 9 | 29 | 51 | 25 | 26 | null | null |
google/haskell-indexer | haskell-indexer-backend-ghc/src/Language/Haskell/Indexer/Backend/Ghc.hs | apache-2.0 | mkModuleTick :: (Given ExtractCtx) => Maybe SrcSpan -> Module -> ModuleTick
mkModuleTick span' mod' = ModuleTick pkgmodule moduleNameSpan
where
moduleNameSpan = srcSpanToSpan =<< span'
pkgmodule = extractModuleName given mod' | 235 | mkModuleTick :: (Given ExtractCtx) => Maybe SrcSpan -> Module -> ModuleTick
mkModuleTick span' mod' = ModuleTick pkgmodule moduleNameSpan
where
moduleNameSpan = srcSpanToSpan =<< span'
pkgmodule = extractModuleName given mod' | 235 | mkModuleTick span' mod' = ModuleTick pkgmodule moduleNameSpan
where
moduleNameSpan = srcSpanToSpan =<< span'
pkgmodule = extractModuleName given mod' | 159 | false | true | 0 | 7 | 38 | 63 | 31 | 32 | null | null |
cchalmers/shaped-pixels | examples/blur.hs | bsd-3-clause | -- Read a png file from the first argument and make a blured file
-- (file_blured.png). JuicyPixels conversion is kinda messy, mainly
-- wrote to test 'sumNeighbours' prototype.
main :: IO ()
main = do
[path] <- getArgs
Right (ImageRGB8 img) <- readPng path
writePng (path & basename <>~ "_blured1") (blurImage img) | 321 | main :: IO ()
main = do
[path] <- getArgs
Right (ImageRGB8 img) <- readPng path
writePng (path & basename <>~ "_blured1") (blurImage img) | 143 | main = do
[path] <- getArgs
Right (ImageRGB8 img) <- readPng path
writePng (path & basename <>~ "_blured1") (blurImage img) | 129 | true | true | 0 | 11 | 57 | 79 | 37 | 42 | null | null |
tel/haskell-maia | maia-example-api/src/Maia/Example/Api.hs | mpl-2.0 | cityHandler "Fakeville" = Just fakeville | 40 | cityHandler "Fakeville" = Just fakeville | 40 | cityHandler "Fakeville" = Just fakeville | 40 | false | false | 0 | 5 | 4 | 12 | 5 | 7 | null | null |
uduki/hsQt | Qtc/Network/QNetworkProxy.hs | bsd-2-clause | user :: QNetworkProxy a -> (()) -> IO (String)
user x0 ()
= withStringResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QNetworkProxy_user cobj_x0 | 150 | user :: QNetworkProxy a -> (()) -> IO (String)
user x0 ()
= withStringResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QNetworkProxy_user cobj_x0 | 150 | user x0 ()
= withStringResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QNetworkProxy_user cobj_x0 | 103 | false | true | 0 | 8 | 31 | 63 | 30 | 33 | null | null |
flipstone/orville | orville-postgresql-libpq/test/Test/Expr/TestSchema.hs | mit | dropAndRecreateTestTable :: Connection.Connection -> IO ()
dropAndRecreateTestTable connection = do
RawSql.executeVoid connection (RawSql.fromString "DROP TABLE IF EXISTS " <> RawSql.toRawSql fooBarTable)
RawSql.executeVoid connection (RawSql.fromString "CREATE TABLE " <> RawSql.toRawSql fooBarTable <> RawSql.fromString "(foo INTEGER, bar TEXT)")
-- SqlValue doesn't have Show or Eq, so use this to compare them in tests | 427 | dropAndRecreateTestTable :: Connection.Connection -> IO ()
dropAndRecreateTestTable connection = do
RawSql.executeVoid connection (RawSql.fromString "DROP TABLE IF EXISTS " <> RawSql.toRawSql fooBarTable)
RawSql.executeVoid connection (RawSql.fromString "CREATE TABLE " <> RawSql.toRawSql fooBarTable <> RawSql.fromString "(foo INTEGER, bar TEXT)")
-- SqlValue doesn't have Show or Eq, so use this to compare them in tests | 427 | dropAndRecreateTestTable connection = do
RawSql.executeVoid connection (RawSql.fromString "DROP TABLE IF EXISTS " <> RawSql.toRawSql fooBarTable)
RawSql.executeVoid connection (RawSql.fromString "CREATE TABLE " <> RawSql.toRawSql fooBarTable <> RawSql.fromString "(foo INTEGER, bar TEXT)")
-- SqlValue doesn't have Show or Eq, so use this to compare them in tests | 368 | false | true | 0 | 12 | 55 | 89 | 41 | 48 | null | null |
lamdu/lamdu | test/Tests/Gui.hs | gpl-3.0 | comparePositions :: Rect -> Rect -> RectOrdering
comparePositions r0 r1
| r0 `Rect.rectWithin` r1 = After
| r1 `Rect.rectWithin` r0 = error "TODO: Before?"
| r0 ^. Rect.bottom < r1 ^. Rect.top = Before
| r1 ^. Rect.bottom < r0 ^. Rect.top = After
| r0 ^. Rect.right < r1 ^. Rect.left = Before
| r1 ^. Rect.right < r0 ^. Rect.left = After
| otherwise = Undetermined | 396 | comparePositions :: Rect -> Rect -> RectOrdering
comparePositions r0 r1
| r0 `Rect.rectWithin` r1 = After
| r1 `Rect.rectWithin` r0 = error "TODO: Before?"
| r0 ^. Rect.bottom < r1 ^. Rect.top = Before
| r1 ^. Rect.bottom < r0 ^. Rect.top = After
| r0 ^. Rect.right < r1 ^. Rect.left = Before
| r1 ^. Rect.right < r0 ^. Rect.left = After
| otherwise = Undetermined | 396 | comparePositions r0 r1
| r0 `Rect.rectWithin` r1 = After
| r1 `Rect.rectWithin` r0 = error "TODO: Before?"
| r0 ^. Rect.bottom < r1 ^. Rect.top = Before
| r1 ^. Rect.bottom < r0 ^. Rect.top = After
| r0 ^. Rect.right < r1 ^. Rect.left = Before
| r1 ^. Rect.right < r0 ^. Rect.left = After
| otherwise = Undetermined | 347 | false | true | 1 | 11 | 99 | 176 | 86 | 90 | null | null |
alexander-at-github/eta | compiler/ETA/BasicTypes/DataCon.hs | bsd-3-clause | -- | The number of fields in the /representation/ of the constructor
-- AFTER taking into account the unpacking of any unboxed tuple fields
dataConRepRepArity :: DataCon -> RepArity
dataConRepRepArity dc = typeRepArity (dataConRepArity dc) (dataConRepType dc) | 259 | dataConRepRepArity :: DataCon -> RepArity
dataConRepRepArity dc = typeRepArity (dataConRepArity dc) (dataConRepType dc) | 119 | dataConRepRepArity dc = typeRepArity (dataConRepArity dc) (dataConRepType dc) | 77 | true | true | 0 | 7 | 36 | 37 | 19 | 18 | null | null |
kmels/dart-haskell | examples/interpreter/RecursiveVdefg.hs | bsd-3-clause | testOdd'' = odd 7 | 17 | testOdd'' = odd 7 | 17 | testOdd'' = odd 7 | 17 | false | false | 1 | 5 | 3 | 13 | 4 | 9 | null | null |
markus1189/xmonad-contrib-710 | XMonad/Hooks/DebugEvents.hs | bsd-3-clause | dumpProp _ "_NET_WM_STRUT" = dumpList [("left gap" ,dump32)
,("right gap" ,dump32)
,("top gap" ,dump32)
,("bottom gap",dump32)
] | 423 | dumpProp _ "_NET_WM_STRUT" = dumpList [("left gap" ,dump32)
,("right gap" ,dump32)
,("top gap" ,dump32)
,("bottom gap",dump32)
] | 423 | dumpProp _ "_NET_WM_STRUT" = dumpList [("left gap" ,dump32)
,("right gap" ,dump32)
,("top gap" ,dump32)
,("bottom gap",dump32)
] | 423 | false | false | 0 | 7 | 311 | 50 | 30 | 20 | null | null |
nikki-and-the-robots/nikki | src/Base/GlobalShortcuts.hs | lgpl-3.0 | handleGlobalShortcuts :: Application -> [AppEvent] -> M [AppEvent]
handleGlobalShortcuts app =
filterM $ handler app | 120 | handleGlobalShortcuts :: Application -> [AppEvent] -> M [AppEvent]
handleGlobalShortcuts app =
filterM $ handler app | 120 | handleGlobalShortcuts app =
filterM $ handler app | 53 | false | true | 2 | 9 | 18 | 44 | 20 | 24 | null | null |
rueshyna/gogol | gogol-admin-directory/gen/Network/Google/Directory/Types/Product.hs | mpl-2.0 | -- | If it user\'s primary organization.
uoPrimary :: Lens' UserOrganization (Maybe Bool)
uoPrimary
= lens _uoPrimary (\ s a -> s{_uoPrimary = a}) | 148 | uoPrimary :: Lens' UserOrganization (Maybe Bool)
uoPrimary
= lens _uoPrimary (\ s a -> s{_uoPrimary = a}) | 107 | uoPrimary
= lens _uoPrimary (\ s a -> s{_uoPrimary = a}) | 58 | true | true | 0 | 9 | 25 | 48 | 25 | 23 | null | null |
bosu/josh | t/progs/Server.hs | bsd-3-clause | register :: b -> Rendezvous a b -> Registrator a -> IO (UnregInfo a)
register b m reg = do
cb <- wrap (go m)
un <- reg cb
return (cb, un)
where go m p = putMVar m (p, b) | 185 | register :: b -> Rendezvous a b -> Registrator a -> IO (UnregInfo a)
register b m reg = do
cb <- wrap (go m)
un <- reg cb
return (cb, un)
where go m p = putMVar m (p, b) | 185 | register b m reg = do
cb <- wrap (go m)
un <- reg cb
return (cb, un)
where go m p = putMVar m (p, b) | 116 | false | true | 1 | 11 | 56 | 117 | 52 | 65 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.