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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ghcjs/jsaddle-dom | src/JSDOM/Generated/ReadableStreamBYOBRequest.hs | mit | -- | <https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBRequest.view Mozilla ReadableStreamBYOBRequest.view documentation>
getView ::
(MonadDOM m) => ReadableStreamBYOBRequest -> m RawTypedArray
getView self = liftDOM ((self ^. js "view") >>= fromJSValUnchecked) | 288 | getView ::
(MonadDOM m) => ReadableStreamBYOBRequest -> m RawTypedArray
getView self = liftDOM ((self ^. js "view") >>= fromJSValUnchecked) | 147 | getView self = liftDOM ((self ^. js "view") >>= fromJSValUnchecked) | 67 | true | true | 0 | 10 | 33 | 51 | 26 | 25 | null | null |
mit-plv/riscv-semantics | src/Platform/RunFast.hs | bsd-3-clause | main :: IO ()
main = do
args <- getArgs
retval <- case args of
[] -> do
putStr "ERROR: this program expects one or more elf files as command-line arguments\n"
return 1
[file] -> runFile file
files -> runFiles files
exitWith (if retval == 0 then ExitSuccess else ExitFailure $ (fromIntegral:: Int64 -> Int) retval) | 343 | main :: IO ()
main = do
args <- getArgs
retval <- case args of
[] -> do
putStr "ERROR: this program expects one or more elf files as command-line arguments\n"
return 1
[file] -> runFile file
files -> runFiles files
exitWith (if retval == 0 then ExitSuccess else ExitFailure $ (fromIntegral:: Int64 -> Int) retval) | 343 | main = do
args <- getArgs
retval <- case args of
[] -> do
putStr "ERROR: this program expects one or more elf files as command-line arguments\n"
return 1
[file] -> runFile file
files -> runFiles files
exitWith (if retval == 0 then ExitSuccess else ExitFailure $ (fromIntegral:: Int64 -> Int) retval) | 329 | false | true | 0 | 14 | 85 | 114 | 54 | 60 | null | null |
juhp/network-uri | tests/uri001.hs | bsd-3-clause | testRelative81 = testRelative "testRelative81"
"file:/some/dir/.." "file:/some/dir/#blort" "./#blort" | 121 | testRelative81 = testRelative "testRelative81"
"file:/some/dir/.." "file:/some/dir/#blort" "./#blort" | 121 | testRelative81 = testRelative "testRelative81"
"file:/some/dir/.." "file:/some/dir/#blort" "./#blort" | 121 | false | false | 0 | 5 | 26 | 15 | 7 | 8 | null | null |
jwbuurlage/category-theory-programmers | examples/parser/lisp_like_dsl.hs | mit | result expr = Left ("Missing variable bindings: " ++ show (dependencies expr)) | 78 | result expr = Left ("Missing variable bindings: " ++ show (dependencies expr)) | 78 | result expr = Left ("Missing variable bindings: " ++ show (dependencies expr)) | 78 | false | false | 1 | 10 | 11 | 32 | 13 | 19 | null | null |
fiigii/dataflow | Parser.hs | mit | convertExpr (Js.BoolLit _ bool) = return $ BoolLit bool | 56 | convertExpr (Js.BoolLit _ bool) = return $ BoolLit bool | 56 | convertExpr (Js.BoolLit _ bool) = return $ BoolLit bool | 56 | false | false | 0 | 8 | 9 | 26 | 12 | 14 | null | null |
jsavatgy/hatupist | hatupist-103.hs | gpl-2.0 | createFrame title func values container = do
box <- vBoxNew False 0
drawingArea <- drawingAreaNew
widgetSetSizeRequest drawingArea 360 300
boxPackStart box drawingArea PackGrow 0
label <- labelNew (Just title)
miscSetAlignment label 0 0
miscSetPadding label 10 0
labelSetSelectable label True
eventbox <- eventBoxNew
containerAdd eventbox label
boxPackStart box eventbox PackGrow 0
widgetModifyBg eventbox StateNormal (toGtkColor white)
boxPackStart container box PackGrow 10
onExpose drawingArea (exposeHandler drawingArea func values) | 568 | createFrame title func values container = do
box <- vBoxNew False 0
drawingArea <- drawingAreaNew
widgetSetSizeRequest drawingArea 360 300
boxPackStart box drawingArea PackGrow 0
label <- labelNew (Just title)
miscSetAlignment label 0 0
miscSetPadding label 10 0
labelSetSelectable label True
eventbox <- eventBoxNew
containerAdd eventbox label
boxPackStart box eventbox PackGrow 0
widgetModifyBg eventbox StateNormal (toGtkColor white)
boxPackStart container box PackGrow 10
onExpose drawingArea (exposeHandler drawingArea func values) | 568 | createFrame title func values container = do
box <- vBoxNew False 0
drawingArea <- drawingAreaNew
widgetSetSizeRequest drawingArea 360 300
boxPackStart box drawingArea PackGrow 0
label <- labelNew (Just title)
miscSetAlignment label 0 0
miscSetPadding label 10 0
labelSetSelectable label True
eventbox <- eventBoxNew
containerAdd eventbox label
boxPackStart box eventbox PackGrow 0
widgetModifyBg eventbox StateNormal (toGtkColor white)
boxPackStart container box PackGrow 10
onExpose drawingArea (exposeHandler drawingArea func values) | 568 | false | false | 0 | 10 | 98 | 174 | 73 | 101 | null | null |
kolmodin/cabal | cabal-install/Distribution/Client/Dependency/TopDown.hs | bsd-3-clause | topDownResolver' :: Platform -> CompilerInfo
-> PackageIndex InstalledPackage
-> PackageIndex UnresolvedSourcePackage
-> (PackageName -> PackagePreferences)
-> [PackageConstraint]
-> [PackageName]
-> Progress Log Failure [ResolverPackage UnresolvedPkgLoc]
topDownResolver' platform cinfo installedPkgIndex sourcePkgIndex
preferences constraints targets =
fmap (uncurry finalise)
. (\cs -> search configure preferences cs initialPkgNames)
=<< pruneBottomUp platform cinfo
=<< addTopLevelConstraints constraints
=<< addTopLevelTargets targets emptyConstraintSet
where
configure = configurePackage platform cinfo
emptyConstraintSet :: Constraints
emptyConstraintSet = Constraints.empty
(annotateInstalledPackages topSortNumber installedPkgIndex')
(annotateSourcePackages constraints topSortNumber sourcePkgIndex')
(installedPkgIndex', sourcePkgIndex') =
selectNeededSubset installedPkgIndex sourcePkgIndex initialPkgNames
topSortNumber = topologicalSortNumbering installedPkgIndex' sourcePkgIndex'
initialPkgNames = Set.fromList targets
finalise selected' constraints' =
map toResolverPackage
. PackageIndex.allPackages
. fst . improvePlan installedPkgIndex' constraints'
. PackageIndex.fromList
$ finaliseSelectedPackages preferences selected' constraints'
toResolverPackage :: FinalSelectedPackage -> ResolverPackage UnresolvedPkgLoc
toResolverPackage (SelectedInstalled (InstalledPackage pkg pid_deps))
= PreExisting pkg deps
where deps = CD.fromLibraryDeps lib
. zipWith PreExistingId pid_deps
$ InstalledPackageInfo.depends pkg
lib = display (packageName pkg)
toResolverPackage (SelectedSource pkg) = Configured pkg | 1,969 | topDownResolver' :: Platform -> CompilerInfo
-> PackageIndex InstalledPackage
-> PackageIndex UnresolvedSourcePackage
-> (PackageName -> PackagePreferences)
-> [PackageConstraint]
-> [PackageName]
-> Progress Log Failure [ResolverPackage UnresolvedPkgLoc]
topDownResolver' platform cinfo installedPkgIndex sourcePkgIndex
preferences constraints targets =
fmap (uncurry finalise)
. (\cs -> search configure preferences cs initialPkgNames)
=<< pruneBottomUp platform cinfo
=<< addTopLevelConstraints constraints
=<< addTopLevelTargets targets emptyConstraintSet
where
configure = configurePackage platform cinfo
emptyConstraintSet :: Constraints
emptyConstraintSet = Constraints.empty
(annotateInstalledPackages topSortNumber installedPkgIndex')
(annotateSourcePackages constraints topSortNumber sourcePkgIndex')
(installedPkgIndex', sourcePkgIndex') =
selectNeededSubset installedPkgIndex sourcePkgIndex initialPkgNames
topSortNumber = topologicalSortNumbering installedPkgIndex' sourcePkgIndex'
initialPkgNames = Set.fromList targets
finalise selected' constraints' =
map toResolverPackage
. PackageIndex.allPackages
. fst . improvePlan installedPkgIndex' constraints'
. PackageIndex.fromList
$ finaliseSelectedPackages preferences selected' constraints'
toResolverPackage :: FinalSelectedPackage -> ResolverPackage UnresolvedPkgLoc
toResolverPackage (SelectedInstalled (InstalledPackage pkg pid_deps))
= PreExisting pkg deps
where deps = CD.fromLibraryDeps lib
. zipWith PreExistingId pid_deps
$ InstalledPackageInfo.depends pkg
lib = display (packageName pkg)
toResolverPackage (SelectedSource pkg) = Configured pkg | 1,969 | topDownResolver' platform cinfo installedPkgIndex sourcePkgIndex
preferences constraints targets =
fmap (uncurry finalise)
. (\cs -> search configure preferences cs initialPkgNames)
=<< pruneBottomUp platform cinfo
=<< addTopLevelConstraints constraints
=<< addTopLevelTargets targets emptyConstraintSet
where
configure = configurePackage platform cinfo
emptyConstraintSet :: Constraints
emptyConstraintSet = Constraints.empty
(annotateInstalledPackages topSortNumber installedPkgIndex')
(annotateSourcePackages constraints topSortNumber sourcePkgIndex')
(installedPkgIndex', sourcePkgIndex') =
selectNeededSubset installedPkgIndex sourcePkgIndex initialPkgNames
topSortNumber = topologicalSortNumbering installedPkgIndex' sourcePkgIndex'
initialPkgNames = Set.fromList targets
finalise selected' constraints' =
map toResolverPackage
. PackageIndex.allPackages
. fst . improvePlan installedPkgIndex' constraints'
. PackageIndex.fromList
$ finaliseSelectedPackages preferences selected' constraints'
toResolverPackage :: FinalSelectedPackage -> ResolverPackage UnresolvedPkgLoc
toResolverPackage (SelectedInstalled (InstalledPackage pkg pid_deps))
= PreExisting pkg deps
where deps = CD.fromLibraryDeps lib
. zipWith PreExistingId pid_deps
$ InstalledPackageInfo.depends pkg
lib = display (packageName pkg)
toResolverPackage (SelectedSource pkg) = Configured pkg | 1,611 | false | true | 11 | 14 | 501 | 381 | 183 | 198 | null | null |
noughtmare/yi | yi-core/src/Yi/Syntax/Tree.hs | gpl-2.0 | nodesOnPath :: IsTree tree => Node (tree a) -> NonEmpty (Path, Node (tree a))
nodesOnPath ([],t) = return ([],([],t)) | 117 | nodesOnPath :: IsTree tree => Node (tree a) -> NonEmpty (Path, Node (tree a))
nodesOnPath ([],t) = return ([],([],t)) | 117 | nodesOnPath ([],t) = return ([],([],t)) | 39 | false | true | 0 | 11 | 18 | 79 | 41 | 38 | null | null |
fizruk/demarcate | examples/writer.hs | bsd-3-clause | -- | Program for our toy language.
prg :: WP ()
prg = do
output "Hello!"
output "Enter your name, please:"
(_, w) <- listen $ do
name <- input
tell $ "Got name: " ++ name ++ "\n"
output $ "Goodbye, " ++ name ++ "!"
return ((), (++ "ok"))
output $ "Log was: " ++ w
output $ "The End" | 326 | prg :: WP ()
prg = do
output "Hello!"
output "Enter your name, please:"
(_, w) <- listen $ do
name <- input
tell $ "Got name: " ++ name ++ "\n"
output $ "Goodbye, " ++ name ++ "!"
return ((), (++ "ok"))
output $ "Log was: " ++ w
output $ "The End" | 291 | prg = do
output "Hello!"
output "Enter your name, please:"
(_, w) <- listen $ do
name <- input
tell $ "Got name: " ++ name ++ "\n"
output $ "Goodbye, " ++ name ++ "!"
return ((), (++ "ok"))
output $ "Log was: " ++ w
output $ "The End" | 278 | true | true | 0 | 13 | 105 | 119 | 57 | 62 | null | null |
goalieca/haskelling | 054.hs | gpl-3.0 | -- will return cards sorted highest-lowest, except pairs first (3 pair before 2 pair)
processHand cards
| all_suit && in_sequence && ((value (head sorted)) == Ace) = RoyalFlush sorted
| all_suit && in_sequence = StraightFlush sorted
| length (head paired) == 4 = FourKind (concat paired)
| ((length (paired!!0)) == 3) && ((length (paired!!1)) == 2) = FullHouse (concat paired)
| all_suit = Flush sorted
| in_sequence = Straight sorted
| (length (paired!!0)) == 3 = ThreeKind (concat paired)
| ((length (paired!!0)) == 2) && ((length (paired!!1)) == 2) = TwoPair (concat paired)
| length (paired!!0) == 2 = OnePair (concat paired)
| otherwise = High sorted
where sorted = sortBy (flip compare) cards
all_suit = all (\x -> (suit x) == (suit (head sorted))) sorted
in_sequence = (map value (reverse sorted)) `isInfixOf` [Two .. ]
paired = sortBy (\x y -> compare (length y) (length x)) (group sorted) | 973 | processHand cards
| all_suit && in_sequence && ((value (head sorted)) == Ace) = RoyalFlush sorted
| all_suit && in_sequence = StraightFlush sorted
| length (head paired) == 4 = FourKind (concat paired)
| ((length (paired!!0)) == 3) && ((length (paired!!1)) == 2) = FullHouse (concat paired)
| all_suit = Flush sorted
| in_sequence = Straight sorted
| (length (paired!!0)) == 3 = ThreeKind (concat paired)
| ((length (paired!!0)) == 2) && ((length (paired!!1)) == 2) = TwoPair (concat paired)
| length (paired!!0) == 2 = OnePair (concat paired)
| otherwise = High sorted
where sorted = sortBy (flip compare) cards
all_suit = all (\x -> (suit x) == (suit (head sorted))) sorted
in_sequence = (map value (reverse sorted)) `isInfixOf` [Two .. ]
paired = sortBy (\x y -> compare (length y) (length x)) (group sorted) | 887 | processHand cards
| all_suit && in_sequence && ((value (head sorted)) == Ace) = RoyalFlush sorted
| all_suit && in_sequence = StraightFlush sorted
| length (head paired) == 4 = FourKind (concat paired)
| ((length (paired!!0)) == 3) && ((length (paired!!1)) == 2) = FullHouse (concat paired)
| all_suit = Flush sorted
| in_sequence = Straight sorted
| (length (paired!!0)) == 3 = ThreeKind (concat paired)
| ((length (paired!!0)) == 2) && ((length (paired!!1)) == 2) = TwoPair (concat paired)
| length (paired!!0) == 2 = OnePair (concat paired)
| otherwise = High sorted
where sorted = sortBy (flip compare) cards
all_suit = all (\x -> (suit x) == (suit (head sorted))) sorted
in_sequence = (map value (reverse sorted)) `isInfixOf` [Two .. ]
paired = sortBy (\x y -> compare (length y) (length x)) (group sorted) | 887 | true | false | 0 | 14 | 224 | 450 | 223 | 227 | null | null |
pasberth/binal1 | Language/Binal/Parser.hs | mit | posOfDelta (D.Tab _ _ _) =
(0, 0) | 35 | posOfDelta (D.Tab _ _ _) =
(0, 0) | 35 | posOfDelta (D.Tab _ _ _) =
(0, 0) | 35 | false | false | 0 | 7 | 9 | 28 | 14 | 14 | null | null |
WSCU/JSEuterpea | Euterpea Examples/Basics.hs | gpl-3.0 | rpDS4 = q (gs4 * b4) * (ds ds4 + ds ds4 + s ds4)
| 49 | arpDS4 = q (gs4 * b4) * (ds ds4 + ds ds4 + s ds4) | 49 | arpDS4 = q (gs4 * b4) * (ds ds4 + ds ds4 + s ds4) | 49 | false | false | 1 | 10 | 15 | 44 | 19 | 25 | null | null |
kdkeyser/kvstore-batch | src/Aggregator.hs | lgpl-3.0 | create :: Backend -> IO Aggregator
create backend = do
ioRef <- newIORef []
return (ioRef, backend) | 107 | create :: Backend -> IO Aggregator
create backend = do
ioRef <- newIORef []
return (ioRef, backend) | 107 | create backend = do
ioRef <- newIORef []
return (ioRef, backend) | 72 | false | true | 0 | 10 | 24 | 50 | 22 | 28 | null | null |
nakamuray/htig | HTIG/IRCServer/Constants.hs | bsd-3-clause | rPL_TRACECLASS = 209 | 20 | rPL_TRACECLASS = 209 | 20 | rPL_TRACECLASS = 209 | 20 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
alanz/Blobs | lib/DData/Scc.hs | lgpl-2.1 | vertices :: Graph v -> [v]
vertices g
= [v | (v,vs) <- nodes g] | 65 | vertices :: Graph v -> [v]
vertices g
= [v | (v,vs) <- nodes g] | 65 | vertices g
= [v | (v,vs) <- nodes g] | 38 | false | true | 0 | 8 | 16 | 44 | 23 | 21 | null | null |
spacekitteh/smcghc | compiler/main/CmdLineParser.hs | bsd-3-clause | arg_ok (VersionSuffix _) _ _ = True | 43 | arg_ok (VersionSuffix _) _ _ = True | 43 | arg_ok (VersionSuffix _) _ _ = True | 43 | false | false | 1 | 6 | 14 | 19 | 8 | 11 | null | null |
rfranek/duckling | Duckling/Numeral/ES/Rules.hs | bsd-3-clause | ruleNumeralDotNumeral :: Rule
ruleNumeralDotNumeral = Rule
{ name = "number dot number"
, pattern =
[ dimension Numeral
, regex "punto"
, numberWith TNumeral.grain isNothing
]
, prod = \tokens -> case tokens of
(Token Numeral (NumeralData {TNumeral.value = v1}):
_:
Token Numeral (NumeralData {TNumeral.value = v2}):
_) -> double $ v1 + decimalsToDouble v2
_ -> Nothing
} | 428 | ruleNumeralDotNumeral :: Rule
ruleNumeralDotNumeral = Rule
{ name = "number dot number"
, pattern =
[ dimension Numeral
, regex "punto"
, numberWith TNumeral.grain isNothing
]
, prod = \tokens -> case tokens of
(Token Numeral (NumeralData {TNumeral.value = v1}):
_:
Token Numeral (NumeralData {TNumeral.value = v2}):
_) -> double $ v1 + decimalsToDouble v2
_ -> Nothing
} | 428 | ruleNumeralDotNumeral = Rule
{ name = "number dot number"
, pattern =
[ dimension Numeral
, regex "punto"
, numberWith TNumeral.grain isNothing
]
, prod = \tokens -> case tokens of
(Token Numeral (NumeralData {TNumeral.value = v1}):
_:
Token Numeral (NumeralData {TNumeral.value = v2}):
_) -> double $ v1 + decimalsToDouble v2
_ -> Nothing
} | 398 | false | true | 0 | 20 | 115 | 142 | 75 | 67 | null | null |
ocharles/hadoom | hadoom-editor/Hadoom/Editor/Render.hs | bsd-3-clause | -- | Render a cross hair at the origin. This is used to indicate the origin
-- point of map space.
renderOrigin :: Diagram
renderOrigin =
D.lc D.yellow
(mconcat (take 4
(iterate (D.rotateBy (1 / 4))
(D.strokeLocLine
(D.fromVertices [D.origin,D.p2 (1 / 3,0)]))))) | 358 | renderOrigin :: Diagram
renderOrigin =
D.lc D.yellow
(mconcat (take 4
(iterate (D.rotateBy (1 / 4))
(D.strokeLocLine
(D.fromVertices [D.origin,D.p2 (1 / 3,0)]))))) | 259 | renderOrigin =
D.lc D.yellow
(mconcat (take 4
(iterate (D.rotateBy (1 / 4))
(D.strokeLocLine
(D.fromVertices [D.origin,D.p2 (1 / 3,0)]))))) | 235 | true | true | 0 | 19 | 137 | 98 | 52 | 46 | null | null |
bos/inttable | tests/Tests.hs | bsd-3-clause | t_reset :: Int -> V -> [KV] -> Bool
t_reset k v kvs = unsafePerformIO $ do
t0 <- IT.fromList kvs
t1 <- IT.fromList kvs
prev <- IT.insertWith (++) k v t0
IT.reset k prev t0
((==) `on` sort) <$> IT.toList t0 <*> IT.toList t1 | 232 | t_reset :: Int -> V -> [KV] -> Bool
t_reset k v kvs = unsafePerformIO $ do
t0 <- IT.fromList kvs
t1 <- IT.fromList kvs
prev <- IT.insertWith (++) k v t0
IT.reset k prev t0
((==) `on` sort) <$> IT.toList t0 <*> IT.toList t1 | 232 | t_reset k v kvs = unsafePerformIO $ do
t0 <- IT.fromList kvs
t1 <- IT.fromList kvs
prev <- IT.insertWith (++) k v t0
IT.reset k prev t0
((==) `on` sort) <$> IT.toList t0 <*> IT.toList t1 | 196 | false | true | 0 | 12 | 54 | 131 | 62 | 69 | null | null |
sdiehl/ghc | testsuite/tests/rename/should_compile/T13839a.hs | bsd-3-clause | main :: IO ()
main = putStrLn used | 34 | main :: IO ()
main = putStrLn used | 34 | main = putStrLn used | 20 | false | true | 0 | 6 | 7 | 19 | 9 | 10 | null | null |
nubis/Monono | Graphics/UI/Monono/Drawing.hs | bsd-3-clause | drawRectangle :: Color a =>
PrimitiveMode -> a -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GameData -> IO ()
drawRectangle mode c x y w h gData = do
renderPrimitive mode $ do
color c
point x y
point x (y+h)
point (x+w) (y+h)
point (x+w) y
-- | Set the drawing to be a game image, and the bounding box to be
-- a rectangle that circumscribes it | 371 | drawRectangle :: Color a =>
PrimitiveMode -> a -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GameData -> IO ()
drawRectangle mode c x y w h gData = do
renderPrimitive mode $ do
color c
point x y
point x (y+h)
point (x+w) (y+h)
point (x+w) y
-- | Set the drawing to be a game image, and the bounding box to be
-- a rectangle that circumscribes it | 371 | drawRectangle mode c x y w h gData = do
renderPrimitive mode $ do
color c
point x y
point x (y+h)
point (x+w) (y+h)
point (x+w) y
-- | Set the drawing to be a game image, and the bounding box to be
-- a rectangle that circumscribes it | 257 | false | true | 0 | 14 | 95 | 144 | 68 | 76 | null | null |
dmjio/BerkeleyDB | src/Data/BerkeleyDB.hs | bsd-3-clause | -- | /O(log n)/. Insert with a combining function.
-- @'insertWithKey' f key value db@
-- will insert the pair (key, value) into @db@ if key does
-- not exist in the database. If the key does exist, the function will
-- insert the pair @(key,f key new_value old_value)@.
-- Note that the key passed to f is the same key passed to 'insertWithKey'.
insertWithKey :: (Binary k, Binary a) => (k -> a -> a -> a) -> k -> a -> Db k a -> Db k a
insertWithKey fn key val db
= unsafePerformIO $
withDB db $ \(Db db range uniq size) ->
do myUniq <- atomicModifyIORef uniq (\a -> (a+1,a))
withVar db $ \ioDB ->
do mbOldValue <- lookupPrim key ioDB range
case mbOldValue of
Nothing -> do IO.insert ioDB key (myUniq, Just $ toObject $ encode val)
return $ Db db (addToRange myUniq range) uniq (size+1)
Just oldValue -> do let newvalue = fn key val (decode (fromObject oldValue))
-- putStrLn $ "oldValue: " ++ show oldValue
IO.insert ioDB key (myUniq, Just $ toObject $ encode newvalue)
return $ Db db (addToRange myUniq range) uniq size
-- | /O(log n)/. Lookup the value at a key in the database.
--
-- The function will
-- @return@ the result in the monad or @fail@ in it the key isn't in the
-- database. Often, the monad to use is 'Maybe', so you get either
-- @('Just' result)@ or @'Nothing'@. | 1,505 | insertWithKey :: (Binary k, Binary a) => (k -> a -> a -> a) -> k -> a -> Db k a -> Db k a
insertWithKey fn key val db
= unsafePerformIO $
withDB db $ \(Db db range uniq size) ->
do myUniq <- atomicModifyIORef uniq (\a -> (a+1,a))
withVar db $ \ioDB ->
do mbOldValue <- lookupPrim key ioDB range
case mbOldValue of
Nothing -> do IO.insert ioDB key (myUniq, Just $ toObject $ encode val)
return $ Db db (addToRange myUniq range) uniq (size+1)
Just oldValue -> do let newvalue = fn key val (decode (fromObject oldValue))
-- putStrLn $ "oldValue: " ++ show oldValue
IO.insert ioDB key (myUniq, Just $ toObject $ encode newvalue)
return $ Db db (addToRange myUniq range) uniq size
-- | /O(log n)/. Lookup the value at a key in the database.
--
-- The function will
-- @return@ the result in the monad or @fail@ in it the key isn't in the
-- database. Often, the monad to use is 'Maybe', so you get either
-- @('Just' result)@ or @'Nothing'@. | 1,158 | insertWithKey fn key val db
= unsafePerformIO $
withDB db $ \(Db db range uniq size) ->
do myUniq <- atomicModifyIORef uniq (\a -> (a+1,a))
withVar db $ \ioDB ->
do mbOldValue <- lookupPrim key ioDB range
case mbOldValue of
Nothing -> do IO.insert ioDB key (myUniq, Just $ toObject $ encode val)
return $ Db db (addToRange myUniq range) uniq (size+1)
Just oldValue -> do let newvalue = fn key val (decode (fromObject oldValue))
-- putStrLn $ "oldValue: " ++ show oldValue
IO.insert ioDB key (myUniq, Just $ toObject $ encode newvalue)
return $ Db db (addToRange myUniq range) uniq size
-- | /O(log n)/. Lookup the value at a key in the database.
--
-- The function will
-- @return@ the result in the monad or @fail@ in it the key isn't in the
-- database. Often, the monad to use is 'Maybe', so you get either
-- @('Just' result)@ or @'Nothing'@. | 1,068 | true | true | 4 | 26 | 465 | 347 | 172 | 175 | null | null |
sgillespie/ghc | compiler/typecheck/TcPatSyn.hs | bsd-3-clause | tcPatSynMatcher :: Located Name
-> LPat Id
-> ([TcTyVar], ThetaType, TcEvBinds, [EvVar])
-> ([TcTyVar], [TcType], ThetaType, [EvTerm])
-> ([LHsExpr TcId], [TcType])
-> TcType
-> TcM ((Id, Bool), LHsBinds Id)
-- See Note [Matchers and builders for pattern synonyms] in PatSyn
tcPatSynMatcher (L loc name) lpat
(univ_tvs, req_theta, req_ev_binds, req_dicts)
(ex_tvs, ex_tys, prov_theta, prov_dicts)
(args, arg_tys) pat_ty
= do { rr_name <- newNameAt (mkTyVarOcc "rep") loc
; tv_name <- newNameAt (mkTyVarOcc "r") loc
; let rr_tv = mkTcTyVar rr_name runtimeRepTy (SkolemTv False)
rr = mkTyVarTy rr_tv
res_tv = mkTcTyVar tv_name (tYPE rr) (SkolemTv False)
is_unlifted = null args && null prov_dicts
res_ty = mkTyVarTy res_tv
(cont_args, cont_arg_tys)
| is_unlifted = ([nlHsVar voidPrimId], [voidPrimTy])
| otherwise = (args, arg_tys)
cont_ty = mkInfSigmaTy ex_tvs prov_theta $
mkFunTys cont_arg_tys res_ty
fail_ty = mkFunTy voidPrimTy res_ty
; matcher_name <- newImplicitBinder name mkMatcherOcc
; scrutinee <- newSysLocalId (fsLit "scrut") pat_ty
; cont <- newSysLocalId (fsLit "cont") cont_ty
; fail <- newSysLocalId (fsLit "fail") fail_ty
; let matcher_tau = mkFunTys [pat_ty, cont_ty, fail_ty] res_ty
matcher_sigma = mkInfSigmaTy (rr_tv:res_tv:univ_tvs) req_theta matcher_tau
matcher_id = mkExportedVanillaId matcher_name matcher_sigma
-- See Note [Exported LocalIds] in Id
inst_wrap = mkWpEvApps prov_dicts <.> mkWpTyApps ex_tys
cont' = foldl nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args
fail' = nlHsApps fail [nlHsVar voidPrimId]
args = map nlVarPat [scrutinee, cont, fail]
lwpat = noLoc $ WildPat pat_ty
cases = if isIrrefutableHsPat lpat
then [mkHsCaseAlt lpat cont']
else [mkHsCaseAlt lpat cont',
mkHsCaseAlt lwpat fail']
body = mkLHsWrap (mkWpLet req_ev_binds) $
L (getLoc lpat) $
HsCase (nlHsVar scrutinee) $
MG{ mg_alts = L (getLoc lpat) cases
, mg_arg_tys = [pat_ty]
, mg_res_ty = res_ty
, mg_origin = Generated
}
body' = noLoc $
HsLam $
MG{ mg_alts = noLoc [mkSimpleMatch LambdaExpr
args body]
, mg_arg_tys = [pat_ty, cont_ty, res_ty]
, mg_res_ty = res_ty
, mg_origin = Generated
}
match = mkMatch (FunRhs (L loc name) Prefix) []
(mkHsLams (rr_tv:res_tv:univ_tvs)
req_dicts body')
(noLoc EmptyLocalBinds)
mg = MG{ mg_alts = L (getLoc match) [match]
, mg_arg_tys = []
, mg_res_ty = res_ty
, mg_origin = Generated
}
; let bind = FunBind{ fun_id = L loc matcher_id
, fun_matches = mg
, fun_co_fn = idHsWrapper
, bind_fvs = emptyNameSet
, fun_tick = [] }
matcher_bind = unitBag (noLoc bind)
; traceTc "tcPatSynMatcher" (ppr name $$ ppr (idType matcher_id))
; traceTc "tcPatSynMatcher" (ppr matcher_bind)
; return ((matcher_id, is_unlifted), matcher_bind) } | 3,989 | tcPatSynMatcher :: Located Name
-> LPat Id
-> ([TcTyVar], ThetaType, TcEvBinds, [EvVar])
-> ([TcTyVar], [TcType], ThetaType, [EvTerm])
-> ([LHsExpr TcId], [TcType])
-> TcType
-> TcM ((Id, Bool), LHsBinds Id)
tcPatSynMatcher (L loc name) lpat
(univ_tvs, req_theta, req_ev_binds, req_dicts)
(ex_tvs, ex_tys, prov_theta, prov_dicts)
(args, arg_tys) pat_ty
= do { rr_name <- newNameAt (mkTyVarOcc "rep") loc
; tv_name <- newNameAt (mkTyVarOcc "r") loc
; let rr_tv = mkTcTyVar rr_name runtimeRepTy (SkolemTv False)
rr = mkTyVarTy rr_tv
res_tv = mkTcTyVar tv_name (tYPE rr) (SkolemTv False)
is_unlifted = null args && null prov_dicts
res_ty = mkTyVarTy res_tv
(cont_args, cont_arg_tys)
| is_unlifted = ([nlHsVar voidPrimId], [voidPrimTy])
| otherwise = (args, arg_tys)
cont_ty = mkInfSigmaTy ex_tvs prov_theta $
mkFunTys cont_arg_tys res_ty
fail_ty = mkFunTy voidPrimTy res_ty
; matcher_name <- newImplicitBinder name mkMatcherOcc
; scrutinee <- newSysLocalId (fsLit "scrut") pat_ty
; cont <- newSysLocalId (fsLit "cont") cont_ty
; fail <- newSysLocalId (fsLit "fail") fail_ty
; let matcher_tau = mkFunTys [pat_ty, cont_ty, fail_ty] res_ty
matcher_sigma = mkInfSigmaTy (rr_tv:res_tv:univ_tvs) req_theta matcher_tau
matcher_id = mkExportedVanillaId matcher_name matcher_sigma
-- See Note [Exported LocalIds] in Id
inst_wrap = mkWpEvApps prov_dicts <.> mkWpTyApps ex_tys
cont' = foldl nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args
fail' = nlHsApps fail [nlHsVar voidPrimId]
args = map nlVarPat [scrutinee, cont, fail]
lwpat = noLoc $ WildPat pat_ty
cases = if isIrrefutableHsPat lpat
then [mkHsCaseAlt lpat cont']
else [mkHsCaseAlt lpat cont',
mkHsCaseAlt lwpat fail']
body = mkLHsWrap (mkWpLet req_ev_binds) $
L (getLoc lpat) $
HsCase (nlHsVar scrutinee) $
MG{ mg_alts = L (getLoc lpat) cases
, mg_arg_tys = [pat_ty]
, mg_res_ty = res_ty
, mg_origin = Generated
}
body' = noLoc $
HsLam $
MG{ mg_alts = noLoc [mkSimpleMatch LambdaExpr
args body]
, mg_arg_tys = [pat_ty, cont_ty, res_ty]
, mg_res_ty = res_ty
, mg_origin = Generated
}
match = mkMatch (FunRhs (L loc name) Prefix) []
(mkHsLams (rr_tv:res_tv:univ_tvs)
req_dicts body')
(noLoc EmptyLocalBinds)
mg = MG{ mg_alts = L (getLoc match) [match]
, mg_arg_tys = []
, mg_res_ty = res_ty
, mg_origin = Generated
}
; let bind = FunBind{ fun_id = L loc matcher_id
, fun_matches = mg
, fun_co_fn = idHsWrapper
, bind_fvs = emptyNameSet
, fun_tick = [] }
matcher_bind = unitBag (noLoc bind)
; traceTc "tcPatSynMatcher" (ppr name $$ ppr (idType matcher_id))
; traceTc "tcPatSynMatcher" (ppr matcher_bind)
; return ((matcher_id, is_unlifted), matcher_bind) } | 3,922 | tcPatSynMatcher (L loc name) lpat
(univ_tvs, req_theta, req_ev_binds, req_dicts)
(ex_tvs, ex_tys, prov_theta, prov_dicts)
(args, arg_tys) pat_ty
= do { rr_name <- newNameAt (mkTyVarOcc "rep") loc
; tv_name <- newNameAt (mkTyVarOcc "r") loc
; let rr_tv = mkTcTyVar rr_name runtimeRepTy (SkolemTv False)
rr = mkTyVarTy rr_tv
res_tv = mkTcTyVar tv_name (tYPE rr) (SkolemTv False)
is_unlifted = null args && null prov_dicts
res_ty = mkTyVarTy res_tv
(cont_args, cont_arg_tys)
| is_unlifted = ([nlHsVar voidPrimId], [voidPrimTy])
| otherwise = (args, arg_tys)
cont_ty = mkInfSigmaTy ex_tvs prov_theta $
mkFunTys cont_arg_tys res_ty
fail_ty = mkFunTy voidPrimTy res_ty
; matcher_name <- newImplicitBinder name mkMatcherOcc
; scrutinee <- newSysLocalId (fsLit "scrut") pat_ty
; cont <- newSysLocalId (fsLit "cont") cont_ty
; fail <- newSysLocalId (fsLit "fail") fail_ty
; let matcher_tau = mkFunTys [pat_ty, cont_ty, fail_ty] res_ty
matcher_sigma = mkInfSigmaTy (rr_tv:res_tv:univ_tvs) req_theta matcher_tau
matcher_id = mkExportedVanillaId matcher_name matcher_sigma
-- See Note [Exported LocalIds] in Id
inst_wrap = mkWpEvApps prov_dicts <.> mkWpTyApps ex_tys
cont' = foldl nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args
fail' = nlHsApps fail [nlHsVar voidPrimId]
args = map nlVarPat [scrutinee, cont, fail]
lwpat = noLoc $ WildPat pat_ty
cases = if isIrrefutableHsPat lpat
then [mkHsCaseAlt lpat cont']
else [mkHsCaseAlt lpat cont',
mkHsCaseAlt lwpat fail']
body = mkLHsWrap (mkWpLet req_ev_binds) $
L (getLoc lpat) $
HsCase (nlHsVar scrutinee) $
MG{ mg_alts = L (getLoc lpat) cases
, mg_arg_tys = [pat_ty]
, mg_res_ty = res_ty
, mg_origin = Generated
}
body' = noLoc $
HsLam $
MG{ mg_alts = noLoc [mkSimpleMatch LambdaExpr
args body]
, mg_arg_tys = [pat_ty, cont_ty, res_ty]
, mg_res_ty = res_ty
, mg_origin = Generated
}
match = mkMatch (FunRhs (L loc name) Prefix) []
(mkHsLams (rr_tv:res_tv:univ_tvs)
req_dicts body')
(noLoc EmptyLocalBinds)
mg = MG{ mg_alts = L (getLoc match) [match]
, mg_arg_tys = []
, mg_res_ty = res_ty
, mg_origin = Generated
}
; let bind = FunBind{ fun_id = L loc matcher_id
, fun_matches = mg
, fun_co_fn = idHsWrapper
, bind_fvs = emptyNameSet
, fun_tick = [] }
matcher_bind = unitBag (noLoc bind)
; traceTc "tcPatSynMatcher" (ppr name $$ ppr (idType matcher_id))
; traceTc "tcPatSynMatcher" (ppr matcher_bind)
; return ((matcher_id, is_unlifted), matcher_bind) } | 3,618 | true | true | 0 | 15 | 1,704 | 991 | 529 | 462 | null | null |
yaxu/hstexture | Main.hs | gpl-3.0 | main = do putStrLn showFunctions
run | 46 | main = do putStrLn showFunctions
run | 46 | main = do putStrLn showFunctions
run | 46 | false | false | 0 | 7 | 15 | 15 | 6 | 9 | null | null |
diagrams/diagrams-contrib | src/Diagrams/Color/XKCD.hs | bsd-3-clause | militaryGreen = fromJust $ readHexColor "#667c3e" | 57 | militaryGreen = fromJust $ readHexColor "#667c3e" | 57 | militaryGreen = fromJust $ readHexColor "#667c3e" | 57 | false | false | 0 | 6 | 13 | 13 | 6 | 7 | null | null |
hlian/zwischenzug | Canvas.hs | bsd-3-clause | white = (1.0, 1.0, 1.0, 1.0) | 28 | white = (1.0, 1.0, 1.0, 1.0) | 28 | white = (1.0, 1.0, 1.0, 1.0) | 28 | false | false | 1 | 5 | 5 | 21 | 11 | 10 | null | null |
sol/pandoc | src/Text/Pandoc/Writers/Docx.hs | gpl-2.0 | inlineToOpenXML opts (Link txt (src,_)) = do
contents <- withTextProp (rStyle "Hyperlink") $ inlinesToOpenXML opts txt
extlinks <- gets stExternalLinks
ind <- case M.lookup src extlinks of
Just i -> return i
Nothing -> do
let i = "link" ++ show (M.size extlinks)
modify $ \st -> st{ stExternalLinks =
M.insert src i extlinks }
return i
return [ mknode "w:hyperlink" [("r:id",ind)] contents ] | 492 | inlineToOpenXML opts (Link txt (src,_)) = do
contents <- withTextProp (rStyle "Hyperlink") $ inlinesToOpenXML opts txt
extlinks <- gets stExternalLinks
ind <- case M.lookup src extlinks of
Just i -> return i
Nothing -> do
let i = "link" ++ show (M.size extlinks)
modify $ \st -> st{ stExternalLinks =
M.insert src i extlinks }
return i
return [ mknode "w:hyperlink" [("r:id",ind)] contents ] | 492 | inlineToOpenXML opts (Link txt (src,_)) = do
contents <- withTextProp (rStyle "Hyperlink") $ inlinesToOpenXML opts txt
extlinks <- gets stExternalLinks
ind <- case M.lookup src extlinks of
Just i -> return i
Nothing -> do
let i = "link" ++ show (M.size extlinks)
modify $ \st -> st{ stExternalLinks =
M.insert src i extlinks }
return i
return [ mknode "w:hyperlink" [("r:id",ind)] contents ] | 492 | false | false | 0 | 20 | 164 | 182 | 85 | 97 | null | null |
bibaijin/cis194 | src/Spring13/Week3/Golf.hs | bsd-3-clause | count :: [Integer] -> [Int]
count xs = map (\n -> length $ filter (== n) xs) [0..9] | 83 | count :: [Integer] -> [Int]
count xs = map (\n -> length $ filter (== n) xs) [0..9] | 83 | count xs = map (\n -> length $ filter (== n) xs) [0..9] | 55 | false | true | 0 | 10 | 17 | 61 | 31 | 30 | null | null |
spechub/Hets | LF/Sign.hs | gpl-2.0 | -- get the set of declared symbols
getDeclaredSyms :: Sign -> Set.Set Symbol
getDeclaredSyms (Sign _ _ ds) =
Set.fromList $ map getSym $ filter (isNothing . getValue) ds | 171 | getDeclaredSyms :: Sign -> Set.Set Symbol
getDeclaredSyms (Sign _ _ ds) =
Set.fromList $ map getSym $ filter (isNothing . getValue) ds | 136 | getDeclaredSyms (Sign _ _ ds) =
Set.fromList $ map getSym $ filter (isNothing . getValue) ds | 94 | true | true | 0 | 8 | 30 | 59 | 29 | 30 | null | null |
phischu/fragnix | benchmarks/containers/Data.Sequence.hs | bsd-3-clause | digitToTree' n (Three a b c) = Deep n (Two a b) Empty (One c) | 61 | digitToTree' n (Three a b c) = Deep n (Two a b) Empty (One c) | 61 | digitToTree' n (Three a b c) = Deep n (Two a b) Empty (One c) | 61 | false | false | 0 | 7 | 14 | 48 | 21 | 27 | null | null |
exercism/xhaskell | exercises/practice/connect/.meta/examples/success-standard/src/Connect.hs | mit | tryConnect :: Board -> Mark -> ConnArr s -> (Int,Int) -> ST s Bool
tryConnect b mark ca c =
case b A.! c of
Just fieldMark
| fieldMark == mark ->
do seen <- MA.readArray ca c
if seen
then return False
else if isTargetEdge b fieldMark c
then return True
else do MA.writeArray ca c True
or `fmap`
mapM (tryConnect b mark ca)
(neighbours b c)
_ -> return False | 563 | tryConnect :: Board -> Mark -> ConnArr s -> (Int,Int) -> ST s Bool
tryConnect b mark ca c =
case b A.! c of
Just fieldMark
| fieldMark == mark ->
do seen <- MA.readArray ca c
if seen
then return False
else if isTargetEdge b fieldMark c
then return True
else do MA.writeArray ca c True
or `fmap`
mapM (tryConnect b mark ca)
(neighbours b c)
_ -> return False | 563 | tryConnect b mark ca c =
case b A.! c of
Just fieldMark
| fieldMark == mark ->
do seen <- MA.readArray ca c
if seen
then return False
else if isTargetEdge b fieldMark c
then return True
else do MA.writeArray ca c True
or `fmap`
mapM (tryConnect b mark ca)
(neighbours b c)
_ -> return False | 496 | false | true | 0 | 18 | 277 | 182 | 86 | 96 | null | null |
wizzup/advent_of_code | 2018/02/haskell/day_02.hs | mit | -- |
-- >>> countDif "fghij" "fguij"
-- 1
countDif :: Eq a => [a] -> [a] -> Int
countDif xs ys = sum $ zipWith f xs ys
where f a b | a == b = 0
| otherwise = 1
-- |
-- >>> getDif "fghij" "fguij"
-- "fgij"
-- | 224 | countDif :: Eq a => [a] -> [a] -> Int
countDif xs ys = sum $ zipWith f xs ys
where f a b | a == b = 0
| otherwise = 1
-- |
-- >>> getDif "fghij" "fguij"
-- "fgij"
-- | 182 | countDif xs ys = sum $ zipWith f xs ys
where f a b | a == b = 0
| otherwise = 1
-- |
-- >>> getDif "fghij" "fguij"
-- "fgij"
-- | 144 | true | true | 0 | 8 | 69 | 86 | 45 | 41 | null | null |
ghcjs/jsaddle-dom | src/JSDOM/Generated/Document.hs | mit | -- | <https://developer.mozilla.org/en-US/docs/Web/API/Document.createNodeIterator Mozilla Document.createNodeIterator documentation>
createNodeIterator_ ::
(MonadDOM m, IsDocument self, IsNode root) =>
self -> root -> Maybe Word -> Maybe NodeFilter -> m ()
createNodeIterator_ self root whatToShow filter
= liftDOM
(void
((toDocument self) ^. jsf "createNodeIterator"
[toJSVal root, toJSVal whatToShow, toJSVal filter])) | 493 | createNodeIterator_ ::
(MonadDOM m, IsDocument self, IsNode root) =>
self -> root -> Maybe Word -> Maybe NodeFilter -> m ()
createNodeIterator_ self root whatToShow filter
= liftDOM
(void
((toDocument self) ^. jsf "createNodeIterator"
[toJSVal root, toJSVal whatToShow, toJSVal filter])) | 358 | createNodeIterator_ self root whatToShow filter
= liftDOM
(void
((toDocument self) ^. jsf "createNodeIterator"
[toJSVal root, toJSVal whatToShow, toJSVal filter])) | 192 | true | true | 0 | 12 | 117 | 114 | 56 | 58 | null | null |
dpieroux/euler | 0/0037.hs | mit | main = do
print $ sum $ filter isLeftTruncatable rightTruncatables | 71 | main = do
print $ sum $ filter isLeftTruncatable rightTruncatables | 71 | main = do
print $ sum $ filter isLeftTruncatable rightTruncatables | 71 | false | false | 0 | 8 | 14 | 22 | 10 | 12 | null | null |
orchid-hybrid/WHILE | EllaBased/While.hs | gpl-2.0 | compileOppositeOpR Greater = CLessEq | 36 | compileOppositeOpR Greater = CLessEq | 36 | compileOppositeOpR Greater = CLessEq | 36 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
rfranek/duckling | Duckling/Time/DA/Rules.hs | bsd-3-clause | ruleNamedmonth12 :: Rule
ruleNamedmonth12 = Rule
{ name = "named-month"
, pattern =
[ regex "december|dec\\.?"
]
, prod = \_ -> tt $ month 12
} | 159 | ruleNamedmonth12 :: Rule
ruleNamedmonth12 = Rule
{ name = "named-month"
, pattern =
[ regex "december|dec\\.?"
]
, prod = \_ -> tt $ month 12
} | 159 | ruleNamedmonth12 = Rule
{ name = "named-month"
, pattern =
[ regex "december|dec\\.?"
]
, prod = \_ -> tt $ month 12
} | 134 | false | true | 0 | 10 | 42 | 59 | 30 | 29 | null | null |
elieux/ghc | compiler/prelude/PrelNames.hs | bsd-3-clause | boundedClassName = clsQual gHC_ENUM (fsLit "Bounded") boundedClassKey | 78 | boundedClassName = clsQual gHC_ENUM (fsLit "Bounded") boundedClassKey | 78 | boundedClassName = clsQual gHC_ENUM (fsLit "Bounded") boundedClassKey | 78 | false | false | 0 | 7 | 15 | 19 | 9 | 10 | null | null |
dmcclean/dimensional-dk-linalg | src/Numeric/LinearAlgebra/Dimensional/DK/QuasiQuotes.hs | bsd-3-clause | makeTypeLevelList [] = [t| '[] |] | 33 | makeTypeLevelList [] = [t| '[] |] | 33 | makeTypeLevelList [] = [t| '[] |] | 33 | false | false | 1 | 5 | 5 | 19 | 9 | 10 | null | null |
forestbelton/revm | app/Opts.hs | bsd-3-clause | programOpts :: [String] -> IO ([Flag], [String])
programOpts argv = case getOpt RequireOrder options argv of
(o, n, []) -> return (o, n)
(_, _, errs) -> printUsage $ concat errs | 187 | programOpts :: [String] -> IO ([Flag], [String])
programOpts argv = case getOpt RequireOrder options argv of
(o, n, []) -> return (o, n)
(_, _, errs) -> printUsage $ concat errs | 187 | programOpts argv = case getOpt RequireOrder options argv of
(o, n, []) -> return (o, n)
(_, _, errs) -> printUsage $ concat errs | 138 | false | true | 0 | 9 | 40 | 95 | 52 | 43 | null | null |
barischj/threepenny-gui-contextmenu | src/Graphics/UI/Threepenny/Ext/ContextMenu.hs | bsd-3-clause | -- |Constructor for a menu item with a nested menu.
nestedMenuItem :: String -> [MenuItem] -> MenuItem
nestedMenuItem text nested =
MenuItem { mIText = text ++ " ›", mIValue = NestedMenu nested } | 198 | nestedMenuItem :: String -> [MenuItem] -> MenuItem
nestedMenuItem text nested =
MenuItem { mIText = text ++ " ›", mIValue = NestedMenu nested } | 146 | nestedMenuItem text nested =
MenuItem { mIText = text ++ " ›", mIValue = NestedMenu nested } | 95 | true | true | 0 | 7 | 36 | 49 | 27 | 22 | null | null |
mrakgr/futhark | src/Language/Futhark/Attributes.hs | bsd-3-clause | -- | @unique t@ is 'True' if the type of the argument is unique.
unique :: TypeBase shape as vn -> Bool
unique = (==Unique) . uniqueness | 136 | unique :: TypeBase shape as vn -> Bool
unique = (==Unique) . uniqueness | 71 | unique = (==Unique) . uniqueness | 32 | true | true | 0 | 6 | 26 | 31 | 17 | 14 | null | null |
matthieubulte/sequent | src/Sequent/Inference.hs | bsd-3-clause | {-
Gamma |- B, A, Delta
--------------------------- right permute
Gamma |- A, B, Delta
-}
iPermuteSuccedent :: InferenceRule
iPermuteSuccedent (P.PermuteSuccedent rest) (gamma, a:b:delta) =
check rest (gamma, b:a:delta) | 231 | iPermuteSuccedent :: InferenceRule
iPermuteSuccedent (P.PermuteSuccedent rest) (gamma, a:b:delta) =
check rest (gamma, b:a:delta) | 133 | iPermuteSuccedent (P.PermuteSuccedent rest) (gamma, a:b:delta) =
check rest (gamma, b:a:delta) | 98 | true | true | 0 | 8 | 39 | 58 | 31 | 27 | null | null |
mightymoose/liquidhaskell | tests/neg/monad4.hs | bsd-3-clause | ys = gpp xs | 11 | ys = gpp xs | 11 | ys = gpp xs | 11 | false | false | 1 | 5 | 3 | 12 | 4 | 8 | null | null |
junjihashimoto/persistent | persistent-mongoDB/Database/Persist/MongoDB.hs | mit | mongoFilterToDoc (ArrayFilter field op) = mongoFilterToBSON (fieldName field) op | 80 | mongoFilterToDoc (ArrayFilter field op) = mongoFilterToBSON (fieldName field) op | 80 | mongoFilterToDoc (ArrayFilter field op) = mongoFilterToBSON (fieldName field) op | 80 | false | false | 0 | 7 | 8 | 29 | 13 | 16 | null | null |
benjijones/red | src/Red/Translate.hs | bsd-3-clause | -- Ignore application if arg is a Type
translateExpr (App func (Type _)) = translateExpr func | 94 | translateExpr (App func (Type _)) = translateExpr func | 55 | translateExpr (App func (Type _)) = translateExpr func | 55 | true | false | 0 | 8 | 16 | 28 | 13 | 15 | null | null |
mpickering/hackage-server | Distribution/Server/Features/Tags/State.hs | bsd-3-clause | renameTag :: Tag -> Tag -> PackageTags -> PackageTags
renameTag tag tag' pkgTags@(PackageTags _ packages) =
let oldPkgs = Map.findWithDefault Set.empty tag packages
in setTag tag' oldPkgs . deleteTag tag $ pkgTags | 221 | renameTag :: Tag -> Tag -> PackageTags -> PackageTags
renameTag tag tag' pkgTags@(PackageTags _ packages) =
let oldPkgs = Map.findWithDefault Set.empty tag packages
in setTag tag' oldPkgs . deleteTag tag $ pkgTags | 221 | renameTag tag tag' pkgTags@(PackageTags _ packages) =
let oldPkgs = Map.findWithDefault Set.empty tag packages
in setTag tag' oldPkgs . deleteTag tag $ pkgTags | 167 | false | true | 0 | 10 | 39 | 79 | 38 | 41 | null | null |
ciderpunx/exercismo | src/Beer.hs | gpl-3.0 | verse n =
if n>0
then bs ++ location ++ ", " ++ bs ++ drink n ++ bottles n' ++ location ++ ".\n"
else error "You cannot have fewer than no bottles of beer. Not even if you are a really heavy drinker."
where
bs = bottles n
n' = n-1 | 252 | verse n =
if n>0
then bs ++ location ++ ", " ++ bs ++ drink n ++ bottles n' ++ location ++ ".\n"
else error "You cannot have fewer than no bottles of beer. Not even if you are a really heavy drinker."
where
bs = bottles n
n' = n-1 | 252 | verse n =
if n>0
then bs ++ location ++ ", " ++ bs ++ drink n ++ bottles n' ++ location ++ ".\n"
else error "You cannot have fewer than no bottles of beer. Not even if you are a really heavy drinker."
where
bs = bottles n
n' = n-1 | 252 | false | false | 2 | 12 | 73 | 84 | 38 | 46 | null | null |
thomasjm/hrtree | Zora-1.1.18/Zora/List.hs | mit | -- | Like `take`, but takes an integer.
take' :: Integer -> [a] -> [a]
take' = take . fromInteger | 97 | take' :: Integer -> [a] -> [a]
take' = take . fromInteger | 57 | take' = take . fromInteger | 26 | true | true | 0 | 7 | 19 | 30 | 17 | 13 | null | null |
prl-tokyo/bigul-configuration-adaptation | Transformations/src/Generics/BiGUL/TH.hs | mit | toconTagsClause :: [(Bool, Name, [ConTag], [Name])] -> Q Clause
toconTagsClause env = do
(_, [vEq, vError]) <- lookupNames [] ["==", "error"] "cannot find functions for eq or error."
conTagsVarName <- newName "name"
expEnv <- mapM (\(b, n, conTags, _) -> liftM2 (,) (dataToExpQ (const Nothing) n) (dataToExpQ (const Nothing) conTags)) env
let conTagsClauseBody = (foldr (\(nExp, lrsExp) e -> CondE ((VarE vEq `AppE` nExp) `AppE` VarE conTagsVarName) lrsExp e)
(VarE vError `AppE` LitE (StringL "cannot find name."))
expEnv)
return $ Clause [WildP, VarP conTagsVarName] (NormalB conTagsClauseBody) [] | 641 | toconTagsClause :: [(Bool, Name, [ConTag], [Name])] -> Q Clause
toconTagsClause env = do
(_, [vEq, vError]) <- lookupNames [] ["==", "error"] "cannot find functions for eq or error."
conTagsVarName <- newName "name"
expEnv <- mapM (\(b, n, conTags, _) -> liftM2 (,) (dataToExpQ (const Nothing) n) (dataToExpQ (const Nothing) conTags)) env
let conTagsClauseBody = (foldr (\(nExp, lrsExp) e -> CondE ((VarE vEq `AppE` nExp) `AppE` VarE conTagsVarName) lrsExp e)
(VarE vError `AppE` LitE (StringL "cannot find name."))
expEnv)
return $ Clause [WildP, VarP conTagsVarName] (NormalB conTagsClauseBody) [] | 641 | toconTagsClause env = do
(_, [vEq, vError]) <- lookupNames [] ["==", "error"] "cannot find functions for eq or error."
conTagsVarName <- newName "name"
expEnv <- mapM (\(b, n, conTags, _) -> liftM2 (,) (dataToExpQ (const Nothing) n) (dataToExpQ (const Nothing) conTags)) env
let conTagsClauseBody = (foldr (\(nExp, lrsExp) e -> CondE ((VarE vEq `AppE` nExp) `AppE` VarE conTagsVarName) lrsExp e)
(VarE vError `AppE` LitE (StringL "cannot find name."))
expEnv)
return $ Clause [WildP, VarP conTagsVarName] (NormalB conTagsClauseBody) [] | 577 | false | true | 0 | 19 | 128 | 274 | 146 | 128 | null | null |
bonnefoa/Shaker | testsuite/tests/Shaker/CommonTest.hs | isc | compileProject :: IO CompileInput
compileProject = do
shIn <- testShakerInput
cpIn <- runReaderT getNonMainCompileInput shIn
_ <- runGhc (Just libdir) $
ghcCompile cpIn
return cpIn | 196 | compileProject :: IO CompileInput
compileProject = do
shIn <- testShakerInput
cpIn <- runReaderT getNonMainCompileInput shIn
_ <- runGhc (Just libdir) $
ghcCompile cpIn
return cpIn | 196 | compileProject = do
shIn <- testShakerInput
cpIn <- runReaderT getNonMainCompileInput shIn
_ <- runGhc (Just libdir) $
ghcCompile cpIn
return cpIn | 162 | false | true | 0 | 11 | 40 | 62 | 27 | 35 | null | null |
rrnewton/accelerate | Data/Array/Accelerate/Interpreter.hs | bsd-3-clause | evalAcos :: FloatingType a -> (a -> a)
evalAcos ty | FloatingDict <- floatingDict ty = acos | 91 | evalAcos :: FloatingType a -> (a -> a)
evalAcos ty | FloatingDict <- floatingDict ty = acos | 91 | evalAcos ty | FloatingDict <- floatingDict ty = acos | 52 | false | true | 0 | 9 | 16 | 47 | 20 | 27 | null | null |
paulrzcz/takusen-oracle | Test/MiniUnit.hs | bsd-3-clause | >) = flip (.)
| 15 | (|>) = flip (.) | 15 | (|>) = flip (.) | 15 | false | false | 2 | 5 | 5 | 13 | 7 | 6 | null | null |
karamellpelle/grid | source/File/Binary/Reader.hs | gpl-3.0 | rNoneOf :: [Word8] -> Reader Word8
rNoneOf cs = rSatisfy (\c -> not (elem c cs)) | 90 | rNoneOf :: [Word8] -> Reader Word8
rNoneOf cs = rSatisfy (\c -> not (elem c cs)) | 90 | rNoneOf cs = rSatisfy (\c -> not (elem c cs)) | 55 | false | true | 0 | 10 | 25 | 49 | 24 | 25 | null | null |
beni55/fay | examples/oscillator.hs | bsd-3-clause | offset :: Point -> Dim -> Point
offset (x,y) (dx,dy) = (x+dx,y+dy) | 66 | offset :: Point -> Dim -> Point
offset (x,y) (dx,dy) = (x+dx,y+dy) | 66 | offset (x,y) (dx,dy) = (x+dx,y+dy) | 34 | false | true | 0 | 6 | 11 | 50 | 28 | 22 | null | null |
hvr/cassava | src/Data/Csv/Encoding.hs | bsd-3-clause | encodeByNameWith :: ToNamedRecord a => EncodeOptions -> Header -> [a]
-> L.ByteString
encodeByNameWith opts hdr v
| validDelim (encDelimiter opts) =
toLazyByteString (rows (encIncludeHeader opts))
| otherwise = encodeOptionsError
where
rows False = records
rows True = encodeRecord (encQuoting opts) (encDelimiter opts) hdr <>
recordSep (encUseCrLf opts) <> records
records = unlines (recordSep (encUseCrLf opts))
. map (encodeNamedRecord hdr (encQuoting opts) (encDelimiter opts)
. toNamedRecord)
$ v
| 616 | encodeByNameWith :: ToNamedRecord a => EncodeOptions -> Header -> [a]
-> L.ByteString
encodeByNameWith opts hdr v
| validDelim (encDelimiter opts) =
toLazyByteString (rows (encIncludeHeader opts))
| otherwise = encodeOptionsError
where
rows False = records
rows True = encodeRecord (encQuoting opts) (encDelimiter opts) hdr <>
recordSep (encUseCrLf opts) <> records
records = unlines (recordSep (encUseCrLf opts))
. map (encodeNamedRecord hdr (encQuoting opts) (encDelimiter opts)
. toNamedRecord)
$ v
| 616 | encodeByNameWith opts hdr v
| validDelim (encDelimiter opts) =
toLazyByteString (rows (encIncludeHeader opts))
| otherwise = encodeOptionsError
where
rows False = records
rows True = encodeRecord (encQuoting opts) (encDelimiter opts) hdr <>
recordSep (encUseCrLf opts) <> records
records = unlines (recordSep (encUseCrLf opts))
. map (encodeNamedRecord hdr (encQuoting opts) (encDelimiter opts)
. toNamedRecord)
$ v
| 513 | false | true | 6 | 11 | 181 | 211 | 94 | 117 | null | null |
osa1/rho-torrent | src/Rho/Bitfield.hs | bsd-3-clause | availableBits :: Bitfield -> IO (S.Set Int)
availableBits = collectBits id | 74 | availableBits :: Bitfield -> IO (S.Set Int)
availableBits = collectBits id | 74 | availableBits = collectBits id | 30 | false | true | 0 | 10 | 10 | 34 | 15 | 19 | null | null |
tcsavage/hsaglgui | src/AGLGUI.hs | mit | callbackMap :: IORef (Map.HashMap String (FunPtr Callback))
callbackMap = unsafePerformIO $ newIORef Map.empty | 110 | callbackMap :: IORef (Map.HashMap String (FunPtr Callback))
callbackMap = unsafePerformIO $ newIORef Map.empty | 110 | callbackMap = unsafePerformIO $ newIORef Map.empty | 50 | false | true | 0 | 9 | 12 | 39 | 19 | 20 | null | null |
creichert/http-client-auth | test/DocTest.hs | bsd-3-clause | main :: IO ()
main = glob "src/**/[A-Z]*.hs" >>= doctest | 56 | main :: IO ()
main = glob "src/**/[A-Z]*.hs" >>= doctest | 56 | main = glob "src/**/[A-Z]*.hs" >>= doctest | 42 | false | true | 0 | 6 | 9 | 23 | 11 | 12 | null | null |
AaronFriel/eff-experiments | bench/Iota.hs | bsd-3-clause | mainRRRS_Eff n = run $
flip runReader (0::Int) $
flip runReader (0::Integer) $
flip runReader True $
runState (benchS_Eff n) (0::Integer) | 146 | mainRRRS_Eff n = run $
flip runReader (0::Int) $
flip runReader (0::Integer) $
flip runReader True $
runState (benchS_Eff n) (0::Integer) | 146 | mainRRRS_Eff n = run $
flip runReader (0::Int) $
flip runReader (0::Integer) $
flip runReader True $
runState (benchS_Eff n) (0::Integer) | 146 | false | false | 9 | 8 | 29 | 62 | 31 | 31 | null | null |
BitFunctor/bitfunctor-theory | src/Network/BitFunctor/Theory/Coq/TheoryAcid.hs | mit | getStatement :: Text -> Query CoqTheoryAcid (AcidResult [CoqStatementT])
getStatement stn = do
CoqTheoryAcid th <- ask
let sts = TE.getStatementsBySuffix th stn
case sts of
[] -> return $ AcidResultError
l -> return $ AcidResultSuccess l
| 370 | getStatement :: Text -> Query CoqTheoryAcid (AcidResult [CoqStatementT])
getStatement stn = do
CoqTheoryAcid th <- ask
let sts = TE.getStatementsBySuffix th stn
case sts of
[] -> return $ AcidResultError
l -> return $ AcidResultSuccess l
| 370 | getStatement stn = do
CoqTheoryAcid th <- ask
let sts = TE.getStatementsBySuffix th stn
case sts of
[] -> return $ AcidResultError
l -> return $ AcidResultSuccess l
| 297 | false | true | 0 | 11 | 168 | 94 | 43 | 51 | null | null |
jwalsh/mal | haskell/Core.hs | mpl-2.0 | do_seq (MalVector lst _:[]) = return $ MalList lst Nil | 56 | do_seq (MalVector lst _:[]) = return $ MalList lst Nil | 56 | do_seq (MalVector lst _:[]) = return $ MalList lst Nil | 56 | false | false | 0 | 7 | 11 | 33 | 15 | 18 | null | null |
Proclivis/wxHaskell | wxcore/src/haskell/Graphics/UI/WXCore/WxcDefs.hs | lgpl-2.1 | wxAUI_TB_HORZ_TEXT :: Int
wxAUI_TB_HORZ_TEXT = 65 | 49 | wxAUI_TB_HORZ_TEXT :: Int
wxAUI_TB_HORZ_TEXT = 65 | 49 | wxAUI_TB_HORZ_TEXT = 65 | 23 | false | true | 0 | 4 | 5 | 11 | 6 | 5 | null | null |
google/codeworld | codeworld-prediction/src/CodeWorld/Prediction/Paper.hs | apache-2.0 | recordActivity :: Game world => Timestamp -> Player -> Log world -> Log world
recordActivity t p log
| t < t_old = error "Messages out of order"
| otherwise = advanceCommitted (log {latest = latest'})
where
latest' = (p, t) : delete (p, t_old) (latest log)
Just t_old = lookup p (latest log) | 305 | recordActivity :: Game world => Timestamp -> Player -> Log world -> Log world
recordActivity t p log
| t < t_old = error "Messages out of order"
| otherwise = advanceCommitted (log {latest = latest'})
where
latest' = (p, t) : delete (p, t_old) (latest log)
Just t_old = lookup p (latest log) | 305 | recordActivity t p log
| t < t_old = error "Messages out of order"
| otherwise = advanceCommitted (log {latest = latest'})
where
latest' = (p, t) : delete (p, t_old) (latest log)
Just t_old = lookup p (latest log) | 227 | false | true | 2 | 9 | 67 | 130 | 65 | 65 | null | null |
sdiehl/ghc | libraries/base/GHC/Natural.hs | bsd-3-clause | naturalToBigNat (NatJ# bn) = bn | 31 | naturalToBigNat (NatJ# bn) = bn | 31 | naturalToBigNat (NatJ# bn) = bn | 31 | false | false | 0 | 6 | 4 | 16 | 7 | 9 | null | null |
facebookincubator/duckling | Duckling/Time/KA/Rules.hs | bsd-3-clause | ruleEndOrBeginningOfYear :: Rule
ruleEndOrBeginningOfYear = Rule
{ name = "at the beginning|end of <year>"
, pattern =
[ Predicate $ isGrainOfTime TG.Year
, regex "(წლის )?დასაწყისი?(ისკენ)?(ში)? |ბოლოს?(კენ)?(ში)? "
]
, prod = \case
(Token Time td:Token RegexMatch (GroupMatch (_:match:_)):_) -> do
(sd, ed) <- case Text.toLower match of
"დასაწყისისკენ" -> Just (1, 4)
"დასაწყისში" -> Just (1, 4)
"ბოლოსკენ" -> Just (9, -1)
"ბოლოს" -> Just (9, -1)
"ბოლოში" -> Just (9, -1)
_ -> Nothing
start <- intersect td $ month sd
end <- if ed /= -1
then intersect td $ cycleLastOf TG.Month $ month ed
else cycleNthAfter False TG.Year 1 <$> intersect td (month 1)
Token Time <$> interval TTime.Open start end
_ -> Nothing
} | 884 | ruleEndOrBeginningOfYear :: Rule
ruleEndOrBeginningOfYear = Rule
{ name = "at the beginning|end of <year>"
, pattern =
[ Predicate $ isGrainOfTime TG.Year
, regex "(წლის )?დასაწყისი?(ისკენ)?(ში)? |ბოლოს?(კენ)?(ში)? "
]
, prod = \case
(Token Time td:Token RegexMatch (GroupMatch (_:match:_)):_) -> do
(sd, ed) <- case Text.toLower match of
"დასაწყისისკენ" -> Just (1, 4)
"დასაწყისში" -> Just (1, 4)
"ბოლოსკენ" -> Just (9, -1)
"ბოლოს" -> Just (9, -1)
"ბოლოში" -> Just (9, -1)
_ -> Nothing
start <- intersect td $ month sd
end <- if ed /= -1
then intersect td $ cycleLastOf TG.Month $ month ed
else cycleNthAfter False TG.Year 1 <$> intersect td (month 1)
Token Time <$> interval TTime.Open start end
_ -> Nothing
} | 884 | ruleEndOrBeginningOfYear = Rule
{ name = "at the beginning|end of <year>"
, pattern =
[ Predicate $ isGrainOfTime TG.Year
, regex "(წლის )?დასაწყისი?(ისკენ)?(ში)? |ბოლოს?(კენ)?(ში)? "
]
, prod = \case
(Token Time td:Token RegexMatch (GroupMatch (_:match:_)):_) -> do
(sd, ed) <- case Text.toLower match of
"დასაწყისისკენ" -> Just (1, 4)
"დასაწყისში" -> Just (1, 4)
"ბოლოსკენ" -> Just (9, -1)
"ბოლოს" -> Just (9, -1)
"ბოლოში" -> Just (9, -1)
_ -> Nothing
start <- intersect td $ month sd
end <- if ed /= -1
then intersect td $ cycleLastOf TG.Month $ month ed
else cycleNthAfter False TG.Year 1 <$> intersect td (month 1)
Token Time <$> interval TTime.Open start end
_ -> Nothing
} | 851 | false | true | 0 | 19 | 290 | 314 | 157 | 157 | null | null |
treeowl/cassava | Data/Csv/Parser.hs | bsd-3-clause | -- | Parse a header name. Header names have the same format as regular
-- 'field's.
name :: Word8 -> AL.Parser Name
name !delim = field delim | 141 | name :: Word8 -> AL.Parser Name
name !delim = field delim | 57 | name !delim = field delim | 25 | true | true | 0 | 9 | 26 | 35 | 16 | 19 | null | null |
yogsototh/hascheme | y.hs | mit | eval (List [Atom "quote", val]) = val | 37 | eval (List [Atom "quote", val]) = val | 37 | eval (List [Atom "quote", val]) = val | 37 | false | false | 0 | 9 | 6 | 24 | 12 | 12 | null | null |
ezyang/ghc | compiler/basicTypes/BasicTypes.hs | bsd-3-clause | hasOverlappingFlag :: OverlapMode -> Bool
hasOverlappingFlag mode =
case mode of
Overlapping _ -> True
Overlaps _ -> True
Incoherent _ -> True
_ -> False | 191 | hasOverlappingFlag :: OverlapMode -> Bool
hasOverlappingFlag mode =
case mode of
Overlapping _ -> True
Overlaps _ -> True
Incoherent _ -> True
_ -> False | 191 | hasOverlappingFlag mode =
case mode of
Overlapping _ -> True
Overlaps _ -> True
Incoherent _ -> True
_ -> False | 149 | false | true | 5 | 5 | 63 | 51 | 26 | 25 | null | null |
dosenfrucht/mcasm | src/Transform.hs | gpl-2.0 | replaceLabels (Syntax.DW imm : xs) m =
let nImm = insertLabelImm imm m
nAst = case nImm of
Just a -> Syntax.DW a
Nothing -> Error $ ulerr ++ getLabelImm imm
in nAst : replaceLabels xs m | 226 | replaceLabels (Syntax.DW imm : xs) m =
let nImm = insertLabelImm imm m
nAst = case nImm of
Just a -> Syntax.DW a
Nothing -> Error $ ulerr ++ getLabelImm imm
in nAst : replaceLabels xs m | 226 | replaceLabels (Syntax.DW imm : xs) m =
let nImm = insertLabelImm imm m
nAst = case nImm of
Just a -> Syntax.DW a
Nothing -> Error $ ulerr ++ getLabelImm imm
in nAst : replaceLabels xs m | 226 | false | false | 3 | 13 | 77 | 93 | 41 | 52 | null | null |
gaoce/haskell_99 | 11.hs | mit | encodeModified :: (Eq a) => [a] -> [Item a]
encodeModified = map (\x -> if length x > 1 then Multiple (length x) (head x) else Single (head x)) . group | 151 | encodeModified :: (Eq a) => [a] -> [Item a]
encodeModified = map (\x -> if length x > 1 then Multiple (length x) (head x) else Single (head x)) . group | 151 | encodeModified = map (\x -> if length x > 1 then Multiple (length x) (head x) else Single (head x)) . group | 107 | false | true | 0 | 12 | 30 | 89 | 46 | 43 | null | null |
sethfowler/bzbeaver | src/Site.hs | bsd-3-clause | twoWeeks = fromIntegral $ 2 * 604800 | 36 | twoWeeks = fromIntegral $ 2 * 604800 | 36 | twoWeeks = fromIntegral $ 2 * 604800 | 36 | false | false | 0 | 6 | 6 | 14 | 7 | 7 | null | null |
romanb/amazonka | amazonka-redshift/gen/Network/AWS/Redshift/Types.hs | mpl-2.0 | -- | A Boolean value indicating whether the subscription is enabled. 'true'
-- indicates the subscription is enabled.
esEnabled :: Lens' EventSubscription (Maybe Bool)
esEnabled = lens _esEnabled (\s a -> s { _esEnabled = a }) | 226 | esEnabled :: Lens' EventSubscription (Maybe Bool)
esEnabled = lens _esEnabled (\s a -> s { _esEnabled = a }) | 108 | esEnabled = lens _esEnabled (\s a -> s { _esEnabled = a }) | 58 | true | true | 0 | 9 | 36 | 47 | 26 | 21 | null | null |
jtdaugherty/vty | test/BenchImageFuzz.hs | bsd-3-clause | randomPicture = picForImage <$> randomImage | 43 | randomPicture = picForImage <$> randomImage | 43 | randomPicture = picForImage <$> randomImage | 43 | false | false | 1 | 5 | 4 | 13 | 5 | 8 | null | null |
agentm/project-m36 | src/lib/ProjectM36/Tuple.hs | unlicense | mkRelationTupleFromMap :: M.Map AttributeName Atom -> RelationTuple
mkRelationTupleFromMap attrMap = RelationTuple (attributesFromList attrs) (V.map (attrMap M.!) (V.fromList attrNames))
where
attrNames = M.keys attrMap
attrs = map (\attrName -> Attribute attrName (atomTypeForAtom (attrMap M.! attrName))) attrNames
--return error if attribute names match but their types do not | 390 | mkRelationTupleFromMap :: M.Map AttributeName Atom -> RelationTuple
mkRelationTupleFromMap attrMap = RelationTuple (attributesFromList attrs) (V.map (attrMap M.!) (V.fromList attrNames))
where
attrNames = M.keys attrMap
attrs = map (\attrName -> Attribute attrName (atomTypeForAtom (attrMap M.! attrName))) attrNames
--return error if attribute names match but their types do not | 390 | mkRelationTupleFromMap attrMap = RelationTuple (attributesFromList attrs) (V.map (attrMap M.!) (V.fromList attrNames))
where
attrNames = M.keys attrMap
attrs = map (\attrName -> Attribute attrName (atomTypeForAtom (attrMap M.! attrName))) attrNames
--return error if attribute names match but their types do not | 322 | false | true | 0 | 12 | 56 | 112 | 57 | 55 | null | null |
taktoa/TSLogAnalyzer | library/Utility/TSLogAnalyzer/MsgParse.hs | gpl-3.0 | octetParser :: Parser IP
octetParser = do
o1 <- decimal
period
o2 <- decimal
period
o3 <- decimal
period
o4 <- decimal
pure (fromOctets (o1, o2, o3, o4)) | 169 | octetParser :: Parser IP
octetParser = do
o1 <- decimal
period
o2 <- decimal
period
o3 <- decimal
period
o4 <- decimal
pure (fromOctets (o1, o2, o3, o4)) | 169 | octetParser = do
o1 <- decimal
period
o2 <- decimal
period
o3 <- decimal
period
o4 <- decimal
pure (fromOctets (o1, o2, o3, o4)) | 144 | false | true | 0 | 10 | 43 | 75 | 35 | 40 | null | null |
tjakway/ghcjvm | compiler/prelude/PrelNames.hs | bsd-3-clause | ltTag_RDR = dataQual_RDR gHC_TYPES (fsLit "LT") | 61 | ltTag_RDR = dataQual_RDR gHC_TYPES (fsLit "LT") | 61 | ltTag_RDR = dataQual_RDR gHC_TYPES (fsLit "LT") | 61 | false | false | 0 | 7 | 19 | 17 | 8 | 9 | null | null |
wskplho/stack | src/Path/IO.hs | bsd-3-clause | -- | Appends a stringly-typed relative path to an absolute path, and then
-- canonicalizes it.
resolveDir :: (MonadIO m, MonadThrow m) => Path Abs Dir -> FilePath -> m (Path Abs Dir)
resolveDir x y =
do result <- resolveDirMaybe x y
case result of
Nothing ->
throwM $ ResolveDirFailed x y fp
where fp = toFilePath x FP.</> y
Just fp -> return fp
-- | Appends a stringly-typed relative path to an absolute path, and then
-- canonicalizes it. | 480 | resolveDir :: (MonadIO m, MonadThrow m) => Path Abs Dir -> FilePath -> m (Path Abs Dir)
resolveDir x y =
do result <- resolveDirMaybe x y
case result of
Nothing ->
throwM $ ResolveDirFailed x y fp
where fp = toFilePath x FP.</> y
Just fp -> return fp
-- | Appends a stringly-typed relative path to an absolute path, and then
-- canonicalizes it. | 385 | resolveDir x y =
do result <- resolveDirMaybe x y
case result of
Nothing ->
throwM $ ResolveDirFailed x y fp
where fp = toFilePath x FP.</> y
Just fp -> return fp
-- | Appends a stringly-typed relative path to an absolute path, and then
-- canonicalizes it. | 297 | true | true | 0 | 13 | 121 | 123 | 60 | 63 | null | null |
kowey/GenI | src/NLP/GenI/Builder.hs | gpl-2.0 | chart_size = "chart_size" | 30 | chart_size = "chart_size" | 30 | chart_size = "chart_size" | 30 | false | false | 0 | 4 | 7 | 6 | 3 | 3 | null | null |
spatial-reasoning/zeno | src/Helpful/General.hs | bsd-2-clause | parMapM :: (a -> IO b) -> [a] -> IO [b]
parMapM f xs = (_fork f xs) >>= _join | 77 | parMapM :: (a -> IO b) -> [a] -> IO [b]
parMapM f xs = (_fork f xs) >>= _join | 77 | parMapM f xs = (_fork f xs) >>= _join | 37 | false | true | 0 | 9 | 19 | 60 | 29 | 31 | null | null |
eb-gh-cr/XMonadContrib1 | XMonad/Hooks/UrgencyHook.hs | bsd-3-clause | handleEvent :: UrgencyHook h => WithUrgencyHook h -> Event -> X ()
handleEvent wuh event =
case event of
-- WM_HINTS urgency flag
PropertyEvent { ev_event_type = t, ev_atom = a, ev_window = w } -> do
when (t == propertyNotify && a == wM_HINTS) $ withDisplay $ \dpy -> do
WMHints { wmh_flags = flags } <- io $ getWMHints dpy w
if (testBit flags urgencyHintBit) then markUrgent w else markNotUrgent w
-- Window destroyed
DestroyWindowEvent {ev_window = w} ->
markNotUrgent w
-- _NET_WM_STATE_DEMANDS_ATTENTION requested by client
ClientMessageEvent {ev_event_display = dpy, ev_window = w, ev_message_type = t, ev_data = action:atoms} -> do
a_wmstate <- getAtom "_NET_WM_STATE"
a_da <- getAtom "_NET_WM_STATE_DEMANDS_ATTENTION"
wstate <- getNetWMState w
let demandsAttention = fromIntegral a_da `elem` wstate
remove = 0
add = 1
toggle = 2
when (t == a_wmstate && fromIntegral a_da `elem` atoms) $ do
when (action == add || (action == toggle && not demandsAttention)) $ do
markUrgent w
addNetWMState dpy w a_da
when (action == remove || (action == toggle && demandsAttention)) $ do
markNotUrgent w
removeNetWMState dpy w a_da
_ ->
mapM_ handleReminder =<< readReminders
where handleReminder reminder = handleTimer (timer reminder) event $ reminderHook wuh reminder
markUrgent w = do
adjustUrgents (\ws -> if elem w ws then ws else w : ws)
callUrgencyHook wuh w
userCodeDef () =<< asks (logHook . config)
markNotUrgent w = do
adjustUrgents (delete w) >> adjustReminders (filter $ (w /=) . window)
userCodeDef () =<< asks (logHook . config) | 1,930 | handleEvent :: UrgencyHook h => WithUrgencyHook h -> Event -> X ()
handleEvent wuh event =
case event of
-- WM_HINTS urgency flag
PropertyEvent { ev_event_type = t, ev_atom = a, ev_window = w } -> do
when (t == propertyNotify && a == wM_HINTS) $ withDisplay $ \dpy -> do
WMHints { wmh_flags = flags } <- io $ getWMHints dpy w
if (testBit flags urgencyHintBit) then markUrgent w else markNotUrgent w
-- Window destroyed
DestroyWindowEvent {ev_window = w} ->
markNotUrgent w
-- _NET_WM_STATE_DEMANDS_ATTENTION requested by client
ClientMessageEvent {ev_event_display = dpy, ev_window = w, ev_message_type = t, ev_data = action:atoms} -> do
a_wmstate <- getAtom "_NET_WM_STATE"
a_da <- getAtom "_NET_WM_STATE_DEMANDS_ATTENTION"
wstate <- getNetWMState w
let demandsAttention = fromIntegral a_da `elem` wstate
remove = 0
add = 1
toggle = 2
when (t == a_wmstate && fromIntegral a_da `elem` atoms) $ do
when (action == add || (action == toggle && not demandsAttention)) $ do
markUrgent w
addNetWMState dpy w a_da
when (action == remove || (action == toggle && demandsAttention)) $ do
markNotUrgent w
removeNetWMState dpy w a_da
_ ->
mapM_ handleReminder =<< readReminders
where handleReminder reminder = handleTimer (timer reminder) event $ reminderHook wuh reminder
markUrgent w = do
adjustUrgents (\ws -> if elem w ws then ws else w : ws)
callUrgencyHook wuh w
userCodeDef () =<< asks (logHook . config)
markNotUrgent w = do
adjustUrgents (delete w) >> adjustReminders (filter $ (w /=) . window)
userCodeDef () =<< asks (logHook . config) | 1,930 | handleEvent wuh event =
case event of
-- WM_HINTS urgency flag
PropertyEvent { ev_event_type = t, ev_atom = a, ev_window = w } -> do
when (t == propertyNotify && a == wM_HINTS) $ withDisplay $ \dpy -> do
WMHints { wmh_flags = flags } <- io $ getWMHints dpy w
if (testBit flags urgencyHintBit) then markUrgent w else markNotUrgent w
-- Window destroyed
DestroyWindowEvent {ev_window = w} ->
markNotUrgent w
-- _NET_WM_STATE_DEMANDS_ATTENTION requested by client
ClientMessageEvent {ev_event_display = dpy, ev_window = w, ev_message_type = t, ev_data = action:atoms} -> do
a_wmstate <- getAtom "_NET_WM_STATE"
a_da <- getAtom "_NET_WM_STATE_DEMANDS_ATTENTION"
wstate <- getNetWMState w
let demandsAttention = fromIntegral a_da `elem` wstate
remove = 0
add = 1
toggle = 2
when (t == a_wmstate && fromIntegral a_da `elem` atoms) $ do
when (action == add || (action == toggle && not demandsAttention)) $ do
markUrgent w
addNetWMState dpy w a_da
when (action == remove || (action == toggle && demandsAttention)) $ do
markNotUrgent w
removeNetWMState dpy w a_da
_ ->
mapM_ handleReminder =<< readReminders
where handleReminder reminder = handleTimer (timer reminder) event $ reminderHook wuh reminder
markUrgent w = do
adjustUrgents (\ws -> if elem w ws then ws else w : ws)
callUrgencyHook wuh w
userCodeDef () =<< asks (logHook . config)
markNotUrgent w = do
adjustUrgents (delete w) >> adjustReminders (filter $ (w /=) . window)
userCodeDef () =<< asks (logHook . config) | 1,863 | false | true | 0 | 19 | 641 | 580 | 285 | 295 | null | null |
rednum/hmlk | examples/classifiers.hs | bsd-3-clause | runAll = do
putStrLn "\n\nRunning clustering:"
clustering 3
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning KNN:"
knns
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning linear:"
linearRegression
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning trees:"
trees
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning bayes:"
bayes
putStrLn . take 80 $ repeat '=' | 432 | runAll = do
putStrLn "\n\nRunning clustering:"
clustering 3
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning KNN:"
knns
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning linear:"
linearRegression
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning trees:"
trees
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning bayes:"
bayes
putStrLn . take 80 $ repeat '=' | 432 | runAll = do
putStrLn "\n\nRunning clustering:"
clustering 3
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning KNN:"
knns
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning linear:"
linearRegression
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning trees:"
trees
putStrLn . take 80 $ repeat '='
putStrLn "\n\nRunning bayes:"
bayes
putStrLn . take 80 $ repeat '=' | 432 | false | false | 1 | 10 | 118 | 143 | 54 | 89 | null | null |
rawlep/MML | sourceCode/LINreg2.hs | mit | appendByColumns :: Element t => [Matrix t] -> Matrix t
appendByColumns = fromRows . concatMap toRows | 102 | appendByColumns :: Element t => [Matrix t] -> Matrix t
appendByColumns = fromRows . concatMap toRows | 101 | appendByColumns = fromRows . concatMap toRows | 46 | false | true | 0 | 8 | 17 | 38 | 18 | 20 | null | null |
rvl/hsoz | src/Network/Hawk/Internal/Client.hs | bsd-3-clause | checkServerAuthorizationHeader creds arts _ now (Just sa) =
parseServerAuthorizationHeader sa >>= check
where check sah | sahMac sah `constEq` mac = Right (Just sah)
| otherwise = Left "Bad response mac"
where
arts' = responseArtifacts sah arts
mac = clientMac creds HawkResponse arts'
-- | Updates the artifacts which were used for client authentication
-- with values from there server's response. | 456 | checkServerAuthorizationHeader creds arts _ now (Just sa) =
parseServerAuthorizationHeader sa >>= check
where check sah | sahMac sah `constEq` mac = Right (Just sah)
| otherwise = Left "Bad response mac"
where
arts' = responseArtifacts sah arts
mac = clientMac creds HawkResponse arts'
-- | Updates the artifacts which were used for client authentication
-- with values from there server's response. | 456 | checkServerAuthorizationHeader creds arts _ now (Just sa) =
parseServerAuthorizationHeader sa >>= check
where check sah | sahMac sah `constEq` mac = Right (Just sah)
| otherwise = Left "Bad response mac"
where
arts' = responseArtifacts sah arts
mac = clientMac creds HawkResponse arts'
-- | Updates the artifacts which were used for client authentication
-- with values from there server's response. | 456 | false | false | 0 | 9 | 117 | 102 | 49 | 53 | null | null |
dimara/ganeti | test/hs/Test/Ganeti/Objects.hs | bsd-2-clause | -- | Enhances a given instance with network information, by connecting it to the
-- given networks and possibly some other networks
enhanceInstWithNets :: Instance -> [String] -> Gen Instance
enhanceInstWithNets inst nets = do
mac <- arbitrary
ip <- arbitrary
nicparams <- arbitrary
name <- arbitrary
uuid <- arbitrary
-- generate some more networks than the given ones
num_more_nets <- choose (0,3)
more_nets <- vectorOf num_more_nets genUUID
let genNic net = PartialNic mac ip nicparams net name uuid
partial_nics = map (genNic . Just)
(List.nub (nets ++ more_nets))
new_inst = case inst of
RealInstance rinst ->
RealInstance rinst { realInstNics = partial_nics }
ForthcomingInstance _ -> inst
return new_inst | 827 | enhanceInstWithNets :: Instance -> [String] -> Gen Instance
enhanceInstWithNets inst nets = do
mac <- arbitrary
ip <- arbitrary
nicparams <- arbitrary
name <- arbitrary
uuid <- arbitrary
-- generate some more networks than the given ones
num_more_nets <- choose (0,3)
more_nets <- vectorOf num_more_nets genUUID
let genNic net = PartialNic mac ip nicparams net name uuid
partial_nics = map (genNic . Just)
(List.nub (nets ++ more_nets))
new_inst = case inst of
RealInstance rinst ->
RealInstance rinst { realInstNics = partial_nics }
ForthcomingInstance _ -> inst
return new_inst | 695 | enhanceInstWithNets inst nets = do
mac <- arbitrary
ip <- arbitrary
nicparams <- arbitrary
name <- arbitrary
uuid <- arbitrary
-- generate some more networks than the given ones
num_more_nets <- choose (0,3)
more_nets <- vectorOf num_more_nets genUUID
let genNic net = PartialNic mac ip nicparams net name uuid
partial_nics = map (genNic . Just)
(List.nub (nets ++ more_nets))
new_inst = case inst of
RealInstance rinst ->
RealInstance rinst { realInstNics = partial_nics }
ForthcomingInstance _ -> inst
return new_inst | 635 | true | true | 0 | 15 | 225 | 197 | 95 | 102 | null | null |
patrickherrmann/advent | src/Day17.hs | bsd-3-clause | numberOfCombos :: Int -> [Int] -> Int
numberOfCombos n cs = length $ checkCapacities n cs | 89 | numberOfCombos :: Int -> [Int] -> Int
numberOfCombos n cs = length $ checkCapacities n cs | 89 | numberOfCombos n cs = length $ checkCapacities n cs | 51 | false | true | 0 | 7 | 15 | 36 | 18 | 18 | null | null |
elbrujohalcon/hfiar | src/HFiaR.hs | bsd-3-clause | doDropIn c OnCourse{gameBoard = theBoard,
gamePlayer= thePlayer} | c < 0 = Left InvalidColumn
| 6 < c = Left InvalidColumn
| length (theBoard !! c) == 7 = Left FullColumn
| otherwise =
let newBoard = insertAt c (tiles thePlayer) theBoard
newResult= if (isWinner c thePlayer newBoard) then WonBy thePlayer else Tie
in if (full newBoard || (newResult == WonBy thePlayer))
then Right Ended{gameResult = newResult,
gameBoard = newBoard}
else Right OnCourse{gameBoard = newBoard,
gamePlayer= otherPlayer thePlayer}
where insertAt :: Int -> a -> [[a]] -> [[a]]
insertAt i x xss = (take i xss) ++ ( (x : (xss !! i)) : drop (i+1) xss)
otherPlayer :: Player -> Player
otherPlayer Pl{tiles=Green} = Pl Red
otherPlayer Pl{tiles=Red} = Pl Green
full :: [[a]] -> Bool
full = all (\x -> 7 == length x)
isWinner :: Int -> Player -> [[Tile]] -> Bool
isWinner cc Pl{tiles=p} b =
let col = b !! cc
in ([p,p,p,p] == take 4 col) ||
fourIn (getRow (length col - 1) b) ||
fourIn (getDiagUpRight cc (length col - 1) b) ||
fourIn (getDiagUpLeft cc (length col - 1) b)
getRow :: Int -> [[Tile]] -> [Maybe Tile]
getRow r = map (cell r)
getDiagUpRight :: Int -> Int -> [[Tile]] -> [Maybe Tile]
getDiagUpRight cc r xss = map (\i -> cell (i+r-cc) (xss !! i)) [0..6]
getDiagUpLeft :: Int -> Int -> [[Tile]] -> [Maybe Tile]
getDiagUpLeft cc r xss = map (\i -> cell (r+cc-i) (xss !! i)) [0..6]
cell :: Int -> [Tile] -> Maybe Tile
cell cc xs = if (cc >= 0 && cc < length xs)
then Just $ (reverse xs) !! cc
else Nothing
fourIn :: [Maybe Tile] -> Bool
fourIn [] = False
fourIn (Nothing:xs) = fourIn xs
fourIn (Just p :xs) = ([Just p, Just p, Just p] == take 3 xs) || fourIn xs
-- | Player who's supposed to play the next tile | 2,641 | doDropIn c OnCourse{gameBoard = theBoard,
gamePlayer= thePlayer} | c < 0 = Left InvalidColumn
| 6 < c = Left InvalidColumn
| length (theBoard !! c) == 7 = Left FullColumn
| otherwise =
let newBoard = insertAt c (tiles thePlayer) theBoard
newResult= if (isWinner c thePlayer newBoard) then WonBy thePlayer else Tie
in if (full newBoard || (newResult == WonBy thePlayer))
then Right Ended{gameResult = newResult,
gameBoard = newBoard}
else Right OnCourse{gameBoard = newBoard,
gamePlayer= otherPlayer thePlayer}
where insertAt :: Int -> a -> [[a]] -> [[a]]
insertAt i x xss = (take i xss) ++ ( (x : (xss !! i)) : drop (i+1) xss)
otherPlayer :: Player -> Player
otherPlayer Pl{tiles=Green} = Pl Red
otherPlayer Pl{tiles=Red} = Pl Green
full :: [[a]] -> Bool
full = all (\x -> 7 == length x)
isWinner :: Int -> Player -> [[Tile]] -> Bool
isWinner cc Pl{tiles=p} b =
let col = b !! cc
in ([p,p,p,p] == take 4 col) ||
fourIn (getRow (length col - 1) b) ||
fourIn (getDiagUpRight cc (length col - 1) b) ||
fourIn (getDiagUpLeft cc (length col - 1) b)
getRow :: Int -> [[Tile]] -> [Maybe Tile]
getRow r = map (cell r)
getDiagUpRight :: Int -> Int -> [[Tile]] -> [Maybe Tile]
getDiagUpRight cc r xss = map (\i -> cell (i+r-cc) (xss !! i)) [0..6]
getDiagUpLeft :: Int -> Int -> [[Tile]] -> [Maybe Tile]
getDiagUpLeft cc r xss = map (\i -> cell (r+cc-i) (xss !! i)) [0..6]
cell :: Int -> [Tile] -> Maybe Tile
cell cc xs = if (cc >= 0 && cc < length xs)
then Just $ (reverse xs) !! cc
else Nothing
fourIn :: [Maybe Tile] -> Bool
fourIn [] = False
fourIn (Nothing:xs) = fourIn xs
fourIn (Just p :xs) = ([Just p, Just p, Just p] == take 3 xs) || fourIn xs
-- | Player who's supposed to play the next tile | 2,641 | doDropIn c OnCourse{gameBoard = theBoard,
gamePlayer= thePlayer} | c < 0 = Left InvalidColumn
| 6 < c = Left InvalidColumn
| length (theBoard !! c) == 7 = Left FullColumn
| otherwise =
let newBoard = insertAt c (tiles thePlayer) theBoard
newResult= if (isWinner c thePlayer newBoard) then WonBy thePlayer else Tie
in if (full newBoard || (newResult == WonBy thePlayer))
then Right Ended{gameResult = newResult,
gameBoard = newBoard}
else Right OnCourse{gameBoard = newBoard,
gamePlayer= otherPlayer thePlayer}
where insertAt :: Int -> a -> [[a]] -> [[a]]
insertAt i x xss = (take i xss) ++ ( (x : (xss !! i)) : drop (i+1) xss)
otherPlayer :: Player -> Player
otherPlayer Pl{tiles=Green} = Pl Red
otherPlayer Pl{tiles=Red} = Pl Green
full :: [[a]] -> Bool
full = all (\x -> 7 == length x)
isWinner :: Int -> Player -> [[Tile]] -> Bool
isWinner cc Pl{tiles=p} b =
let col = b !! cc
in ([p,p,p,p] == take 4 col) ||
fourIn (getRow (length col - 1) b) ||
fourIn (getDiagUpRight cc (length col - 1) b) ||
fourIn (getDiagUpLeft cc (length col - 1) b)
getRow :: Int -> [[Tile]] -> [Maybe Tile]
getRow r = map (cell r)
getDiagUpRight :: Int -> Int -> [[Tile]] -> [Maybe Tile]
getDiagUpRight cc r xss = map (\i -> cell (i+r-cc) (xss !! i)) [0..6]
getDiagUpLeft :: Int -> Int -> [[Tile]] -> [Maybe Tile]
getDiagUpLeft cc r xss = map (\i -> cell (r+cc-i) (xss !! i)) [0..6]
cell :: Int -> [Tile] -> Maybe Tile
cell cc xs = if (cc >= 0 && cc < length xs)
then Just $ (reverse xs) !! cc
else Nothing
fourIn :: [Maybe Tile] -> Bool
fourIn [] = False
fourIn (Nothing:xs) = fourIn xs
fourIn (Just p :xs) = ([Just p, Just p, Just p] == take 3 xs) || fourIn xs
-- | Player who's supposed to play the next tile | 2,641 | false | false | 33 | 16 | 1,273 | 922 | 477 | 445 | null | null |
mudphone/HaskellBook | src/Nine.hs | mit | squishMap :: (a -> [b]) -> [a] -> [b]
squishMap _ [] = [] | 57 | squishMap :: (a -> [b]) -> [a] -> [b]
squishMap _ [] = [] | 57 | squishMap _ [] = [] | 19 | false | true | 0 | 8 | 13 | 44 | 24 | 20 | null | null |
facebookarchive/lex-pass | src/Lang/Php/Ast/StmtParse.hs | bsd-3-clause | eptDiv = binOp (BByable BDiv) tokDivP | 37 | eptDiv = binOp (BByable BDiv) tokDivP | 37 | eptDiv = binOp (BByable BDiv) tokDivP | 37 | false | false | 1 | 7 | 5 | 21 | 8 | 13 | null | null |
conal/hermit | src/HERMIT/Dictionary/Navigation.hs | bsd-2-clause | varOccurrenceExpr :: CoreExpr -> Maybe Var
varOccurrenceExpr (Var v) = Just v | 83 | varOccurrenceExpr :: CoreExpr -> Maybe Var
varOccurrenceExpr (Var v) = Just v | 83 | varOccurrenceExpr (Var v) = Just v | 40 | false | true | 0 | 7 | 17 | 30 | 14 | 16 | null | null |
yxm4109/pandoc | tests/RunTests.hs | gpl-2.0 | lhsWriterFormats :: [String]
lhsWriterFormats = [ "markdown"
, "markdown+lhs"
, "rst"
, "rst+lhs"
, "latex"
, "latex+lhs"
, "html"
, "html+lhs"
] | 297 | lhsWriterFormats :: [String]
lhsWriterFormats = [ "markdown"
, "markdown+lhs"
, "rst"
, "rst+lhs"
, "latex"
, "latex+lhs"
, "html"
, "html+lhs"
] | 297 | lhsWriterFormats = [ "markdown"
, "markdown+lhs"
, "rst"
, "rst+lhs"
, "latex"
, "latex+lhs"
, "html"
, "html+lhs"
] | 268 | false | true | 0 | 5 | 173 | 38 | 24 | 14 | null | null |
acowley/language-c | src/Language/C/Syntax/Constants.hs | bsd-3-clause | -- dummy implementation
readCFloat :: String -> CFloat
readCFloat = CFloat | 74 | readCFloat :: String -> CFloat
readCFloat = CFloat | 50 | readCFloat = CFloat | 19 | true | true | 0 | 5 | 10 | 16 | 9 | 7 | null | null |
agrafix/HSmarty | src/Text/HSmarty/Render/Engine.hs | bsd-3-clause | evalStmt env (SmartyIf (If cases elseBody)) =
do evaledCases <- mapM (\(cond, body) ->
do r <- evalExpr env cond
(_, b) <- seqStmts env body
case r of
(A.Bool False) ->
return Nothing
A.Null -> return Nothing
(A.Array v) | null v -> return Nothing
_ ->
return $ Just b
) cases
case catMaybes evaledCases of
(x:_) ->
return (env, x)
_ ->
case elseBody of
Just elseB ->
(,) <$> pure env <*> (snd <$> seqStmts env elseB)
Nothing ->
return (env, T.empty) | 932 | evalStmt env (SmartyIf (If cases elseBody)) =
do evaledCases <- mapM (\(cond, body) ->
do r <- evalExpr env cond
(_, b) <- seqStmts env body
case r of
(A.Bool False) ->
return Nothing
A.Null -> return Nothing
(A.Array v) | null v -> return Nothing
_ ->
return $ Just b
) cases
case catMaybes evaledCases of
(x:_) ->
return (env, x)
_ ->
case elseBody of
Just elseB ->
(,) <$> pure env <*> (snd <$> seqStmts env elseB)
Nothing ->
return (env, T.empty) | 932 | evalStmt env (SmartyIf (If cases elseBody)) =
do evaledCases <- mapM (\(cond, body) ->
do r <- evalExpr env cond
(_, b) <- seqStmts env body
case r of
(A.Bool False) ->
return Nothing
A.Null -> return Nothing
(A.Array v) | null v -> return Nothing
_ ->
return $ Just b
) cases
case catMaybes evaledCases of
(x:_) ->
return (env, x)
_ ->
case elseBody of
Just elseB ->
(,) <$> pure env <*> (snd <$> seqStmts env elseB)
Nothing ->
return (env, T.empty) | 932 | false | false | 0 | 19 | 567 | 249 | 120 | 129 | null | null |
eb-gh-cr/XMonadContrib1 | XMonad/Layout/IndependentScreens.hs | bsd-3-clause | -- | Convert the tag of the 'WindowSpace' from a 'PhysicalWorkspace' to a 'VirtualWorkspace'.
unmarshallWindowSpace :: WindowSpace -> WindowSpace
marshallWindowSpace s ws = ws { tag = marshall s (tag ws) } | 207 | unmarshallWindowSpace :: WindowSpace -> WindowSpace
marshallWindowSpace s ws = ws { tag = marshall s (tag ws) } | 112 | marshallWindowSpace s ws = ws { tag = marshall s (tag ws) } | 60 | true | true | 0 | 10 | 33 | 46 | 22 | 24 | null | null |
themoritz/cabal | Cabal/Distribution/Simple/Compiler.hs | bsd-3-clause | flagToOptimisationLevel (Just s) = case reads s of
[(i, "")]
| i >= fromEnum (minBound :: OptimisationLevel)
&& i <= fromEnum (maxBound :: OptimisationLevel)
-> toEnum i
| otherwise -> error $ "Bad optimisation level: " ++ show i
++ ". Valid values are 0..2"
_ -> error $ "Can't parse optimisation level " ++ s
-- ------------------------------------------------------------
-- * Debug info levels
-- ------------------------------------------------------------
-- | Some compilers support emitting debug info. Some have different
-- levels. For compilers that do not the level is just capped to the
-- level they do support.
-- | 698 | flagToOptimisationLevel (Just s) = case reads s of
[(i, "")]
| i >= fromEnum (minBound :: OptimisationLevel)
&& i <= fromEnum (maxBound :: OptimisationLevel)
-> toEnum i
| otherwise -> error $ "Bad optimisation level: " ++ show i
++ ". Valid values are 0..2"
_ -> error $ "Can't parse optimisation level " ++ s
-- ------------------------------------------------------------
-- * Debug info levels
-- ------------------------------------------------------------
-- | Some compilers support emitting debug info. Some have different
-- levels. For compilers that do not the level is just capped to the
-- level they do support.
-- | 698 | flagToOptimisationLevel (Just s) = case reads s of
[(i, "")]
| i >= fromEnum (minBound :: OptimisationLevel)
&& i <= fromEnum (maxBound :: OptimisationLevel)
-> toEnum i
| otherwise -> error $ "Bad optimisation level: " ++ show i
++ ". Valid values are 0..2"
_ -> error $ "Can't parse optimisation level " ++ s
-- ------------------------------------------------------------
-- * Debug info levels
-- ------------------------------------------------------------
-- | Some compilers support emitting debug info. Some have different
-- levels. For compilers that do not the level is just capped to the
-- level they do support.
-- | 698 | false | false | 0 | 15 | 165 | 121 | 63 | 58 | null | null |
int-e/hint | src/Hint/Configuration.hs | bsd-3-clause | fromConf :: MonadInterpreter m => (InterpreterConfiguration -> a) -> m a
fromConf f = fromState (f . configuration) | 115 | fromConf :: MonadInterpreter m => (InterpreterConfiguration -> a) -> m a
fromConf f = fromState (f . configuration) | 115 | fromConf f = fromState (f . configuration) | 42 | false | true | 0 | 8 | 17 | 45 | 22 | 23 | null | null |
bitemyapp/ruby-marshal | src/Data/Ruby/Marshal/Get.hs | mit | -- | Deserialises a subset of Ruby objects.
getRubyObject :: Marshal RubyObject
getRubyObject = getMarshalVersion >> go
where
go :: Marshal RubyObject
go = liftMarshal getWord8 >>= \case
NilC -> return RNil
TrueC -> return $ RBool True
FalseC -> return $ RBool False
ArrayC -> RArray <$> getArray go
FixnumC -> RFixnum <$> getFixnum
FloatC -> RFloat <$> getFloat
HashC -> RHash <$> getHash go go
IVarC -> RIVar <$> getIVar go
ObjectLinkC -> RIVar <$> getObjectLink
StringC -> RString <$> getString
SymbolC -> RSymbol <$> getSymbol
SymlinkC -> RSymbol <$> getSymlink
_ -> return $ RError Unsupported
--------------------------------------------------------------------
-- Ancillary functions.
-- | Deserialises <http://ruby-doc.org/core-2.2.0/NilClass.html nil>. | 924 | getRubyObject :: Marshal RubyObject
getRubyObject = getMarshalVersion >> go
where
go :: Marshal RubyObject
go = liftMarshal getWord8 >>= \case
NilC -> return RNil
TrueC -> return $ RBool True
FalseC -> return $ RBool False
ArrayC -> RArray <$> getArray go
FixnumC -> RFixnum <$> getFixnum
FloatC -> RFloat <$> getFloat
HashC -> RHash <$> getHash go go
IVarC -> RIVar <$> getIVar go
ObjectLinkC -> RIVar <$> getObjectLink
StringC -> RString <$> getString
SymbolC -> RSymbol <$> getSymbol
SymlinkC -> RSymbol <$> getSymlink
_ -> return $ RError Unsupported
--------------------------------------------------------------------
-- Ancillary functions.
-- | Deserialises <http://ruby-doc.org/core-2.2.0/NilClass.html nil>. | 880 | getRubyObject = getMarshalVersion >> go
where
go :: Marshal RubyObject
go = liftMarshal getWord8 >>= \case
NilC -> return RNil
TrueC -> return $ RBool True
FalseC -> return $ RBool False
ArrayC -> RArray <$> getArray go
FixnumC -> RFixnum <$> getFixnum
FloatC -> RFloat <$> getFloat
HashC -> RHash <$> getHash go go
IVarC -> RIVar <$> getIVar go
ObjectLinkC -> RIVar <$> getObjectLink
StringC -> RString <$> getString
SymbolC -> RSymbol <$> getSymbol
SymlinkC -> RSymbol <$> getSymlink
_ -> return $ RError Unsupported
--------------------------------------------------------------------
-- Ancillary functions.
-- | Deserialises <http://ruby-doc.org/core-2.2.0/NilClass.html nil>. | 844 | true | true | 0 | 10 | 270 | 196 | 96 | 100 | null | null |
kbok/lang-lei-la | Vec2Lens.hs | bsd-3-clause | setX :: Vec2 -> Float -> Vec2
setX (Vec2 _ y') nx = Vec2 nx y' | 62 | setX :: Vec2 -> Float -> Vec2
setX (Vec2 _ y') nx = Vec2 nx y' | 62 | setX (Vec2 _ y') nx = Vec2 nx y' | 32 | false | true | 0 | 10 | 15 | 42 | 19 | 23 | null | null |
garetht/jsons-to-schema | test/JSONSchema/Draft4/ComplexTypeTests.hs | mit | testComplexObjectInArray :: Spec
testComplexObjectInArray =
it "can generate the schema for objects that are in arrays" $
let j1 =
[text| [
{"name": "Sir Lancelot of Camelot",
"quest": "to seek the Holy Grail",
"favorite colour": "blue"},
{"name": "Sir Robin of Camelot",
"quest": "to seek the Holy Grail",
"capitol of Assyria": null
}]
|]
expected =
[text| {
"type": "array",
"items": {
"type": "object",
"required": ["name", "quest"],
"properties": {
"quest": {"type": "string"},
"name": {"type": "string"},
"favorite colour": {"type": "string"},
"capitol of Assyria": {"type": "null"}
}
}
}
|]
in testJsonsToSchema [j1] expected | 1,255 | testComplexObjectInArray :: Spec
testComplexObjectInArray =
it "can generate the schema for objects that are in arrays" $
let j1 =
[text| [
{"name": "Sir Lancelot of Camelot",
"quest": "to seek the Holy Grail",
"favorite colour": "blue"},
{"name": "Sir Robin of Camelot",
"quest": "to seek the Holy Grail",
"capitol of Assyria": null
}]
|]
expected =
[text| {
"type": "array",
"items": {
"type": "object",
"required": ["name", "quest"],
"properties": {
"quest": {"type": "string"},
"name": {"type": "string"},
"favorite colour": {"type": "string"},
"capitol of Assyria": {"type": "null"}
}
}
}
|]
in testJsonsToSchema [j1] expected | 1,255 | testComplexObjectInArray =
it "can generate the schema for objects that are in arrays" $
let j1 =
[text| [
{"name": "Sir Lancelot of Camelot",
"quest": "to seek the Holy Grail",
"favorite colour": "blue"},
{"name": "Sir Robin of Camelot",
"quest": "to seek the Holy Grail",
"capitol of Assyria": null
}]
|]
expected =
[text| {
"type": "array",
"items": {
"type": "object",
"required": ["name", "quest"],
"properties": {
"quest": {"type": "string"},
"name": {"type": "string"},
"favorite colour": {"type": "string"},
"capitol of Assyria": {"type": "null"}
}
}
}
|]
in testJsonsToSchema [j1] expected | 1,222 | false | true | 0 | 9 | 714 | 58 | 30 | 28 | null | null |
Laar/OpenGLRawgen | src/Code/ModuleCode.hs | bsd-3-clause | funcPrags :: [ModulePragma]
funcPrags =
[ LanguagePragma noSrcLoc [Ident "CPP"]
, LanguagePragma noSrcLoc [Ident "ForeignFunctionInterface"]
] | 154 | funcPrags :: [ModulePragma]
funcPrags =
[ LanguagePragma noSrcLoc [Ident "CPP"]
, LanguagePragma noSrcLoc [Ident "ForeignFunctionInterface"]
] | 154 | funcPrags =
[ LanguagePragma noSrcLoc [Ident "CPP"]
, LanguagePragma noSrcLoc [Ident "ForeignFunctionInterface"]
] | 126 | false | true | 0 | 8 | 27 | 42 | 22 | 20 | null | null |
siddhanathan/yi | yi-keymap-vim/src/Yi/Keymap/Vim/Ex/Commands/Common.hs | gpl-2.0 | parseNormalLinePoint :: P.Parser (BufferM Point)
parseNormalLinePoint = do
ln <- read <$> P.many1 P.digit
return . savingPointB $ gotoLn ln >> pointB | 157 | parseNormalLinePoint :: P.Parser (BufferM Point)
parseNormalLinePoint = do
ln <- read <$> P.many1 P.digit
return . savingPointB $ gotoLn ln >> pointB | 157 | parseNormalLinePoint = do
ln <- read <$> P.many1 P.digit
return . savingPointB $ gotoLn ln >> pointB | 108 | false | true | 0 | 10 | 29 | 58 | 27 | 31 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.