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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
aristidb/datastorage | src/RollingVector.hs | bsd-3-clause | byteHashShort :: HashType Word8
byteHashShort = HashType { hash = \x -> 31 * fromIntegral x, window = 16, mask = 0xf } | 118 | byteHashShort :: HashType Word8
byteHashShort = HashType { hash = \x -> 31 * fromIntegral x, window = 16, mask = 0xf } | 118 | byteHashShort = HashType { hash = \x -> 31 * fromIntegral x, window = 16, mask = 0xf } | 86 | false | true | 0 | 9 | 22 | 46 | 26 | 20 | null | null |
fpco/fay | tests/GuardWhere.hs | bsd-3-clause | poseL _ = "OK" | 14 | poseL _ = "OK" | 14 | poseL _ = "OK" | 14 | false | false | 0 | 4 | 3 | 10 | 4 | 6 | null | null |
vTurbine/ghc | ghc/Main.hs | bsd-3-clause | dumpFastStringStats :: DynFlags -> IO ()
dumpFastStringStats dflags = do
buckets <- getFastStringTable
let (entries, longest, has_z) = countFS 0 0 0 buckets
msg = text "FastString stats:" $$
nest 4 (vcat [text "size: " <+> int (length buckets),
text "entries: " <+> int entries,
text "longest chain: " <+> int longest,
text "has z-encoding: " <+> (has_z `pcntOf` entries)
])
-- we usually get more "has z-encoding" than "z-encoded", because
-- when we z-encode a string it might hash to the exact same string,
-- which will is not counted as "z-encoded". Only strings whose
-- Z-encoding is different from the original string are counted in
-- the "z-encoded" total.
putMsg dflags msg
where
x `pcntOf` y = int ((x * 100) `quot` y) <> char '%' | 933 | dumpFastStringStats :: DynFlags -> IO ()
dumpFastStringStats dflags = do
buckets <- getFastStringTable
let (entries, longest, has_z) = countFS 0 0 0 buckets
msg = text "FastString stats:" $$
nest 4 (vcat [text "size: " <+> int (length buckets),
text "entries: " <+> int entries,
text "longest chain: " <+> int longest,
text "has z-encoding: " <+> (has_z `pcntOf` entries)
])
-- we usually get more "has z-encoding" than "z-encoded", because
-- when we z-encode a string it might hash to the exact same string,
-- which will is not counted as "z-encoded". Only strings whose
-- Z-encoding is different from the original string are counted in
-- the "z-encoded" total.
putMsg dflags msg
where
x `pcntOf` y = int ((x * 100) `quot` y) <> char '%' | 933 | dumpFastStringStats dflags = do
buckets <- getFastStringTable
let (entries, longest, has_z) = countFS 0 0 0 buckets
msg = text "FastString stats:" $$
nest 4 (vcat [text "size: " <+> int (length buckets),
text "entries: " <+> int entries,
text "longest chain: " <+> int longest,
text "has z-encoding: " <+> (has_z `pcntOf` entries)
])
-- we usually get more "has z-encoding" than "z-encoded", because
-- when we z-encode a string it might hash to the exact same string,
-- which will is not counted as "z-encoded". Only strings whose
-- Z-encoding is different from the original string are counted in
-- the "z-encoded" total.
putMsg dflags msg
where
x `pcntOf` y = int ((x * 100) `quot` y) <> char '%' | 892 | false | true | 0 | 18 | 318 | 200 | 101 | 99 | null | null |
naohaq/gf256-hs | example/MyUtil.hs | mit | joinStr delim words = foldr1 (\a b->a ++ delim ++ b) words | 58 | joinStr delim words = foldr1 (\a b->a ++ delim ++ b) words | 58 | joinStr delim words = foldr1 (\a b->a ++ delim ++ b) words | 58 | false | false | 0 | 9 | 11 | 34 | 17 | 17 | null | null |
shirazb/orpiva-k-means | src/ARFFParser/BasicCombinators.hs | bsd-3-clause | -- POST: Parses one or more occurences of p seperated by sep. Returns
-- parsed items as a list
sepby' :: Parser Char a -> Parser Char b -> Parser Char [a]
sepby' p sep = do
x <- p
xs <- many (sep >> p)
return (x : xs)
-- POST: Parses one occurence of p, removing opening and closing
-- delimiters. Expects no whitespace. Returns result of parsing p
-- EXAMPLE: Remove brackets and parse the contents inside:
-- bracketNoWS (char '(') intLiteral (char ')') "(1)" will return 1 | 511 | sepby' :: Parser Char a -> Parser Char b -> Parser Char [a]
sepby' p sep = do
x <- p
xs <- many (sep >> p)
return (x : xs)
-- POST: Parses one occurence of p, removing opening and closing
-- delimiters. Expects no whitespace. Returns result of parsing p
-- EXAMPLE: Remove brackets and parse the contents inside:
-- bracketNoWS (char '(') intLiteral (char ')') "(1)" will return 1 | 409 | sepby' p sep = do
x <- p
xs <- many (sep >> p)
return (x : xs)
-- POST: Parses one occurence of p, removing opening and closing
-- delimiters. Expects no whitespace. Returns result of parsing p
-- EXAMPLE: Remove brackets and parse the contents inside:
-- bracketNoWS (char '(') intLiteral (char ')') "(1)" will return 1 | 349 | true | true | 0 | 10 | 125 | 85 | 43 | 42 | null | null |
ozgurakgun/Idris-dev | src/Idris/AbsSyntaxTree.hs | bsd-3-clause | bi = fileFC "builtin" | 21 | bi = fileFC "builtin" | 21 | bi = fileFC "builtin" | 21 | false | false | 1 | 5 | 3 | 13 | 4 | 9 | null | null |
FranklinChen/hugs98-plus-Sep2006 | packages/Cabal/Distribution/Program.hs | bsd-3-clause | cpphsProgram :: Program
cpphsProgram = simpleProgram "cpphs" | 60 | cpphsProgram :: Program
cpphsProgram = simpleProgram "cpphs" | 60 | cpphsProgram = simpleProgram "cpphs" | 36 | false | true | 0 | 5 | 6 | 14 | 7 | 7 | null | null |
acharal/parsec-prolog | src/Language/Prolog/Parser.hs | lgpl-3.0 | parseProlog2 input = do
ops <- readFile "/home/angel/edu/phd/code/parsec-prolog/pl/op.pl"
(p, optable)<- parse st' "pl/op.pl" ops
f <- readFile input
result <- parse optable input f
return result
where parse st src input = case runPrologParser (buildTable >> many1 sentence') st src input of
Left err -> do putStr "parse error at"
print err
fail ""
Right res -> return res
sentence' = do
s <- sentence
when (isCommand s) (opDirective1 s)
return s
buildTable = do
cached <- buildOpTable
updateState (\st -> st{ cachedTable = cached })
ops = [(1200, Operators.Operator ":-" "xfx")
,(1200, Operators.Operator ":-" "fx")
,(1000, Operators.Operator "," "xfx")
]
st' = ParseSt ops [] | 1,028 | parseProlog2 input = do
ops <- readFile "/home/angel/edu/phd/code/parsec-prolog/pl/op.pl"
(p, optable)<- parse st' "pl/op.pl" ops
f <- readFile input
result <- parse optable input f
return result
where parse st src input = case runPrologParser (buildTable >> many1 sentence') st src input of
Left err -> do putStr "parse error at"
print err
fail ""
Right res -> return res
sentence' = do
s <- sentence
when (isCommand s) (opDirective1 s)
return s
buildTable = do
cached <- buildOpTable
updateState (\st -> st{ cachedTable = cached })
ops = [(1200, Operators.Operator ":-" "xfx")
,(1200, Operators.Operator ":-" "fx")
,(1000, Operators.Operator "," "xfx")
]
st' = ParseSt ops [] | 1,028 | parseProlog2 input = do
ops <- readFile "/home/angel/edu/phd/code/parsec-prolog/pl/op.pl"
(p, optable)<- parse st' "pl/op.pl" ops
f <- readFile input
result <- parse optable input f
return result
where parse st src input = case runPrologParser (buildTable >> many1 sentence') st src input of
Left err -> do putStr "parse error at"
print err
fail ""
Right res -> return res
sentence' = do
s <- sentence
when (isCommand s) (opDirective1 s)
return s
buildTable = do
cached <- buildOpTable
updateState (\st -> st{ cachedTable = cached })
ops = [(1200, Operators.Operator ":-" "xfx")
,(1200, Operators.Operator ":-" "fx")
,(1000, Operators.Operator "," "xfx")
]
st' = ParseSt ops [] | 1,028 | false | false | 1 | 13 | 456 | 284 | 133 | 151 | null | null |
sampou-org/pfad | Code/Code17.hs | bsd-3-clause | endswith0 :: Eq a => [a] -> [a] -> Bool
endswith0 ws xs = ws `elem` tails xs | 76 | endswith0 :: Eq a => [a] -> [a] -> Bool
endswith0 ws xs = ws `elem` tails xs | 76 | endswith0 ws xs = ws `elem` tails xs | 36 | false | true | 0 | 9 | 17 | 54 | 26 | 28 | null | null |
nushio3/Paraiso | examples-old/GA/HydroMain.hs | bsd-3-clause | -- the list of static variables for this machine
hydroVars :: [Named DynValue]
hydroVars =
[Named (mkName "generation") intGDV] ++
[Named (mkName "time") realGDV] ++
[Named (mkName "cfl") realGDV] ++
foldMap (\name0 -> [Named name0 realGDV]) dRNames ++
foldMap (\name0 -> [Named name0 realGDV]) extentNames ++
[Named (mkName "density") realDV] ++
foldMap (\name0 -> [Named name0 realDV]) velocityNames ++
[Named (mkName "pressure") realDV] | 460 | hydroVars :: [Named DynValue]
hydroVars =
[Named (mkName "generation") intGDV] ++
[Named (mkName "time") realGDV] ++
[Named (mkName "cfl") realGDV] ++
foldMap (\name0 -> [Named name0 realGDV]) dRNames ++
foldMap (\name0 -> [Named name0 realGDV]) extentNames ++
[Named (mkName "density") realDV] ++
foldMap (\name0 -> [Named name0 realDV]) velocityNames ++
[Named (mkName "pressure") realDV] | 411 | hydroVars =
[Named (mkName "generation") intGDV] ++
[Named (mkName "time") realGDV] ++
[Named (mkName "cfl") realGDV] ++
foldMap (\name0 -> [Named name0 realGDV]) dRNames ++
foldMap (\name0 -> [Named name0 realGDV]) extentNames ++
[Named (mkName "density") realDV] ++
foldMap (\name0 -> [Named name0 realDV]) velocityNames ++
[Named (mkName "pressure") realDV] | 381 | true | true | 0 | 15 | 83 | 179 | 92 | 87 | null | null |
dcjohnson/Project-Euler | 220/interpolate_execute.hs | mit | -- main = do
-- let Movements _ movements = executeProgramTrackMoves (interpolate 9 "Fa") (-1) (Movements (defaultPos) [])
-- filteredMovements = fmap (\l -> abs ((trd3 (l !! 0)) - ((trd3 (l !! 1))))) $ nub $ filter (\l -> (length l) > 1) $ fmap (\(x1, y1, _) -> filter (\(x2, y2, _) -> (x1, y1) == (x2, y2)) movements) movements
-- in print filteredMovements
-- main = do
-- args <- getArgs
-- let interpolateCount = read (args !! 0)
-- moveCount = (-1)
-- in print $ executeProgramTrackMoveDirection (interpolate interpolateCount "Fa") moveCount 0 defaultPos
-- main = do
-- print $ executeProgramWithInitialDirection "Fa" (-1) North
-- print $ executeProgram (interpolate 0 "Fa") (-1)
-- putStrLn "--"
-- print $ executeProgramWithInitialDirection "Rb FR" (-1) North
-- print $ executeProgram (interpolate 1 "Fa") (-1)
-- putStrLn "--"
-- print $ executeProgramWithInitialDirection "RLF aLb FR" (-1) South
-- print $ executeProgram (interpolate 2 "Fa") (-1)
-- putStrLn "--"
-- print $ executeProgramWithInitialDirection "RLF aRb FRLLF aLb FR" (-1) South
-- print $ executeProgram (interpolate 3 "Fa") (-1)
-- putStrLn "--"
-- print $ executeProgramWithInitialDirection "RLF aRb FRRLF aLb FRLLF aRb FRLLF aLb FR" (-1) South
-- print $ executeProgram (interpolate 4 "Fa") (-1)
-- putStrLn "--"
-- print $ executeProgramWithInitialDirection "RLF aRb FRRLF aLb FRRLF aRb FRLLF aLb FRLLF aRb FRRLF aLb FRLLF aRb FRLLF aLb FR" (-1) South
-- print $ executeProgram (interpolate 5 "Fa") (-1)
-- main = do
-- print $ executeProgram (interpolate 0 i) (-1)
-- print $ executeProgram (interpolate 1 i) (-1)
-- print $ executeProgram (interpolate 2 i) (-1)
-- print $ executeProgram (interpolate 3 i) (-1)
-- print $ executeProgram (interpolate 4 i) (-1)
-- print $ executeProgram (interpolate 5 i) (-1)
-- print $ executeProgram (interpolate 6 i) (-1)
-- print $ executeProgram (interpolate 7 i) (-1)
-- print $ executeProgram (interpolate 8 i) (-1)
-- print $ executeProgram (interpolate 9 i) (-1)
-- print $ executeProgram (interpolate 10 i) (-1)
-- print $ executeProgram (interpolate 11 i) (-1)
i = "Fa" | 2,202 | i = "Fa" | 8 | i = "Fa" | 8 | true | false | 1 | 5 | 442 | 50 | 43 | 7 | null | null |
DavidAlphaFox/darcs | src/Darcs/Patch/Witnesses/WZipper.hs | gpl-2.0 | --destructors
nullFZ :: FZipper a wX wY -> Bool
nullFZ (FZipper l r) = nullRL l && nullFL r | 91 | nullFZ :: FZipper a wX wY -> Bool
nullFZ (FZipper l r) = nullRL l && nullFL r | 77 | nullFZ (FZipper l r) = nullRL l && nullFL r | 43 | true | true | 2 | 9 | 18 | 50 | 22 | 28 | null | null |
danr/hipspec | testsuite/prod/zeno_version/PropT12.hs | gpl-3.0 | sorted _ = True | 15 | sorted _ = True | 15 | sorted _ = True | 15 | false | false | 0 | 4 | 3 | 10 | 4 | 6 | null | null |
liamoc/tea-hs | Tea/Tea.hs | bsd-3-clause | modifyT = Tea . lift . modify | 29 | modifyT = Tea . lift . modify | 29 | modifyT = Tea . lift . modify | 29 | false | false | 0 | 6 | 6 | 14 | 7 | 7 | null | null |
acowley/ghc | compiler/coreSyn/TrieMap.hs | bsd-3-clause | foldMaybe k (Just a) b = k a b | 30 | foldMaybe k (Just a) b = k a b | 30 | foldMaybe k (Just a) b = k a b | 30 | false | false | 1 | 6 | 8 | 29 | 11 | 18 | null | null |
JacquesCarette/literate-scientific-software | code/drasil-example/Drasil/GlassBR/Body.hs | bsd-2-clause | orgOfDocIntroEnd = foldlSent_ [atStartNP' (the Doc.dataDefn) `sAre`
S "used to support", plural definition `ofThe` S "different", plural model] | 145 | orgOfDocIntroEnd = foldlSent_ [atStartNP' (the Doc.dataDefn) `sAre`
S "used to support", plural definition `ofThe` S "different", plural model] | 145 | orgOfDocIntroEnd = foldlSent_ [atStartNP' (the Doc.dataDefn) `sAre`
S "used to support", plural definition `ofThe` S "different", plural model] | 145 | false | false | 0 | 11 | 19 | 53 | 27 | 26 | null | null |
spetz911/progames | nehe-tuts-master/lesson05.hs | mit | resizeScene :: GLFW.WindowSizeCallback
resizeScene win w 0 = resizeScene win w 1 | 89 | resizeScene :: GLFW.WindowSizeCallback
resizeScene win w 0 = resizeScene win w 1 | 89 | resizeScene win w 0 = resizeScene win w 1 | 50 | false | true | 1 | 5 | 20 | 33 | 13 | 20 | null | null |
ngzax/urbit | pkg/hs/urbit-king/lib/Urbit/Vere/Log.hs | mit | readBatch :: EventLog -> Word64 -> RIO e (V.Vector ByteString)
readBatch log first = start
where
start = do
last <- lastEv log
if (first > last)
then pure mempty
else readRows $ fromIntegral $ min 1000 $ ((last+1) - first)
assertFound :: EventId -> Bool -> RIO e ()
assertFound id found = do
unless found $ throwIO $ MissingEvent id
readRows count =
withWordPtr first $ \pIdx ->
withKVPtrs' (MDB_val 8 (castPtr pIdx)) nullVal $ \pKey pVal ->
rwith (readTxn $ env log) $ \txn ->
rwith (cursor txn $ eventsTbl log) $ \cur -> do
assertFound first =<< io (mdb_cursor_get MDB_SET_KEY cur pKey pVal)
fetchRows count cur pKey pVal
fetchRows count cur pKey pVal = do
env <- ask
V.generateM count $ \i -> runRIO env $ do
key <- io $ peek pKey >>= mdbValToWord64
val <- io $ peek pVal >>= mdbValToBytes
idx <- pure (first + word i)
unless (key == idx) $ throwIO $ MissingEvent idx
when (count /= succ i) $ do
assertFound idx =<< io (mdb_cursor_get MDB_NEXT cur pKey pVal)
pure val
{-|
Read 1000 rows from the database, starting from key `first`.
-} | 1,275 | readBatch :: EventLog -> Word64 -> RIO e (V.Vector ByteString)
readBatch log first = start
where
start = do
last <- lastEv log
if (first > last)
then pure mempty
else readRows $ fromIntegral $ min 1000 $ ((last+1) - first)
assertFound :: EventId -> Bool -> RIO e ()
assertFound id found = do
unless found $ throwIO $ MissingEvent id
readRows count =
withWordPtr first $ \pIdx ->
withKVPtrs' (MDB_val 8 (castPtr pIdx)) nullVal $ \pKey pVal ->
rwith (readTxn $ env log) $ \txn ->
rwith (cursor txn $ eventsTbl log) $ \cur -> do
assertFound first =<< io (mdb_cursor_get MDB_SET_KEY cur pKey pVal)
fetchRows count cur pKey pVal
fetchRows count cur pKey pVal = do
env <- ask
V.generateM count $ \i -> runRIO env $ do
key <- io $ peek pKey >>= mdbValToWord64
val <- io $ peek pVal >>= mdbValToBytes
idx <- pure (first + word i)
unless (key == idx) $ throwIO $ MissingEvent idx
when (count /= succ i) $ do
assertFound idx =<< io (mdb_cursor_get MDB_NEXT cur pKey pVal)
pure val
{-|
Read 1000 rows from the database, starting from key `first`.
-} | 1,275 | readBatch log first = start
where
start = do
last <- lastEv log
if (first > last)
then pure mempty
else readRows $ fromIntegral $ min 1000 $ ((last+1) - first)
assertFound :: EventId -> Bool -> RIO e ()
assertFound id found = do
unless found $ throwIO $ MissingEvent id
readRows count =
withWordPtr first $ \pIdx ->
withKVPtrs' (MDB_val 8 (castPtr pIdx)) nullVal $ \pKey pVal ->
rwith (readTxn $ env log) $ \txn ->
rwith (cursor txn $ eventsTbl log) $ \cur -> do
assertFound first =<< io (mdb_cursor_get MDB_SET_KEY cur pKey pVal)
fetchRows count cur pKey pVal
fetchRows count cur pKey pVal = do
env <- ask
V.generateM count $ \i -> runRIO env $ do
key <- io $ peek pKey >>= mdbValToWord64
val <- io $ peek pVal >>= mdbValToBytes
idx <- pure (first + word i)
unless (key == idx) $ throwIO $ MissingEvent idx
when (count /= succ i) $ do
assertFound idx =<< io (mdb_cursor_get MDB_NEXT cur pKey pVal)
pure val
{-|
Read 1000 rows from the database, starting from key `first`.
-} | 1,212 | false | true | 0 | 18 | 429 | 463 | 218 | 245 | null | null |
olya-d/virtual-arrow | src/VirtualArrow/Election.hs | mit | thresholdProportionality :: I.Input -> Double -> I.Parliament
thresholdProportionality input threshold =
calculateSeats $
filter ((>= requiredVotes) . snd) (U.frequencies $ I.firstChoices input)
where
requiredVotes :: Int
requiredVotes = round $ threshold * fromIntegral (I.nvoters input)
calculateSeats :: [(Int, I.Party)] -> I.Parliament
calculateSeats results =
map (second seats) results
where
parliamentSizeToNumberOfCountedVotes :: Double
parliamentSizeToNumberOfCountedVotes =
fromIntegral (I.parliamentSize input) /
fromIntegral (sum $ map snd results)
seats :: Int -> Int
seats votes =
round (fromIntegral votes * parliamentSizeToNumberOfCountedVotes)
-- | Helper function for singleTransferableVote
-- The current state (table) is a 2d array, s.t. [i,j] element
-- = the order of preference of the ith candidate for the jth voter,
-- starting from 1. | 974 | thresholdProportionality :: I.Input -> Double -> I.Parliament
thresholdProportionality input threshold =
calculateSeats $
filter ((>= requiredVotes) . snd) (U.frequencies $ I.firstChoices input)
where
requiredVotes :: Int
requiredVotes = round $ threshold * fromIntegral (I.nvoters input)
calculateSeats :: [(Int, I.Party)] -> I.Parliament
calculateSeats results =
map (second seats) results
where
parliamentSizeToNumberOfCountedVotes :: Double
parliamentSizeToNumberOfCountedVotes =
fromIntegral (I.parliamentSize input) /
fromIntegral (sum $ map snd results)
seats :: Int -> Int
seats votes =
round (fromIntegral votes * parliamentSizeToNumberOfCountedVotes)
-- | Helper function for singleTransferableVote
-- The current state (table) is a 2d array, s.t. [i,j] element
-- = the order of preference of the ith candidate for the jth voter,
-- starting from 1. | 974 | thresholdProportionality input threshold =
calculateSeats $
filter ((>= requiredVotes) . snd) (U.frequencies $ I.firstChoices input)
where
requiredVotes :: Int
requiredVotes = round $ threshold * fromIntegral (I.nvoters input)
calculateSeats :: [(Int, I.Party)] -> I.Parliament
calculateSeats results =
map (second seats) results
where
parliamentSizeToNumberOfCountedVotes :: Double
parliamentSizeToNumberOfCountedVotes =
fromIntegral (I.parliamentSize input) /
fromIntegral (sum $ map snd results)
seats :: Int -> Int
seats votes =
round (fromIntegral votes * parliamentSizeToNumberOfCountedVotes)
-- | Helper function for singleTransferableVote
-- The current state (table) is a 2d array, s.t. [i,j] element
-- = the order of preference of the ith candidate for the jth voter,
-- starting from 1. | 912 | false | true | 0 | 10 | 226 | 212 | 110 | 102 | null | null |
cryptica/CodeEval | Challenges/96_SwapCase/main.hs | gpl-3.0 | processLine :: String -> String
processLine = map swapCase | 58 | processLine :: String -> String
processLine = map swapCase | 58 | processLine = map swapCase | 26 | false | true | 0 | 5 | 8 | 18 | 9 | 9 | null | null |
thoughtpolice/binary-serialise-cbor | Data/Binary/Serialise/CBOR/ByteOrder.hs | bsd-3-clause | grabWord8 :: Ptr () -> Word
grabWord8 (Ptr ip#) =
W# (indexWord8OffAddr# ip# 0#) | 84 | grabWord8 :: Ptr () -> Word
grabWord8 (Ptr ip#) =
W# (indexWord8OffAddr# ip# 0#) | 84 | grabWord8 (Ptr ip#) =
W# (indexWord8OffAddr# ip# 0#) | 56 | false | true | 0 | 7 | 17 | 45 | 20 | 25 | null | null |
nevrenato/Hets_Fork | Propositional/Sublogic.hs | gpl-2.0 | bottom :: PropSL
bottom = PropSL HornClause | 43 | bottom :: PropSL
bottom = PropSL HornClause | 43 | bottom = PropSL HornClause | 26 | false | true | 0 | 5 | 6 | 14 | 7 | 7 | null | null |
mimi1vx/dotfiles | home/.xmonad/xmonad.hs | bsd-2-clause | myManageHook :: ManageHook
myManageHook =
composeAll $
[isDialog --> doFloat] ++
[appName =? r --> doIgnore | r <- myIgnores] ++
-- auto-float certain windows
[className =? c --> doCenterFloat | c <- myCenFloats] ++
[title =? t --> doFloat | t <- myFloat] ++
-- send certain windows to certain workspaces
[appName =? r --> doShift wsp | (r,wsp) <- myWorkspaceMove]
-- fulscreen windows to fullfloating
++
[isFullscreen --> doFullFloat] ++
-- unmanage docks such as gnome-panel and dzen
[fullscreenManageHook
,scratchpadManageHookDefault]
where
-- windows to operate
myIgnores =
["desktop","kdesktop","desktop_window","stalonetray"]
myCenFloats =
["Steam","steam","vlc","Vlc","mpv"]
myFloat = ["Hangouts"]
myWorkspaceMove =
[("Google-chrome-stable","web")
,("urxvt","con")
,("weechat","irc")
,("Steam","steam")
,("steam","steam")
,("Navigator","web")
,("Hexchat","irc")
,("hexchat","irc")
,("Thunderbird","email")
,("Mail","email")]
------------------------------------------------------------------------
-- Event handling
--
-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
--
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
-- | 1,496 | myManageHook :: ManageHook
myManageHook =
composeAll $
[isDialog --> doFloat] ++
[appName =? r --> doIgnore | r <- myIgnores] ++
-- auto-float certain windows
[className =? c --> doCenterFloat | c <- myCenFloats] ++
[title =? t --> doFloat | t <- myFloat] ++
-- send certain windows to certain workspaces
[appName =? r --> doShift wsp | (r,wsp) <- myWorkspaceMove]
-- fulscreen windows to fullfloating
++
[isFullscreen --> doFullFloat] ++
-- unmanage docks such as gnome-panel and dzen
[fullscreenManageHook
,scratchpadManageHookDefault]
where
-- windows to operate
myIgnores =
["desktop","kdesktop","desktop_window","stalonetray"]
myCenFloats =
["Steam","steam","vlc","Vlc","mpv"]
myFloat = ["Hangouts"]
myWorkspaceMove =
[("Google-chrome-stable","web")
,("urxvt","con")
,("weechat","irc")
,("Steam","steam")
,("steam","steam")
,("Navigator","web")
,("Hexchat","irc")
,("hexchat","irc")
,("Thunderbird","email")
,("Mail","email")]
------------------------------------------------------------------------
-- Event handling
--
-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
--
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
-- | 1,496 | myManageHook =
composeAll $
[isDialog --> doFloat] ++
[appName =? r --> doIgnore | r <- myIgnores] ++
-- auto-float certain windows
[className =? c --> doCenterFloat | c <- myCenFloats] ++
[title =? t --> doFloat | t <- myFloat] ++
-- send certain windows to certain workspaces
[appName =? r --> doShift wsp | (r,wsp) <- myWorkspaceMove]
-- fulscreen windows to fullfloating
++
[isFullscreen --> doFullFloat] ++
-- unmanage docks such as gnome-panel and dzen
[fullscreenManageHook
,scratchpadManageHookDefault]
where
-- windows to operate
myIgnores =
["desktop","kdesktop","desktop_window","stalonetray"]
myCenFloats =
["Steam","steam","vlc","Vlc","mpv"]
myFloat = ["Hangouts"]
myWorkspaceMove =
[("Google-chrome-stable","web")
,("urxvt","con")
,("weechat","irc")
,("Steam","steam")
,("steam","steam")
,("Navigator","web")
,("Hexchat","irc")
,("hexchat","irc")
,("Thunderbird","email")
,("Mail","email")]
------------------------------------------------------------------------
-- Event handling
--
-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
--
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
-- | 1,469 | false | true | 5 | 11 | 349 | 306 | 184 | 122 | null | null |
dschalk/monads-for-functional-javascript | test.hs | mit | makeCounter :: IO Counter
makeCounter = do
r <- newIORef 0
return (\i -> do modifyIORef r (+i) >> readIORef r) | 118 | makeCounter :: IO Counter
makeCounter = do
r <- newIORef 0
return (\i -> do modifyIORef r (+i) >> readIORef r) | 118 | makeCounter = do
r <- newIORef 0
return (\i -> do modifyIORef r (+i) >> readIORef r) | 92 | false | true | 0 | 14 | 28 | 57 | 27 | 30 | null | null |
bgamari/criterion | Criterion/Types/Internal.hs | bsd-2-clause | -- | A dummy environment that is passed to functions that create benchmarks
-- from environments when no concrete environment is available.
fakeEnvironment :: env
fakeEnvironment = error $ unlines
[ "Criterion atttempted to retrieve a non-existent environment!"
, "\tPerhaps you forgot to use lazy pattern matching in a function which"
, "\tconstructs benchmarks from an environment?"
, "\t(see the documentation for `env` for details)"
] | 448 | fakeEnvironment :: env
fakeEnvironment = error $ unlines
[ "Criterion atttempted to retrieve a non-existent environment!"
, "\tPerhaps you forgot to use lazy pattern matching in a function which"
, "\tconstructs benchmarks from an environment?"
, "\t(see the documentation for `env` for details)"
] | 308 | fakeEnvironment = error $ unlines
[ "Criterion atttempted to retrieve a non-existent environment!"
, "\tPerhaps you forgot to use lazy pattern matching in a function which"
, "\tconstructs benchmarks from an environment?"
, "\t(see the documentation for `env` for details)"
] | 285 | true | true | 0 | 5 | 75 | 32 | 19 | 13 | null | null |
alessandroleite/hephaestus-pl | src/core/src/BasicTypes.hs | lgpl-3.0 | precedence' [] ls = [l | l<- ls] | 33 | precedence' [] ls = [l | l<- ls] | 33 | precedence' [] ls = [l | l<- ls] | 33 | false | false | 0 | 7 | 8 | 24 | 12 | 12 | null | null |
lukemaurer/sequent-core | src/Language/SequentCore/Syntax.hs | bsd-3-clause | -- | Find whether a command is free of side effects from primops.
commandOkForSideEffects = commOk primOpOkForSideEffects | 121 | commandOkForSideEffects = commOk primOpOkForSideEffects | 55 | commandOkForSideEffects = commOk primOpOkForSideEffects | 55 | true | false | 0 | 5 | 16 | 10 | 5 | 5 | null | null |
HaskVan/tiempo | src/Tiempo.hs | mit | -- | converts the supplied @TimeInterval@ to hours
toHours :: TimeInterval -> Double
toHours (TimeInterval u v) = timeToHours u v | 129 | toHours :: TimeInterval -> Double
toHours (TimeInterval u v) = timeToHours u v | 78 | toHours (TimeInterval u v) = timeToHours u v | 44 | true | true | 0 | 6 | 20 | 36 | 17 | 19 | null | null |
foreverbell/unlimited-plt-toys | tapl/fullsimple/Type.hs | bsd-3-clause | typeOf ctx (TermAbs var ty t) = TypeArrow ty (typeShift (typeOf ctx' t) (-1))
where
ctx' = addBinding ctx var (BindVar ty) | 128 | typeOf ctx (TermAbs var ty t) = TypeArrow ty (typeShift (typeOf ctx' t) (-1))
where
ctx' = addBinding ctx var (BindVar ty) | 128 | typeOf ctx (TermAbs var ty t) = TypeArrow ty (typeShift (typeOf ctx' t) (-1))
where
ctx' = addBinding ctx var (BindVar ty) | 128 | false | false | 0 | 9 | 27 | 68 | 33 | 35 | null | null |
jfranklin9000/urbit | pkg/hs/urbit-king/lib/Urbit/Noun/Tree.hs | mit | {-
Orders in ascending +mug hash order.
Collisions fall back to dor.
-}
gor ∷ Noun → Noun → Bool
gor a b = if c==d then dor a b else c<d
where (c, d) = (mug a, mug b) | 177 | gor ∷ Noun → Noun → Bool
gor a b = if c==d then dor a b else c<d
where (c, d) = (mug a, mug b) | 96 | gor a b = if c==d then dor a b else c<d
where (c, d) = (mug a, mug b) | 71 | true | true | 0 | 6 | 50 | 72 | 38 | 34 | null | null |
schell/odin | odin-engine/src/Odin/Engine/Tiled.hs | mit | allocImageTexture :: Image -> IO (Maybe (Image, GLuint))
allocImageTexture i@Image{..} = ((i,) <$>) <$> loadImageAsTexture iSource | 130 | allocImageTexture :: Image -> IO (Maybe (Image, GLuint))
allocImageTexture i@Image{..} = ((i,) <$>) <$> loadImageAsTexture iSource | 130 | allocImageTexture i@Image{..} = ((i,) <$>) <$> loadImageAsTexture iSource | 73 | false | true | 0 | 9 | 15 | 57 | 31 | 26 | null | null |
akhileshs/stack | src/Stack/Types/StackT.hs | bsd-3-clause | withSticky :: (MonadIO m)
=> Bool -> (Sticky -> m b) -> m b
withSticky terminal m = do
if terminal
then do state <- liftIO (newMVar Nothing)
originalMode <- liftIO (hGetBuffering stdout)
liftIO (hSetBuffering stdout NoBuffering)
a <- m (Sticky (Just state))
state' <- liftIO (takeMVar state)
liftIO (when (isJust state') (S8.putStr "\n"))
liftIO (hSetBuffering stdout originalMode)
return a
else m (Sticky Nothing)
-- | Write a "sticky" line to the terminal. Any subsequent lines will
-- overwrite this one, and that same line will be repeated below
-- again. In other words, the line sticks at the bottom of the output
-- forever. Running this function again will replace the sticky line
-- with a new sticky line. When you want to get rid of the sticky
-- line, run 'logStickyDone'.
-- | 922 | withSticky :: (MonadIO m)
=> Bool -> (Sticky -> m b) -> m b
withSticky terminal m = do
if terminal
then do state <- liftIO (newMVar Nothing)
originalMode <- liftIO (hGetBuffering stdout)
liftIO (hSetBuffering stdout NoBuffering)
a <- m (Sticky (Just state))
state' <- liftIO (takeMVar state)
liftIO (when (isJust state') (S8.putStr "\n"))
liftIO (hSetBuffering stdout originalMode)
return a
else m (Sticky Nothing)
-- | Write a "sticky" line to the terminal. Any subsequent lines will
-- overwrite this one, and that same line will be repeated below
-- again. In other words, the line sticks at the bottom of the output
-- forever. Running this function again will replace the sticky line
-- with a new sticky line. When you want to get rid of the sticky
-- line, run 'logStickyDone'.
-- | 922 | withSticky terminal m = do
if terminal
then do state <- liftIO (newMVar Nothing)
originalMode <- liftIO (hGetBuffering stdout)
liftIO (hSetBuffering stdout NoBuffering)
a <- m (Sticky (Just state))
state' <- liftIO (takeMVar state)
liftIO (when (isJust state') (S8.putStr "\n"))
liftIO (hSetBuffering stdout originalMode)
return a
else m (Sticky Nothing)
-- | Write a "sticky" line to the terminal. Any subsequent lines will
-- overwrite this one, and that same line will be repeated below
-- again. In other words, the line sticks at the bottom of the output
-- forever. Running this function again will replace the sticky line
-- with a new sticky line. When you want to get rid of the sticky
-- line, run 'logStickyDone'.
-- | 851 | false | true | 0 | 15 | 268 | 205 | 98 | 107 | null | null |
pparkkin/eta | compiler/ETA/Prelude/PrimOp.hs | bsd-3-clause | primOpInfo CloneMutableArrayOp = mkGenPrimOp (fsLit "cloneMutableArray#") [deltaTyVar, alphaTyVar] [mkMutableArrayPrimTy deltaTy alphaTy, intPrimTy, intPrimTy, mkStatePrimTy deltaTy] ((mkTupleTy UnboxedTuple [mkStatePrimTy deltaTy, mkMutableArrayPrimTy deltaTy alphaTy])) | 272 | primOpInfo CloneMutableArrayOp = mkGenPrimOp (fsLit "cloneMutableArray#") [deltaTyVar, alphaTyVar] [mkMutableArrayPrimTy deltaTy alphaTy, intPrimTy, intPrimTy, mkStatePrimTy deltaTy] ((mkTupleTy UnboxedTuple [mkStatePrimTy deltaTy, mkMutableArrayPrimTy deltaTy alphaTy])) | 272 | primOpInfo CloneMutableArrayOp = mkGenPrimOp (fsLit "cloneMutableArray#") [deltaTyVar, alphaTyVar] [mkMutableArrayPrimTy deltaTy alphaTy, intPrimTy, intPrimTy, mkStatePrimTy deltaTy] ((mkTupleTy UnboxedTuple [mkStatePrimTy deltaTy, mkMutableArrayPrimTy deltaTy alphaTy])) | 272 | false | false | 0 | 10 | 22 | 75 | 39 | 36 | null | null |
forsyde/forsyde-atom | src/ForSyDe/Atom/MoC/DE/Lib.hs | bsd-3-clause | reconfig24 = MoC.reconfig24 | 27 | reconfig24 = MoC.reconfig24 | 27 | reconfig24 = MoC.reconfig24 | 27 | false | false | 1 | 6 | 2 | 12 | 4 | 8 | null | null |
ComputationWithBoundedResources/ara-inference | doc/tpdb_trs/Haskell/basic_haskell/elem_2.hs | mit | primEqInt (Neg Zero) (Neg Zero) = MyTrue | 40 | primEqInt (Neg Zero) (Neg Zero) = MyTrue | 40 | primEqInt (Neg Zero) (Neg Zero) = MyTrue | 40 | false | false | 0 | 7 | 6 | 23 | 11 | 12 | null | null |
BeautifulDestinations/fb | gen/src/Facebook/Gen/CodeGenStr.hs | bsd-3-clause | genDefFields :: V.Vector FieldInfo -> Text
genDefFields fis =
let ds = genReqFields fis
defs = V.foldr' append "" $ V.map (\req -> req <> " ::: ") ds
in defs | 167 | genDefFields :: V.Vector FieldInfo -> Text
genDefFields fis =
let ds = genReqFields fis
defs = V.foldr' append "" $ V.map (\req -> req <> " ::: ") ds
in defs | 167 | genDefFields fis =
let ds = genReqFields fis
defs = V.foldr' append "" $ V.map (\req -> req <> " ::: ") ds
in defs | 124 | false | true | 0 | 13 | 40 | 72 | 35 | 37 | null | null |
nadavshemer/buildsome | src/Lib/Makefile/Types.hs | gpl-2.0 | onInputPatPaths f (InputPattern x) = InputPattern <$> onFilePatternPaths f x | 76 | onInputPatPaths f (InputPattern x) = InputPattern <$> onFilePatternPaths f x | 76 | onInputPatPaths f (InputPattern x) = InputPattern <$> onFilePatternPaths f x | 76 | false | false | 0 | 7 | 9 | 26 | 12 | 14 | null | null |
snoyberg/ghc | compiler/hsSyn/HsPat.hs | bsd-3-clause | pprConArgs (InfixCon p1 p2) = sep [pprParendLPat p1, pprParendLPat p2] | 70 | pprConArgs (InfixCon p1 p2) = sep [pprParendLPat p1, pprParendLPat p2] | 70 | pprConArgs (InfixCon p1 p2) = sep [pprParendLPat p1, pprParendLPat p2] | 70 | false | false | 0 | 7 | 9 | 33 | 15 | 18 | null | null |
brendanhay/gogol | gogol-analytics/gen/Network/Google/Analytics/Types/Product.hs | mpl-2.0 | -- | List of real time metrics.
rdqMetrics :: Lens' RealtimeDataQuery [Text]
rdqMetrics
= lens _rdqMetrics (\ s a -> s{_rdqMetrics = a}) .
_Default
. _Coerce | 171 | rdqMetrics :: Lens' RealtimeDataQuery [Text]
rdqMetrics
= lens _rdqMetrics (\ s a -> s{_rdqMetrics = a}) .
_Default
. _Coerce | 139 | rdqMetrics
= lens _rdqMetrics (\ s a -> s{_rdqMetrics = a}) .
_Default
. _Coerce | 94 | true | true | 0 | 11 | 40 | 53 | 28 | 25 | null | null |
fmthoma/ghc | compiler/main/GhcMake.hs | bsd-3-clause | noModError :: DynFlags -> SrcSpan -> ModuleName -> FindResult -> ErrMsg
-- ToDo: we don't have a proper line number for this error
noModError dflags loc wanted_mod err
= mkPlainErrMsg dflags loc $ cannotFindModule dflags wanted_mod err | 237 | noModError :: DynFlags -> SrcSpan -> ModuleName -> FindResult -> ErrMsg
noModError dflags loc wanted_mod err
= mkPlainErrMsg dflags loc $ cannotFindModule dflags wanted_mod err | 178 | noModError dflags loc wanted_mod err
= mkPlainErrMsg dflags loc $ cannotFindModule dflags wanted_mod err | 106 | true | true | 0 | 8 | 38 | 53 | 26 | 27 | null | null |
palf/haskellSDL2Examples | examples/lesson12/src/Lesson12/Transitions.hs | gpl-2.0 | toggle Green w = w { toggles = newToggles }
where newGreenT = not $ greenT (toggles w)
newToggles = (toggles w) { greenT = newGreenT } | 144 | toggle Green w = w { toggles = newToggles }
where newGreenT = not $ greenT (toggles w)
newToggles = (toggles w) { greenT = newGreenT } | 144 | toggle Green w = w { toggles = newToggles }
where newGreenT = not $ greenT (toggles w)
newToggles = (toggles w) { greenT = newGreenT } | 144 | false | false | 3 | 8 | 36 | 73 | 32 | 41 | null | null |
dysinger/amazonka | amazonka-opsworks/gen/Network/AWS/OpsWorks/RegisterRdsDbInstance.hs | mpl-2.0 | -- | 'RegisterRdsDbInstanceResponse' constructor.
registerRdsDbInstanceResponse :: RegisterRdsDbInstanceResponse
registerRdsDbInstanceResponse = RegisterRdsDbInstanceResponse | 174 | registerRdsDbInstanceResponse :: RegisterRdsDbInstanceResponse
registerRdsDbInstanceResponse = RegisterRdsDbInstanceResponse | 124 | registerRdsDbInstanceResponse = RegisterRdsDbInstanceResponse | 61 | true | true | 0 | 4 | 9 | 12 | 7 | 5 | null | null |
kqr/cod2stats | Models.hs | bsd-3-clause | getEfficacy :: Connection -> Int -> IO Double
getEfficacy pg player_id = do
row <- flip (query pg) (Only player_id) $
"SELECT AVG(efficacy) FROM (SELECT " <> efficacyQuery <>
"FROM roundplayers WHERE player_id=? ORDER BY round_id DESC LIMIT 10) a"
-- Return the result, but default to zero if it doesn't exist
return . head . (++[0]) . map fromOnly $ row | 382 | getEfficacy :: Connection -> Int -> IO Double
getEfficacy pg player_id = do
row <- flip (query pg) (Only player_id) $
"SELECT AVG(efficacy) FROM (SELECT " <> efficacyQuery <>
"FROM roundplayers WHERE player_id=? ORDER BY round_id DESC LIMIT 10) a"
-- Return the result, but default to zero if it doesn't exist
return . head . (++[0]) . map fromOnly $ row | 382 | getEfficacy pg player_id = do
row <- flip (query pg) (Only player_id) $
"SELECT AVG(efficacy) FROM (SELECT " <> efficacyQuery <>
"FROM roundplayers WHERE player_id=? ORDER BY round_id DESC LIMIT 10) a"
-- Return the result, but default to zero if it doesn't exist
return . head . (++[0]) . map fromOnly $ row | 336 | false | true | 0 | 13 | 89 | 93 | 46 | 47 | null | null |
yu-i9/thih | src/Thih/Static/Prelude.hs | bsd-3-clause | fromDoubleMfun
= "fromDouble" :>: (Forall [Star]
([isIn1 cFractional (TGen 0)] :=>
(tDouble `fn` TGen 0))) | 152 | fromDoubleMfun
= "fromDouble" :>: (Forall [Star]
([isIn1 cFractional (TGen 0)] :=>
(tDouble `fn` TGen 0))) | 152 | fromDoubleMfun
= "fromDouble" :>: (Forall [Star]
([isIn1 cFractional (TGen 0)] :=>
(tDouble `fn` TGen 0))) | 152 | false | false | 1 | 14 | 60 | 58 | 29 | 29 | null | null |
tylerprete/haskell-minimax-games | src/tictactoe.hs | bsd-3-clause | makeMoveGS gs = let (score, move) = alphabeta gs 0 10 (-100) 100 in
case move of
(Just x) -> makeSuccessor gs x
Nothing -> error "should never get Nothing as a move" | 185 | makeMoveGS gs = let (score, move) = alphabeta gs 0 10 (-100) 100 in
case move of
(Just x) -> makeSuccessor gs x
Nothing -> error "should never get Nothing as a move" | 185 | makeMoveGS gs = let (score, move) = alphabeta gs 0 10 (-100) 100 in
case move of
(Just x) -> makeSuccessor gs x
Nothing -> error "should never get Nothing as a move" | 185 | false | false | 2 | 11 | 52 | 65 | 32 | 33 | null | null |
futtetennista/IntroductionToFunctionalProgramming | RWH/src/ch19/ParseInt.hs | mit | runParser :: Parser a -> B.ByteString
-> Either ParseError (a, B.ByteString)
runParser p xs =
case S.runState (E.runExceptT . runP $ p) xs of
(Left err, _) ->
Left err
(Right x, ys) ->
Right (x, ys) | 231 | runParser :: Parser a -> B.ByteString
-> Either ParseError (a, B.ByteString)
runParser p xs =
case S.runState (E.runExceptT . runP $ p) xs of
(Left err, _) ->
Left err
(Right x, ys) ->
Right (x, ys) | 231 | runParser p xs =
case S.runState (E.runExceptT . runP $ p) xs of
(Left err, _) ->
Left err
(Right x, ys) ->
Right (x, ys) | 144 | false | true | 0 | 10 | 69 | 108 | 55 | 53 | null | null |
chrisdone/haskell-docs | src/Haskell/Docs/Formatting.hs | bsd-3-clause | -- * Formatting
-- | Print docs as s-expressions.
printSexp :: [IdentDoc] -> Ghc ()
printSexp = mapM toSexp >=> liftIO . putStrLn . renderSexp . List | 150 | printSexp :: [IdentDoc] -> Ghc ()
printSexp = mapM toSexp >=> liftIO . putStrLn . renderSexp . List | 99 | printSexp = mapM toSexp >=> liftIO . putStrLn . renderSexp . List | 65 | true | true | 0 | 9 | 27 | 44 | 23 | 21 | null | null |
printedheart/atomspace | opencog/haskell/OpenCog/AtomSpace/Internal.hs | agpl-3.0 | fromTVRaw :: TVRaw -> TruthVal
fromTVRaw (TVRaw SIMPLE_TRUTH_VALUE (a:b:_)) = SimpleTV a b | 91 | fromTVRaw :: TVRaw -> TruthVal
fromTVRaw (TVRaw SIMPLE_TRUTH_VALUE (a:b:_)) = SimpleTV a b | 91 | fromTVRaw (TVRaw SIMPLE_TRUTH_VALUE (a:b:_)) = SimpleTV a b | 60 | false | true | 0 | 12 | 13 | 47 | 22 | 25 | null | null |
sdiehl/ghc | compiler/simplCore/OccurAnal.hs | bsd-3-clause | zapDetails = markAllMany . markAllNonTailCalled | 47 | zapDetails = markAllMany . markAllNonTailCalled | 47 | zapDetails = markAllMany . markAllNonTailCalled | 47 | false | false | 0 | 5 | 4 | 10 | 5 | 5 | null | null |
nushio3/ghc | compiler/nativeGen/Dwarf/Constants.hs | bsd-3-clause | dW_AT_ghc_span_start_col = 0x2b02 | 34 | dW_AT_ghc_span_start_col = 0x2b02 | 34 | dW_AT_ghc_span_start_col = 0x2b02 | 34 | false | false | 0 | 4 | 3 | 6 | 3 | 3 | null | null |
dpwright/igo | src/Game/Go/Board.hs | bsd-3-clause | at :: R.Shape sh => Board sh p -> sh -> Maybe p
at b = (asArray b !) | 68 | at :: R.Shape sh => Board sh p -> sh -> Maybe p
at b = (asArray b !) | 68 | at b = (asArray b !) | 20 | false | true | 0 | 8 | 18 | 50 | 23 | 27 | null | null |
Th30n/hasgel | app/Main.hs | mit | handleGameEvent (KeyPressedEvent KeyS) = modify $ moveCamera MoveBack | 69 | handleGameEvent (KeyPressedEvent KeyS) = modify $ moveCamera MoveBack | 69 | handleGameEvent (KeyPressedEvent KeyS) = modify $ moveCamera MoveBack | 69 | false | false | 0 | 7 | 7 | 22 | 10 | 12 | null | null |
hsyl20/ViperVM | haskus-system/src/lib/Haskus/System/Linux/Sound/Pcm.hs | bsd-3-clause | -- | Convert raw PCM hw params into PcmConfig
toConfig :: PcmHwParams -> PcmConfig
toConfig params = PcmConfig
{ pcmConfigAccess = fromMask m1
, pcmConfigFormat = fromMask m2
, pcmConfigSubFormat = fromMask m3
}
where
fromMask :: forall a. (Ord a, Bounded a, Enum a, CBitSet a) => Mask -> Set a
fromMask (Mask v) = Set.fromList (BitSet.enumerateSetBits v)
m1:m2:m3:_ = Vector.toList (pcmHwParamsMasks params) | 448 | toConfig :: PcmHwParams -> PcmConfig
toConfig params = PcmConfig
{ pcmConfigAccess = fromMask m1
, pcmConfigFormat = fromMask m2
, pcmConfigSubFormat = fromMask m3
}
where
fromMask :: forall a. (Ord a, Bounded a, Enum a, CBitSet a) => Mask -> Set a
fromMask (Mask v) = Set.fromList (BitSet.enumerateSetBits v)
m1:m2:m3:_ = Vector.toList (pcmHwParamsMasks params) | 402 | toConfig params = PcmConfig
{ pcmConfigAccess = fromMask m1
, pcmConfigFormat = fromMask m2
, pcmConfigSubFormat = fromMask m3
}
where
fromMask :: forall a. (Ord a, Bounded a, Enum a, CBitSet a) => Mask -> Set a
fromMask (Mask v) = Set.fromList (BitSet.enumerateSetBits v)
m1:m2:m3:_ = Vector.toList (pcmHwParamsMasks params) | 365 | true | true | 0 | 10 | 103 | 150 | 77 | 73 | null | null |
spechub/Hets | SoftFOL/DFGParser.hs | gpl-2.0 | text :: Parser String
text = fmap (reverse . dropWhile isSpace . reverse) $
symbolT "{*" >> manyTill anyChar (symbolT "*}") | 127 | text :: Parser String
text = fmap (reverse . dropWhile isSpace . reverse) $
symbolT "{*" >> manyTill anyChar (symbolT "*}") | 127 | text = fmap (reverse . dropWhile isSpace . reverse) $
symbolT "{*" >> manyTill anyChar (symbolT "*}") | 105 | false | true | 2 | 9 | 24 | 59 | 26 | 33 | null | null |
ghcjs/jsaddle-dom | src/JSDOM/Generated/FontFace.hs | mit | -- | <https://developer.mozilla.org/en-US/docs/Web/API/FontFace.weight Mozilla FontFace.weight documentation>
setWeight ::
(MonadDOM m, ToJSString val) => FontFace -> val -> m ()
setWeight self val = liftDOM (self ^. jss "weight" (toJSVal val)) | 255 | setWeight ::
(MonadDOM m, ToJSString val) => FontFace -> val -> m ()
setWeight self val = liftDOM (self ^. jss "weight" (toJSVal val)) | 144 | setWeight self val = liftDOM (self ^. jss "weight" (toJSVal val)) | 65 | true | true | 0 | 10 | 40 | 66 | 33 | 33 | null | null |
jfranklin9000/urbit | pkg/hs/terminal-progress-bar/src/System/ProgressBar.hs | mit | totalTime
:: (NominalDiffTime -> TL.Text)
-> TL.Text
-- ^ Alternative message when total time can't be calculated
-- (yet).
-> Label s
totalTime formatNDT altMsg = Label render
where
render progress timing
| dt > 1 = formatNDT estimatedTotalTime
| progressDone progress <= 0 = altMsg
| otherwise = altMsg
where
estimatedTotalTime = dt * recip progressFraction
progressFraction :: NominalDiffTime
progressFraction
| progressTodo progress <= 0 = 1
| otherwise = fromIntegral (progressDone progress)
/ fromIntegral (progressTodo progress)
dt :: NominalDiffTime
dt = diffUTCTime (timingLastUpdate timing) (timingStart timing)
-- | Show amount of time.
--
-- > renderDuration (fromInteger 42)
-- 42
--
-- > renderDuration (fromInteger $ 5 * 60 + 42)
-- 05:42
--
-- > renderDuration (fromInteger $ 8 * 60 * 60 + 5 * 60 + 42)
-- 08:05:42
--
-- Use the time >= 1.9 package to get a formatTime function which
-- accepts 'NominalDiffTime'. | 1,076 | totalTime
:: (NominalDiffTime -> TL.Text)
-> TL.Text
-- ^ Alternative message when total time can't be calculated
-- (yet).
-> Label s
totalTime formatNDT altMsg = Label render
where
render progress timing
| dt > 1 = formatNDT estimatedTotalTime
| progressDone progress <= 0 = altMsg
| otherwise = altMsg
where
estimatedTotalTime = dt * recip progressFraction
progressFraction :: NominalDiffTime
progressFraction
| progressTodo progress <= 0 = 1
| otherwise = fromIntegral (progressDone progress)
/ fromIntegral (progressTodo progress)
dt :: NominalDiffTime
dt = diffUTCTime (timingLastUpdate timing) (timingStart timing)
-- | Show amount of time.
--
-- > renderDuration (fromInteger 42)
-- 42
--
-- > renderDuration (fromInteger $ 5 * 60 + 42)
-- 05:42
--
-- > renderDuration (fromInteger $ 8 * 60 * 60 + 5 * 60 + 42)
-- 08:05:42
--
-- Use the time >= 1.9 package to get a formatTime function which
-- accepts 'NominalDiffTime'. | 1,076 | totalTime formatNDT altMsg = Label render
where
render progress timing
| dt > 1 = formatNDT estimatedTotalTime
| progressDone progress <= 0 = altMsg
| otherwise = altMsg
where
estimatedTotalTime = dt * recip progressFraction
progressFraction :: NominalDiffTime
progressFraction
| progressTodo progress <= 0 = 1
| otherwise = fromIntegral (progressDone progress)
/ fromIntegral (progressTodo progress)
dt :: NominalDiffTime
dt = diffUTCTime (timingLastUpdate timing) (timingStart timing)
-- | Show amount of time.
--
-- > renderDuration (fromInteger 42)
-- 42
--
-- > renderDuration (fromInteger $ 5 * 60 + 42)
-- 05:42
--
-- > renderDuration (fromInteger $ 8 * 60 * 60 + 5 * 60 + 42)
-- 08:05:42
--
-- Use the time >= 1.9 package to get a formatTime function which
-- accepts 'NominalDiffTime'. | 915 | false | true | 0 | 11 | 297 | 206 | 104 | 102 | null | null |
spetz911/progames | vinyl-gl-master/examples/src/example1-vinyl.hs | mit | animate :: Resources -> IO Resources
animate r = do seconds <- getTime
let fade = sin seconds * 0.5 + 0.5
return r { fadeFactor = realToFrac fade } | 177 | animate :: Resources -> IO Resources
animate r = do seconds <- getTime
let fade = sin seconds * 0.5 + 0.5
return r { fadeFactor = realToFrac fade } | 177 | animate r = do seconds <- getTime
let fade = sin seconds * 0.5 + 0.5
return r { fadeFactor = realToFrac fade } | 140 | false | true | 0 | 13 | 59 | 70 | 31 | 39 | null | null |
philopon/apiary | apiary-purescript/src/Web/Apiary/PureScript.hs | mit | initPureScript :: MonadIO m => I.PureScriptConfig -> Initializer' m I.PureScript
initPureScript = initializer' . liftIO . I.makePureScript | 138 | initPureScript :: MonadIO m => I.PureScriptConfig -> Initializer' m I.PureScript
initPureScript = initializer' . liftIO . I.makePureScript | 138 | initPureScript = initializer' . liftIO . I.makePureScript | 57 | false | true | 0 | 8 | 16 | 41 | 20 | 21 | null | null |
mit-plv/riscv-semantics | src/Spec/Decode.hs | bsd-3-clause | isValidA inst = inst /= InvalidA | 32 | isValidA inst = inst /= InvalidA | 32 | isValidA inst = inst /= InvalidA | 32 | false | false | 3 | 5 | 5 | 19 | 7 | 12 | null | null |
brendanhay/gogol | gogol-slides/gen/Network/Google/Resource/Slides/Presentations/BatchUpdate.hs | mpl-2.0 | -- | Multipart request metadata.
pbuPayload :: Lens' PresentationsBatchUpdate BatchUpdatePresentationRequest
pbuPayload
= lens _pbuPayload (\ s a -> s{_pbuPayload = a}) | 170 | pbuPayload :: Lens' PresentationsBatchUpdate BatchUpdatePresentationRequest
pbuPayload
= lens _pbuPayload (\ s a -> s{_pbuPayload = a}) | 137 | pbuPayload
= lens _pbuPayload (\ s a -> s{_pbuPayload = a}) | 61 | true | true | 0 | 9 | 22 | 42 | 22 | 20 | null | null |
juhp/stack | src/Stack/Types/NamedComponent.hs | bsd-3-clause | isCLib _ = False | 16 | isCLib _ = False | 16 | isCLib _ = False | 16 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
sweirich/hs-inferno | test/G.hs | bsd-3-clause | flet x t u = Let x Nothing t u | 30 | flet x t u = Let x Nothing t u | 30 | flet x t u = Let x Nothing t u | 30 | false | false | 0 | 5 | 9 | 24 | 10 | 14 | null | null |
DanielG/hipo | HostListParser.hs | gpl-3.0 | ipNet :: Tokenizer (IP,Int)
ipNet = do (addr :: Maybe IP) <- (readMaybe <$> (many1 (digit <|> oneOf ".")))
(prefix :: Maybe Int) <- (readMaybe <$> (char '/' >> many1 digit))
case liftA2 (,) addr prefix of
Just r -> return (r :: (IP,Int))
Nothing -> fail $ msg addr prefix
where
msg a p = "Not an IPv4/prefix (" ++ show a ++ "/" ++ show p ++ ")" | 402 | ipNet :: Tokenizer (IP,Int)
ipNet = do (addr :: Maybe IP) <- (readMaybe <$> (many1 (digit <|> oneOf ".")))
(prefix :: Maybe Int) <- (readMaybe <$> (char '/' >> many1 digit))
case liftA2 (,) addr prefix of
Just r -> return (r :: (IP,Int))
Nothing -> fail $ msg addr prefix
where
msg a p = "Not an IPv4/prefix (" ++ show a ++ "/" ++ show p ++ ")" | 402 | ipNet = do (addr :: Maybe IP) <- (readMaybe <$> (many1 (digit <|> oneOf ".")))
(prefix :: Maybe Int) <- (readMaybe <$> (char '/' >> many1 digit))
case liftA2 (,) addr prefix of
Just r -> return (r :: (IP,Int))
Nothing -> fail $ msg addr prefix
where
msg a p = "Not an IPv4/prefix (" ++ show a ++ "/" ++ show p ++ ")" | 374 | false | true | 0 | 14 | 127 | 187 | 93 | 94 | null | null |
phischu/fragnix | tests/packages/scotty/Data.Text.Internal.Builder.hs | bsd-3-clause | ------------------------------------------------------------------------
-- | Ensure that there are at least @n@ many elements available.
ensureFree :: Int -> Builder
ensureFree !n = withSize $ \ l ->
if n <= l
then empty
else flush `append'` withBuffer (const (newBuffer (max n smallChunkSize))) | 309 | ensureFree :: Int -> Builder
ensureFree !n = withSize $ \ l ->
if n <= l
then empty
else flush `append'` withBuffer (const (newBuffer (max n smallChunkSize))) | 170 | ensureFree !n = withSize $ \ l ->
if n <= l
then empty
else flush `append'` withBuffer (const (newBuffer (max n smallChunkSize))) | 141 | true | true | 0 | 15 | 53 | 71 | 38 | 33 | null | null |
ulricha/dsh | src/Database/DSH/Frontend/Externals.hs | bsd-3-clause | empty :: QA a => Q [a] -> Q Bool
empty = null | 45 | empty :: QA a => Q [a] -> Q Bool
empty = null | 45 | empty = null | 12 | false | true | 0 | 8 | 12 | 31 | 15 | 16 | null | null |
ocramz/CurveProject | src/Math/TikzGenerator.hs | bsd-3-clause | drawAxis :: CGConfig -> Builder
drawAxis CGConfig{axisOptions=AxisOpts {..}, comments} =
mWhen comments "% Axes du repère\n"
<> "\\draw [->] " <> point (xMin ^& yOrig) <> " -- " <> point (xMax ^& yOrig) <> ";\n"
<> "\\draw [->] " <> point (xOrig ^& yMin) <> " -- " <> point (xOrig ^& yMax) <> ";\n"
<> "\\foreach \\x in {"
<> showListF 2 (filter (inRange xMin xMax) $ [xOrig + xTicks, xOrig + 2*xTicks..xMax]
++ [xOrig - xTicks, xOrig - 2*xTicks..xMin]) <> "}\n"
<> " \\draw[shift={(\\x," <> showF 3 yOrig <> ")}] (0,0.2) -- (0,-0.2) node[below,fill=white] {$\\x$};\n"
<> "\\foreach \\y in {"
<> showListF 2 (filter (inRange yMin yMax) $ [yOrig + yTicks, yOrig + 2*yTicks..yMax]
++ [yOrig - yTicks, yOrig - 2*yTicks..yMin]) <> "}\n"
<> " \\draw[shift={(" <> showF 3 xOrig <> ",\\y)}] (0.2,0) -- (-0.2,0) node[left,fill=white] {$\\y$};\n\n" | 899 | drawAxis :: CGConfig -> Builder
drawAxis CGConfig{axisOptions=AxisOpts {..}, comments} =
mWhen comments "% Axes du repère\n"
<> "\\draw [->] " <> point (xMin ^& yOrig) <> " -- " <> point (xMax ^& yOrig) <> ";\n"
<> "\\draw [->] " <> point (xOrig ^& yMin) <> " -- " <> point (xOrig ^& yMax) <> ";\n"
<> "\\foreach \\x in {"
<> showListF 2 (filter (inRange xMin xMax) $ [xOrig + xTicks, xOrig + 2*xTicks..xMax]
++ [xOrig - xTicks, xOrig - 2*xTicks..xMin]) <> "}\n"
<> " \\draw[shift={(\\x," <> showF 3 yOrig <> ")}] (0,0.2) -- (0,-0.2) node[below,fill=white] {$\\x$};\n"
<> "\\foreach \\y in {"
<> showListF 2 (filter (inRange yMin yMax) $ [yOrig + yTicks, yOrig + 2*yTicks..yMax]
++ [yOrig - yTicks, yOrig - 2*yTicks..yMin]) <> "}\n"
<> " \\draw[shift={(" <> showF 3 xOrig <> ",\\y)}] (0.2,0) -- (-0.2,0) node[left,fill=white] {$\\y$};\n\n" | 899 | drawAxis CGConfig{axisOptions=AxisOpts {..}, comments} =
mWhen comments "% Axes du repère\n"
<> "\\draw [->] " <> point (xMin ^& yOrig) <> " -- " <> point (xMax ^& yOrig) <> ";\n"
<> "\\draw [->] " <> point (xOrig ^& yMin) <> " -- " <> point (xOrig ^& yMax) <> ";\n"
<> "\\foreach \\x in {"
<> showListF 2 (filter (inRange xMin xMax) $ [xOrig + xTicks, xOrig + 2*xTicks..xMax]
++ [xOrig - xTicks, xOrig - 2*xTicks..xMin]) <> "}\n"
<> " \\draw[shift={(\\x," <> showF 3 yOrig <> ")}] (0,0.2) -- (0,-0.2) node[below,fill=white] {$\\x$};\n"
<> "\\foreach \\y in {"
<> showListF 2 (filter (inRange yMin yMax) $ [yOrig + yTicks, yOrig + 2*yTicks..yMax]
++ [yOrig - yTicks, yOrig - 2*yTicks..yMin]) <> "}\n"
<> " \\draw[shift={(" <> showF 3 xOrig <> ",\\y)}] (0.2,0) -- (-0.2,0) node[left,fill=white] {$\\y$};\n\n" | 867 | false | true | 16 | 12 | 199 | 323 | 159 | 164 | null | null |
rueshyna/gogol | gogol-storage/gen/Network/Google/Resource/Storage/ObjectAccessControls/List.hs | mpl-2.0 | -- | Creates a value of 'ObjectAccessControlsList' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'oaclBucket'
--
-- * 'oaclObject'
--
-- * 'oaclGeneration'
objectAccessControlsList
:: Text -- ^ 'oaclBucket'
-> Text -- ^ 'oaclObject'
-> ObjectAccessControlsList
objectAccessControlsList pOaclBucket_ pOaclObject_ =
ObjectAccessControlsList'
{ _oaclBucket = pOaclBucket_
, _oaclObject = pOaclObject_
, _oaclGeneration = Nothing
} | 546 | objectAccessControlsList
:: Text -- ^ 'oaclBucket'
-> Text -- ^ 'oaclObject'
-> ObjectAccessControlsList
objectAccessControlsList pOaclBucket_ pOaclObject_ =
ObjectAccessControlsList'
{ _oaclBucket = pOaclBucket_
, _oaclObject = pOaclObject_
, _oaclGeneration = Nothing
} | 303 | objectAccessControlsList pOaclBucket_ pOaclObject_ =
ObjectAccessControlsList'
{ _oaclBucket = pOaclBucket_
, _oaclObject = pOaclObject_
, _oaclGeneration = Nothing
} | 186 | true | true | 0 | 8 | 104 | 64 | 38 | 26 | null | null |
possiblywrong/linear-generic-tries | trie.hs | bsd-3-clause | -- Only unit can lookup
tlookup (TSum t1 _) (Left a) = tlookup t1 a | 68 | tlookup (TSum t1 _) (Left a) = tlookup t1 a | 44 | tlookup (TSum t1 _) (Left a) = tlookup t1 a | 44 | true | false | 0 | 7 | 15 | 31 | 15 | 16 | null | null |
nushio3/ghc | compiler/deSugar/DsUtils.hs | bsd-3-clause | mkDataConCase var ty alts@(alt1:_) = MatchResult fail_flag mk_case
where
con1 = alt_pat alt1
tycon = dataConTyCon con1
data_cons = tyConDataCons tycon
match_results = map alt_result alts
sorted_alts :: [CaseAlt DataCon]
sorted_alts = sort_alts alts
var_ty = idType var
(_, ty_args) = tcSplitTyConApp var_ty -- Don't look through newtypes
-- (not that splitTyConApp does, these days)
mk_case :: CoreExpr -> DsM CoreExpr
mk_case fail = do
alts <- mapM (mk_alt fail) sorted_alts
return $ mkWildCase (Var var) (idType var) ty (mk_default fail ++ alts)
mk_alt :: CoreExpr -> CaseAlt DataCon -> DsM CoreAlt
mk_alt fail MkCaseAlt{ alt_pat = con,
alt_bndrs = args,
alt_result = MatchResult _ body_fn }
= do { body <- body_fn fail
; case dataConBoxer con of {
Nothing -> return (DataAlt con, args, body) ;
Just (DCB boxer) ->
do { us <- newUniqueSupply
; let (rep_ids, binds) = initUs_ us (boxer ty_args args)
; return (DataAlt con, rep_ids, mkLets binds body) } } }
mk_default :: CoreExpr -> [CoreAlt]
mk_default fail | exhaustive_case = []
| otherwise = [(DEFAULT, [], fail)]
fail_flag :: CanItFail
fail_flag | exhaustive_case
= foldr orFail CantFail [can_it_fail | MatchResult can_it_fail _ <- match_results]
| otherwise
= CanFail
mentioned_constructors = mkUniqSet $ map alt_pat alts
un_mentioned_constructors
= mkUniqSet data_cons `minusUniqSet` mentioned_constructors
exhaustive_case = isEmptyUniqSet un_mentioned_constructors
--- Stuff for parallel arrays
--
-- * the following is to desugar cases over fake constructors for
-- parallel arrays, which are introduced by `tidy1' in the `PArrPat'
-- case
-- | 1,988 | mkDataConCase var ty alts@(alt1:_) = MatchResult fail_flag mk_case
where
con1 = alt_pat alt1
tycon = dataConTyCon con1
data_cons = tyConDataCons tycon
match_results = map alt_result alts
sorted_alts :: [CaseAlt DataCon]
sorted_alts = sort_alts alts
var_ty = idType var
(_, ty_args) = tcSplitTyConApp var_ty -- Don't look through newtypes
-- (not that splitTyConApp does, these days)
mk_case :: CoreExpr -> DsM CoreExpr
mk_case fail = do
alts <- mapM (mk_alt fail) sorted_alts
return $ mkWildCase (Var var) (idType var) ty (mk_default fail ++ alts)
mk_alt :: CoreExpr -> CaseAlt DataCon -> DsM CoreAlt
mk_alt fail MkCaseAlt{ alt_pat = con,
alt_bndrs = args,
alt_result = MatchResult _ body_fn }
= do { body <- body_fn fail
; case dataConBoxer con of {
Nothing -> return (DataAlt con, args, body) ;
Just (DCB boxer) ->
do { us <- newUniqueSupply
; let (rep_ids, binds) = initUs_ us (boxer ty_args args)
; return (DataAlt con, rep_ids, mkLets binds body) } } }
mk_default :: CoreExpr -> [CoreAlt]
mk_default fail | exhaustive_case = []
| otherwise = [(DEFAULT, [], fail)]
fail_flag :: CanItFail
fail_flag | exhaustive_case
= foldr orFail CantFail [can_it_fail | MatchResult can_it_fail _ <- match_results]
| otherwise
= CanFail
mentioned_constructors = mkUniqSet $ map alt_pat alts
un_mentioned_constructors
= mkUniqSet data_cons `minusUniqSet` mentioned_constructors
exhaustive_case = isEmptyUniqSet un_mentioned_constructors
--- Stuff for parallel arrays
--
-- * the following is to desugar cases over fake constructors for
-- parallel arrays, which are introduced by `tidy1' in the `PArrPat'
-- case
-- | 1,988 | mkDataConCase var ty alts@(alt1:_) = MatchResult fail_flag mk_case
where
con1 = alt_pat alt1
tycon = dataConTyCon con1
data_cons = tyConDataCons tycon
match_results = map alt_result alts
sorted_alts :: [CaseAlt DataCon]
sorted_alts = sort_alts alts
var_ty = idType var
(_, ty_args) = tcSplitTyConApp var_ty -- Don't look through newtypes
-- (not that splitTyConApp does, these days)
mk_case :: CoreExpr -> DsM CoreExpr
mk_case fail = do
alts <- mapM (mk_alt fail) sorted_alts
return $ mkWildCase (Var var) (idType var) ty (mk_default fail ++ alts)
mk_alt :: CoreExpr -> CaseAlt DataCon -> DsM CoreAlt
mk_alt fail MkCaseAlt{ alt_pat = con,
alt_bndrs = args,
alt_result = MatchResult _ body_fn }
= do { body <- body_fn fail
; case dataConBoxer con of {
Nothing -> return (DataAlt con, args, body) ;
Just (DCB boxer) ->
do { us <- newUniqueSupply
; let (rep_ids, binds) = initUs_ us (boxer ty_args args)
; return (DataAlt con, rep_ids, mkLets binds body) } } }
mk_default :: CoreExpr -> [CoreAlt]
mk_default fail | exhaustive_case = []
| otherwise = [(DEFAULT, [], fail)]
fail_flag :: CanItFail
fail_flag | exhaustive_case
= foldr orFail CantFail [can_it_fail | MatchResult can_it_fail _ <- match_results]
| otherwise
= CanFail
mentioned_constructors = mkUniqSet $ map alt_pat alts
un_mentioned_constructors
= mkUniqSet data_cons `minusUniqSet` mentioned_constructors
exhaustive_case = isEmptyUniqSet un_mentioned_constructors
--- Stuff for parallel arrays
--
-- * the following is to desugar cases over fake constructors for
-- parallel arrays, which are introduced by `tidy1' in the `PArrPat'
-- case
-- | 1,988 | false | false | 18 | 17 | 630 | 568 | 267 | 301 | null | null |
michaelt/streaming-bytestring | Data/ByteString/Streaming.hs | bsd-3-clause | null (Chunk bs rest) = if S.null bs
then null rest
else do
r <- SP.effects (toChunks rest)
return (False :> r)
| 130 | null (Chunk bs rest) = if S.null bs
then null rest
else do
r <- SP.effects (toChunks rest)
return (False :> r)
| 130 | null (Chunk bs rest) = if S.null bs
then null rest
else do
r <- SP.effects (toChunks rest)
return (False :> r)
| 130 | false | false | 0 | 11 | 41 | 65 | 30 | 35 | null | null |
jecisc/TP_PF_L3 | PF-TP4/tp4_PF_ferlicot.hs | mit | -- Question 21
insertArbre :: Ord a => a -> Arbre Couleur a -> Arbre Couleur a
insertArbre val arbre = equilibre (insertWithoutEq val arbre) | 140 | insertArbre :: Ord a => a -> Arbre Couleur a -> Arbre Couleur a
insertArbre val arbre = equilibre (insertWithoutEq val arbre) | 125 | insertArbre val arbre = equilibre (insertWithoutEq val arbre) | 61 | true | true | 0 | 9 | 24 | 57 | 26 | 31 | null | null |
urbanslug/ghc | compiler/nativeGen/Dwarf/Types.hs | bsd-3-clause | -- | Assembly for a DWARF word of dynamic data. This means 32 bit, as
-- we are generating 32 bit DWARF.
pprDwWord :: SDoc -> SDoc
pprDwWord = pprData4' | 152 | pprDwWord :: SDoc -> SDoc
pprDwWord = pprData4' | 47 | pprDwWord = pprData4' | 21 | true | true | 0 | 5 | 29 | 17 | 10 | 7 | null | null |
kosmoskatten/hats | src/Network/Nats/Subscriber.hs | mit | -- | Enumerate all subscriber SUB 'Message's from the 'SubscriberMap'.
subscribeMessages :: SubscriberMap -> IO [Message]
subscribeMessages subscriberMap =
map extractMessage . HM.elems <$> readTVarIO subscriberMap | 218 | subscribeMessages :: SubscriberMap -> IO [Message]
subscribeMessages subscriberMap =
map extractMessage . HM.elems <$> readTVarIO subscriberMap | 147 | subscribeMessages subscriberMap =
map extractMessage . HM.elems <$> readTVarIO subscriberMap | 96 | true | true | 0 | 7 | 29 | 41 | 20 | 21 | null | null |
tensorflow/haskell | tensorflow/src/TensorFlow/Internal/FFI.hs | apache-2.0 | -- | Runs the given action after creating a session with options
-- populated by the given optionSetter.
withSession :: (MonadIO m, MonadMask m)
=> (Raw.SessionOptions -> IO ())
-> ((IO () -> IO ()) -> Raw.Session -> m a)
-- ^ The action can spawn concurrent tasks which will
-- be canceled before withSession returns.
-> m a
withSession optionSetter action = do
drain <- liftIO $ newMVar []
let cleanup s =
-- Closes the session to nudge the pending run calls to fail and exit.
finally (checkStatus (Raw.closeSession s)) $ do
runners <- takeMVar drain
-- Collects all runners before deleting the session.
mapM_ shutDownRunner runners
checkStatus (Raw.deleteSession s)
let bracketIO x y = bracket (liftIO x) (liftIO . y)
bracketIO Raw.newSessionOptions Raw.deleteSessionOptions $ \options -> do
bracketIO
(optionSetter options >> checkStatus (Raw.newSession options))
cleanup
(action (asyncCollector drain)) | 1,111 | withSession :: (MonadIO m, MonadMask m)
=> (Raw.SessionOptions -> IO ())
-> ((IO () -> IO ()) -> Raw.Session -> m a)
-- ^ The action can spawn concurrent tasks which will
-- be canceled before withSession returns.
-> m a
withSession optionSetter action = do
drain <- liftIO $ newMVar []
let cleanup s =
-- Closes the session to nudge the pending run calls to fail and exit.
finally (checkStatus (Raw.closeSession s)) $ do
runners <- takeMVar drain
-- Collects all runners before deleting the session.
mapM_ shutDownRunner runners
checkStatus (Raw.deleteSession s)
let bracketIO x y = bracket (liftIO x) (liftIO . y)
bracketIO Raw.newSessionOptions Raw.deleteSessionOptions $ \options -> do
bracketIO
(optionSetter options >> checkStatus (Raw.newSession options))
cleanup
(action (asyncCollector drain)) | 1,006 | withSession optionSetter action = do
drain <- liftIO $ newMVar []
let cleanup s =
-- Closes the session to nudge the pending run calls to fail and exit.
finally (checkStatus (Raw.closeSession s)) $ do
runners <- takeMVar drain
-- Collects all runners before deleting the session.
mapM_ shutDownRunner runners
checkStatus (Raw.deleteSession s)
let bracketIO x y = bracket (liftIO x) (liftIO . y)
bracketIO Raw.newSessionOptions Raw.deleteSessionOptions $ \options -> do
bracketIO
(optionSetter options >> checkStatus (Raw.newSession options))
cleanup
(action (asyncCollector drain)) | 725 | true | true | 0 | 17 | 344 | 272 | 130 | 142 | null | null |
wesleybowman/dotfiles | .xmonad/xmonad.hs | mit | --}}}
-- Main {{{
main = do
dzenLeftBar <- spawnPipe myStatusBar
spawn myBtmStatusBar
spawn "sh /home/wesley/.xmonad/autostart.sh"
xmonad $ defaultConfig
{ terminal = myTerminal
, workspaces = myWorkspaces
, keys = keys'
, modMask = modMask'
, startupHook = ewmhDesktopsStartup >> setWMName "LG3D"
, layoutHook = layoutHook'
, manageHook = manageHook'
, logHook = myLogHook dzenLeftBar >> fadeInactiveLogHook 0xdddddddd >> setWMName "LG3D"
, normalBorderColor = colorNormalBorder
, focusedBorderColor = colorFocusedBorder
, focusFollowsMouse = myFocusFollowsMouse
}
--}}}
-- Hooks {{{
-- ManageHook {{{ | 777 | main = do
dzenLeftBar <- spawnPipe myStatusBar
spawn myBtmStatusBar
spawn "sh /home/wesley/.xmonad/autostart.sh"
xmonad $ defaultConfig
{ terminal = myTerminal
, workspaces = myWorkspaces
, keys = keys'
, modMask = modMask'
, startupHook = ewmhDesktopsStartup >> setWMName "LG3D"
, layoutHook = layoutHook'
, manageHook = manageHook'
, logHook = myLogHook dzenLeftBar >> fadeInactiveLogHook 0xdddddddd >> setWMName "LG3D"
, normalBorderColor = colorNormalBorder
, focusedBorderColor = colorFocusedBorder
, focusFollowsMouse = myFocusFollowsMouse
}
--}}}
-- Hooks {{{
-- ManageHook {{{ | 759 | main = do
dzenLeftBar <- spawnPipe myStatusBar
spawn myBtmStatusBar
spawn "sh /home/wesley/.xmonad/autostart.sh"
xmonad $ defaultConfig
{ terminal = myTerminal
, workspaces = myWorkspaces
, keys = keys'
, modMask = modMask'
, startupHook = ewmhDesktopsStartup >> setWMName "LG3D"
, layoutHook = layoutHook'
, manageHook = manageHook'
, logHook = myLogHook dzenLeftBar >> fadeInactiveLogHook 0xdddddddd >> setWMName "LG3D"
, normalBorderColor = colorNormalBorder
, focusedBorderColor = colorFocusedBorder
, focusFollowsMouse = myFocusFollowsMouse
}
--}}}
-- Hooks {{{
-- ManageHook {{{ | 759 | true | false | 0 | 12 | 255 | 132 | 74 | 58 | null | null |
sonyandy/tnt | Control/Monad/Code/Opcode.hs | bsd-3-clause | dconst_1 :: Word8
dconst_1 = 0x0f | 33 | dconst_1 :: Word8
dconst_1 = 0x0f | 33 | dconst_1 = 0x0f | 15 | false | true | 0 | 4 | 5 | 11 | 6 | 5 | null | null |
simonmichael/hledger | hledger-lib/Hledger/Query.hs | gpl-3.0 | parseQueryTerm d (T.stripPrefix "not:" -> Just s) =
case parseQueryTerm d s of
Right (Left m) -> Right $ Left $ Not m
Right (Right _) -> Right $ Left Any -- not:somequeryoption will be ignored
Left err -> Left err | 235 | parseQueryTerm d (T.stripPrefix "not:" -> Just s) =
case parseQueryTerm d s of
Right (Left m) -> Right $ Left $ Not m
Right (Right _) -> Right $ Left Any -- not:somequeryoption will be ignored
Left err -> Left err | 235 | parseQueryTerm d (T.stripPrefix "not:" -> Just s) =
case parseQueryTerm d s of
Right (Left m) -> Right $ Left $ Not m
Right (Right _) -> Right $ Left Any -- not:somequeryoption will be ignored
Left err -> Left err | 235 | false | false | 0 | 10 | 62 | 98 | 44 | 54 | null | null |
damoxc/ganeti | src/Ganeti/OpParams.hs | gpl-2.0 | -- | Another name for the shutdown timeout, because we like to be
-- inconsistent.
pShutdownTimeout' :: Field
pShutdownTimeout' =
renameField "InstShutdownTimeout" .
defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
simpleField "timeout" [t| NonNegative Int |] | 274 | pShutdownTimeout' :: Field
pShutdownTimeout' =
renameField "InstShutdownTimeout" .
defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
simpleField "timeout" [t| NonNegative Int |] | 191 | pShutdownTimeout' =
renameField "InstShutdownTimeout" .
defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
simpleField "timeout" [t| NonNegative Int |] | 164 | true | true | 0 | 7 | 40 | 39 | 23 | 16 | null | null |
hkuplg/fcore | examples/case_studies/PureLambda.hs | bsd-2-clause | allAlphaCon (x:xs@(y:ys)) = (alphaCongruent xl yl) && allAlphaCon xs
where xl = head $ reverse (limitedReduce x)
yl = head $ reverse (limitedReduce y) | 216 | allAlphaCon (x:xs@(y:ys)) = (alphaCongruent xl yl) && allAlphaCon xs
where xl = head $ reverse (limitedReduce x)
yl = head $ reverse (limitedReduce y) | 216 | allAlphaCon (x:xs@(y:ys)) = (alphaCongruent xl yl) && allAlphaCon xs
where xl = head $ reverse (limitedReduce x)
yl = head $ reverse (limitedReduce y) | 216 | false | false | 0 | 10 | 89 | 80 | 40 | 40 | null | null |
haslab/SecreC | src/Language/SecreC/Prover/Semantics.hs | gpl-3.0 | evalIBinOp l IXor (boolILit -> Just b1) (boolILit -> Just b2) = return $ ILit $ IBool $ (b1 || b2) && not (b1 && b2) | 117 | evalIBinOp l IXor (boolILit -> Just b1) (boolILit -> Just b2) = return $ ILit $ IBool $ (b1 || b2) && not (b1 && b2) | 117 | evalIBinOp l IXor (boolILit -> Just b1) (boolILit -> Just b2) = return $ ILit $ IBool $ (b1 || b2) && not (b1 && b2) | 117 | false | false | 0 | 8 | 26 | 68 | 34 | 34 | null | null |
albertov/hs-mapnik | swagger/spec/Mapnik/SwaggerSpec.hs | bsd-3-clause | main :: IO ()
main = hspec spec | 31 | main :: IO ()
main = hspec spec | 31 | main = hspec spec | 17 | false | true | 0 | 6 | 7 | 19 | 9 | 10 | null | null |
k0001/gtk2hs | tools/apiGen/src/MarshalFixup.hs | gpl-3.0 | -- some special cases for when converting "gtk_foo_bar" to "GtkFooBar"
-- eg instead of doing gtk_hadjustment -> GtkHadjustment
-- we would prefer gtk_hadjustment -> GtkHAdjustment
-- so list those special cases here:
fixCFunctionName :: String -> String
fixCFunctionName "hadjustment" = "HAdjustment" | 305 | fixCFunctionName :: String -> String
fixCFunctionName "hadjustment" = "HAdjustment" | 83 | fixCFunctionName "hadjustment" = "HAdjustment" | 46 | true | true | 0 | 5 | 44 | 26 | 14 | 12 | null | null |
Southern-Exposure-Seed-Exchange/southernexposure.com | server/test/Spec.hs | gpl-3.0 | routesStoneEdge :: TestTree
routesStoneEdge = testGroup "Routes.StoneEdge Module"
[ testCase "Unsupported setifunction Parameter" unsupportedFunction
, testCase "Missing setifunction Parameter" noFunction
, testCase "Incomplete downloadorders Form" parseErrorXml
, orderTransformTests
]
where
unsupportedFunction :: Assertion
unsupportedFunction =
let expectedForm = fromEntriesByKey @Text @Text
[("setifunction", ["nanjidesuka"]), ("setiuser", ["auser"])]
in testFormParsing "setifunction=nanjidesuka&setiuser=auser"
$ UnexpectedFunction "nanjidesuka" expectedForm
noFunction :: Assertion
noFunction =
let expectedForm = fromEntriesByKey @Text @Text
[("setiuser", ["auser"]), ("password", ["pwd"])]
in testFormParsing "setiuser=auser&password=pwd"
$ InvalidRequest expectedForm
parseErrorXml :: Assertion
parseErrorXml =
(urlDecodeForm "setifunction=downloadorders" >>= fromForm @StoneEdgeRequest)
@?= Left (decodeUtf8 SEF.ordersParseErrorXml)
orderTransformTests :: TestTree
orderTransformTests = testGroup "Order Transformation"
[ testCase "Coupon" couponTransform
, testCase "Coupon to Nothing" couponTransformNothing
, testCase "Store Credit" storeCreditTransform
, testCase "Store Credit to Nothing" storeCreditTransformNothing
, testCase "Tax" taxTransform
, testCase "Tax with Rate" taxTransformRate
, testCase "Discount" discountTransform
, testCase "Surcharge" surchargeTransform
, testCase "Shipping Total" shippingTotalTransform
]
couponTransform :: Assertion
couponTransform =
let c = Entity nullSqlKey $ Coupon "CC" "Coup" "" True (FlatDiscount 300) 0 fillerTime 0 0 fillerTime
li = Entity nullSqlKey $ OrderLineItem nullSqlKey CouponDiscountLine "Coup Discount" 300
sc = StoneEdgeCoupon "Coup" Nothing (StoneEdgeCents 300) (Just True)
in Just sc @=? transformCoupon c li
storeCreditTransform :: Assertion
storeCreditTransform =
let li = Entity nullSqlKey $ OrderLineItem nullSqlKey StoreCreditLine "Store Credit" 500
sc = StoneEdgeOrderStoreCredit $ StoneEdgePaymentStoreCredit
(StoneEdgeCents 500) (Just "Store Credit")
in Just sc @=? transformStoreCredit li
couponTransformNothing :: Assertion
couponTransformNothing =
let c = Entity nullSqlKey $ Coupon "CC" "Coup" "" True (FlatDiscount 300) 0 fillerTime 0 0 fillerTime
li = Entity nullSqlKey $ OrderLineItem nullSqlKey PriorityShippingLine "Not a coupon" 900
in Nothing @=? transformCoupon c li
storeCreditTransformNothing :: Assertion
storeCreditTransformNothing =
let li = Entity nullSqlKey $ OrderLineItem nullSqlKey PriorityShippingLine "Not store credit" 900
in Nothing @=? transformStoreCredit li
taxTransform :: Assertion
taxTransform =
let st = StoneEdgeTax (StoneEdgeCents 9001) Nothing (Just True) (Just False) Nothing
in st @=? transformTax (makeTaxLine "Tax Description" (Cents 9001))
taxTransformRate :: Assertion
taxTransformRate =
let st = StoneEdgeTax (StoneEdgeCents 9001) (Just 0.053) (Just True) (Just False) Nothing
in st @=? transformTax (makeTaxLine "VA Tax (5.3%)" (Cents 9001))
discountTransform :: Assertion
discountTransform =
let dc = StoneEdgeDiscount (Just SEFlatDiscount) (Just "description")
Nothing (StoneEdgeCents 9001) (Just True)
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey MemberDiscountLine "description" (Cents 9001)
in dc @=? transformDiscount ol
surchargeTransform :: Assertion
surchargeTransform =
let ss = StoneEdgeSurcharge (StoneEdgeCents 200) (Just "Fee")
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey SurchargeLine "Fee" (Cents 200)
in ss @=? transformSurcharge ol
shippingTotalTransform :: Assertion
shippingTotalTransform =
let st = StoneEdgeShippingTotal (StoneEdgeCents 200) (Just "Shipping")
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey ShippingLine "Shipping" (Cents 200)
in st @=? transformShippingTotal ol
makeTaxLine :: Text -> Cents -> OrderLineItem
makeTaxLine =
OrderLineItem nullSqlKey TaxLine
fillerTime :: UTCTime
fillerTime =
UTCTime
(ModifiedJulianDay 1000)
(secondsToDiffTime 0)
nullSqlKey :: ToBackendKey SqlBackend a => Key a
nullSqlKey = toSqlKey 0
-- AVALARA | 4,669 | routesStoneEdge :: TestTree
routesStoneEdge = testGroup "Routes.StoneEdge Module"
[ testCase "Unsupported setifunction Parameter" unsupportedFunction
, testCase "Missing setifunction Parameter" noFunction
, testCase "Incomplete downloadorders Form" parseErrorXml
, orderTransformTests
]
where
unsupportedFunction :: Assertion
unsupportedFunction =
let expectedForm = fromEntriesByKey @Text @Text
[("setifunction", ["nanjidesuka"]), ("setiuser", ["auser"])]
in testFormParsing "setifunction=nanjidesuka&setiuser=auser"
$ UnexpectedFunction "nanjidesuka" expectedForm
noFunction :: Assertion
noFunction =
let expectedForm = fromEntriesByKey @Text @Text
[("setiuser", ["auser"]), ("password", ["pwd"])]
in testFormParsing "setiuser=auser&password=pwd"
$ InvalidRequest expectedForm
parseErrorXml :: Assertion
parseErrorXml =
(urlDecodeForm "setifunction=downloadorders" >>= fromForm @StoneEdgeRequest)
@?= Left (decodeUtf8 SEF.ordersParseErrorXml)
orderTransformTests :: TestTree
orderTransformTests = testGroup "Order Transformation"
[ testCase "Coupon" couponTransform
, testCase "Coupon to Nothing" couponTransformNothing
, testCase "Store Credit" storeCreditTransform
, testCase "Store Credit to Nothing" storeCreditTransformNothing
, testCase "Tax" taxTransform
, testCase "Tax with Rate" taxTransformRate
, testCase "Discount" discountTransform
, testCase "Surcharge" surchargeTransform
, testCase "Shipping Total" shippingTotalTransform
]
couponTransform :: Assertion
couponTransform =
let c = Entity nullSqlKey $ Coupon "CC" "Coup" "" True (FlatDiscount 300) 0 fillerTime 0 0 fillerTime
li = Entity nullSqlKey $ OrderLineItem nullSqlKey CouponDiscountLine "Coup Discount" 300
sc = StoneEdgeCoupon "Coup" Nothing (StoneEdgeCents 300) (Just True)
in Just sc @=? transformCoupon c li
storeCreditTransform :: Assertion
storeCreditTransform =
let li = Entity nullSqlKey $ OrderLineItem nullSqlKey StoreCreditLine "Store Credit" 500
sc = StoneEdgeOrderStoreCredit $ StoneEdgePaymentStoreCredit
(StoneEdgeCents 500) (Just "Store Credit")
in Just sc @=? transformStoreCredit li
couponTransformNothing :: Assertion
couponTransformNothing =
let c = Entity nullSqlKey $ Coupon "CC" "Coup" "" True (FlatDiscount 300) 0 fillerTime 0 0 fillerTime
li = Entity nullSqlKey $ OrderLineItem nullSqlKey PriorityShippingLine "Not a coupon" 900
in Nothing @=? transformCoupon c li
storeCreditTransformNothing :: Assertion
storeCreditTransformNothing =
let li = Entity nullSqlKey $ OrderLineItem nullSqlKey PriorityShippingLine "Not store credit" 900
in Nothing @=? transformStoreCredit li
taxTransform :: Assertion
taxTransform =
let st = StoneEdgeTax (StoneEdgeCents 9001) Nothing (Just True) (Just False) Nothing
in st @=? transformTax (makeTaxLine "Tax Description" (Cents 9001))
taxTransformRate :: Assertion
taxTransformRate =
let st = StoneEdgeTax (StoneEdgeCents 9001) (Just 0.053) (Just True) (Just False) Nothing
in st @=? transformTax (makeTaxLine "VA Tax (5.3%)" (Cents 9001))
discountTransform :: Assertion
discountTransform =
let dc = StoneEdgeDiscount (Just SEFlatDiscount) (Just "description")
Nothing (StoneEdgeCents 9001) (Just True)
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey MemberDiscountLine "description" (Cents 9001)
in dc @=? transformDiscount ol
surchargeTransform :: Assertion
surchargeTransform =
let ss = StoneEdgeSurcharge (StoneEdgeCents 200) (Just "Fee")
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey SurchargeLine "Fee" (Cents 200)
in ss @=? transformSurcharge ol
shippingTotalTransform :: Assertion
shippingTotalTransform =
let st = StoneEdgeShippingTotal (StoneEdgeCents 200) (Just "Shipping")
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey ShippingLine "Shipping" (Cents 200)
in st @=? transformShippingTotal ol
makeTaxLine :: Text -> Cents -> OrderLineItem
makeTaxLine =
OrderLineItem nullSqlKey TaxLine
fillerTime :: UTCTime
fillerTime =
UTCTime
(ModifiedJulianDay 1000)
(secondsToDiffTime 0)
nullSqlKey :: ToBackendKey SqlBackend a => Key a
nullSqlKey = toSqlKey 0
-- AVALARA | 4,669 | routesStoneEdge = testGroup "Routes.StoneEdge Module"
[ testCase "Unsupported setifunction Parameter" unsupportedFunction
, testCase "Missing setifunction Parameter" noFunction
, testCase "Incomplete downloadorders Form" parseErrorXml
, orderTransformTests
]
where
unsupportedFunction :: Assertion
unsupportedFunction =
let expectedForm = fromEntriesByKey @Text @Text
[("setifunction", ["nanjidesuka"]), ("setiuser", ["auser"])]
in testFormParsing "setifunction=nanjidesuka&setiuser=auser"
$ UnexpectedFunction "nanjidesuka" expectedForm
noFunction :: Assertion
noFunction =
let expectedForm = fromEntriesByKey @Text @Text
[("setiuser", ["auser"]), ("password", ["pwd"])]
in testFormParsing "setiuser=auser&password=pwd"
$ InvalidRequest expectedForm
parseErrorXml :: Assertion
parseErrorXml =
(urlDecodeForm "setifunction=downloadorders" >>= fromForm @StoneEdgeRequest)
@?= Left (decodeUtf8 SEF.ordersParseErrorXml)
orderTransformTests :: TestTree
orderTransformTests = testGroup "Order Transformation"
[ testCase "Coupon" couponTransform
, testCase "Coupon to Nothing" couponTransformNothing
, testCase "Store Credit" storeCreditTransform
, testCase "Store Credit to Nothing" storeCreditTransformNothing
, testCase "Tax" taxTransform
, testCase "Tax with Rate" taxTransformRate
, testCase "Discount" discountTransform
, testCase "Surcharge" surchargeTransform
, testCase "Shipping Total" shippingTotalTransform
]
couponTransform :: Assertion
couponTransform =
let c = Entity nullSqlKey $ Coupon "CC" "Coup" "" True (FlatDiscount 300) 0 fillerTime 0 0 fillerTime
li = Entity nullSqlKey $ OrderLineItem nullSqlKey CouponDiscountLine "Coup Discount" 300
sc = StoneEdgeCoupon "Coup" Nothing (StoneEdgeCents 300) (Just True)
in Just sc @=? transformCoupon c li
storeCreditTransform :: Assertion
storeCreditTransform =
let li = Entity nullSqlKey $ OrderLineItem nullSqlKey StoreCreditLine "Store Credit" 500
sc = StoneEdgeOrderStoreCredit $ StoneEdgePaymentStoreCredit
(StoneEdgeCents 500) (Just "Store Credit")
in Just sc @=? transformStoreCredit li
couponTransformNothing :: Assertion
couponTransformNothing =
let c = Entity nullSqlKey $ Coupon "CC" "Coup" "" True (FlatDiscount 300) 0 fillerTime 0 0 fillerTime
li = Entity nullSqlKey $ OrderLineItem nullSqlKey PriorityShippingLine "Not a coupon" 900
in Nothing @=? transformCoupon c li
storeCreditTransformNothing :: Assertion
storeCreditTransformNothing =
let li = Entity nullSqlKey $ OrderLineItem nullSqlKey PriorityShippingLine "Not store credit" 900
in Nothing @=? transformStoreCredit li
taxTransform :: Assertion
taxTransform =
let st = StoneEdgeTax (StoneEdgeCents 9001) Nothing (Just True) (Just False) Nothing
in st @=? transformTax (makeTaxLine "Tax Description" (Cents 9001))
taxTransformRate :: Assertion
taxTransformRate =
let st = StoneEdgeTax (StoneEdgeCents 9001) (Just 0.053) (Just True) (Just False) Nothing
in st @=? transformTax (makeTaxLine "VA Tax (5.3%)" (Cents 9001))
discountTransform :: Assertion
discountTransform =
let dc = StoneEdgeDiscount (Just SEFlatDiscount) (Just "description")
Nothing (StoneEdgeCents 9001) (Just True)
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey MemberDiscountLine "description" (Cents 9001)
in dc @=? transformDiscount ol
surchargeTransform :: Assertion
surchargeTransform =
let ss = StoneEdgeSurcharge (StoneEdgeCents 200) (Just "Fee")
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey SurchargeLine "Fee" (Cents 200)
in ss @=? transformSurcharge ol
shippingTotalTransform :: Assertion
shippingTotalTransform =
let st = StoneEdgeShippingTotal (StoneEdgeCents 200) (Just "Shipping")
ol = Entity nullSqlKey $ OrderLineItem nullSqlKey ShippingLine "Shipping" (Cents 200)
in st @=? transformShippingTotal ol
makeTaxLine :: Text -> Cents -> OrderLineItem
makeTaxLine =
OrderLineItem nullSqlKey TaxLine
fillerTime :: UTCTime
fillerTime =
UTCTime
(ModifiedJulianDay 1000)
(secondsToDiffTime 0)
nullSqlKey :: ToBackendKey SqlBackend a => Key a
nullSqlKey = toSqlKey 0
-- AVALARA | 4,641 | false | true | 16 | 12 | 1,128 | 1,141 | 555 | 586 | null | null |
diagrams/diagrams-contrib | src/Diagrams/TwoD/Path/Turtle/Internal.hs | bsd-3-clause | -- Modifies the current style after starting a new trail
modifyCurrStyle :: (Floating n, Ord n) =>
(PenStyle n -> PenStyle n)
-> TurtleState n
-> TurtleState n
modifyCurrStyle f t = t # makeNewTrail # \t' -> t' { currPenStyle = (f . currPenStyle) t' } | 303 | modifyCurrStyle :: (Floating n, Ord n) =>
(PenStyle n -> PenStyle n)
-> TurtleState n
-> TurtleState n
modifyCurrStyle f t = t # makeNewTrail # \t' -> t' { currPenStyle = (f . currPenStyle) t' } | 246 | modifyCurrStyle f t = t # makeNewTrail # \t' -> t' { currPenStyle = (f . currPenStyle) t' } | 92 | true | true | 0 | 11 | 98 | 90 | 46 | 44 | null | null |
punitrathore/haskell-first-principles | src/Chap18.hs | bsd-3-clause | testPhhhbbtttEither = do
let t = (undefined :: (PhhhbbtttEither Int (Int, Int, Int)))
quickBatch $ functor t
quickBatch $ applicative t
quickBatch $ monad t | 164 | testPhhhbbtttEither = do
let t = (undefined :: (PhhhbbtttEither Int (Int, Int, Int)))
quickBatch $ functor t
quickBatch $ applicative t
quickBatch $ monad t | 164 | testPhhhbbtttEither = do
let t = (undefined :: (PhhhbbtttEither Int (Int, Int, Int)))
quickBatch $ functor t
quickBatch $ applicative t
quickBatch $ monad t | 164 | false | false | 0 | 13 | 32 | 68 | 33 | 35 | null | null |
zaxtax/hakaru | haskell/Tests/TestTools.hs | bsd-3-clause | hasLab :: String -> Test -> Bool
hasLab l (TestLabel lab _) = lab == l | 70 | hasLab :: String -> Test -> Bool
hasLab l (TestLabel lab _) = lab == l | 70 | hasLab l (TestLabel lab _) = lab == l | 37 | false | true | 0 | 7 | 15 | 36 | 18 | 18 | null | null |
hth313/hthforth | src/Translator/Expression.hs | bsd-2-clause | showExpr (Select n elts) _ _ = "select " ++ show n ++ " of " ++ show elts | 73 | showExpr (Select n elts) _ _ = "select " ++ show n ++ " of " ++ show elts | 73 | showExpr (Select n elts) _ _ = "select " ++ show n ++ " of " ++ show elts | 73 | false | false | 0 | 8 | 18 | 39 | 18 | 21 | null | null |
SteffenMichels/IHPMC | test/IntegrationExactProbabilities.hs | mit | objectsOtherUniform :: IntegrationTest
objectsOtherUniform = IntegrationTest
{ label = "uniform other object distributions"
, model = unpack $ [text|
~x ~ uniformObjects(100).
~y ~ uniformOtherObject(~x).
q1 <- ~y = #0.
q2 <- ~y /= #0.
q3 <- ~x = #0, ~y = #1.
q4 <- ~y /= #0, ~y /= #1.
q5 <- ~x = #0, ~y = #0.
|]
, expectedResults =
[ (query "q1", preciseProb 0.01)
, (query "q2", preciseProb 0.99)
, (query "q3", preciseProb $ 1/9900)
, (query "q4", preciseProb 0.98)
, (query "q5", preciseProb 0.0)
]
} | 708 | objectsOtherUniform :: IntegrationTest
objectsOtherUniform = IntegrationTest
{ label = "uniform other object distributions"
, model = unpack $ [text|
~x ~ uniformObjects(100).
~y ~ uniformOtherObject(~x).
q1 <- ~y = #0.
q2 <- ~y /= #0.
q3 <- ~x = #0, ~y = #1.
q4 <- ~y /= #0, ~y /= #1.
q5 <- ~x = #0, ~y = #0.
|]
, expectedResults =
[ (query "q1", preciseProb 0.01)
, (query "q2", preciseProb 0.99)
, (query "q3", preciseProb $ 1/9900)
, (query "q4", preciseProb 0.98)
, (query "q5", preciseProb 0.0)
]
} | 708 | objectsOtherUniform = IntegrationTest
{ label = "uniform other object distributions"
, model = unpack $ [text|
~x ~ uniformObjects(100).
~y ~ uniformOtherObject(~x).
q1 <- ~y = #0.
q2 <- ~y /= #0.
q3 <- ~x = #0, ~y = #1.
q4 <- ~y /= #0, ~y /= #1.
q5 <- ~x = #0, ~y = #0.
|]
, expectedResults =
[ (query "q1", preciseProb 0.01)
, (query "q2", preciseProb 0.99)
, (query "q3", preciseProb $ 1/9900)
, (query "q4", preciseProb 0.98)
, (query "q5", preciseProb 0.0)
]
} | 669 | false | true | 0 | 11 | 294 | 123 | 69 | 54 | null | null |
brendanhay/gogol | gogol-compute/gen/Network/Google/Resource/Compute/Instances/ListReferrers.hs | mpl-2.0 | -- | Specifies a page token to use. Set \`pageToken\` to the
-- \`nextPageToken\` returned by a previous list request to get the next
-- page of results.
ilrPageToken :: Lens' InstancesListReferrers (Maybe Text)
ilrPageToken
= lens _ilrPageToken (\ s a -> s{_ilrPageToken = a}) | 279 | ilrPageToken :: Lens' InstancesListReferrers (Maybe Text)
ilrPageToken
= lens _ilrPageToken (\ s a -> s{_ilrPageToken = a}) | 125 | ilrPageToken
= lens _ilrPageToken (\ s a -> s{_ilrPageToken = a}) | 67 | true | true | 0 | 9 | 46 | 50 | 27 | 23 | null | null |
tolysz/dsp | DSP/Estimation/Spectral/AR.hs | gpl-2.0 | ar_mcov :: (Ix a, Integral a, RealFloat b) => Array a (Complex b) -- ^ x
-> a -- ^ p
-> (Array a (Complex b), b) -- ^ (a,rho)
ar_mcov x p = (a, sig2 / (fromIntegral (2*(n-p))))
where a = cholesky m v
sig2 = realPart ((cxx 0 0) + sum [ a!k * (cxx 0 k) | k <- [1..p] ])
m = array ((1,1),(p,p)) [ ((j,k), cxx j k) | j <- [1..p], k <- [1..j] ]
v = array (1,p) [ (j, -(cxx j 0)) | j <- [1..p] ]
cxx j k = (sum [ (conjugate (x!(i-j))) * x!(i-k) | i <- [p..(n-1)] ] + sum [ x!(i+j) * (conjugate (x!(i+k))) | i <- [0..(n-1-p)] ])
n = snd (bounds x) + 1
-------------------------------------------------------------------------------
-- ar_burg x p
-------------------------------------------------------------------------------
-- Section 7.6 in Kay
-- TODO: rho doesn't need to be an array
-- TODO: kk doesn't need to be an array
-- TODO: ef and eb don't need to be 2-D arrays
-- | Computes an AR(p) model estimate from x using the Burg' method | 1,041 | ar_mcov :: (Ix a, Integral a, RealFloat b) => Array a (Complex b) -- ^ x
-> a -- ^ p
-> (Array a (Complex b), b)
ar_mcov x p = (a, sig2 / (fromIntegral (2*(n-p))))
where a = cholesky m v
sig2 = realPart ((cxx 0 0) + sum [ a!k * (cxx 0 k) | k <- [1..p] ])
m = array ((1,1),(p,p)) [ ((j,k), cxx j k) | j <- [1..p], k <- [1..j] ]
v = array (1,p) [ (j, -(cxx j 0)) | j <- [1..p] ]
cxx j k = (sum [ (conjugate (x!(i-j))) * x!(i-k) | i <- [p..(n-1)] ] + sum [ x!(i+j) * (conjugate (x!(i+k))) | i <- [0..(n-1-p)] ])
n = snd (bounds x) + 1
-------------------------------------------------------------------------------
-- ar_burg x p
-------------------------------------------------------------------------------
-- Section 7.6 in Kay
-- TODO: rho doesn't need to be an array
-- TODO: kk doesn't need to be an array
-- TODO: ef and eb don't need to be 2-D arrays
-- | Computes an AR(p) model estimate from x using the Burg' method | 1,027 | ar_mcov x p = (a, sig2 / (fromIntegral (2*(n-p))))
where a = cholesky m v
sig2 = realPart ((cxx 0 0) + sum [ a!k * (cxx 0 k) | k <- [1..p] ])
m = array ((1,1),(p,p)) [ ((j,k), cxx j k) | j <- [1..p], k <- [1..j] ]
v = array (1,p) [ (j, -(cxx j 0)) | j <- [1..p] ]
cxx j k = (sum [ (conjugate (x!(i-j))) * x!(i-k) | i <- [p..(n-1)] ] + sum [ x!(i+j) * (conjugate (x!(i+k))) | i <- [0..(n-1-p)] ])
n = snd (bounds x) + 1
-------------------------------------------------------------------------------
-- ar_burg x p
-------------------------------------------------------------------------------
-- Section 7.6 in Kay
-- TODO: rho doesn't need to be an array
-- TODO: kk doesn't need to be an array
-- TODO: ef and eb don't need to be 2-D arrays
-- | Computes an AR(p) model estimate from x using the Burg' method | 870 | true | true | 5 | 16 | 285 | 491 | 258 | 233 | null | null |
kawu/ltag | src/NLP/LTAG/Early3.hs | bsd-2-clause | trySubst
:: (VOrd t, VOrd n)
=> State n t
-> State n t
-> Earley n t ()
trySubst p q = void $ runMaybeT $ do
-- make sure that `p' is a fully-parsed regular rule
guard $ completed p && regular p
-- make sure `q' is not yet completed and expects
-- a non-terminal
(NonT x, right') <- expects q
-- make sure that `p' begins where `q' ends
guard $ beg p == end q
-- make sure that the root of `p' matches with the next
-- non-terminal of `q'; IDs of the symbols have to be
-- the same as well
guard $ root p == x
-- construct the resultant state
let q' = q
{ end = end p
, left = NonT x : left q
, right = right' }
-- print logging information
lift . lift $ do
putStr "[U] " >> printState p
putStr " + " >> printState q
putStr " : " >> printState q'
-- push the resulting state into the waiting queue
lift $ pushState q'
-- | `tryAdjoinInit p q':
-- * `p' is a completed state (regular or auxiliary)
-- * `q' not completed and expects a *real* foot | 1,096 | trySubst
:: (VOrd t, VOrd n)
=> State n t
-> State n t
-> Earley n t ()
trySubst p q = void $ runMaybeT $ do
-- make sure that `p' is a fully-parsed regular rule
guard $ completed p && regular p
-- make sure `q' is not yet completed and expects
-- a non-terminal
(NonT x, right') <- expects q
-- make sure that `p' begins where `q' ends
guard $ beg p == end q
-- make sure that the root of `p' matches with the next
-- non-terminal of `q'; IDs of the symbols have to be
-- the same as well
guard $ root p == x
-- construct the resultant state
let q' = q
{ end = end p
, left = NonT x : left q
, right = right' }
-- print logging information
lift . lift $ do
putStr "[U] " >> printState p
putStr " + " >> printState q
putStr " : " >> printState q'
-- push the resulting state into the waiting queue
lift $ pushState q'
-- | `tryAdjoinInit p q':
-- * `p' is a completed state (regular or auxiliary)
-- * `q' not completed and expects a *real* foot | 1,096 | trySubst p q = void $ runMaybeT $ do
-- make sure that `p' is a fully-parsed regular rule
guard $ completed p && regular p
-- make sure `q' is not yet completed and expects
-- a non-terminal
(NonT x, right') <- expects q
-- make sure that `p' begins where `q' ends
guard $ beg p == end q
-- make sure that the root of `p' matches with the next
-- non-terminal of `q'; IDs of the symbols have to be
-- the same as well
guard $ root p == x
-- construct the resultant state
let q' = q
{ end = end p
, left = NonT x : left q
, right = right' }
-- print logging information
lift . lift $ do
putStr "[U] " >> printState p
putStr " + " >> printState q
putStr " : " >> printState q'
-- push the resulting state into the waiting queue
lift $ pushState q'
-- | `tryAdjoinInit p q':
-- * `p' is a completed state (regular or auxiliary)
-- * `q' not completed and expects a *real* foot | 1,008 | false | true | 0 | 15 | 358 | 253 | 121 | 132 | null | null |
karlvoigtland/romkan-hs | NLP/Romkan.hs | bsd-3-clause | -- katakana and hiragana to romaji substitutions
kanRomSubs :: Parser T.Text
kanRomSubs = choice $ map sub $ kanRomAList ++ kanRomAList_H | 137 | kanRomSubs :: Parser T.Text
kanRomSubs = choice $ map sub $ kanRomAList ++ kanRomAList_H | 88 | kanRomSubs = choice $ map sub $ kanRomAList ++ kanRomAList_H | 60 | true | true | 0 | 8 | 20 | 32 | 16 | 16 | null | null |
randen/cabal | Cabal/Distribution/Simple/Setup.hs | bsd-3-clause | defaultTestFlags :: TestFlags
defaultTestFlags = TestFlags {
testDistPref = NoFlag,
testVerbosity = Flag normal,
testHumanLog = toFlag $ toPathTemplate $ "$pkgid-$test-suite.log",
testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
testShowDetails = toFlag Failures,
testKeepTix = toFlag False,
testOptions = []
} | 366 | defaultTestFlags :: TestFlags
defaultTestFlags = TestFlags {
testDistPref = NoFlag,
testVerbosity = Flag normal,
testHumanLog = toFlag $ toPathTemplate $ "$pkgid-$test-suite.log",
testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
testShowDetails = toFlag Failures,
testKeepTix = toFlag False,
testOptions = []
} | 366 | defaultTestFlags = TestFlags {
testDistPref = NoFlag,
testVerbosity = Flag normal,
testHumanLog = toFlag $ toPathTemplate $ "$pkgid-$test-suite.log",
testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
testShowDetails = toFlag Failures,
testKeepTix = toFlag False,
testOptions = []
} | 336 | false | true | 0 | 8 | 87 | 82 | 47 | 35 | null | null |
a-ford/notghc | Llvm/TypeConversions.hs | bsd-3-clause | metaExprToOperand (MetaNode n ) =
MetadataNodeOperand
(MetadataNodeReference (MetadataNodeID (fromIntegral n))) | 123 | metaExprToOperand (MetaNode n ) =
MetadataNodeOperand
(MetadataNodeReference (MetadataNodeID (fromIntegral n))) | 123 | metaExprToOperand (MetaNode n ) =
MetadataNodeOperand
(MetadataNodeReference (MetadataNodeID (fromIntegral n))) | 123 | false | false | 0 | 11 | 21 | 36 | 17 | 19 | null | null |
energyflowanalysis/efa-2.1 | src/EFA/Application/Optimisation/Balance.hs | bsd-3-clause | nocondition :: StateQty.Graph node b (Result v) -> Bool
nocondition _ = True | 76 | nocondition :: StateQty.Graph node b (Result v) -> Bool
nocondition _ = True | 76 | nocondition _ = True | 20 | false | true | 0 | 8 | 12 | 33 | 16 | 17 | null | null |
AlexanderPankiv/ghc | compiler/coreSyn/PprCore.hs | bsd-3-clause | pprRules :: [CoreRule] -> SDoc
pprRules rules = vcat (map pprRule rules) | 72 | pprRules :: [CoreRule] -> SDoc
pprRules rules = vcat (map pprRule rules) | 72 | pprRules rules = vcat (map pprRule rules) | 41 | false | true | 0 | 7 | 11 | 32 | 16 | 16 | null | null |
ComputationWithBoundedResources/ara-inference | doc/tpdb_trs/Haskell/basic_haskell/lookup_2.hs | mit | lookup3 vy vz = lookup2 vy vz | 29 | lookup3 vy vz = lookup2 vy vz | 29 | lookup3 vy vz = lookup2 vy vz | 29 | false | false | 0 | 5 | 6 | 16 | 7 | 9 | null | null |
mozkeeler/cryptopals | set1/challenge3/singleByteXOR.hs | mit | contains e (l:ls) = if (==) e l then True else contains e ls | 60 | contains e (l:ls) = if (==) e l then True else contains e ls | 60 | contains e (l:ls) = if (==) e l then True else contains e ls | 60 | false | false | 0 | 7 | 13 | 38 | 20 | 18 | null | null |
Heather/clay | src/Clay/Size.hs | bsd-3-clause | -- | Size in points (1pt = 1/72 of 1in).
pt i = Size (value i <> "pt") | 70 | pt i = Size (value i <> "pt") | 29 | pt i = Size (value i <> "pt") | 29 | true | false | 0 | 8 | 17 | 23 | 11 | 12 | null | null |
ajhc/drift | src/DrIFT.hs | mit | derive :: Env -> FilePath -> IO ()
derive env fname = do
let findent xs = f (lines xs) where
f (x:xs) = let (w,n) = span isSpace x in case n of
(c:_) | isAlpha c -> length w
_ -> f xs
f [] = 0
file <- readFile fname
let (body,_) = userCode file
b = ".lhs" `isSuffixOf` fname
zz = fromLit b body
ss = if b then replicate (findent zz) ' ' else ""
handle <- getOutput env
hPutStr handle $ ss ++ "{- Generated by " ++ package ++ " (Automatic class derivations for Haskell) -}\n"
unless (envNoline env) $ hPutStr handle $ ss ++ "{-# LINE 1 \"" ++ fname ++ "\" #-}\n"
let (docs,dats,todo) = process . addGlobals env . parser $ zz
moreDocs <- fmap ((\(x,_,_) -> x) . process) (chaseImports body todo)
let result = (\r -> codeSeperator ++ '\n':r) . render . vsep $ (docs ++ sepDoc:moreDocs)
if (envResultsOnly env) then hPutStr handle result else do
hPutStr handle zz
hPutStr handle $ unlines . map (ss ++) . lines $ result
hFlush handle | 1,073 | derive :: Env -> FilePath -> IO ()
derive env fname = do
let findent xs = f (lines xs) where
f (x:xs) = let (w,n) = span isSpace x in case n of
(c:_) | isAlpha c -> length w
_ -> f xs
f [] = 0
file <- readFile fname
let (body,_) = userCode file
b = ".lhs" `isSuffixOf` fname
zz = fromLit b body
ss = if b then replicate (findent zz) ' ' else ""
handle <- getOutput env
hPutStr handle $ ss ++ "{- Generated by " ++ package ++ " (Automatic class derivations for Haskell) -}\n"
unless (envNoline env) $ hPutStr handle $ ss ++ "{-# LINE 1 \"" ++ fname ++ "\" #-}\n"
let (docs,dats,todo) = process . addGlobals env . parser $ zz
moreDocs <- fmap ((\(x,_,_) -> x) . process) (chaseImports body todo)
let result = (\r -> codeSeperator ++ '\n':r) . render . vsep $ (docs ++ sepDoc:moreDocs)
if (envResultsOnly env) then hPutStr handle result else do
hPutStr handle zz
hPutStr handle $ unlines . map (ss ++) . lines $ result
hFlush handle | 1,073 | derive env fname = do
let findent xs = f (lines xs) where
f (x:xs) = let (w,n) = span isSpace x in case n of
(c:_) | isAlpha c -> length w
_ -> f xs
f [] = 0
file <- readFile fname
let (body,_) = userCode file
b = ".lhs" `isSuffixOf` fname
zz = fromLit b body
ss = if b then replicate (findent zz) ' ' else ""
handle <- getOutput env
hPutStr handle $ ss ++ "{- Generated by " ++ package ++ " (Automatic class derivations for Haskell) -}\n"
unless (envNoline env) $ hPutStr handle $ ss ++ "{-# LINE 1 \"" ++ fname ++ "\" #-}\n"
let (docs,dats,todo) = process . addGlobals env . parser $ zz
moreDocs <- fmap ((\(x,_,_) -> x) . process) (chaseImports body todo)
let result = (\r -> codeSeperator ++ '\n':r) . render . vsep $ (docs ++ sepDoc:moreDocs)
if (envResultsOnly env) then hPutStr handle result else do
hPutStr handle zz
hPutStr handle $ unlines . map (ss ++) . lines $ result
hFlush handle | 1,038 | false | true | 0 | 20 | 328 | 470 | 229 | 241 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.