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
frantisekfarka/ghc-dsi
compiler/codeGen/StgCmmUtils.hs
bsd-3-clause
------------------------------------------------------------------------- -- mkSwitch ------------------------------------------------------------------------- emitSwitch :: CmmExpr -- Tag to switch on -> [(ConTagZ, CmmAGraph)] -- Tagged branches -> Maybe CmmAGraph -- Default branch (if any) -> ConTagZ -> ConTagZ -- Min and Max possible values; behaviour -- outside this range is undefined -> FCode () emitSwitch tag_expr branches mb_deflt lo_tag hi_tag = do { dflags <- getDynFlags ; mkCmmSwitch (via_C dflags) tag_expr branches mb_deflt lo_tag hi_tag } where via_C dflags | HscC <- hscTarget dflags = True | otherwise = False
792
emitSwitch :: CmmExpr -- Tag to switch on -> [(ConTagZ, CmmAGraph)] -- Tagged branches -> Maybe CmmAGraph -- Default branch (if any) -> ConTagZ -> ConTagZ -- Min and Max possible values; behaviour -- outside this range is undefined -> FCode () emitSwitch tag_expr branches mb_deflt lo_tag hi_tag = do { dflags <- getDynFlags ; mkCmmSwitch (via_C dflags) tag_expr branches mb_deflt lo_tag hi_tag } where via_C dflags | HscC <- hscTarget dflags = True | otherwise = False
625
emitSwitch tag_expr branches mb_deflt lo_tag hi_tag = do { dflags <- getDynFlags ; mkCmmSwitch (via_C dflags) tag_expr branches mb_deflt lo_tag hi_tag } where via_C dflags | HscC <- hscTarget dflags = True | otherwise = False
274
true
true
0
12
244
137
69
68
null
null
foreverbell/fm-client
exe/Test.hs
bsd-3-clause
test :: IO () test = void $ do session <- initSession True player <- initPlayer [username, password] <- take 2 . lines <$> liftIO (readFile "passport") fm <- runSession session $ do login username (encryptPassword password) fetchFM mapM print fm lyrics <- runSession session $ fetchLyrics (fm !! 0) print lyrics
333
test :: IO () test = void $ do session <- initSession True player <- initPlayer [username, password] <- take 2 . lines <$> liftIO (readFile "passport") fm <- runSession session $ do login username (encryptPassword password) fetchFM mapM print fm lyrics <- runSession session $ fetchLyrics (fm !! 0) print lyrics
333
test = void $ do session <- initSession True player <- initPlayer [username, password] <- take 2 . lines <$> liftIO (readFile "passport") fm <- runSession session $ do login username (encryptPassword password) fetchFM mapM print fm lyrics <- runSession session $ fetchLyrics (fm !! 0) print lyrics
319
false
true
0
14
73
139
62
77
null
null
ademinn/JavaWithClasses
src/Checker.hs
bsd-3-clause
checkExpression (Expr (QN qn) line) = checkQualifiedName qn
59
checkExpression (Expr (QN qn) line) = checkQualifiedName qn
59
checkExpression (Expr (QN qn) line) = checkQualifiedName qn
59
false
false
0
9
7
26
12
14
null
null
keithodulaigh/Hets
EVT/ParseEVT.hs
gpl-2.0
evtBasicSpec :: PrefixMap -> AParser st MACHINE evtBasicSpec _ = do spaces -- pos1 <- getPos es <- many parseEVTEvents -- pos2 <- getPos return (MACHINE es)
250
evtBasicSpec :: PrefixMap -> AParser st MACHINE evtBasicSpec _ = do spaces -- pos1 <- getPos es <- many parseEVTEvents -- pos2 <- getPos return (MACHINE es)
250
evtBasicSpec _ = do spaces -- pos1 <- getPos es <- many parseEVTEvents -- pos2 <- getPos return (MACHINE es)
202
false
true
0
9
120
50
23
27
null
null
adinapoli/Shelly.hs
src/Shelly.hs
bsd-3-clause
lineSeqToText :: Seq Text -> Text -- extra append puts a newline at the end lineSeqToText = T.intercalate "\n" . toList . flip (|>) ""
134
lineSeqToText :: Seq Text -> Text lineSeqToText = T.intercalate "\n" . toList . flip (|>) ""
92
lineSeqToText = T.intercalate "\n" . toList . flip (|>) ""
58
true
true
0
8
24
39
20
19
null
null
UBMLtonGroup/timberc
src/Desugar2.hs
bsd-3-clause
dsDefault (Default t a b) = Default t a b
47
dsDefault (Default t a b) = Default t a b
47
dsDefault (Default t a b) = Default t a b
47
false
false
0
7
15
26
12
14
null
null
urbanslug/ghc
compiler/deSugar/Coverage.hs
bsd-3-clause
{- ************************************************************************ * * * initialisation * * ************************************************************************ Each module compiled with -fhpc declares an initialisation function of the form `hpc_init_<module>()`, which is emitted into the _stub.c file and annotated with __attribute__((constructor)) so that it gets executed at startup time. The function's purpose is to call hs_hpc_module to register this module with the RTS, and it looks something like this: static void hpc_init_Main(void) __attribute__((constructor)); static void hpc_init_Main(void) {extern StgWord64 _hpc_tickboxes_Main_hpc[]; hs_hpc_module("Main",8,1150288664,_hpc_tickboxes_Main_hpc);} -} hpcInitCode :: Module -> HpcInfo -> SDoc hpcInitCode _ (NoHpcInfo {}) = Outputable.empty
973
hpcInitCode :: Module -> HpcInfo -> SDoc hpcInitCode _ (NoHpcInfo {}) = Outputable.empty
88
hpcInitCode _ (NoHpcInfo {}) = Outputable.empty
47
true
true
0
7
241
34
18
16
null
null
tomahawkins/trs
Language/TRS/FeedbackArcSet.hs
bsd-3-clause
-- | Optimizes the vertice order by minimizing the -- number of soft edges removed to form an acyclic graph. optimize :: (Show a, Ord a) => Set.Set a -> Set.Set (Edge a) -> IO (Either (Set.Set a) ([a],String)) optimize vertices edges' = do putStr "Attempting to satisfy hard constraints..." hFlush stdout if not $ Set.null remaining then do putStrLn "failed" return $ Left remaining else do putStrLn "success" finalOrder <- annealing hardEdges softEdges initOrder return $ Right (finalOrder, doc finalOrder softEdges) where edges = Set.filter isNotLoopback edges' isNotLoopback (Hard a b) | a == b = False isNotLoopback (Soft a b) | a == b = False isNotLoopback _ = True hardVertices = Set.fold addHard Set.empty edges addHard (Hard a b) s = Set.insert a $ Set.insert b s addHard _ s = s softVertices = vertices Set.\\ hardVertices hardEdges = Set.map extractVertices $ Set.filter isHard edges softEdges = Set.filter isNotRelatedToHardEdge $ Set.map extractVertices $ Set.filter (not . isHard) edges isHard (Hard _ _) = True isHard (Soft _ _) = False extractVertices (Hard a b) = (a,b) extractVertices (Soft a b) = (a,b) isNotRelatedToHardEdge (a,b) = not $ Set.member (a,b) hardEdges || Set.member (b,a) hardEdges hardRoots = Set.fold removeHard hardVertices hardEdges removeHard (_, a) s = Set.delete a s hardUpstreams v = Set.map fst $ Set.filter (\ (_,b) -> v == b) hardEdges --XXX Make a Map to improve performance. (remaining, _, hardOrder) = topo (hardVertices Set.\\ hardRoots, hardRoots, [hardRoots]) topo (remaining, computed, order) = if Set.null next then (remaining, computed, reverse order) else topo (remaining Set.\\ next, Set.union computed next, next : order) where next = Set.filter (\ v -> Set.isSubsetOf (hardUpstreams v) computed) remaining initOrder = concatMap Set.toList hardOrder ++ Set.toList softVertices -- XXX
1,964
optimize :: (Show a, Ord a) => Set.Set a -> Set.Set (Edge a) -> IO (Either (Set.Set a) ([a],String)) optimize vertices edges' = do putStr "Attempting to satisfy hard constraints..." hFlush stdout if not $ Set.null remaining then do putStrLn "failed" return $ Left remaining else do putStrLn "success" finalOrder <- annealing hardEdges softEdges initOrder return $ Right (finalOrder, doc finalOrder softEdges) where edges = Set.filter isNotLoopback edges' isNotLoopback (Hard a b) | a == b = False isNotLoopback (Soft a b) | a == b = False isNotLoopback _ = True hardVertices = Set.fold addHard Set.empty edges addHard (Hard a b) s = Set.insert a $ Set.insert b s addHard _ s = s softVertices = vertices Set.\\ hardVertices hardEdges = Set.map extractVertices $ Set.filter isHard edges softEdges = Set.filter isNotRelatedToHardEdge $ Set.map extractVertices $ Set.filter (not . isHard) edges isHard (Hard _ _) = True isHard (Soft _ _) = False extractVertices (Hard a b) = (a,b) extractVertices (Soft a b) = (a,b) isNotRelatedToHardEdge (a,b) = not $ Set.member (a,b) hardEdges || Set.member (b,a) hardEdges hardRoots = Set.fold removeHard hardVertices hardEdges removeHard (_, a) s = Set.delete a s hardUpstreams v = Set.map fst $ Set.filter (\ (_,b) -> v == b) hardEdges --XXX Make a Map to improve performance. (remaining, _, hardOrder) = topo (hardVertices Set.\\ hardRoots, hardRoots, [hardRoots]) topo (remaining, computed, order) = if Set.null next then (remaining, computed, reverse order) else topo (remaining Set.\\ next, Set.union computed next, next : order) where next = Set.filter (\ v -> Set.isSubsetOf (hardUpstreams v) computed) remaining initOrder = concatMap Set.toList hardOrder ++ Set.toList softVertices -- XXX
1,853
optimize vertices edges' = do putStr "Attempting to satisfy hard constraints..." hFlush stdout if not $ Set.null remaining then do putStrLn "failed" return $ Left remaining else do putStrLn "success" finalOrder <- annealing hardEdges softEdges initOrder return $ Right (finalOrder, doc finalOrder softEdges) where edges = Set.filter isNotLoopback edges' isNotLoopback (Hard a b) | a == b = False isNotLoopback (Soft a b) | a == b = False isNotLoopback _ = True hardVertices = Set.fold addHard Set.empty edges addHard (Hard a b) s = Set.insert a $ Set.insert b s addHard _ s = s softVertices = vertices Set.\\ hardVertices hardEdges = Set.map extractVertices $ Set.filter isHard edges softEdges = Set.filter isNotRelatedToHardEdge $ Set.map extractVertices $ Set.filter (not . isHard) edges isHard (Hard _ _) = True isHard (Soft _ _) = False extractVertices (Hard a b) = (a,b) extractVertices (Soft a b) = (a,b) isNotRelatedToHardEdge (a,b) = not $ Set.member (a,b) hardEdges || Set.member (b,a) hardEdges hardRoots = Set.fold removeHard hardVertices hardEdges removeHard (_, a) s = Set.delete a s hardUpstreams v = Set.map fst $ Set.filter (\ (_,b) -> v == b) hardEdges --XXX Make a Map to improve performance. (remaining, _, hardOrder) = topo (hardVertices Set.\\ hardRoots, hardRoots, [hardRoots]) topo (remaining, computed, order) = if Set.null next then (remaining, computed, reverse order) else topo (remaining Set.\\ next, Set.union computed next, next : order) where next = Set.filter (\ v -> Set.isSubsetOf (hardUpstreams v) computed) remaining initOrder = concatMap Set.toList hardOrder ++ Set.toList softVertices -- XXX
1,752
true
true
0
13
412
747
377
370
null
null
coghex/abridgefaraway
src/ABFA/Shell.hs
bsd-3-clause
-- executes a string in the lua state execShell :: Lua.State -> String -> IO (String) execShell ls str = do Lua.runWith ls $ Lua.openlibs error <- Lua.runWith ls $ Lua.loadstring $ BL.pack str res <- Lua.runWith ls $ Lua.pcall 0 1 Nothing ret <- Lua.runWith ls $ Lua.tostring' $ Lua.nthFromBottom (-1) Lua.runWith ls $ Lua.pop $ Lua.nthFromBottom (-1) return $ (show error) ++ ": " ++ (BL.unpack ret) -- draws a shell
431
execShell :: Lua.State -> String -> IO (String) execShell ls str = do Lua.runWith ls $ Lua.openlibs error <- Lua.runWith ls $ Lua.loadstring $ BL.pack str res <- Lua.runWith ls $ Lua.pcall 0 1 Nothing ret <- Lua.runWith ls $ Lua.tostring' $ Lua.nthFromBottom (-1) Lua.runWith ls $ Lua.pop $ Lua.nthFromBottom (-1) return $ (show error) ++ ": " ++ (BL.unpack ret) -- draws a shell
393
execShell ls str = do Lua.runWith ls $ Lua.openlibs error <- Lua.runWith ls $ Lua.loadstring $ BL.pack str res <- Lua.runWith ls $ Lua.pcall 0 1 Nothing ret <- Lua.runWith ls $ Lua.tostring' $ Lua.nthFromBottom (-1) Lua.runWith ls $ Lua.pop $ Lua.nthFromBottom (-1) return $ (show error) ++ ": " ++ (BL.unpack ret) -- draws a shell
345
true
true
0
11
86
189
89
100
null
null
zachsully/hakaru
haskell/Tests/Disintegrate.hs
bsd-3-clause
testDisintegrate1a, testDisintegrate1b, testDisintegrate1c :: [Cond 'HReal HUnit] testDisintegrate1a = disintegrate norm1a
126
testDisintegrate1a, testDisintegrate1b, testDisintegrate1c :: [Cond 'HReal HUnit] testDisintegrate1a = disintegrate norm1a
126
testDisintegrate1a = disintegrate norm1a
40
false
true
3
7
14
35
16
19
null
null
dysinger/amazonka
amazonka-s3/gen/Network/AWS/S3/Types.hs
mpl-2.0
-- | Screen name of the grantee. gDisplayName :: Lens' Grantee (Maybe Text) gDisplayName = lens _gDisplayName (\s a -> s { _gDisplayName = a })
143
gDisplayName :: Lens' Grantee (Maybe Text) gDisplayName = lens _gDisplayName (\s a -> s { _gDisplayName = a })
110
gDisplayName = lens _gDisplayName (\s a -> s { _gDisplayName = a })
67
true
true
1
9
25
51
25
26
null
null
cullina/Extractor
src/Delannoy.hs
bsd-3-clause
pointToPath = unfoldr pTP . unradius where pTP (0, []) = Nothing pTP (0, x:xs) = if x >= 0 then Just (Vertical, (x, xs)) else Just (Diagonal, (-x - 1, xs)) pTP (x, xs) = Just (Horizontal, (x - 1, xs)) unradius (xs, bound) = (bound - sum (map abs xs), xs)
332
pointToPath = unfoldr pTP . unradius where pTP (0, []) = Nothing pTP (0, x:xs) = if x >= 0 then Just (Vertical, (x, xs)) else Just (Diagonal, (-x - 1, xs)) pTP (x, xs) = Just (Horizontal, (x - 1, xs)) unradius (xs, bound) = (bound - sum (map abs xs), xs)
332
pointToPath = unfoldr pTP . unradius where pTP (0, []) = Nothing pTP (0, x:xs) = if x >= 0 then Just (Vertical, (x, xs)) else Just (Diagonal, (-x - 1, xs)) pTP (x, xs) = Just (Horizontal, (x - 1, xs)) unradius (xs, bound) = (bound - sum (map abs xs), xs)
332
false
false
3
12
130
165
92
73
null
null
jbracker/supermonad-plugin
examples/monad/hmtc/monad-param/TypeChecker.hs
bsd-3-clause
sinks_nonreftype (Src t) e = sinks_nonreftype t (deref e)
62
sinks_nonreftype (Src t) e = sinks_nonreftype t (deref e)
62
sinks_nonreftype (Src t) e = sinks_nonreftype t (deref e)
62
false
false
0
7
13
28
13
15
null
null
google/codeworld
codeworld-api/src/CodeWorld/DrawState.hs
apache-2.0
mapDSColor :: (Maybe Color -> Maybe Color) -> DrawState -> DrawState mapDSColor f (DrawState at mc) = DrawState at (f mc)
121
mapDSColor :: (Maybe Color -> Maybe Color) -> DrawState -> DrawState mapDSColor f (DrawState at mc) = DrawState at (f mc)
121
mapDSColor f (DrawState at mc) = DrawState at (f mc)
52
false
true
0
8
20
61
28
33
null
null
sseefried/shady-graphics
src/Shady/ParamSurf.hs
agpl-3.0
sinU = sin . (* pi)
19
sinU = sin . (* pi)
19
sinU = sin . (* pi)
19
false
false
0
6
5
14
8
6
null
null
dmp1ce/Haskell-Programming-Exercises
Chapter 8/WordNumber.hs
unlicense
digitToWord 9 = "nine"
22
digitToWord 9 = "nine"
22
digitToWord 9 = "nine"
22
false
false
0
5
3
9
4
5
null
null
vincenthz/cryptonite
tests/Utils.hs
bsd-3-clause
chunksL :: ChunkingLen -> L.ByteString -> L.ByteString chunksL (ChunkingLen originalChunks) = L.fromChunks . loop originalChunks . L.toChunks where loop _ [] = [] loop l (b:bs) | B.null b = loop l bs | otherwise = case l of (x:xs) -> let (b1, b2) = B.splitAt x b in b1 : loop xs (b2:bs) [] -> loop originalChunks (b:bs)
420
chunksL :: ChunkingLen -> L.ByteString -> L.ByteString chunksL (ChunkingLen originalChunks) = L.fromChunks . loop originalChunks . L.toChunks where loop _ [] = [] loop l (b:bs) | B.null b = loop l bs | otherwise = case l of (x:xs) -> let (b1, b2) = B.splitAt x b in b1 : loop xs (b2:bs) [] -> loop originalChunks (b:bs)
420
chunksL (ChunkingLen originalChunks) = L.fromChunks . loop originalChunks . L.toChunks where loop _ [] = [] loop l (b:bs) | B.null b = loop l bs | otherwise = case l of (x:xs) -> let (b1, b2) = B.splitAt x b in b1 : loop xs (b2:bs) [] -> loop originalChunks (b:bs)
365
false
true
4
14
159
179
89
90
null
null
olorin/amazonka
amazonka-rds/gen/Network/AWS/RDS/Types/Product.hs
mpl-2.0
-- | This value is currently \"read replication.\" disiStatusType :: Lens' DBInstanceStatusInfo (Maybe Text) disiStatusType = lens _disiStatusType (\ s a -> s{_disiStatusType = a})
180
disiStatusType :: Lens' DBInstanceStatusInfo (Maybe Text) disiStatusType = lens _disiStatusType (\ s a -> s{_disiStatusType = a})
129
disiStatusType = lens _disiStatusType (\ s a -> s{_disiStatusType = a})
71
true
true
0
9
24
46
25
21
null
null
qpliu/esolang
01_/hs/compiler/Parser3.hs
gpl-3.0
parseParams :: GenParser Param1 () ([Param],[String]) parseParams = do (params,names) <- parseParamList ([],[]) return (reverse params,reverse names)
157
parseParams :: GenParser Param1 () ([Param],[String]) parseParams = do (params,names) <- parseParamList ([],[]) return (reverse params,reverse names)
157
parseParams = do (params,names) <- parseParamList ([],[]) return (reverse params,reverse names)
103
false
true
0
10
24
76
40
36
null
null
svaiter/fay-canvas
src/HtmlCanvas.hs
bsd-3-clause
closePath :: Context -> Fay () closePath = ffi "%1['closePath']()"
66
closePath :: Context -> Fay () closePath = ffi "%1['closePath']()"
66
closePath = ffi "%1['closePath']()"
35
false
true
0
7
9
23
11
12
null
null
MichaelBurge/ToxicSludgeDB
Tests/Database/Toxic/Query/Interpreter.hs
mit
test_case_when_when :: Assertion test_case_when_when = let condition1 = (ELiteral $ LBool False, ELiteral $ LBool True) condition2 =(ELiteral $ LBool True, ELiteral $ LBool False) otherwise = Just $ ELiteral $ LBool True expression = ECase (V.fromList [condition1,condition2]) otherwise statement = singleton_query expression expectedColumn = Column { columnName = "case", columnType = TBool } expectedStream = singleton_stream expectedColumn $ VBool False in do actualStream <- evaluateQuery nullEnvironment statement assertEqual "Case when when else" expectedStream actualStream
654
test_case_when_when :: Assertion test_case_when_when = let condition1 = (ELiteral $ LBool False, ELiteral $ LBool True) condition2 =(ELiteral $ LBool True, ELiteral $ LBool False) otherwise = Just $ ELiteral $ LBool True expression = ECase (V.fromList [condition1,condition2]) otherwise statement = singleton_query expression expectedColumn = Column { columnName = "case", columnType = TBool } expectedStream = singleton_stream expectedColumn $ VBool False in do actualStream <- evaluateQuery nullEnvironment statement assertEqual "Case when when else" expectedStream actualStream
654
test_case_when_when = let condition1 = (ELiteral $ LBool False, ELiteral $ LBool True) condition2 =(ELiteral $ LBool True, ELiteral $ LBool False) otherwise = Just $ ELiteral $ LBool True expression = ECase (V.fromList [condition1,condition2]) otherwise statement = singleton_query expression expectedColumn = Column { columnName = "case", columnType = TBool } expectedStream = singleton_stream expectedColumn $ VBool False in do actualStream <- evaluateQuery nullEnvironment statement assertEqual "Case when when else" expectedStream actualStream
621
false
true
0
12
148
171
87
84
null
null
cdepillabout/subhask
src/SubHask/Algebra/Parallel.hs
bsd-3-clause
law_Partitionable_monoid :: (ClassicalLogic t, Eq_ t, Partitionable t) => Int -> t -> Bool law_Partitionable_monoid n t | n > 0 = sum (partition n t) == t | otherwise = True
181
law_Partitionable_monoid :: (ClassicalLogic t, Eq_ t, Partitionable t) => Int -> t -> Bool law_Partitionable_monoid n t | n > 0 = sum (partition n t) == t | otherwise = True
181
law_Partitionable_monoid n t | n > 0 = sum (partition n t) == t | otherwise = True
90
false
true
0
8
39
86
40
46
null
null
vTurbine/ghc
compiler/utils/FastString.hs
bsd-3-clause
copyNewFastString :: Ptr Word8 -> Int -> Int -> IO FastString copyNewFastString ptr len uid = do fp <- copyBytesToForeignPtr ptr len ref <- newIORef Nothing n_chars <- countUTF8Chars ptr len return (FastString uid n_chars (BS.fromForeignPtr fp 0 len) ref)
263
copyNewFastString :: Ptr Word8 -> Int -> Int -> IO FastString copyNewFastString ptr len uid = do fp <- copyBytesToForeignPtr ptr len ref <- newIORef Nothing n_chars <- countUTF8Chars ptr len return (FastString uid n_chars (BS.fromForeignPtr fp 0 len) ref)
263
copyNewFastString ptr len uid = do fp <- copyBytesToForeignPtr ptr len ref <- newIORef Nothing n_chars <- countUTF8Chars ptr len return (FastString uid n_chars (BS.fromForeignPtr fp 0 len) ref)
201
false
true
0
12
47
100
45
55
null
null
triplepointfive/hogldev
tutorial22/Tutorial22.hs
mit
windowWidth = 1024
18
windowWidth = 1024
18
windowWidth = 1024
18
false
false
1
5
2
10
3
7
null
null
nastya13/fold-foldr
dist/build/autogen/Paths_fold_foldr.hs
gpl-3.0
getLibexecDir = catchIO (getEnv "fold_foldr_libexecdir") (\_ -> return libexecdir)
82
getLibexecDir = catchIO (getEnv "fold_foldr_libexecdir") (\_ -> return libexecdir)
82
getLibexecDir = catchIO (getEnv "fold_foldr_libexecdir") (\_ -> return libexecdir)
82
false
false
0
8
8
28
14
14
null
null
ambiata/mafia
test/Test/IO/Mafia/Chaos.hs
bsd-3-clause
submoduleNames :: Set SubmoduleName submoduleNames = Set.fromList (T.replace " " "-" <$> muppets)
97
submoduleNames :: Set SubmoduleName submoduleNames = Set.fromList (T.replace " " "-" <$> muppets)
97
submoduleNames = Set.fromList (T.replace " " "-" <$> muppets)
61
false
true
0
9
12
33
16
17
null
null
text-utf8/text
Data/Text/Internal/Fusion/Size.hs
bsd-2-clause
-- | Maximum of two size hints. larger :: Size -> Size -> Size larger a@(Between ma mb) b@(Between na nb) | ma >= nb = a | na >= mb = b | otherwise = Between (ma `max` na) (mb `max` nb)
199
larger :: Size -> Size -> Size larger a@(Between ma mb) b@(Between na nb) | ma >= nb = a | na >= mb = b | otherwise = Between (ma `max` na) (mb `max` nb)
167
larger a@(Between ma mb) b@(Between na nb) | ma >= nb = a | na >= mb = b | otherwise = Between (ma `max` na) (mb `max` nb)
136
true
true
0
8
56
102
53
49
null
null
bgold-cosmos/Tidal
test/Sound/Tidal/ScalesTest.hs
gpl-3.0
run :: Microspec () run = describe "Sound.Tidal.Scales" $ do describe "scale" $ do describe "5 note scales" $ do let twoOctavesOf5NoteScale = "0 1 2 3 4 5 6 7 8 9" it "can transform notes correctly over 2 octaves - minPent" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minPent" twoOctavesOf5NoteScale) ("0 3 5 7 10 12 15 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - majPent" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "majPent" twoOctavesOf5NoteScale) ("0 2 4 7 9 12 14 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - ritusen" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ritusen" twoOctavesOf5NoteScale) ("0 2 5 7 9 12 14 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - egyptian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "egyptian" twoOctavesOf5NoteScale) ("0 2 5 7 10 12 14 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - kumai" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "kumai" twoOctavesOf5NoteScale) ("0 2 3 7 9 12 14 15 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hirajoshi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hirajoshi" twoOctavesOf5NoteScale) ("0 2 3 7 8 12 14 15 19 20"::Pattern Rational) it "can transform notes correctly over 2 octaves - iwato" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "iwato" twoOctavesOf5NoteScale) ("0 1 5 6 10 12 13 17 18 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - chinese" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "chinese" twoOctavesOf5NoteScale) ("0 4 6 7 11 12 16 18 19 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - indian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "indian" twoOctavesOf5NoteScale) ("0 4 5 7 10 12 16 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - pelog" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "pelog" twoOctavesOf5NoteScale) ("0 1 3 7 8 12 13 15 19 20"::Pattern Rational) it "can transform notes correctly over 2 octaves - prometheus" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "prometheus" twoOctavesOf5NoteScale) ("0 2 4 6 11 12 14 16 18 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - scriabin" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "scriabin" twoOctavesOf5NoteScale) ("0 1 4 7 9 12 13 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - gong" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "gong" twoOctavesOf5NoteScale) ("0 2 4 7 9 12 14 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - shang" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "shang" twoOctavesOf5NoteScale) ("0 2 5 7 10 12 14 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - jiao" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "jiao" twoOctavesOf5NoteScale) ("0 3 5 8 10 12 15 17 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - zhi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "zhi" twoOctavesOf5NoteScale) ("0 2 5 7 9 12 14 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - yu" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "yu" twoOctavesOf5NoteScale) ("0 3 5 7 10 12 15 17 19 22"::Pattern Rational) describe "6 note scales" $ do let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11" it "can transform notes correctly over 2 octaves - whole" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale) ("0 2 4 6 8 10 12 14 16 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - wholetone" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale) (Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale :: Pattern Rational) it "can transform notes correctly over 2 octaves - augmented" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "augmented" twoOctavesOf6NoteScale) ("0 3 4 7 8 11 12 15 16 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - augmented2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "augmented2" twoOctavesOf6NoteScale) ("0 1 4 5 8 9 12 13 16 17 20 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexMajor7" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexMajor7" twoOctavesOf6NoteScale) ("0 2 4 7 9 11 12 14 16 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexPhrygian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexPhrygian" twoOctavesOf6NoteScale) ("0 1 3 5 8 10 12 13 15 17 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexDorian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexDorian" twoOctavesOf6NoteScale) ("0 2 3 5 7 10 12 14 15 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexSus" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexSus" twoOctavesOf6NoteScale) ("0 2 5 7 9 10 12 14 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexMajor6" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexMajor6" twoOctavesOf6NoteScale) ("0 2 4 5 7 9 12 14 16 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexAeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexAeolian" twoOctavesOf6NoteScale) ("0 3 5 7 8 10 12 15 17 19 20 22"::Pattern Rational) describe "7 note scales" $ do let twoOctavesOf7NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13" it "can transform notes correctly over 2 octaves - major" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale) ("0 2 4 5 7 9 11 12 14 16 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - ionian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ionian" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale :: Pattern Rational) it "can transform notes correctly over 2 octaves - dorian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "dorian" twoOctavesOf7NoteScale) ("0 2 3 5 7 9 10 12 14 15 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - aeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale) ("0 2 3 5 7 8 10 12 14 15 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - aeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - minor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - locrian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "locrian" twoOctavesOf7NoteScale) ("0 1 3 5 6 8 10 12 13 15 17 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - harmonicMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "harmonicMinor" twoOctavesOf7NoteScale) ("0 2 3 5 7 8 11 12 14 15 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - harmonicMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "harmonicMajor" twoOctavesOf7NoteScale) ("0 2 4 5 7 8 11 12 14 16 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMinor" twoOctavesOf7NoteScale) ("0 2 3 5 7 9 11 12 14 15 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMinorDesc" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMinorDesc" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale) ("0 2 4 5 7 8 10 12 14 16 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - bartok" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "bartok" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - hindu" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hindu" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - todi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "todi" twoOctavesOf7NoteScale) ("0 1 3 6 7 8 11 12 13 15 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - purvi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "purvi" twoOctavesOf7NoteScale) ("0 1 4 6 7 8 11 12 13 16 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - marva" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "marva" twoOctavesOf7NoteScale) ("0 1 4 6 7 9 11 12 13 16 18 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - bhairav" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "bhairav" twoOctavesOf7NoteScale) ("0 1 4 5 7 8 11 12 13 16 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - ahirbhairav" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ahirbhairav" twoOctavesOf7NoteScale) ("0 1 4 5 7 9 10 12 13 16 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - superLocrian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "superLocrian" twoOctavesOf7NoteScale) ("0 1 3 4 6 8 10 12 13 15 16 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - romanianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "romanianMinor" twoOctavesOf7NoteScale) ("0 2 3 6 7 9 10 12 14 15 18 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hungarianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hungarianMinor" twoOctavesOf7NoteScale) ("0 2 3 6 7 8 11 12 14 15 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - neapolitanMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "neapolitanMinor" twoOctavesOf7NoteScale) ("0 1 3 5 7 8 11 12 13 15 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - enigmatic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "enigmatic" twoOctavesOf7NoteScale) ("0 1 4 6 8 10 11 12 13 16 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - spanish" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "spanish" twoOctavesOf7NoteScale) ("0 1 4 5 7 8 10 12 13 16 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - leadingWhole" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "leadingWhole" twoOctavesOf7NoteScale) ("0 2 4 6 8 10 11 12 14 16 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - lydianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "lydianMinor" twoOctavesOf7NoteScale) ("0 2 4 6 7 8 10 12 14 16 18 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - neapolitanMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "neapolitanMajor" twoOctavesOf7NoteScale) ("0 1 3 5 7 9 11 12 13 15 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - locrianMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "locrianMajor" twoOctavesOf7NoteScale) ("0 2 4 5 6 8 10 12 14 16 17 18 20 22"::Pattern Rational) describe "8 note scales" $ do let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" it "can transform notes correctly over 2 octaves - diminished" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale) ("0 1 3 4 6 7 9 10 12 13 15 16 18 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - octatonic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "octatonic" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - diminished2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale) ("0 2 3 5 6 8 9 11 12 14 15 17 18 20 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - octatonic2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "octatonic2" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale::Pattern Rational) describe "modes of limited transposition" $ do let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11" let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" let twoOctavesOf9NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17" let twoOctavesOf10NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19" it "can transform notes correctly over 2 octaves - messiaen1" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen1" twoOctavesOf6NoteScale) (Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen2" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen3" $ do -- tone, semitone, semitone, tone, semitone, semitone, tone, semitone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen3" twoOctavesOf9NoteScale) ("0 2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen4" $ do -- semitone, semitone, minor third, semitone, semitone, semitone, minor third, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen4" twoOctavesOf8NoteScale) ("0 1 2 5 6 7 8 11 12 13 14 17 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen5" $ do -- semitone, major third, semitone, semitone, major third, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen5" twoOctavesOf6NoteScale) ("0 1 5 6 7 11 12 13 17 18 19 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen6" $ do -- tone, tone, semitone, semitone, tone, tone, semitone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen6" twoOctavesOf8NoteScale) ("0 2 4 5 6 8 10 11 12 14 16 17 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen7" $ do -- semitone, semitone, semitone, tone, semitone, semitone, semitone, semitone, tone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen7" twoOctavesOf10NoteScale) ("0 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18 19 20 21 23"::Pattern Rational) describe "12 note scales" $ do let twoOctavesOf12NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" it "can transform notes correctly over 2 octaves - chromatic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "chromatic" twoOctavesOf12NoteScale) ("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"::Pattern Rational) describe "edge cases" $ do it "responds to unknown scales by mapping to octaves" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ergaerv" "0 1 2 3 4") ("0 12 24 36 48"::Pattern Rational) it "correctly maps negative numbers" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "major" "0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13") ("0 -1 -3 -5 -7 -8 -10 -12 -13 -15 -17 -19 -20 -22 "::Pattern Rational)
20,723
run :: Microspec () run = describe "Sound.Tidal.Scales" $ do describe "scale" $ do describe "5 note scales" $ do let twoOctavesOf5NoteScale = "0 1 2 3 4 5 6 7 8 9" it "can transform notes correctly over 2 octaves - minPent" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minPent" twoOctavesOf5NoteScale) ("0 3 5 7 10 12 15 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - majPent" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "majPent" twoOctavesOf5NoteScale) ("0 2 4 7 9 12 14 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - ritusen" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ritusen" twoOctavesOf5NoteScale) ("0 2 5 7 9 12 14 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - egyptian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "egyptian" twoOctavesOf5NoteScale) ("0 2 5 7 10 12 14 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - kumai" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "kumai" twoOctavesOf5NoteScale) ("0 2 3 7 9 12 14 15 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hirajoshi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hirajoshi" twoOctavesOf5NoteScale) ("0 2 3 7 8 12 14 15 19 20"::Pattern Rational) it "can transform notes correctly over 2 octaves - iwato" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "iwato" twoOctavesOf5NoteScale) ("0 1 5 6 10 12 13 17 18 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - chinese" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "chinese" twoOctavesOf5NoteScale) ("0 4 6 7 11 12 16 18 19 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - indian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "indian" twoOctavesOf5NoteScale) ("0 4 5 7 10 12 16 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - pelog" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "pelog" twoOctavesOf5NoteScale) ("0 1 3 7 8 12 13 15 19 20"::Pattern Rational) it "can transform notes correctly over 2 octaves - prometheus" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "prometheus" twoOctavesOf5NoteScale) ("0 2 4 6 11 12 14 16 18 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - scriabin" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "scriabin" twoOctavesOf5NoteScale) ("0 1 4 7 9 12 13 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - gong" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "gong" twoOctavesOf5NoteScale) ("0 2 4 7 9 12 14 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - shang" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "shang" twoOctavesOf5NoteScale) ("0 2 5 7 10 12 14 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - jiao" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "jiao" twoOctavesOf5NoteScale) ("0 3 5 8 10 12 15 17 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - zhi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "zhi" twoOctavesOf5NoteScale) ("0 2 5 7 9 12 14 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - yu" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "yu" twoOctavesOf5NoteScale) ("0 3 5 7 10 12 15 17 19 22"::Pattern Rational) describe "6 note scales" $ do let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11" it "can transform notes correctly over 2 octaves - whole" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale) ("0 2 4 6 8 10 12 14 16 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - wholetone" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale) (Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale :: Pattern Rational) it "can transform notes correctly over 2 octaves - augmented" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "augmented" twoOctavesOf6NoteScale) ("0 3 4 7 8 11 12 15 16 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - augmented2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "augmented2" twoOctavesOf6NoteScale) ("0 1 4 5 8 9 12 13 16 17 20 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexMajor7" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexMajor7" twoOctavesOf6NoteScale) ("0 2 4 7 9 11 12 14 16 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexPhrygian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexPhrygian" twoOctavesOf6NoteScale) ("0 1 3 5 8 10 12 13 15 17 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexDorian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexDorian" twoOctavesOf6NoteScale) ("0 2 3 5 7 10 12 14 15 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexSus" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexSus" twoOctavesOf6NoteScale) ("0 2 5 7 9 10 12 14 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexMajor6" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexMajor6" twoOctavesOf6NoteScale) ("0 2 4 5 7 9 12 14 16 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexAeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexAeolian" twoOctavesOf6NoteScale) ("0 3 5 7 8 10 12 15 17 19 20 22"::Pattern Rational) describe "7 note scales" $ do let twoOctavesOf7NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13" it "can transform notes correctly over 2 octaves - major" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale) ("0 2 4 5 7 9 11 12 14 16 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - ionian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ionian" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale :: Pattern Rational) it "can transform notes correctly over 2 octaves - dorian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "dorian" twoOctavesOf7NoteScale) ("0 2 3 5 7 9 10 12 14 15 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - aeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale) ("0 2 3 5 7 8 10 12 14 15 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - aeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - minor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - locrian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "locrian" twoOctavesOf7NoteScale) ("0 1 3 5 6 8 10 12 13 15 17 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - harmonicMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "harmonicMinor" twoOctavesOf7NoteScale) ("0 2 3 5 7 8 11 12 14 15 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - harmonicMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "harmonicMajor" twoOctavesOf7NoteScale) ("0 2 4 5 7 8 11 12 14 16 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMinor" twoOctavesOf7NoteScale) ("0 2 3 5 7 9 11 12 14 15 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMinorDesc" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMinorDesc" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale) ("0 2 4 5 7 8 10 12 14 16 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - bartok" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "bartok" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - hindu" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hindu" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - todi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "todi" twoOctavesOf7NoteScale) ("0 1 3 6 7 8 11 12 13 15 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - purvi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "purvi" twoOctavesOf7NoteScale) ("0 1 4 6 7 8 11 12 13 16 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - marva" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "marva" twoOctavesOf7NoteScale) ("0 1 4 6 7 9 11 12 13 16 18 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - bhairav" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "bhairav" twoOctavesOf7NoteScale) ("0 1 4 5 7 8 11 12 13 16 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - ahirbhairav" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ahirbhairav" twoOctavesOf7NoteScale) ("0 1 4 5 7 9 10 12 13 16 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - superLocrian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "superLocrian" twoOctavesOf7NoteScale) ("0 1 3 4 6 8 10 12 13 15 16 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - romanianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "romanianMinor" twoOctavesOf7NoteScale) ("0 2 3 6 7 9 10 12 14 15 18 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hungarianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hungarianMinor" twoOctavesOf7NoteScale) ("0 2 3 6 7 8 11 12 14 15 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - neapolitanMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "neapolitanMinor" twoOctavesOf7NoteScale) ("0 1 3 5 7 8 11 12 13 15 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - enigmatic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "enigmatic" twoOctavesOf7NoteScale) ("0 1 4 6 8 10 11 12 13 16 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - spanish" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "spanish" twoOctavesOf7NoteScale) ("0 1 4 5 7 8 10 12 13 16 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - leadingWhole" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "leadingWhole" twoOctavesOf7NoteScale) ("0 2 4 6 8 10 11 12 14 16 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - lydianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "lydianMinor" twoOctavesOf7NoteScale) ("0 2 4 6 7 8 10 12 14 16 18 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - neapolitanMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "neapolitanMajor" twoOctavesOf7NoteScale) ("0 1 3 5 7 9 11 12 13 15 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - locrianMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "locrianMajor" twoOctavesOf7NoteScale) ("0 2 4 5 6 8 10 12 14 16 17 18 20 22"::Pattern Rational) describe "8 note scales" $ do let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" it "can transform notes correctly over 2 octaves - diminished" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale) ("0 1 3 4 6 7 9 10 12 13 15 16 18 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - octatonic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "octatonic" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - diminished2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale) ("0 2 3 5 6 8 9 11 12 14 15 17 18 20 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - octatonic2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "octatonic2" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale::Pattern Rational) describe "modes of limited transposition" $ do let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11" let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" let twoOctavesOf9NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17" let twoOctavesOf10NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19" it "can transform notes correctly over 2 octaves - messiaen1" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen1" twoOctavesOf6NoteScale) (Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen2" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen3" $ do -- tone, semitone, semitone, tone, semitone, semitone, tone, semitone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen3" twoOctavesOf9NoteScale) ("0 2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen4" $ do -- semitone, semitone, minor third, semitone, semitone, semitone, minor third, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen4" twoOctavesOf8NoteScale) ("0 1 2 5 6 7 8 11 12 13 14 17 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen5" $ do -- semitone, major third, semitone, semitone, major third, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen5" twoOctavesOf6NoteScale) ("0 1 5 6 7 11 12 13 17 18 19 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen6" $ do -- tone, tone, semitone, semitone, tone, tone, semitone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen6" twoOctavesOf8NoteScale) ("0 2 4 5 6 8 10 11 12 14 16 17 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen7" $ do -- semitone, semitone, semitone, tone, semitone, semitone, semitone, semitone, tone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen7" twoOctavesOf10NoteScale) ("0 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18 19 20 21 23"::Pattern Rational) describe "12 note scales" $ do let twoOctavesOf12NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" it "can transform notes correctly over 2 octaves - chromatic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "chromatic" twoOctavesOf12NoteScale) ("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"::Pattern Rational) describe "edge cases" $ do it "responds to unknown scales by mapping to octaves" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ergaerv" "0 1 2 3 4") ("0 12 24 36 48"::Pattern Rational) it "correctly maps negative numbers" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "major" "0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13") ("0 -1 -3 -5 -7 -8 -10 -12 -13 -15 -17 -19 -20 -22 "::Pattern Rational)
20,723
run = describe "Sound.Tidal.Scales" $ do describe "scale" $ do describe "5 note scales" $ do let twoOctavesOf5NoteScale = "0 1 2 3 4 5 6 7 8 9" it "can transform notes correctly over 2 octaves - minPent" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minPent" twoOctavesOf5NoteScale) ("0 3 5 7 10 12 15 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - majPent" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "majPent" twoOctavesOf5NoteScale) ("0 2 4 7 9 12 14 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - ritusen" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ritusen" twoOctavesOf5NoteScale) ("0 2 5 7 9 12 14 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - egyptian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "egyptian" twoOctavesOf5NoteScale) ("0 2 5 7 10 12 14 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - kumai" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "kumai" twoOctavesOf5NoteScale) ("0 2 3 7 9 12 14 15 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hirajoshi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hirajoshi" twoOctavesOf5NoteScale) ("0 2 3 7 8 12 14 15 19 20"::Pattern Rational) it "can transform notes correctly over 2 octaves - iwato" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "iwato" twoOctavesOf5NoteScale) ("0 1 5 6 10 12 13 17 18 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - chinese" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "chinese" twoOctavesOf5NoteScale) ("0 4 6 7 11 12 16 18 19 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - indian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "indian" twoOctavesOf5NoteScale) ("0 4 5 7 10 12 16 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - pelog" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "pelog" twoOctavesOf5NoteScale) ("0 1 3 7 8 12 13 15 19 20"::Pattern Rational) it "can transform notes correctly over 2 octaves - prometheus" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "prometheus" twoOctavesOf5NoteScale) ("0 2 4 6 11 12 14 16 18 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - scriabin" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "scriabin" twoOctavesOf5NoteScale) ("0 1 4 7 9 12 13 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - gong" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "gong" twoOctavesOf5NoteScale) ("0 2 4 7 9 12 14 16 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - shang" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "shang" twoOctavesOf5NoteScale) ("0 2 5 7 10 12 14 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - jiao" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "jiao" twoOctavesOf5NoteScale) ("0 3 5 8 10 12 15 17 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - zhi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "zhi" twoOctavesOf5NoteScale) ("0 2 5 7 9 12 14 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - yu" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "yu" twoOctavesOf5NoteScale) ("0 3 5 7 10 12 15 17 19 22"::Pattern Rational) describe "6 note scales" $ do let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11" it "can transform notes correctly over 2 octaves - whole" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale) ("0 2 4 6 8 10 12 14 16 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - wholetone" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale) (Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale :: Pattern Rational) it "can transform notes correctly over 2 octaves - augmented" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "augmented" twoOctavesOf6NoteScale) ("0 3 4 7 8 11 12 15 16 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - augmented2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "augmented2" twoOctavesOf6NoteScale) ("0 1 4 5 8 9 12 13 16 17 20 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexMajor7" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexMajor7" twoOctavesOf6NoteScale) ("0 2 4 7 9 11 12 14 16 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexPhrygian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexPhrygian" twoOctavesOf6NoteScale) ("0 1 3 5 8 10 12 13 15 17 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexDorian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexDorian" twoOctavesOf6NoteScale) ("0 2 3 5 7 10 12 14 15 17 19 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexSus" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexSus" twoOctavesOf6NoteScale) ("0 2 5 7 9 10 12 14 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexMajor6" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexMajor6" twoOctavesOf6NoteScale) ("0 2 4 5 7 9 12 14 16 17 19 21"::Pattern Rational) it "can transform notes correctly over 2 octaves - hexAeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hexAeolian" twoOctavesOf6NoteScale) ("0 3 5 7 8 10 12 15 17 19 20 22"::Pattern Rational) describe "7 note scales" $ do let twoOctavesOf7NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13" it "can transform notes correctly over 2 octaves - major" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale) ("0 2 4 5 7 9 11 12 14 16 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - ionian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ionian" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale :: Pattern Rational) it "can transform notes correctly over 2 octaves - dorian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "dorian" twoOctavesOf7NoteScale) ("0 2 3 5 7 9 10 12 14 15 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - aeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale) ("0 2 3 5 7 8 10 12 14 15 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - aeolian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - minor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - locrian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "locrian" twoOctavesOf7NoteScale) ("0 1 3 5 6 8 10 12 13 15 17 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - harmonicMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "harmonicMinor" twoOctavesOf7NoteScale) ("0 2 3 5 7 8 11 12 14 15 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - harmonicMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "harmonicMajor" twoOctavesOf7NoteScale) ("0 2 4 5 7 8 11 12 14 16 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMinor" twoOctavesOf7NoteScale) ("0 2 3 5 7 9 11 12 14 15 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMinorDesc" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMinorDesc" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - melodicMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale) ("0 2 4 5 7 8 10 12 14 16 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - bartok" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "bartok" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - hindu" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hindu" twoOctavesOf7NoteScale) (Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - todi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "todi" twoOctavesOf7NoteScale) ("0 1 3 6 7 8 11 12 13 15 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - purvi" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "purvi" twoOctavesOf7NoteScale) ("0 1 4 6 7 8 11 12 13 16 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - marva" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "marva" twoOctavesOf7NoteScale) ("0 1 4 6 7 9 11 12 13 16 18 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - bhairav" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "bhairav" twoOctavesOf7NoteScale) ("0 1 4 5 7 8 11 12 13 16 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - ahirbhairav" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ahirbhairav" twoOctavesOf7NoteScale) ("0 1 4 5 7 9 10 12 13 16 17 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - superLocrian" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "superLocrian" twoOctavesOf7NoteScale) ("0 1 3 4 6 8 10 12 13 15 16 18 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - romanianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "romanianMinor" twoOctavesOf7NoteScale) ("0 2 3 6 7 9 10 12 14 15 18 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - hungarianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "hungarianMinor" twoOctavesOf7NoteScale) ("0 2 3 6 7 8 11 12 14 15 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - neapolitanMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "neapolitanMinor" twoOctavesOf7NoteScale) ("0 1 3 5 7 8 11 12 13 15 17 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - enigmatic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "enigmatic" twoOctavesOf7NoteScale) ("0 1 4 6 8 10 11 12 13 16 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - spanish" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "spanish" twoOctavesOf7NoteScale) ("0 1 4 5 7 8 10 12 13 16 17 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - leadingWhole" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "leadingWhole" twoOctavesOf7NoteScale) ("0 2 4 6 8 10 11 12 14 16 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - lydianMinor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "lydianMinor" twoOctavesOf7NoteScale) ("0 2 4 6 7 8 10 12 14 16 18 19 20 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - neapolitanMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "neapolitanMajor" twoOctavesOf7NoteScale) ("0 1 3 5 7 9 11 12 13 15 17 19 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - locrianMajor" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "locrianMajor" twoOctavesOf7NoteScale) ("0 2 4 5 6 8 10 12 14 16 17 18 20 22"::Pattern Rational) describe "8 note scales" $ do let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" it "can transform notes correctly over 2 octaves - diminished" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale) ("0 1 3 4 6 7 9 10 12 13 15 16 18 19 21 22"::Pattern Rational) it "can transform notes correctly over 2 octaves - octatonic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "octatonic" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - diminished2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale) ("0 2 3 5 6 8 9 11 12 14 15 17 18 20 21 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - octatonic2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "octatonic2" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale::Pattern Rational) describe "modes of limited transposition" $ do let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11" let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" let twoOctavesOf9NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17" let twoOctavesOf10NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19" it "can transform notes correctly over 2 octaves - messiaen1" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen1" twoOctavesOf6NoteScale) (Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen2" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen2" twoOctavesOf8NoteScale) (Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen3" $ do -- tone, semitone, semitone, tone, semitone, semitone, tone, semitone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen3" twoOctavesOf9NoteScale) ("0 2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen4" $ do -- semitone, semitone, minor third, semitone, semitone, semitone, minor third, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen4" twoOctavesOf8NoteScale) ("0 1 2 5 6 7 8 11 12 13 14 17 18 19 20 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen5" $ do -- semitone, major third, semitone, semitone, major third, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen5" twoOctavesOf6NoteScale) ("0 1 5 6 7 11 12 13 17 18 19 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen6" $ do -- tone, tone, semitone, semitone, tone, tone, semitone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen6" twoOctavesOf8NoteScale) ("0 2 4 5 6 8 10 11 12 14 16 17 18 20 22 23"::Pattern Rational) it "can transform notes correctly over 2 octaves - messiaen7" $ do -- semitone, semitone, semitone, tone, semitone, semitone, semitone, semitone, tone, semitone compareP (Arc 0 1) (Sound.Tidal.Scales.scale "messiaen7" twoOctavesOf10NoteScale) ("0 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18 19 20 21 23"::Pattern Rational) describe "12 note scales" $ do let twoOctavesOf12NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" it "can transform notes correctly over 2 octaves - chromatic" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "chromatic" twoOctavesOf12NoteScale) ("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"::Pattern Rational) describe "edge cases" $ do it "responds to unknown scales by mapping to octaves" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "ergaerv" "0 1 2 3 4") ("0 12 24 36 48"::Pattern Rational) it "correctly maps negative numbers" $ do compareP (Arc 0 1) (Sound.Tidal.Scales.scale "major" "0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13") ("0 -1 -3 -5 -7 -8 -10 -12 -13 -15 -17 -19 -20 -22 "::Pattern Rational)
20,703
false
true
0
20
7,490
3,718
1,819
1,899
null
null
kim/amazonka
amazonka-iam/gen/Network/AWS/IAM/DeletePolicyVersion.hs
mpl-2.0
-- | 'DeletePolicyVersionResponse' constructor. deletePolicyVersionResponse :: DeletePolicyVersionResponse deletePolicyVersionResponse = DeletePolicyVersionResponse
164
deletePolicyVersionResponse :: DeletePolicyVersionResponse deletePolicyVersionResponse = DeletePolicyVersionResponse
116
deletePolicyVersionResponse = DeletePolicyVersionResponse
57
true
true
0
4
9
12
7
5
null
null
seagreen/hjsonschema
src/JSONSchema/Validator/Draft4/String.hs
mit
maxLengthVal :: MaxLength -> Text -> Maybe MaxLengthInvalid maxLengthVal a@(MaxLength n) x | T.length x > n = Just (MaxLengthInvalid a x) | otherwise = Nothing
172
maxLengthVal :: MaxLength -> Text -> Maybe MaxLengthInvalid maxLengthVal a@(MaxLength n) x | T.length x > n = Just (MaxLengthInvalid a x) | otherwise = Nothing
172
maxLengthVal a@(MaxLength n) x | T.length x > n = Just (MaxLengthInvalid a x) | otherwise = Nothing
112
false
true
1
10
38
70
33
37
null
null
tjakway/ghcjvm
compiler/typecheck/FunDeps.hs
bsd-3-clause
-- Improve a class constraint from instance declarations -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pprEquation :: FunDepEqn a -> SDoc pprEquation (FDEqn { fd_qtvs = qtvs, fd_eqs = pairs }) = vcat [text "forall" <+> braces (pprWithCommas ppr qtvs), nest 2 (vcat [ ppr t1 <+> text "~" <+> ppr t2 | Pair t1 t2 <- pairs])]
370
pprEquation :: FunDepEqn a -> SDoc pprEquation (FDEqn { fd_qtvs = qtvs, fd_eqs = pairs }) = vcat [text "forall" <+> braces (pprWithCommas ppr qtvs), nest 2 (vcat [ ppr t1 <+> text "~" <+> ppr t2 | Pair t1 t2 <- pairs])]
254
pprEquation (FDEqn { fd_qtvs = qtvs, fd_eqs = pairs }) = vcat [text "forall" <+> braces (pprWithCommas ppr qtvs), nest 2 (vcat [ ppr t1 <+> text "~" <+> ppr t2 | Pair t1 t2 <- pairs])]
219
true
true
0
13
88
112
56
56
null
null
piccolo-lang/piccolo
src/Core/Parser.hs
gpl-3.0
branchOutput :: Parser Branch branchOutput = do pos <- getPosition g <- brackets expr c <- identifier reservedOp "!" e <- expr reservedOp "," p <- process pos' <- getPosition return $ BOutput g c e (-1) p (mkLoc pos pos')
239
branchOutput :: Parser Branch branchOutput = do pos <- getPosition g <- brackets expr c <- identifier reservedOp "!" e <- expr reservedOp "," p <- process pos' <- getPosition return $ BOutput g c e (-1) p (mkLoc pos pos')
239
branchOutput = do pos <- getPosition g <- brackets expr c <- identifier reservedOp "!" e <- expr reservedOp "," p <- process pos' <- getPosition return $ BOutput g c e (-1) p (mkLoc pos pos')
209
false
true
0
10
58
104
46
58
null
null
bkoropoff/Idris-dev
src/Idris/Error.hs
bsd-3-clause
getErrSpan :: Err -> FC getErrSpan (At fc _) = fc
49
getErrSpan :: Err -> FC getErrSpan (At fc _) = fc
49
getErrSpan (At fc _) = fc
25
false
true
0
7
10
26
13
13
null
null
andreasbock/hql
src/Utils/Calendar.hs
gpl-2.0
getYearOffsets :: Date -> [Date] -> [Years] getYearOffsets now dates = map (getYearOffset now) dates
100
getYearOffsets :: Date -> [Date] -> [Years] getYearOffsets now dates = map (getYearOffset now) dates
100
getYearOffsets now dates = map (getYearOffset now) dates
56
false
true
0
7
14
41
21
20
null
null
mainland/nikola
examples/common/GUI.hs
bsd-3-clause
openWindowGLUT :: Display -> IO () openWindowGLUT disp = do open disp GLUT.perWindowKeyRepeat $= GLUT.PerWindowKeyRepeatOff where open :: Display -> IO () open (InWindow windowName (sizeX, sizeY) (posX, posY)) = do GLUT.initialWindowSize $= GL.Size (fromIntegral sizeX) (fromIntegral sizeY) GLUT.initialWindowPosition $= GL.Position (fromIntegral posX) (fromIntegral posY) void $ GLUT.createWindow windowName GLUT.windowSize $= GL.Size (fromIntegral sizeX) (fromIntegral sizeY) open (FullScreen (sizeX, sizeY)) = do GLUT.gameModeCapabilities $= [ GLUT.Where' GLUT.GameModeWidth GLUT.IsEqualTo sizeX , GLUT.Where' GLUT.GameModeHeight GLUT.IsEqualTo sizeY ] void $ GLUT.enterGameMode
914
openWindowGLUT :: Display -> IO () openWindowGLUT disp = do open disp GLUT.perWindowKeyRepeat $= GLUT.PerWindowKeyRepeatOff where open :: Display -> IO () open (InWindow windowName (sizeX, sizeY) (posX, posY)) = do GLUT.initialWindowSize $= GL.Size (fromIntegral sizeX) (fromIntegral sizeY) GLUT.initialWindowPosition $= GL.Position (fromIntegral posX) (fromIntegral posY) void $ GLUT.createWindow windowName GLUT.windowSize $= GL.Size (fromIntegral sizeX) (fromIntegral sizeY) open (FullScreen (sizeX, sizeY)) = do GLUT.gameModeCapabilities $= [ GLUT.Where' GLUT.GameModeWidth GLUT.IsEqualTo sizeX , GLUT.Where' GLUT.GameModeHeight GLUT.IsEqualTo sizeY ] void $ GLUT.enterGameMode
914
openWindowGLUT disp = do open disp GLUT.perWindowKeyRepeat $= GLUT.PerWindowKeyRepeatOff where open :: Display -> IO () open (InWindow windowName (sizeX, sizeY) (posX, posY)) = do GLUT.initialWindowSize $= GL.Size (fromIntegral sizeX) (fromIntegral sizeY) GLUT.initialWindowPosition $= GL.Position (fromIntegral posX) (fromIntegral posY) void $ GLUT.createWindow windowName GLUT.windowSize $= GL.Size (fromIntegral sizeX) (fromIntegral sizeY) open (FullScreen (sizeX, sizeY)) = do GLUT.gameModeCapabilities $= [ GLUT.Where' GLUT.GameModeWidth GLUT.IsEqualTo sizeX , GLUT.Where' GLUT.GameModeHeight GLUT.IsEqualTo sizeY ] void $ GLUT.enterGameMode
879
false
true
0
10
310
254
122
132
null
null
vikraman/ghc-mod
Language/Haskell/GhcMod/GHCApi.hs
bsd-3-clause
initializeFlags :: GhcMonad m => Options -> m () initializeFlags opt = do dflags0 <- getSessionDynFlags dflags1 <- modifyFlagsWithOpts dflags0 $ ghcOpts opt void $ setSessionDynFlags dflags1 ---------------------------------------------------------------- -- FIXME removing Options
295
initializeFlags :: GhcMonad m => Options -> m () initializeFlags opt = do dflags0 <- getSessionDynFlags dflags1 <- modifyFlagsWithOpts dflags0 $ ghcOpts opt void $ setSessionDynFlags dflags1 ---------------------------------------------------------------- -- FIXME removing Options
295
initializeFlags opt = do dflags0 <- getSessionDynFlags dflags1 <- modifyFlagsWithOpts dflags0 $ ghcOpts opt void $ setSessionDynFlags dflags1 ---------------------------------------------------------------- -- FIXME removing Options
246
false
true
0
9
45
66
30
36
null
null
mhwombat/creatur-image-wains
src/ALife/Creatur/Wain/Image/Pattern.hs
bsd-3-clause
zipWithCopyRight _ _ [] = []
28
zipWithCopyRight _ _ [] = []
28
zipWithCopyRight _ _ [] = []
28
false
false
2
6
5
20
7
13
null
null
uriba/dwarf
src/Data/Dwarf.hs
bsd-3-clause
dw_at 0x2c = DW_AT_start_scope
30
dw_at 0x2c = DW_AT_start_scope
30
dw_at 0x2c = DW_AT_start_scope
30
false
false
0
5
3
9
4
5
null
null
maximkulkin/aeson
Data/Aeson/TH.hs
bsd-3-clause
encodeArgs :: Options -> Bool -> Con -> Q Match -- Nullary constructors. Generates code that explicitly matches against the -- constructor even though it doesn't contain data. This is useful to prevent -- type errors. encodeArgs opts multiCons (NormalC conName []) = match (conP conName []) (normalB (encodeSum opts multiCons conName [e|toJSON ([] :: [()])|])) []
388
encodeArgs :: Options -> Bool -> Con -> Q Match encodeArgs opts multiCons (NormalC conName []) = match (conP conName []) (normalB (encodeSum opts multiCons conName [e|toJSON ([] :: [()])|])) []
218
encodeArgs opts multiCons (NormalC conName []) = match (conP conName []) (normalB (encodeSum opts multiCons conName [e|toJSON ([] :: [()])|])) []
170
true
true
0
12
81
94
47
47
null
null
gcross/LogicGrowsOnTrees
LogicGrowsOnTrees/sources/LogicGrowsOnTrees/Examples/Queens/Advanced.hs
bsd-2-clause
nqueensBreak180 :: MonadPlus m ⇒ Updater α β {-^ how to add new partial coordinates to the current solution -} → (α → m β) {-^ function that finalizes the partial solution -} → (α → NQueensBreak180State → m β) {-^ function to break the 180-degree rotational symmetry for the next inner layer -} → (α → Int → NQueensSearchState → m β) {-^ function to apply a brute-force search -} → α {-^ partial solution -} → NQueensBreak180State {-^ current state -} → m β {-^ the final result -} nqueensBreak180 !updater !finalizeValue !break180 !search !value !(NQueensBreak180State number_of_queens_remaining window_start window_size occupied_rows occupied_columns occupied_negative_diagonals occupied_positive_diagonals occupied_right_positive_diagonals ) | number_of_queens_remaining == 0 = finalizeValue value | window_size > 3 = if occupied_rows .&. 1 == 0 then if occupied_columns .&. 1 == 0 then mplus preserve180 $ if occupied_negative_diagonals .&. end_bit .|. occupied_positive_diagonals .&. end_bit == 0 then if occupied_negative_diagonals .&. bit (2*end) .|. occupied_positive_diagonals .&. 1 == 0 then breakAtBottomLeftCorner `mplus` breakAtTopLeftCorner `mplus` breakAtSides else breakAtTopLeftCorner `mplus` breakAtSides else if occupied_negative_diagonals .&. bit (2*end) .|. occupied_positive_diagonals .&. 1 == 0 then breakAtBottomLeftCorner `mplus` breakAtSides else breakAtSides else preserve180Horizontal `mplus` breakAtHorizontalSides else if occupied_columns .&. 1 == 0 then preserve180Vertical `mplus` breakAtVerticalSides else nextWindow | number_of_queens_remaining == 1 && (occupied_rows .|. occupied_columns) .&. 2 == 0 = finalizeValue ([(window_start+1,window_start+1)] `convertAndUpdateValue` value) | otherwise = mzero where convertAndUpdateValue = convertAndUpdateValueFor updater end = window_size-1 end_bit = bit end window_end = window_start+end inner_size = window_size-2 inner_end = window_size-3 horizontal_blocked = occupied_columns .|. occupied_negative_diagonals .|. occupied_positive_diagonals inner_horizontal_blocked = horizontal_blocked `unsafeShiftR` 1 inner_horizontal_blocked_excluding_middle | window_size .&. 1 == 0 = inner_horizontal_blocked | otherwise = inner_horizontal_blocked .|. bit (window_size `div` 2 - 1) vertical_blocked = occupied_rows .|. occupied_negative_diagonals .|. occupied_right_positive_diagonals inner_vertical_blocked = vertical_blocked `unsafeShiftR` 1 inner_vertical_blocked_excluding_middle | window_size .&. 1 == 0 = inner_vertical_blocked | otherwise = inner_vertical_blocked .|. bit (window_size `div` 2 - 1) -- break the symmetry without placing a queen at a corner breakAtSides = do PositionAndBit inner_top_column inner_top_column_bit ← getOpenings inner_size inner_horizontal_blocked let inner_reflected_top_column_bit = bit (inner_end - inner_top_column) PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size (inner_vertical_blocked .|. inner_top_column_bit) PositionAndBit inner_reflected_bottom_column_offset _ ← getOpenings (inner_end-inner_top_column+1) ((inner_horizontal_blocked .|. inner_reflected_top_column_bit .|. inner_right_row_bit) `unsafeShiftR` inner_top_column) let inner_reflected_bottom_column = inner_top_column + inner_reflected_bottom_column_offset inner_reflected_bottom_column_bit = bit inner_reflected_bottom_column PositionAndBit inner_reflected_left_row _ ← getOpenings (if inner_reflected_bottom_column_offset > 0 then inner_size else inner_right_row ) (inner_vertical_blocked .|. bit (inner_end - inner_right_row) .|. inner_reflected_bottom_column_bit .|. inner_top_column_bit) let top_column = inner_top_column + 1 top_column_bit = bit top_column right_row = inner_right_row + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) bottom_column = inner_end - inner_reflected_bottom_column + 1 bottom_column_bit = bit bottom_column left_row = inner_end - inner_reflected_left_row + 1 left_row_bit = bit left_row reflected_left_row_bit = bit (end-left_row) search (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_end,window_start+bottom_column) ,(window_start+right_row,window_start) ,(window_start,window_start+top_column) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-4) (window_start+1) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. reflected_left_row_bit .|. ((bottom_column_bit .|. reflected_right_row_bit) `rotateR` end)) ) -- break the symmetry by placing queens only on the horizontal sides breakAtHorizontalSides = do PositionAndBit inner_top_column _ ← getOpenings (inner_size-1) inner_horizontal_blocked PositionAndBit inner_reflected_bottom_column_offset _ ← getOpenings (inner_end-inner_top_column) ((inner_horizontal_blocked .|. bit (inner_end - inner_top_column)) `unsafeShiftR` (inner_top_column+1)) let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - (inner_top_column + inner_reflected_bottom_column_offset + 1) + 1 bottom_column_bit = bit bottom_column search (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-2) (window_start+1) (occupied_rows `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. (bottom_column_bit `rotateR` end)) ) -- break the symmetry by placing queens only on the vertical sides breakAtVerticalSides = do PositionAndBit inner_right_row _ ← getOpenings (inner_size-1) inner_vertical_blocked PositionAndBit inner_reflected_left_row_offset _ ← getOpenings (inner_end-inner_right_row) ((inner_vertical_blocked .|. bit (inner_end - inner_right_row)) `unsafeShiftR` (inner_right_row+1)) let right_row = inner_right_row + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) left_row = inner_end - (inner_right_row + inner_reflected_left_row_offset + 1) + 1 left_row_bit = bit left_row reflected_left_row_bit = bit (end-left_row) search (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-2) (window_start+1) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. (left_row_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. reflected_left_row_bit .|. (reflected_right_row_bit `rotateR` end)) ) -- break by placing a queen at the bottom-left corner breakAtBottomLeftCorner = do PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size inner_vertical_blocked PositionAndBit inner_top_column _ ← getOpenings inner_size (inner_horizontal_blocked .|. inner_right_row_bit) let right_row = inner_right_row+1 top_column = inner_top_column+1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) top_column_bit = bit top_column search (convertAndUpdateValue [(window_start,window_start+top_column) ,(window_start+right_row,window_start) ,(window_end,window_end) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-3) (window_start+1) ((occupied_rows .|. right_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. top_column_bit) `unsafeShiftR` 2) (occupied_positive_diagonals .|. 1 .|. top_column_bit .|. (reflected_right_row_bit `rotateR` end)) ) -- break by placing a queen at the top-left corner breakAtTopLeftCorner = do PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size inner_vertical_blocked PositionAndBit inner_reflected_bottom_column _ ← getOpenings inner_size (inner_horizontal_blocked .|. inner_right_row_bit) let right_row = inner_right_row + 1 bottom_column = inner_end - inner_reflected_bottom_column + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) bottom_column_bit = bit bottom_column search (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start+right_row,window_start) ,(window_start,window_end) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-3) (window_start+1) ((occupied_rows .|. right_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. end_bit .|. right_row_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. ((reflected_right_row_bit .|. bottom_column_bit) `rotateR` end)) ) -- preserve the 180-degree rotational symmetry preserve180 = do PositionAndBit inner_top_column inner_top_column_bit ← getOpenings inner_size inner_horizontal_blocked_excluding_middle let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - inner_top_column + 1 bottom_column_bit = bit bottom_column PositionAndBit inner_right_row _ ← getOpenings inner_size (inner_vertical_blocked_excluding_middle .|. inner_top_column_bit) let right_row = inner_right_row + 1 right_row_bit = bit right_row left_row = inner_end - inner_right_row + 1 left_row_bit = bit left_row break180 (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ,(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (NQueensBreak180State (number_of_queens_remaining-4) (window_start+1) (window_size-2) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `rotateR` end)) (occupied_right_positive_diagonals .|. top_column_bit .|. right_row_bit) ) -- preserve the 180-degree symmetry for the horizontal sides preserve180Horizontal = do PositionAndBit inner_top_column _ ← getOpenings inner_size inner_horizontal_blocked_excluding_middle let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - inner_top_column + 1 bottom_column_bit = bit bottom_column break180 (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (NQueensBreak180State (number_of_queens_remaining-2) (window_start+1) (window_size-2) (occupied_rows `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. (bottom_column_bit `rotateR` end)) (occupied_right_positive_diagonals .|. top_column_bit) ) -- preserve the 180-degree symmetry for the vertical sides preserve180Vertical = do PositionAndBit inner_right_row _ ← getOpenings inner_size inner_vertical_blocked_excluding_middle let right_row = inner_right_row + 1 right_row_bit = bit right_row left_row = inner_end - inner_right_row + 1 left_row_bit = bit left_row break180 (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ] value ) (NQueensBreak180State (number_of_queens_remaining-2) (window_start+1) (window_size-2) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. (left_row_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. right_row_bit .|. (left_row_bit `rotateR` end)) (occupied_right_positive_diagonals .|. right_row_bit) ) -- all sides are occupied, so go to the next layer in nextWindow = break180 value $ NQueensBreak180State number_of_queens_remaining (window_start+1) (window_size-2) (occupied_rows `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) (occupied_negative_diagonals `unsafeShiftR` 2) occupied_positive_diagonals occupied_right_positive_diagonals -------------------------------------------------------------------------------- ---------------------------- Brute-force searching ----------------------------- -------------------------------------------------------------------------------- {- $brute-force After the symmetry has been fully broken, the brute-force approach attempts to place queens in the remaining inner sub-board. When the number of queens falls to 10 or less, it farms the rest of the search out to a routine written in C. -} {-| The state during the brute-force search. -}
17,033
nqueensBreak180 :: MonadPlus m ⇒ Updater α β {-^ how to add new partial coordinates to the current solution -} → (α → m β) {-^ function that finalizes the partial solution -} → (α → NQueensBreak180State → m β) {-^ function to break the 180-degree rotational symmetry for the next inner layer -} → (α → Int → NQueensSearchState → m β) {-^ function to apply a brute-force search -} → α {-^ partial solution -} → NQueensBreak180State {-^ current state -} → m β nqueensBreak180 !updater !finalizeValue !break180 !search !value !(NQueensBreak180State number_of_queens_remaining window_start window_size occupied_rows occupied_columns occupied_negative_diagonals occupied_positive_diagonals occupied_right_positive_diagonals ) | number_of_queens_remaining == 0 = finalizeValue value | window_size > 3 = if occupied_rows .&. 1 == 0 then if occupied_columns .&. 1 == 0 then mplus preserve180 $ if occupied_negative_diagonals .&. end_bit .|. occupied_positive_diagonals .&. end_bit == 0 then if occupied_negative_diagonals .&. bit (2*end) .|. occupied_positive_diagonals .&. 1 == 0 then breakAtBottomLeftCorner `mplus` breakAtTopLeftCorner `mplus` breakAtSides else breakAtTopLeftCorner `mplus` breakAtSides else if occupied_negative_diagonals .&. bit (2*end) .|. occupied_positive_diagonals .&. 1 == 0 then breakAtBottomLeftCorner `mplus` breakAtSides else breakAtSides else preserve180Horizontal `mplus` breakAtHorizontalSides else if occupied_columns .&. 1 == 0 then preserve180Vertical `mplus` breakAtVerticalSides else nextWindow | number_of_queens_remaining == 1 && (occupied_rows .|. occupied_columns) .&. 2 == 0 = finalizeValue ([(window_start+1,window_start+1)] `convertAndUpdateValue` value) | otherwise = mzero where convertAndUpdateValue = convertAndUpdateValueFor updater end = window_size-1 end_bit = bit end window_end = window_start+end inner_size = window_size-2 inner_end = window_size-3 horizontal_blocked = occupied_columns .|. occupied_negative_diagonals .|. occupied_positive_diagonals inner_horizontal_blocked = horizontal_blocked `unsafeShiftR` 1 inner_horizontal_blocked_excluding_middle | window_size .&. 1 == 0 = inner_horizontal_blocked | otherwise = inner_horizontal_blocked .|. bit (window_size `div` 2 - 1) vertical_blocked = occupied_rows .|. occupied_negative_diagonals .|. occupied_right_positive_diagonals inner_vertical_blocked = vertical_blocked `unsafeShiftR` 1 inner_vertical_blocked_excluding_middle | window_size .&. 1 == 0 = inner_vertical_blocked | otherwise = inner_vertical_blocked .|. bit (window_size `div` 2 - 1) -- break the symmetry without placing a queen at a corner breakAtSides = do PositionAndBit inner_top_column inner_top_column_bit ← getOpenings inner_size inner_horizontal_blocked let inner_reflected_top_column_bit = bit (inner_end - inner_top_column) PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size (inner_vertical_blocked .|. inner_top_column_bit) PositionAndBit inner_reflected_bottom_column_offset _ ← getOpenings (inner_end-inner_top_column+1) ((inner_horizontal_blocked .|. inner_reflected_top_column_bit .|. inner_right_row_bit) `unsafeShiftR` inner_top_column) let inner_reflected_bottom_column = inner_top_column + inner_reflected_bottom_column_offset inner_reflected_bottom_column_bit = bit inner_reflected_bottom_column PositionAndBit inner_reflected_left_row _ ← getOpenings (if inner_reflected_bottom_column_offset > 0 then inner_size else inner_right_row ) (inner_vertical_blocked .|. bit (inner_end - inner_right_row) .|. inner_reflected_bottom_column_bit .|. inner_top_column_bit) let top_column = inner_top_column + 1 top_column_bit = bit top_column right_row = inner_right_row + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) bottom_column = inner_end - inner_reflected_bottom_column + 1 bottom_column_bit = bit bottom_column left_row = inner_end - inner_reflected_left_row + 1 left_row_bit = bit left_row reflected_left_row_bit = bit (end-left_row) search (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_end,window_start+bottom_column) ,(window_start+right_row,window_start) ,(window_start,window_start+top_column) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-4) (window_start+1) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. reflected_left_row_bit .|. ((bottom_column_bit .|. reflected_right_row_bit) `rotateR` end)) ) -- break the symmetry by placing queens only on the horizontal sides breakAtHorizontalSides = do PositionAndBit inner_top_column _ ← getOpenings (inner_size-1) inner_horizontal_blocked PositionAndBit inner_reflected_bottom_column_offset _ ← getOpenings (inner_end-inner_top_column) ((inner_horizontal_blocked .|. bit (inner_end - inner_top_column)) `unsafeShiftR` (inner_top_column+1)) let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - (inner_top_column + inner_reflected_bottom_column_offset + 1) + 1 bottom_column_bit = bit bottom_column search (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-2) (window_start+1) (occupied_rows `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. (bottom_column_bit `rotateR` end)) ) -- break the symmetry by placing queens only on the vertical sides breakAtVerticalSides = do PositionAndBit inner_right_row _ ← getOpenings (inner_size-1) inner_vertical_blocked PositionAndBit inner_reflected_left_row_offset _ ← getOpenings (inner_end-inner_right_row) ((inner_vertical_blocked .|. bit (inner_end - inner_right_row)) `unsafeShiftR` (inner_right_row+1)) let right_row = inner_right_row + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) left_row = inner_end - (inner_right_row + inner_reflected_left_row_offset + 1) + 1 left_row_bit = bit left_row reflected_left_row_bit = bit (end-left_row) search (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-2) (window_start+1) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. (left_row_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. reflected_left_row_bit .|. (reflected_right_row_bit `rotateR` end)) ) -- break by placing a queen at the bottom-left corner breakAtBottomLeftCorner = do PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size inner_vertical_blocked PositionAndBit inner_top_column _ ← getOpenings inner_size (inner_horizontal_blocked .|. inner_right_row_bit) let right_row = inner_right_row+1 top_column = inner_top_column+1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) top_column_bit = bit top_column search (convertAndUpdateValue [(window_start,window_start+top_column) ,(window_start+right_row,window_start) ,(window_end,window_end) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-3) (window_start+1) ((occupied_rows .|. right_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. top_column_bit) `unsafeShiftR` 2) (occupied_positive_diagonals .|. 1 .|. top_column_bit .|. (reflected_right_row_bit `rotateR` end)) ) -- break by placing a queen at the top-left corner breakAtTopLeftCorner = do PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size inner_vertical_blocked PositionAndBit inner_reflected_bottom_column _ ← getOpenings inner_size (inner_horizontal_blocked .|. inner_right_row_bit) let right_row = inner_right_row + 1 bottom_column = inner_end - inner_reflected_bottom_column + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) bottom_column_bit = bit bottom_column search (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start+right_row,window_start) ,(window_start,window_end) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-3) (window_start+1) ((occupied_rows .|. right_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. end_bit .|. right_row_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. ((reflected_right_row_bit .|. bottom_column_bit) `rotateR` end)) ) -- preserve the 180-degree rotational symmetry preserve180 = do PositionAndBit inner_top_column inner_top_column_bit ← getOpenings inner_size inner_horizontal_blocked_excluding_middle let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - inner_top_column + 1 bottom_column_bit = bit bottom_column PositionAndBit inner_right_row _ ← getOpenings inner_size (inner_vertical_blocked_excluding_middle .|. inner_top_column_bit) let right_row = inner_right_row + 1 right_row_bit = bit right_row left_row = inner_end - inner_right_row + 1 left_row_bit = bit left_row break180 (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ,(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (NQueensBreak180State (number_of_queens_remaining-4) (window_start+1) (window_size-2) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `rotateR` end)) (occupied_right_positive_diagonals .|. top_column_bit .|. right_row_bit) ) -- preserve the 180-degree symmetry for the horizontal sides preserve180Horizontal = do PositionAndBit inner_top_column _ ← getOpenings inner_size inner_horizontal_blocked_excluding_middle let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - inner_top_column + 1 bottom_column_bit = bit bottom_column break180 (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (NQueensBreak180State (number_of_queens_remaining-2) (window_start+1) (window_size-2) (occupied_rows `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. (bottom_column_bit `rotateR` end)) (occupied_right_positive_diagonals .|. top_column_bit) ) -- preserve the 180-degree symmetry for the vertical sides preserve180Vertical = do PositionAndBit inner_right_row _ ← getOpenings inner_size inner_vertical_blocked_excluding_middle let right_row = inner_right_row + 1 right_row_bit = bit right_row left_row = inner_end - inner_right_row + 1 left_row_bit = bit left_row break180 (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ] value ) (NQueensBreak180State (number_of_queens_remaining-2) (window_start+1) (window_size-2) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. (left_row_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. right_row_bit .|. (left_row_bit `rotateR` end)) (occupied_right_positive_diagonals .|. right_row_bit) ) -- all sides are occupied, so go to the next layer in nextWindow = break180 value $ NQueensBreak180State number_of_queens_remaining (window_start+1) (window_size-2) (occupied_rows `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) (occupied_negative_diagonals `unsafeShiftR` 2) occupied_positive_diagonals occupied_right_positive_diagonals -------------------------------------------------------------------------------- ---------------------------- Brute-force searching ----------------------------- -------------------------------------------------------------------------------- {- $brute-force After the symmetry has been fully broken, the brute-force approach attempts to place queens in the remaining inner sub-board. When the number of queens falls to 10 or less, it farms the rest of the search out to a routine written in C. -} {-| The state during the brute-force search. -}
17,009
nqueensBreak180 !updater !finalizeValue !break180 !search !value !(NQueensBreak180State number_of_queens_remaining window_start window_size occupied_rows occupied_columns occupied_negative_diagonals occupied_positive_diagonals occupied_right_positive_diagonals ) | number_of_queens_remaining == 0 = finalizeValue value | window_size > 3 = if occupied_rows .&. 1 == 0 then if occupied_columns .&. 1 == 0 then mplus preserve180 $ if occupied_negative_diagonals .&. end_bit .|. occupied_positive_diagonals .&. end_bit == 0 then if occupied_negative_diagonals .&. bit (2*end) .|. occupied_positive_diagonals .&. 1 == 0 then breakAtBottomLeftCorner `mplus` breakAtTopLeftCorner `mplus` breakAtSides else breakAtTopLeftCorner `mplus` breakAtSides else if occupied_negative_diagonals .&. bit (2*end) .|. occupied_positive_diagonals .&. 1 == 0 then breakAtBottomLeftCorner `mplus` breakAtSides else breakAtSides else preserve180Horizontal `mplus` breakAtHorizontalSides else if occupied_columns .&. 1 == 0 then preserve180Vertical `mplus` breakAtVerticalSides else nextWindow | number_of_queens_remaining == 1 && (occupied_rows .|. occupied_columns) .&. 2 == 0 = finalizeValue ([(window_start+1,window_start+1)] `convertAndUpdateValue` value) | otherwise = mzero where convertAndUpdateValue = convertAndUpdateValueFor updater end = window_size-1 end_bit = bit end window_end = window_start+end inner_size = window_size-2 inner_end = window_size-3 horizontal_blocked = occupied_columns .|. occupied_negative_diagonals .|. occupied_positive_diagonals inner_horizontal_blocked = horizontal_blocked `unsafeShiftR` 1 inner_horizontal_blocked_excluding_middle | window_size .&. 1 == 0 = inner_horizontal_blocked | otherwise = inner_horizontal_blocked .|. bit (window_size `div` 2 - 1) vertical_blocked = occupied_rows .|. occupied_negative_diagonals .|. occupied_right_positive_diagonals inner_vertical_blocked = vertical_blocked `unsafeShiftR` 1 inner_vertical_blocked_excluding_middle | window_size .&. 1 == 0 = inner_vertical_blocked | otherwise = inner_vertical_blocked .|. bit (window_size `div` 2 - 1) -- break the symmetry without placing a queen at a corner breakAtSides = do PositionAndBit inner_top_column inner_top_column_bit ← getOpenings inner_size inner_horizontal_blocked let inner_reflected_top_column_bit = bit (inner_end - inner_top_column) PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size (inner_vertical_blocked .|. inner_top_column_bit) PositionAndBit inner_reflected_bottom_column_offset _ ← getOpenings (inner_end-inner_top_column+1) ((inner_horizontal_blocked .|. inner_reflected_top_column_bit .|. inner_right_row_bit) `unsafeShiftR` inner_top_column) let inner_reflected_bottom_column = inner_top_column + inner_reflected_bottom_column_offset inner_reflected_bottom_column_bit = bit inner_reflected_bottom_column PositionAndBit inner_reflected_left_row _ ← getOpenings (if inner_reflected_bottom_column_offset > 0 then inner_size else inner_right_row ) (inner_vertical_blocked .|. bit (inner_end - inner_right_row) .|. inner_reflected_bottom_column_bit .|. inner_top_column_bit) let top_column = inner_top_column + 1 top_column_bit = bit top_column right_row = inner_right_row + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) bottom_column = inner_end - inner_reflected_bottom_column + 1 bottom_column_bit = bit bottom_column left_row = inner_end - inner_reflected_left_row + 1 left_row_bit = bit left_row reflected_left_row_bit = bit (end-left_row) search (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_end,window_start+bottom_column) ,(window_start+right_row,window_start) ,(window_start,window_start+top_column) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-4) (window_start+1) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. reflected_left_row_bit .|. ((bottom_column_bit .|. reflected_right_row_bit) `rotateR` end)) ) -- break the symmetry by placing queens only on the horizontal sides breakAtHorizontalSides = do PositionAndBit inner_top_column _ ← getOpenings (inner_size-1) inner_horizontal_blocked PositionAndBit inner_reflected_bottom_column_offset _ ← getOpenings (inner_end-inner_top_column) ((inner_horizontal_blocked .|. bit (inner_end - inner_top_column)) `unsafeShiftR` (inner_top_column+1)) let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - (inner_top_column + inner_reflected_bottom_column_offset + 1) + 1 bottom_column_bit = bit bottom_column search (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-2) (window_start+1) (occupied_rows `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. (bottom_column_bit `rotateR` end)) ) -- break the symmetry by placing queens only on the vertical sides breakAtVerticalSides = do PositionAndBit inner_right_row _ ← getOpenings (inner_size-1) inner_vertical_blocked PositionAndBit inner_reflected_left_row_offset _ ← getOpenings (inner_end-inner_right_row) ((inner_vertical_blocked .|. bit (inner_end - inner_right_row)) `unsafeShiftR` (inner_right_row+1)) let right_row = inner_right_row + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) left_row = inner_end - (inner_right_row + inner_reflected_left_row_offset + 1) + 1 left_row_bit = bit left_row reflected_left_row_bit = bit (end-left_row) search (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-2) (window_start+1) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. (left_row_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. reflected_left_row_bit .|. (reflected_right_row_bit `rotateR` end)) ) -- break by placing a queen at the bottom-left corner breakAtBottomLeftCorner = do PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size inner_vertical_blocked PositionAndBit inner_top_column _ ← getOpenings inner_size (inner_horizontal_blocked .|. inner_right_row_bit) let right_row = inner_right_row+1 top_column = inner_top_column+1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) top_column_bit = bit top_column search (convertAndUpdateValue [(window_start,window_start+top_column) ,(window_start+right_row,window_start) ,(window_end,window_end) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-3) (window_start+1) ((occupied_rows .|. right_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. top_column_bit) `unsafeShiftR` 2) (occupied_positive_diagonals .|. 1 .|. top_column_bit .|. (reflected_right_row_bit `rotateR` end)) ) -- break by placing a queen at the top-left corner breakAtTopLeftCorner = do PositionAndBit inner_right_row inner_right_row_bit ← getOpenings inner_size inner_vertical_blocked PositionAndBit inner_reflected_bottom_column _ ← getOpenings inner_size (inner_horizontal_blocked .|. inner_right_row_bit) let right_row = inner_right_row + 1 bottom_column = inner_end - inner_reflected_bottom_column + 1 right_row_bit = bit right_row reflected_right_row_bit = bit (end-right_row) bottom_column_bit = bit bottom_column search (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start+right_row,window_start) ,(window_start,window_end) ] value ) (window_size-2) (NQueensSearchState (number_of_queens_remaining-3) (window_start+1) ((occupied_rows .|. right_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. end_bit .|. right_row_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. ((reflected_right_row_bit .|. bottom_column_bit) `rotateR` end)) ) -- preserve the 180-degree rotational symmetry preserve180 = do PositionAndBit inner_top_column inner_top_column_bit ← getOpenings inner_size inner_horizontal_blocked_excluding_middle let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - inner_top_column + 1 bottom_column_bit = bit bottom_column PositionAndBit inner_right_row _ ← getOpenings inner_size (inner_vertical_blocked_excluding_middle .|. inner_top_column_bit) let right_row = inner_right_row + 1 right_row_bit = bit right_row left_row = inner_end - inner_right_row + 1 left_row_bit = bit left_row break180 (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ,(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (NQueensBreak180State (number_of_queens_remaining-4) (window_start+1) (window_size-2) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. right_row_bit .|. ((bottom_column_bit .|. left_row_bit) `rotateR` end)) (occupied_right_positive_diagonals .|. top_column_bit .|. right_row_bit) ) -- preserve the 180-degree symmetry for the horizontal sides preserve180Horizontal = do PositionAndBit inner_top_column _ ← getOpenings inner_size inner_horizontal_blocked_excluding_middle let top_column = inner_top_column + 1 top_column_bit = bit top_column bottom_column = inner_end - inner_top_column + 1 bottom_column_bit = bit bottom_column break180 (convertAndUpdateValue [(window_end,window_start+bottom_column) ,(window_start,window_start+top_column) ] value ) (NQueensBreak180State (number_of_queens_remaining-2) (window_start+1) (window_size-2) (occupied_rows `unsafeShiftR` 1) ((occupied_columns .|. top_column_bit .|. bottom_column_bit) `unsafeShiftR` 1) ((occupied_negative_diagonals .|. top_column_bit .|. (bottom_column_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. top_column_bit .|. (bottom_column_bit `rotateR` end)) (occupied_right_positive_diagonals .|. top_column_bit) ) -- preserve the 180-degree symmetry for the vertical sides preserve180Vertical = do PositionAndBit inner_right_row _ ← getOpenings inner_size inner_vertical_blocked_excluding_middle let right_row = inner_right_row + 1 right_row_bit = bit right_row left_row = inner_end - inner_right_row + 1 left_row_bit = bit left_row break180 (convertAndUpdateValue [(window_start+left_row,window_end) ,(window_start+right_row,window_start) ] value ) (NQueensBreak180State (number_of_queens_remaining-2) (window_start+1) (window_size-2) ((occupied_rows .|. right_row_bit .|. left_row_bit) `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) ((occupied_negative_diagonals .|. right_row_bit .|. (left_row_bit `unsafeShiftL` end)) `unsafeShiftR` 2) (occupied_positive_diagonals .|. right_row_bit .|. (left_row_bit `rotateR` end)) (occupied_right_positive_diagonals .|. right_row_bit) ) -- all sides are occupied, so go to the next layer in nextWindow = break180 value $ NQueensBreak180State number_of_queens_remaining (window_start+1) (window_size-2) (occupied_rows `unsafeShiftR` 1) (occupied_columns `unsafeShiftR` 1) (occupied_negative_diagonals `unsafeShiftR` 2) occupied_positive_diagonals occupied_right_positive_diagonals -------------------------------------------------------------------------------- ---------------------------- Brute-force searching ----------------------------- -------------------------------------------------------------------------------- {- $brute-force After the symmetry has been fully broken, the brute-force approach attempts to place queens in the remaining inner sub-board. When the number of queens falls to 10 or less, it farms the rest of the search out to a routine written in C. -} {-| The state during the brute-force search. -}
16,519
true
true
28
22
5,182
3,245
1,754
1,491
null
null
lukexi/ghc-7.8-arm64
compiler/codeGen/StgCmmProf.hs
bsd-3-clause
ldvWord :: DynFlags -> CmmExpr -> CmmExpr -- Takes the address of a closure, and returns -- the address of the LDV word in the closure ldvWord dflags closure_ptr = cmmOffsetB dflags closure_ptr (oFFSET_StgHeader_ldvw dflags)
228
ldvWord :: DynFlags -> CmmExpr -> CmmExpr ldvWord dflags closure_ptr = cmmOffsetB dflags closure_ptr (oFFSET_StgHeader_ldvw dflags)
135
ldvWord dflags closure_ptr = cmmOffsetB dflags closure_ptr (oFFSET_StgHeader_ldvw dflags)
93
true
true
0
7
38
39
20
19
null
null
eigengrau/panopticus
src/Main.hs
gpl-3.0
panopticus ∷ Bot panopticus = do (channels, channelsPart) ← initChannelsPart channels let parts = [pingPart, channelsPart, greetPart] simpleBot' channelLogger logger limits host port nick commandPrefix user parts where channelLogger = Nothing commandPrefix = "!" nick = "panopticus" host = "irc.freenode.net" port = PortNumber 6667 logger = stdoutLogger logLevel logLevel = Debug channels = ["#panopticus"] limits = Nothing user = User { username = nick, hostname = "panopticus", servername = "⁇", realname = nick }
882
panopticus ∷ Bot panopticus = do (channels, channelsPart) ← initChannelsPart channels let parts = [pingPart, channelsPart, greetPart] simpleBot' channelLogger logger limits host port nick commandPrefix user parts where channelLogger = Nothing commandPrefix = "!" nick = "panopticus" host = "irc.freenode.net" port = PortNumber 6667 logger = stdoutLogger logLevel logLevel = Debug channels = ["#panopticus"] limits = Nothing user = User { username = nick, hostname = "panopticus", servername = "⁇", realname = nick }
882
panopticus = do (channels, channelsPart) ← initChannelsPart channels let parts = [pingPart, channelsPart, greetPart] simpleBot' channelLogger logger limits host port nick commandPrefix user parts where channelLogger = Nothing commandPrefix = "!" nick = "panopticus" host = "irc.freenode.net" port = PortNumber 6667 logger = stdoutLogger logLevel logLevel = Debug channels = ["#panopticus"] limits = Nothing user = User { username = nick, hostname = "panopticus", servername = "⁇", realname = nick }
865
false
true
0
10
440
154
86
68
null
null
lefant/kurt
test/Test-Data.Goban.STVector.hs
gpl-3.0
-- instance Arbitrary VertexState where -- arbitrary = choose (chr 0, chr 255) -- coarbitrary c = variant (ord c `rem` 4) main :: IO () main = do defaultMain tests
179
main :: IO () main = do defaultMain tests
43
main = do defaultMain tests
29
true
true
0
8
46
31
14
17
null
null
alexander-at-github/eta
compiler/ETA/SimplCore/CoreMonad.hs
bsd-3-clause
tickString (KnownBranch _) = "KnownBranch"
55
tickString (KnownBranch _) = "KnownBranch"
55
tickString (KnownBranch _) = "KnownBranch"
55
false
false
0
6
17
16
7
9
null
null
ezyang/ghc
compiler/cmm/CLabel.hs
bsd-3-clause
pprAsmCLbl :: Platform -> CLabel -> SDoc pprAsmCLbl platform (ForeignLabel fs (Just sz) _ _) | platformOS platform == OSMinGW32 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel. -- (The C compiler does this itself). = ftext fs <> char '@' <> int sz
280
pprAsmCLbl :: Platform -> CLabel -> SDoc pprAsmCLbl platform (ForeignLabel fs (Just sz) _ _) | platformOS platform == OSMinGW32 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel. -- (The C compiler does this itself). = ftext fs <> char '@' <> int sz
280
pprAsmCLbl platform (ForeignLabel fs (Just sz) _ _) | platformOS platform == OSMinGW32 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel. -- (The C compiler does this itself). = ftext fs <> char '@' <> int sz
239
false
true
4
12
62
81
36
45
null
null
unisonweb/platform
parser-typechecker/src/Unison/PrintError.hs
mit
_printArrowsAtPos :: String -> Int -> Int -> String _printArrowsAtPos s line column = let lineCaret s i = s ++ if i == line then "\n" ++ columnCaret else "" columnCaret = replicate (column - 1) '-' ++ "^" source = unlines (uncurry lineCaret <$> lines s `zip` [1 ..]) in source
298
_printArrowsAtPos :: String -> Int -> Int -> String _printArrowsAtPos s line column = let lineCaret s i = s ++ if i == line then "\n" ++ columnCaret else "" columnCaret = replicate (column - 1) '-' ++ "^" source = unlines (uncurry lineCaret <$> lines s `zip` [1 ..]) in source
298
_printArrowsAtPos s line column = let lineCaret s i = s ++ if i == line then "\n" ++ columnCaret else "" columnCaret = replicate (column - 1) '-' ++ "^" source = unlines (uncurry lineCaret <$> lines s `zip` [1 ..]) in source
246
false
true
0
13
74
118
61
57
null
null
NatureShade/SymbolicHaskell
src/Math/Symbolic/Simplify.hs
mit
collectSLike x = x
18
collectSLike x = x
18
collectSLike x = x
18
false
false
1
5
3
13
4
9
null
null
sdiehl/ghc
compiler/main/Packages.hs
bsd-3-clause
upd_wired_in :: WiredPackagesMap -> DefUnitId -> DefUnitId upd_wired_in wiredInMap key | Just key' <- Map.lookup key wiredInMap = key' | otherwise = key
160
upd_wired_in :: WiredPackagesMap -> DefUnitId -> DefUnitId upd_wired_in wiredInMap key | Just key' <- Map.lookup key wiredInMap = key' | otherwise = key
160
upd_wired_in wiredInMap key | Just key' <- Map.lookup key wiredInMap = key' | otherwise = key
101
false
true
1
10
30
52
24
28
null
null
nagyf/wyas
src/Evaluator.hs
mit
strBoolBinop :: (String -> String -> Bool) -> [LispVal] -> ThrowsError LispVal strBoolBinop = boolBinop unpackStr
114
strBoolBinop :: (String -> String -> Bool) -> [LispVal] -> ThrowsError LispVal strBoolBinop = boolBinop unpackStr
114
strBoolBinop = boolBinop unpackStr
35
false
true
0
9
16
45
21
24
null
null
edwardwas/adventOfCode
src/Day11.hs
mit
increment :: String -> String increment = helper where helper (x:xs) | x == 'z' = 'a' : helper xs | otherwise = succ x : xs helper [] = []
176
increment :: String -> String increment = helper where helper (x:xs) | x == 'z' = 'a' : helper xs | otherwise = succ x : xs helper [] = []
176
increment = helper where helper (x:xs) | x == 'z' = 'a' : helper xs | otherwise = succ x : xs helper [] = []
146
false
true
1
8
68
78
37
41
null
null
scravy/multimap
src/Data/BagMultiMap.hs
mit
elems :: BagMultiMap k a -> [[a]] -- ^ /O(n)./ Return all elements of the multimap in the -- ascending order of their keys. -- -- A list of lists is returned since a key can have -- multiple values. Use 'concat' to flatten. elems (BagMultiMap (_, _, map)) = Map.elems map
271
elems :: BagMultiMap k a -> [[a]] elems (BagMultiMap (_, _, map)) = Map.elems map
81
elems (BagMultiMap (_, _, map)) = Map.elems map
47
true
true
0
7
51
58
32
26
null
null
haskell-opengl/OpenGLRaw
src/Graphics/GL/Functions/F02.hs
bsd-3-clause
ptr_glBindVideoCaptureStreamTextureNV :: FunPtr (GLuint -> GLuint -> GLenum -> GLenum -> GLuint -> IO ()) ptr_glBindVideoCaptureStreamTextureNV = unsafePerformIO $ getCommand "glBindVideoCaptureStreamTextureNV"
210
ptr_glBindVideoCaptureStreamTextureNV :: FunPtr (GLuint -> GLuint -> GLenum -> GLenum -> GLuint -> IO ()) ptr_glBindVideoCaptureStreamTextureNV = unsafePerformIO $ getCommand "glBindVideoCaptureStreamTextureNV"
210
ptr_glBindVideoCaptureStreamTextureNV = unsafePerformIO $ getCommand "glBindVideoCaptureStreamTextureNV"
104
false
true
0
13
20
49
24
25
null
null
agentm/project-m36
src/lib/ProjectM36/Client.hs
unlicense
disconnectedTransactionIsDirty sessionId conn@(RemoteConnection _) = remoteCall conn (RetrieveSessionIsDirty sessionId)
119
disconnectedTransactionIsDirty sessionId conn@(RemoteConnection _) = remoteCall conn (RetrieveSessionIsDirty sessionId)
119
disconnectedTransactionIsDirty sessionId conn@(RemoteConnection _) = remoteCall conn (RetrieveSessionIsDirty sessionId)
119
false
false
0
8
8
31
15
16
null
null
onponomarev/ganeti
src/Ganeti/Query/Instance.hs
bsd-2-clause
-- | Map each name to a function that extracts that value from the RPC result. instanceLiveFieldExtract :: FieldName -> InstanceInfo -> Instance -> J.JSValue instanceLiveFieldExtract "oper_ram" info _ = J.showJSON $ instInfoMemory info
237
instanceLiveFieldExtract :: FieldName -> InstanceInfo -> Instance -> J.JSValue instanceLiveFieldExtract "oper_ram" info _ = J.showJSON $ instInfoMemory info
158
instanceLiveFieldExtract "oper_ram" info _ = J.showJSON $ instInfoMemory info
79
true
true
0
8
35
42
21
21
null
null
batterseapower/graph-wrapper
Data/Graph/Wrapper/Internal.hs
bsd-3-clause
gVertexVertex :: Graph i v -> G.Vertex -> v gVertexVertex g gv = gVertexVertexArray g ! gv
90
gVertexVertex :: Graph i v -> G.Vertex -> v gVertexVertex g gv = gVertexVertexArray g ! gv
90
gVertexVertex g gv = gVertexVertexArray g ! gv
46
false
true
0
7
16
38
18
20
null
null
liyang/thyme
tests/sanity.hs
bsd-3-clause
------------------------------------------------------------------------ prop_ShowRead :: (Eq a, Show a, Read a) => a -> Bool prop_ShowRead a = (a, "") `elem` reads (show a)
174
prop_ShowRead :: (Eq a, Show a, Read a) => a -> Bool prop_ShowRead a = (a, "") `elem` reads (show a)
100
prop_ShowRead a = (a, "") `elem` reads (show a)
47
true
true
0
8
22
61
33
28
null
null
xenog/haskoin
src/Network/Haskoin/Network/Message.hs
unlicense
msgType (MGetData _) = "getdata"
36
msgType (MGetData _) = "getdata"
36
msgType (MGetData _) = "getdata"
36
false
false
0
6
8
16
7
9
null
null
brendanhay/gogol
gogol-dataproc/gen/Network/Google/Dataproc/Types/Product.hs
mpl-2.0
-- | Optional. Job is a Presto job. jPrestoJob :: Lens' Job (Maybe PrestoJob) jPrestoJob = lens _jPrestoJob (\ s a -> s{_jPrestoJob = a})
139
jPrestoJob :: Lens' Job (Maybe PrestoJob) jPrestoJob = lens _jPrestoJob (\ s a -> s{_jPrestoJob = a})
103
jPrestoJob = lens _jPrestoJob (\ s a -> s{_jPrestoJob = a})
61
true
true
0
9
26
48
25
23
null
null
rahulmutt/ghcvm
compiler/Eta/Prelude/THNames.hs
bsd-3-clause
pragSpecDIdKey = mkPreludeMiscIdUnique 331
61
pragSpecDIdKey = mkPreludeMiscIdUnique 331
61
pragSpecDIdKey = mkPreludeMiscIdUnique 331
61
false
false
0
5
22
9
4
5
null
null
rahulmutt/ghcvm
compiler/Eta/Utils/Pretty.hs
bsd-3-clause
layLeft _ _ = panic "layLeft: Unhandled case"
62
layLeft _ _ = panic "layLeft: Unhandled case"
62
layLeft _ _ = panic "layLeft: Unhandled case"
62
false
false
0
5
24
14
6
8
null
null
olsner/ghc
testsuite/tests/indexed-types/should_compile/T11361.hs
bsd-3-clause
inc _proxy Nothing (_, y) = Just y
35
inc _proxy Nothing (_, y) = Just y
35
inc _proxy Nothing (_, y) = Just y
35
false
false
0
5
8
25
11
14
null
null
nomeata/sat-britney
Data/DenseIntSet.hs
gpl-2.0
showsTreeHang :: Bool -> [String] -> IntSet -> ShowS showsTreeHang wide bars t = case t of Bin p m l r -> showsBars bars . showString (showBin p m) . showString "\n" . showWide wide bars . showsTreeHang wide (withBar bars) l . showWide wide bars . showsTreeHang wide (withEmpty bars) r Tip kx bm -> showsBars bars . showString " " . shows kx . showString " + " . showsBitMap bm . showString "\n" Nil -> showsBars bars . showString "|\n"
578
showsTreeHang :: Bool -> [String] -> IntSet -> ShowS showsTreeHang wide bars t = case t of Bin p m l r -> showsBars bars . showString (showBin p m) . showString "\n" . showWide wide bars . showsTreeHang wide (withBar bars) l . showWide wide bars . showsTreeHang wide (withEmpty bars) r Tip kx bm -> showsBars bars . showString " " . shows kx . showString " + " . showsBitMap bm . showString "\n" Nil -> showsBars bars . showString "|\n"
578
showsTreeHang wide bars t = case t of Bin p m l r -> showsBars bars . showString (showBin p m) . showString "\n" . showWide wide bars . showsTreeHang wide (withBar bars) l . showWide wide bars . showsTreeHang wide (withEmpty bars) r Tip kx bm -> showsBars bars . showString " " . shows kx . showString " + " . showsBitMap bm . showString "\n" Nil -> showsBars bars . showString "|\n"
525
false
true
0
16
225
199
90
109
null
null
mulderr/haskell-wamp
wamp-router/Network/Wamp/Broker.hs
mit
lookupSubscription :: SubscriptionStore -> SubId -> IO (Maybe Subscription) lookupSubscription (SubscriptionStore m) subId = do store <- readMVar m return $ getOne $ store @= subId -- | Lookup a 'Subscription' by 'Network.Wamp.Types.TopicUri'
248
lookupSubscription :: SubscriptionStore -> SubId -> IO (Maybe Subscription) lookupSubscription (SubscriptionStore m) subId = do store <- readMVar m return $ getOne $ store @= subId -- | Lookup a 'Subscription' by 'Network.Wamp.Types.TopicUri'
248
lookupSubscription (SubscriptionStore m) subId = do store <- readMVar m return $ getOne $ store @= subId -- | Lookup a 'Subscription' by 'Network.Wamp.Types.TopicUri'
172
false
true
0
10
38
70
32
38
null
null
acowley/ghc
compiler/hsSyn/HsBinds.hs
bsd-3-clause
isPragLSig :: LSig name -> Bool -- Identifies pragmas isPragLSig (L _ (SpecSig {})) = True
92
isPragLSig :: LSig name -> Bool isPragLSig (L _ (SpecSig {})) = True
70
isPragLSig (L _ (SpecSig {})) = True
38
true
true
0
9
17
37
19
18
null
null
juliagoda/givenfind
src/GivenFind/Geography.hs
bsd-3-clause
-- takes only numeric values from found degrees reduceDegChar :: Maybe [String] -> Maybe [String] reduceDegChar list = list >>= \b -> return $ map (filter(\x -> (isDigit x) || (isPunctuation x))) b
197
reduceDegChar :: Maybe [String] -> Maybe [String] reduceDegChar list = list >>= \b -> return $ map (filter(\x -> (isDigit x) || (isPunctuation x))) b
149
reduceDegChar list = list >>= \b -> return $ map (filter(\x -> (isDigit x) || (isPunctuation x))) b
99
true
true
0
15
32
79
41
38
null
null
cauterize-tools/caut-erl-ref
app/Cauterize/ErlangRef/Options.hs
bsd-3-clause
optParser :: Parser ErlangOpts optParser = ErlangOpts <$> strOption ( long "spec" <> short 's' <> metavar "FILE_PATH" <> help "Input Cauterize specification file." ) <*> strOption ( long "output" <> short 'o' <> metavar "DIRECTORY_PATH" <> help "Output Cauterize directory." )
314
optParser :: Parser ErlangOpts optParser = ErlangOpts <$> strOption ( long "spec" <> short 's' <> metavar "FILE_PATH" <> help "Input Cauterize specification file." ) <*> strOption ( long "output" <> short 'o' <> metavar "DIRECTORY_PATH" <> help "Output Cauterize directory." )
314
optParser = ErlangOpts <$> strOption ( long "spec" <> short 's' <> metavar "FILE_PATH" <> help "Input Cauterize specification file." ) <*> strOption ( long "output" <> short 'o' <> metavar "DIRECTORY_PATH" <> help "Output Cauterize directory." )
283
false
true
5
10
79
92
40
52
null
null
andorp/bead
src/Bead/Controller/Pages.hs
bsd-3-clause
isNewGroupAssessment (ViewModify (NewGroupAssessment _ _)) = True
65
isNewGroupAssessment (ViewModify (NewGroupAssessment _ _)) = True
65
isNewGroupAssessment (ViewModify (NewGroupAssessment _ _)) = True
65
false
false
0
9
6
23
11
12
null
null
Chouffe/skelme
src/Data.hs
bsd-3-clause
defineVar :: Env -> String -> LispVal -> IOThrowsError LispVal defineVar envRef var val = do alreadyBound <- liftIO $ isBound envRef var if alreadyBound then setVar envRef var val else do valRef <- liftIO $ newIORef val liftIO $ modifyIORef envRef ((var, valRef):) return $ val
297
defineVar :: Env -> String -> LispVal -> IOThrowsError LispVal defineVar envRef var val = do alreadyBound <- liftIO $ isBound envRef var if alreadyBound then setVar envRef var val else do valRef <- liftIO $ newIORef val liftIO $ modifyIORef envRef ((var, valRef):) return $ val
297
defineVar envRef var val = do alreadyBound <- liftIO $ isBound envRef var if alreadyBound then setVar envRef var val else do valRef <- liftIO $ newIORef val liftIO $ modifyIORef envRef ((var, valRef):) return $ val
234
false
true
0
13
66
110
53
57
null
null
pseudonom/persistent
persistent-template/Database/Persist/TH/Internal.hs
mit
mkUniqueKeys def = do c <- clause return $ FunD 'persistUniqueKeys [c] where clause = do xs <- forM (entityFields def) $ \fd -> do let x = fieldHaskell fd x' <- newName $ '_' : unpack (unHaskellName x) return (x, x') let pcs = map (go xs) $ entityUniques def let pat = ConP (mkName $ unpack $ unHaskellName $ entityHaskell def) (map (VarP . snd) xs) return $ normalClause [pat] (ListE pcs) go :: [(HaskellName, Name)] -> UniqueDef -> Exp go xs (UniqueDef name _ cols _) = foldl' (go' xs) (ConE (mkName $ unpack $ unHaskellName name)) (map fst cols) go' :: [(HaskellName, Name)] -> Exp -> HaskellName -> Exp go' xs front col = let Just col' = lookup col xs in front `AppE` VarE col'
838
mkUniqueKeys def = do c <- clause return $ FunD 'persistUniqueKeys [c] where clause = do xs <- forM (entityFields def) $ \fd -> do let x = fieldHaskell fd x' <- newName $ '_' : unpack (unHaskellName x) return (x, x') let pcs = map (go xs) $ entityUniques def let pat = ConP (mkName $ unpack $ unHaskellName $ entityHaskell def) (map (VarP . snd) xs) return $ normalClause [pat] (ListE pcs) go :: [(HaskellName, Name)] -> UniqueDef -> Exp go xs (UniqueDef name _ cols _) = foldl' (go' xs) (ConE (mkName $ unpack $ unHaskellName name)) (map fst cols) go' :: [(HaskellName, Name)] -> Exp -> HaskellName -> Exp go' xs front col = let Just col' = lookup col xs in front `AppE` VarE col'
838
mkUniqueKeys def = do c <- clause return $ FunD 'persistUniqueKeys [c] where clause = do xs <- forM (entityFields def) $ \fd -> do let x = fieldHaskell fd x' <- newName $ '_' : unpack (unHaskellName x) return (x, x') let pcs = map (go xs) $ entityUniques def let pat = ConP (mkName $ unpack $ unHaskellName $ entityHaskell def) (map (VarP . snd) xs) return $ normalClause [pat] (ListE pcs) go :: [(HaskellName, Name)] -> UniqueDef -> Exp go xs (UniqueDef name _ cols _) = foldl' (go' xs) (ConE (mkName $ unpack $ unHaskellName name)) (map fst cols) go' :: [(HaskellName, Name)] -> Exp -> HaskellName -> Exp go' xs front col = let Just col' = lookup col xs in front `AppE` VarE col'
838
false
false
0
16
286
358
175
183
null
null
jecisc/TP_PF_L3
PF-TP4/.dist-buildwrapper/dist/build/autogen/Paths_PF_TP4.hs
mit
getLibexecDir = catchIO (getEnv "PF_TP4_libexecdir") (\_ -> return libexecdir)
78
getLibexecDir = catchIO (getEnv "PF_TP4_libexecdir") (\_ -> return libexecdir)
78
getLibexecDir = catchIO (getEnv "PF_TP4_libexecdir") (\_ -> return libexecdir)
78
false
false
1
8
8
31
14
17
null
null
aelve/json-x
tests/UnitTests.hs
bsd-3-clause
roundTripCamel :: String -> Assertion roundTripCamel name = assertEqual "" name (camelFrom '_' $ camelTo '_' name)
114
roundTripCamel :: String -> Assertion roundTripCamel name = assertEqual "" name (camelFrom '_' $ camelTo '_' name)
114
roundTripCamel name = assertEqual "" name (camelFrom '_' $ camelTo '_' name)
76
false
true
0
8
16
40
19
21
null
null
nomeata/L-seed
src/Lseed/Constants.hs
bsd-3-clause
-- | Minimum radial angular distance between two branches minAngle :: Double minAngle = pi/20
93
minAngle :: Double minAngle = pi/20
35
minAngle = pi/20
16
true
true
0
5
14
16
9
7
null
null
AndrewRademacher/wai
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs
mit
checkPriority :: Priority -> StreamId -> IO () checkPriority p me | dep == me = E.throwIO $ StreamError ProtocolError me | otherwise = return () where dep = streamDependency p
185
checkPriority :: Priority -> StreamId -> IO () checkPriority p me | dep == me = E.throwIO $ StreamError ProtocolError me | otherwise = return () where dep = streamDependency p
185
checkPriority p me | dep == me = E.throwIO $ StreamError ProtocolError me | otherwise = return () where dep = streamDependency p
138
false
true
1
8
40
73
34
39
null
null
wilbowma/accelerate
Data/Array/Accelerate/CUDA/CodeGen.hs
bsd-3-clause
codeGenPrim (PrimMax ty) [a,b] = codeGenMax ty a b
62
codeGenPrim (PrimMax ty) [a,b] = codeGenMax ty a b
62
codeGenPrim (PrimMax ty) [a,b] = codeGenMax ty a b
62
false
false
0
7
20
30
15
15
null
null
andorp/bead
src/Bead/Persistence/SQL/Registration.hs
bsd-3-clause
loadUserReg :: Domain.UserRegKey -> Persist Domain.UserRegistration loadUserReg key = do value <- get (toEntityKey key) return $ maybe (persistError "loadUserReg" $ "no registration key was found:" ++ show key) toDomainValue value #ifdef TEST
271
loadUserReg :: Domain.UserRegKey -> Persist Domain.UserRegistration loadUserReg key = do value <- get (toEntityKey key) return $ maybe (persistError "loadUserReg" $ "no registration key was found:" ++ show key) toDomainValue value #ifdef TEST
271
loadUserReg key = do value <- get (toEntityKey key) return $ maybe (persistError "loadUserReg" $ "no registration key was found:" ++ show key) toDomainValue value #ifdef TEST
203
false
true
0
12
61
73
34
39
null
null
lpeterse/koka
src/Type/TypeVar.hs
apache-2.0
tvsInsertAll :: [TypeVar] -> Tvs -> Tvs tvsInsertAll vars (Tvs set) = Tvs (foldr S.insert set vars)
101
tvsInsertAll :: [TypeVar] -> Tvs -> Tvs tvsInsertAll vars (Tvs set) = Tvs (foldr S.insert set vars)
101
tvsInsertAll vars (Tvs set) = Tvs (foldr S.insert set vars)
61
false
true
0
8
18
48
24
24
null
null
thoughtpolice/cabal
Cabal/Distribution/PackageDescription/Check.hs
bsd-3-clause
checkTestSuite :: PackageDescription -> TestSuite -> [PackageCheck] checkTestSuite pkg test = catMaybes [ case testInterface test of TestSuiteUnsupported tt@(TestTypeUnknown _ _) -> Just $ PackageBuildWarning $ quote (display tt) ++ " is not a known type of test suite. " ++ "The known test suite types are: " ++ commaSep (map display knownTestTypes) TestSuiteUnsupported tt -> Just $ PackageBuildWarning $ quote (display tt) ++ " is not a supported test suite version. " ++ "The known test suite types are: " ++ commaSep (map display knownTestTypes) _ -> Nothing , check (not $ null moduleDuplicates) $ PackageBuildImpossible $ "Duplicate modules in test suite '" ++ testName test ++ "': " ++ commaSep (map display moduleDuplicates) , check mainIsWrongExt $ PackageBuildImpossible $ "The 'main-is' field must specify a '.hs' or '.lhs' file " ++ "(even if it is generated by a preprocessor), " ++ "or it may specify a C/C++/obj-C source file." , checkSpecVersion pkg [1,17] (mainIsNotHsExt && not mainIsWrongExt) $ PackageDistInexcusable $ "The package uses a C/C++/obj-C source file for the 'main-is' field. " ++ "To use this feature you must specify 'cabal-version: >= 1.18'." -- Test suites might be built as (internal) libraries named after -- the test suite and thus their names must not clash with the -- name of the package. , check libNameClash $ PackageBuildImpossible $ "The test suite " ++ testName test ++ " has the same name as the package." ] where moduleDuplicates = dups $ testModules test mainIsWrongExt = case testInterface test of TestSuiteExeV10 _ f -> not $ fileExtensionSupportedLanguage f _ -> False mainIsNotHsExt = case testInterface test of TestSuiteExeV10 _ f -> takeExtension f `notElem` [".hs", ".lhs"] _ -> False libNameClash = testName test `elem` [ libName | _lib <- maybeToList (library pkg) , let PackageName libName = pkgName (package pkg) ]
2,327
checkTestSuite :: PackageDescription -> TestSuite -> [PackageCheck] checkTestSuite pkg test = catMaybes [ case testInterface test of TestSuiteUnsupported tt@(TestTypeUnknown _ _) -> Just $ PackageBuildWarning $ quote (display tt) ++ " is not a known type of test suite. " ++ "The known test suite types are: " ++ commaSep (map display knownTestTypes) TestSuiteUnsupported tt -> Just $ PackageBuildWarning $ quote (display tt) ++ " is not a supported test suite version. " ++ "The known test suite types are: " ++ commaSep (map display knownTestTypes) _ -> Nothing , check (not $ null moduleDuplicates) $ PackageBuildImpossible $ "Duplicate modules in test suite '" ++ testName test ++ "': " ++ commaSep (map display moduleDuplicates) , check mainIsWrongExt $ PackageBuildImpossible $ "The 'main-is' field must specify a '.hs' or '.lhs' file " ++ "(even if it is generated by a preprocessor), " ++ "or it may specify a C/C++/obj-C source file." , checkSpecVersion pkg [1,17] (mainIsNotHsExt && not mainIsWrongExt) $ PackageDistInexcusable $ "The package uses a C/C++/obj-C source file for the 'main-is' field. " ++ "To use this feature you must specify 'cabal-version: >= 1.18'." -- Test suites might be built as (internal) libraries named after -- the test suite and thus their names must not clash with the -- name of the package. , check libNameClash $ PackageBuildImpossible $ "The test suite " ++ testName test ++ " has the same name as the package." ] where moduleDuplicates = dups $ testModules test mainIsWrongExt = case testInterface test of TestSuiteExeV10 _ f -> not $ fileExtensionSupportedLanguage f _ -> False mainIsNotHsExt = case testInterface test of TestSuiteExeV10 _ f -> takeExtension f `notElem` [".hs", ".lhs"] _ -> False libNameClash = testName test `elem` [ libName | _lib <- maybeToList (library pkg) , let PackageName libName = pkgName (package pkg) ]
2,327
checkTestSuite pkg test = catMaybes [ case testInterface test of TestSuiteUnsupported tt@(TestTypeUnknown _ _) -> Just $ PackageBuildWarning $ quote (display tt) ++ " is not a known type of test suite. " ++ "The known test suite types are: " ++ commaSep (map display knownTestTypes) TestSuiteUnsupported tt -> Just $ PackageBuildWarning $ quote (display tt) ++ " is not a supported test suite version. " ++ "The known test suite types are: " ++ commaSep (map display knownTestTypes) _ -> Nothing , check (not $ null moduleDuplicates) $ PackageBuildImpossible $ "Duplicate modules in test suite '" ++ testName test ++ "': " ++ commaSep (map display moduleDuplicates) , check mainIsWrongExt $ PackageBuildImpossible $ "The 'main-is' field must specify a '.hs' or '.lhs' file " ++ "(even if it is generated by a preprocessor), " ++ "or it may specify a C/C++/obj-C source file." , checkSpecVersion pkg [1,17] (mainIsNotHsExt && not mainIsWrongExt) $ PackageDistInexcusable $ "The package uses a C/C++/obj-C source file for the 'main-is' field. " ++ "To use this feature you must specify 'cabal-version: >= 1.18'." -- Test suites might be built as (internal) libraries named after -- the test suite and thus their names must not clash with the -- name of the package. , check libNameClash $ PackageBuildImpossible $ "The test suite " ++ testName test ++ " has the same name as the package." ] where moduleDuplicates = dups $ testModules test mainIsWrongExt = case testInterface test of TestSuiteExeV10 _ f -> not $ fileExtensionSupportedLanguage f _ -> False mainIsNotHsExt = case testInterface test of TestSuiteExeV10 _ f -> takeExtension f `notElem` [".hs", ".lhs"] _ -> False libNameClash = testName test `elem` [ libName | _lib <- maybeToList (library pkg) , let PackageName libName = pkgName (package pkg) ]
2,259
false
true
5
16
751
441
217
224
null
null
ktvoelker/hjc
Util.hs
gpl-3.0
compileName :: (GetName a) => a -> Expr compileName bndr = let (maybeModName, varName) = hsName bndr in case maybeModName of Nothing -> Use varName Just modName -> Index (Index (ENative "M") (Literal $ LitStr modName)) $ Literal $ LitStr varName
269
compileName :: (GetName a) => a -> Expr compileName bndr = let (maybeModName, varName) = hsName bndr in case maybeModName of Nothing -> Use varName Just modName -> Index (Index (ENative "M") (Literal $ LitStr modName)) $ Literal $ LitStr varName
269
compileName bndr = let (maybeModName, varName) = hsName bndr in case maybeModName of Nothing -> Use varName Just modName -> Index (Index (ENative "M") (Literal $ LitStr modName)) $ Literal $ LitStr varName
229
false
true
0
17
64
113
53
60
null
null
joshuaclayton/unused
src/Unused/ResultsClassifier/Types.hs
mit
displayFailure :: T.Text -> Y.Parser a displayFailure t = fail $ "Parse error: '" ++ T.unpack t ++ "' is not a valid key in a singleOnly matcher"
145
displayFailure :: T.Text -> Y.Parser a displayFailure t = fail $ "Parse error: '" ++ T.unpack t ++ "' is not a valid key in a singleOnly matcher"
145
displayFailure t = fail $ "Parse error: '" ++ T.unpack t ++ "' is not a valid key in a singleOnly matcher"
106
false
true
0
8
27
42
20
22
null
null
romanb/amazonka
amazonka-ec2/gen/Network/AWS/EC2/DescribeKeyPairs.hs
mpl-2.0
-- | 'DescribeKeyPairs' constructor. -- -- The fields accessible through corresponding lenses are: -- -- * 'dkp1DryRun' @::@ 'Maybe' 'Bool' -- -- * 'dkp1Filters' @::@ ['Filter'] -- -- * 'dkp1KeyNames' @::@ ['Text'] -- describeKeyPairs :: DescribeKeyPairs describeKeyPairs = DescribeKeyPairs { _dkp1DryRun = Nothing , _dkp1KeyNames = mempty , _dkp1Filters = mempty }
384
describeKeyPairs :: DescribeKeyPairs describeKeyPairs = DescribeKeyPairs { _dkp1DryRun = Nothing , _dkp1KeyNames = mempty , _dkp1Filters = mempty }
166
describeKeyPairs = DescribeKeyPairs { _dkp1DryRun = Nothing , _dkp1KeyNames = mempty , _dkp1Filters = mempty }
129
true
true
0
7
70
45
30
15
null
null
holdenlee/notebook
src/Utilities.hs
mit
-- * Maps and Lists isInitialSegment :: Eq a => [a] -> [a] -> Bool isInitialSegment = isJust `c2` stripPrefix
110
isInitialSegment :: Eq a => [a] -> [a] -> Bool isInitialSegment = isJust `c2` stripPrefix
89
isInitialSegment = isJust `c2` stripPrefix
42
true
true
0
8
20
39
22
17
null
null
yupferris/write-you-a-haskell
chapter8/protohaskell/Pretty.hs
mit
------------------------------------------------------------------------------- -- Kinds ------------------------------------------------------------------------------- isKArrow :: Kind -> Bool isKArrow KArr{} = True
217
isKArrow :: Kind -> Bool isKArrow KArr{} = True
47
isKArrow KArr{} = True
22
true
true
0
6
13
25
14
11
null
null
fmapfmapfmap/amazonka
gen/src/Gen/AST/Subst.hs
mpl-2.0
verify :: (MonadState (Env a) m, MonadError e m) => Id -> Format (Id -> LText.Text) (Id -> e) -> m () verify n msg = do p <- uses memo (Map.member n) when p . throwError $ format (msg % " for " % iprimary) n
244
verify :: (MonadState (Env a) m, MonadError e m) => Id -> Format (Id -> LText.Text) (Id -> e) -> m () verify n msg = do p <- uses memo (Map.member n) when p . throwError $ format (msg % " for " % iprimary) n
244
verify n msg = do p <- uses memo (Map.member n) when p . throwError $ format (msg % " for " % iprimary) n
121
false
true
0
12
83
130
62
68
null
null
ku-fpg/kansas-amber
System/Hardware/Haskino/Protocol.hs
bsd-3-clause
packageCommand (WriteRemoteRefBE (RemoteRefB i) e) = addWriteRefCommand EXPR_BOOL i e
85
packageCommand (WriteRemoteRefBE (RemoteRefB i) e) = addWriteRefCommand EXPR_BOOL i e
85
packageCommand (WriteRemoteRefBE (RemoteRefB i) e) = addWriteRefCommand EXPR_BOOL i e
85
false
false
0
9
9
30
14
16
null
null
erlandsona/caldwell-api
library/Config.hs
mit
runDb :: (MonadReader Settings m, MonadIO m) => SqlPersistT IO b -> m b runDb query = do pool <- asks getPool liftIO $ runSqlPool query pool -- | Looks up a setting in the environment, with a provided default, and -- 'read's that information into the inferred type.
274
runDb :: (MonadReader Settings m, MonadIO m) => SqlPersistT IO b -> m b runDb query = do pool <- asks getPool liftIO $ runSqlPool query pool -- | Looks up a setting in the environment, with a provided default, and -- 'read's that information into the inferred type.
274
runDb query = do pool <- asks getPool liftIO $ runSqlPool query pool -- | Looks up a setting in the environment, with a provided default, and -- 'read's that information into the inferred type.
202
false
true
0
8
57
67
32
35
null
null
lynnard/cocos2d-hs
src/Graphics/UI/Cocos2d/Director.hs
bsd-3-clause
gLView_getFrameZoomFactor :: (GLViewValue arg'1) => arg'1 -> HoppyP.IO HoppyP.Float gLView_getFrameZoomFactor arg'1 = withGLViewPtr arg'1 $ HoppyP.flip HoppyFHR.withCppPtr $ \arg'1' -> HoppyP.fmap HoppyP.realToFrac (gLView_getFrameZoomFactor' arg'1')
256
gLView_getFrameZoomFactor :: (GLViewValue arg'1) => arg'1 -> HoppyP.IO HoppyP.Float gLView_getFrameZoomFactor arg'1 = withGLViewPtr arg'1 $ HoppyP.flip HoppyFHR.withCppPtr $ \arg'1' -> HoppyP.fmap HoppyP.realToFrac (gLView_getFrameZoomFactor' arg'1')
256
gLView_getFrameZoomFactor arg'1 = withGLViewPtr arg'1 $ HoppyP.flip HoppyFHR.withCppPtr $ \arg'1' -> HoppyP.fmap HoppyP.realToFrac (gLView_getFrameZoomFactor' arg'1')
172
false
true
0
8
29
73
35
38
null
null
beni55/egison
hs-src/Language/Egison/Primitives.hs
mit
readChar :: PrimitiveFunc readChar = noArg $ return $ makeIO $ liftIO $ liftM Char getChar
90
readChar :: PrimitiveFunc readChar = noArg $ return $ makeIO $ liftIO $ liftM Char getChar
90
readChar = noArg $ return $ makeIO $ liftIO $ liftM Char getChar
64
false
true
0
8
15
32
16
16
null
null
kawu/concraft
src/NLP/Concraft/DAG/DisambSeg.hs
bsd-2-clause
probsCRF :: (X.Word w, Ord t) => CRF.ProbType -> Disamb t -> X.Sent w t -> CRF.SentL Ob P.Atom probsCRF probTyp dmb = CRF.probs probTyp (crf dmb) . schematize schema . X.mapSent (split (tiers dmb) . simplify dmb) where schema = fromConf (schemaConf dmb) -------------------------- -- Disambiguation -------------------------- -- -- | Perform disambiguation. -- disamb :: (X.Word w, Ord t) => Disamb t -> X.Sent w t -> DAG () (X.WMap t) -- disamb probTyp dmb = fmap X.tags . probsSent probTyp dmb -- | Perform disambiguation.
555
probsCRF :: (X.Word w, Ord t) => CRF.ProbType -> Disamb t -> X.Sent w t -> CRF.SentL Ob P.Atom probsCRF probTyp dmb = CRF.probs probTyp (crf dmb) . schematize schema . X.mapSent (split (tiers dmb) . simplify dmb) where schema = fromConf (schemaConf dmb) -------------------------- -- Disambiguation -------------------------- -- -- | Perform disambiguation. -- disamb :: (X.Word w, Ord t) => Disamb t -> X.Sent w t -> DAG () (X.WMap t) -- disamb probTyp dmb = fmap X.tags . probsSent probTyp dmb -- | Perform disambiguation.
555
probsCRF probTyp dmb = CRF.probs probTyp (crf dmb) . schematize schema . X.mapSent (split (tiers dmb) . simplify dmb) where schema = fromConf (schemaConf dmb) -------------------------- -- Disambiguation -------------------------- -- -- | Perform disambiguation. -- disamb :: (X.Word w, Ord t) => Disamb t -> X.Sent w t -> DAG () (X.WMap t) -- disamb probTyp dmb = fmap X.tags . probsSent probTyp dmb -- | Perform disambiguation.
447
false
true
3
11
117
147
70
77
null
null
d0kt0r0/estuary
client/src/Estuary/Widgets/View.hs
gpl-3.0
viewWidget _ (Example n t) = do b <- clickableDiv "example code-font" $ text t bTime <- performEvent $ fmap (liftIO . const getCurrentTime) b hint $ fmap (\et -> ZoneHint 1 (TextProgram (Live (n,t,et) L3))) bTime return never
233
viewWidget _ (Example n t) = do b <- clickableDiv "example code-font" $ text t bTime <- performEvent $ fmap (liftIO . const getCurrentTime) b hint $ fmap (\et -> ZoneHint 1 (TextProgram (Live (n,t,et) L3))) bTime return never
233
viewWidget _ (Example n t) = do b <- clickableDiv "example code-font" $ text t bTime <- performEvent $ fmap (liftIO . const getCurrentTime) b hint $ fmap (\et -> ZoneHint 1 (TextProgram (Live (n,t,et) L3))) bTime return never
233
false
false
1
17
46
119
55
64
null
null
acowley/ghc
compiler/main/HscTypes.hs
bsd-3-clause
hscSourceString' :: DynFlags -> ModuleName -> HscSource -> String hscSourceString' _ _ HsSrcFile = ""
103
hscSourceString' :: DynFlags -> ModuleName -> HscSource -> String hscSourceString' _ _ HsSrcFile = ""
103
hscSourceString' _ _ HsSrcFile = ""
37
false
true
0
9
16
36
16
20
null
null
sol/pandoc
src/Text/Pandoc/CharacterReferences.hs
gpl-2.0
-- | Parse character entity. characterReference :: GenParser Char st Char characterReference = try $ do char '&' character <- numRef <|> entity char ';' return character
179
characterReference :: GenParser Char st Char characterReference = try $ do char '&' character <- numRef <|> entity char ';' return character
150
characterReference = try $ do char '&' character <- numRef <|> entity char ';' return character
105
true
true
0
9
36
52
23
29
null
null
Concomitant/LambdaHack
Game/LambdaHack/Server/ProtocolServer.hs
bsd-3-clause
-- | Update connections to the new definition of factions. -- Connect to clients in old or newly spawned threads -- that read and write directly to the channels. updateConn :: (MonadAtomic m, MonadServerReadRequest m) => (FactionId -> ChanServer ResponseUI RequestUI -> IO ()) -> (FactionId -> ChanServer ResponseAI RequestAI -> IO ()) -> m () updateConn executorUI executorAI = do -- Prepare connections based on factions. oldD <- getDict let mkChanServer :: IO (ChanServer resp req) mkChanServer = do responseS <- STM.newTQueueIO requestS <- STM.newTQueueIO return $! ChanServer{..} addConn :: FactionId -> Faction -> IO ConnServerFaction addConn fid fact = case EM.lookup fid oldD of Just conns -> return conns -- share old conns and threads Nothing | fhasUI $ gplayer fact -> do connS <- mkChanServer connAI <- mkChanServer return (Just connS, connAI) Nothing -> do connAI <- mkChanServer return (Nothing, connAI) factionD <- getsState sfactionD d <- liftIO $ mapWithKeyM addConn factionD let newD = d `EM.union` oldD -- never kill old clients putDict newD -- Spawn client threads. let toSpawn = newD EM.\\ oldD let forkUI fid connS = forkChild childrenServer $ executorUI fid connS forkAI fid connS = forkChild childrenServer $ executorAI fid connS forkClient fid (connUI, connAI) = do -- When a connection is reused, clients are not respawned, -- even if UI usage changes, but it works OK thanks to UI faction -- clients distinguished by positive FactionId numbers. forkAI fid connAI -- AI clients always needed, e.g., for auto-explore maybe (return ()) (forkUI fid) connUI liftIO $ mapWithKeyM_ forkClient toSpawn
1,922
updateConn :: (MonadAtomic m, MonadServerReadRequest m) => (FactionId -> ChanServer ResponseUI RequestUI -> IO ()) -> (FactionId -> ChanServer ResponseAI RequestAI -> IO ()) -> m () updateConn executorUI executorAI = do -- Prepare connections based on factions. oldD <- getDict let mkChanServer :: IO (ChanServer resp req) mkChanServer = do responseS <- STM.newTQueueIO requestS <- STM.newTQueueIO return $! ChanServer{..} addConn :: FactionId -> Faction -> IO ConnServerFaction addConn fid fact = case EM.lookup fid oldD of Just conns -> return conns -- share old conns and threads Nothing | fhasUI $ gplayer fact -> do connS <- mkChanServer connAI <- mkChanServer return (Just connS, connAI) Nothing -> do connAI <- mkChanServer return (Nothing, connAI) factionD <- getsState sfactionD d <- liftIO $ mapWithKeyM addConn factionD let newD = d `EM.union` oldD -- never kill old clients putDict newD -- Spawn client threads. let toSpawn = newD EM.\\ oldD let forkUI fid connS = forkChild childrenServer $ executorUI fid connS forkAI fid connS = forkChild childrenServer $ executorAI fid connS forkClient fid (connUI, connAI) = do -- When a connection is reused, clients are not respawned, -- even if UI usage changes, but it works OK thanks to UI faction -- clients distinguished by positive FactionId numbers. forkAI fid connAI -- AI clients always needed, e.g., for auto-explore maybe (return ()) (forkUI fid) connUI liftIO $ mapWithKeyM_ forkClient toSpawn
1,760
updateConn executorUI executorAI = do -- Prepare connections based on factions. oldD <- getDict let mkChanServer :: IO (ChanServer resp req) mkChanServer = do responseS <- STM.newTQueueIO requestS <- STM.newTQueueIO return $! ChanServer{..} addConn :: FactionId -> Faction -> IO ConnServerFaction addConn fid fact = case EM.lookup fid oldD of Just conns -> return conns -- share old conns and threads Nothing | fhasUI $ gplayer fact -> do connS <- mkChanServer connAI <- mkChanServer return (Just connS, connAI) Nothing -> do connAI <- mkChanServer return (Nothing, connAI) factionD <- getsState sfactionD d <- liftIO $ mapWithKeyM addConn factionD let newD = d `EM.union` oldD -- never kill old clients putDict newD -- Spawn client threads. let toSpawn = newD EM.\\ oldD let forkUI fid connS = forkChild childrenServer $ executorUI fid connS forkAI fid connS = forkChild childrenServer $ executorAI fid connS forkClient fid (connUI, connAI) = do -- When a connection is reused, clients are not respawned, -- even if UI usage changes, but it works OK thanks to UI faction -- clients distinguished by positive FactionId numbers. forkAI fid connAI -- AI clients always needed, e.g., for auto-explore maybe (return ()) (forkUI fid) connUI liftIO $ mapWithKeyM_ forkClient toSpawn
1,485
true
true
0
18
559
453
216
237
null
null
ancientlanguage/haskell-analysis
prepare/src/Prepare/Decompose.hs
mit
decomposeChar '\xF901' = "\x66F4"
33
decomposeChar '\xF901' = "\x66F4"
33
decomposeChar '\xF901' = "\x66F4"
33
false
false
1
5
3
13
4
9
null
null
leshchevds/ganeti
src/Ganeti/Constants.hs
bsd-2-clause
beMaxmem :: String beMaxmem = "maxmem"
38
beMaxmem :: String beMaxmem = "maxmem"
38
beMaxmem = "maxmem"
19
false
true
0
4
5
11
6
5
null
null
isovector/haystack
src/Utils.hs
bsd-3-clause
unwrapPair :: Monad m => (a, m b) -> m (a, b) unwrapPair (a, mb) = do b <- mb return (a, b)
115
unwrapPair :: Monad m => (a, m b) -> m (a, b) unwrapPair (a, mb) = do b <- mb return (a, b)
115
unwrapPair (a, mb) = do b <- mb return (a, b)
69
false
true
0
8
46
72
36
36
null
null
BartAdv/Idris-dev
src/Idris/Reflection.hs
bsd-3-clause
reflectErr x = raw_apply (Var (sNS (sUN "Msg") ["Errors", "Reflection", "Language"])) [RConstant . Str $ "Default reflection: " ++ show x]
138
reflectErr x = raw_apply (Var (sNS (sUN "Msg") ["Errors", "Reflection", "Language"])) [RConstant . Str $ "Default reflection: " ++ show x]
138
reflectErr x = raw_apply (Var (sNS (sUN "Msg") ["Errors", "Reflection", "Language"])) [RConstant . Str $ "Default reflection: " ++ show x]
138
false
false
0
11
20
61
31
30
null
null
Bodigrim/katas
src/haskell/B-Writing-applicative-parsers-from-scratch.hs
bsd-2-clause
-- | Given a parser with a function value and another parser, parse the function -- first and then the value, return a parser which applies the function to the -- value. (<@>) :: Parser (a -> b) -> Parser a -> Parser b pf <@> px = P $ \xs -> concatMap (\(ys, f) -> unP (pmap f px) ys) (unP pf xs)
296
(<@>) :: Parser (a -> b) -> Parser a -> Parser b pf <@> px = P $ \xs -> concatMap (\(ys, f) -> unP (pmap f px) ys) (unP pf xs)
126
pf <@> px = P $ \xs -> concatMap (\(ys, f) -> unP (pmap f px) ys) (unP pf xs)
77
true
true
2
10
63
100
51
49
null
null
kalhauge/vagnplayer
src/Data/Control.hs
mit
control (Control Prev) = MPD.previous
37
control (Control Prev) = MPD.previous
37
control (Control Prev) = MPD.previous
37
false
false
0
6
4
18
8
10
null
null
khalilfazal/sscript
test/Data/Char/SScriptSpec.hs
bsd-3-clause
spec :: Spec spec = do context "Data.Char.SScript.subscript" $ do it "should work for a single char" $ subscript '0' `shouldBe` '₀' it "should work for all single digit decimals" $ convertDecimals subscript `shouldBe` "₀₁₂₃₄₅₆₇₈₉" it "should work for +-=() symbols" $ map subscript symbols `shouldBe` "₊₋₌₍₎" it "should work for selected letters" $ map subscript "aeioruvx" `shouldBe` "ₐₑᵢₒᵣᵤᵥₓ" it "should return the same char if it can't be subscripted" $ shouldBeFixed (map subscript) "AEIORUVX" context "Data.Char.SScript.superscript" $ do it "should work for a single char" $ superscript '0' `shouldBe` '⁰' it "should work for all single digit decimals" $ convertDecimals superscript `shouldBe` "⁰¹²³⁴⁵⁶⁷⁸⁹" it "should work for +-=() symbols" $ map superscript symbols `shouldBe` "⁺⁻⁼⁽⁾" it "should work for all letters except qCFQSVXYZ" $ map superscript "abcdefghijklmnoprstuvwxyzABDEGHIJKLMNOPRTUW" `shouldBe` "ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁᵂ" it "should return the same char if it can't be superscripted" $ shouldBeFixed (map superscript) "qCFQSVXYZ" context "Data.Char.SScript.formatSS" $ do it "should convert chars following an underscore to its subscript, \ \like in the chemical formula for dravite: \ \https://en.wikipedia.org/wiki/Tourmaline#Dravite" $ formatSS "NaMg_{3}(Al,Mg)_6B_3Si_6O_{27}(OH)" `shouldBe` "NaMg₃(Al,Mg)₆B₃Si₆O₂₇(OH)" it "should convert chars following a caret to its superscript" $ formatSS "(a^n)^{r+s}" `shouldBe` "(aⁿ)ʳ⁺ˢ" it "should convert strings containing a mixture of \ \underscores and carets" $ formatSS "(x_{12} - x_{21})^{25} + (y_1 - y_2)^2" `shouldBe` "(x₁₂ - x₂₁)²⁵ + (y₁ - y₂)²"
2,026
spec :: Spec spec = do context "Data.Char.SScript.subscript" $ do it "should work for a single char" $ subscript '0' `shouldBe` '₀' it "should work for all single digit decimals" $ convertDecimals subscript `shouldBe` "₀₁₂₃₄₅₆₇₈₉" it "should work for +-=() symbols" $ map subscript symbols `shouldBe` "₊₋₌₍₎" it "should work for selected letters" $ map subscript "aeioruvx" `shouldBe` "ₐₑᵢₒᵣᵤᵥₓ" it "should return the same char if it can't be subscripted" $ shouldBeFixed (map subscript) "AEIORUVX" context "Data.Char.SScript.superscript" $ do it "should work for a single char" $ superscript '0' `shouldBe` '⁰' it "should work for all single digit decimals" $ convertDecimals superscript `shouldBe` "⁰¹²³⁴⁵⁶⁷⁸⁹" it "should work for +-=() symbols" $ map superscript symbols `shouldBe` "⁺⁻⁼⁽⁾" it "should work for all letters except qCFQSVXYZ" $ map superscript "abcdefghijklmnoprstuvwxyzABDEGHIJKLMNOPRTUW" `shouldBe` "ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁᵂ" it "should return the same char if it can't be superscripted" $ shouldBeFixed (map superscript) "qCFQSVXYZ" context "Data.Char.SScript.formatSS" $ do it "should convert chars following an underscore to its subscript, \ \like in the chemical formula for dravite: \ \https://en.wikipedia.org/wiki/Tourmaline#Dravite" $ formatSS "NaMg_{3}(Al,Mg)_6B_3Si_6O_{27}(OH)" `shouldBe` "NaMg₃(Al,Mg)₆B₃Si₆O₂₇(OH)" it "should convert chars following a caret to its superscript" $ formatSS "(a^n)^{r+s}" `shouldBe` "(aⁿ)ʳ⁺ˢ" it "should convert strings containing a mixture of \ \underscores and carets" $ formatSS "(x_{12} - x_{21})^{25} + (y_1 - y_2)^2" `shouldBe` "(x₁₂ - x₂₁)²⁵ + (y₁ - y₂)²"
2,026
spec = do context "Data.Char.SScript.subscript" $ do it "should work for a single char" $ subscript '0' `shouldBe` '₀' it "should work for all single digit decimals" $ convertDecimals subscript `shouldBe` "₀₁₂₃₄₅₆₇₈₉" it "should work for +-=() symbols" $ map subscript symbols `shouldBe` "₊₋₌₍₎" it "should work for selected letters" $ map subscript "aeioruvx" `shouldBe` "ₐₑᵢₒᵣᵤᵥₓ" it "should return the same char if it can't be subscripted" $ shouldBeFixed (map subscript) "AEIORUVX" context "Data.Char.SScript.superscript" $ do it "should work for a single char" $ superscript '0' `shouldBe` '⁰' it "should work for all single digit decimals" $ convertDecimals superscript `shouldBe` "⁰¹²³⁴⁵⁶⁷⁸⁹" it "should work for +-=() symbols" $ map superscript symbols `shouldBe` "⁺⁻⁼⁽⁾" it "should work for all letters except qCFQSVXYZ" $ map superscript "abcdefghijklmnoprstuvwxyzABDEGHIJKLMNOPRTUW" `shouldBe` "ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁᵂ" it "should return the same char if it can't be superscripted" $ shouldBeFixed (map superscript) "qCFQSVXYZ" context "Data.Char.SScript.formatSS" $ do it "should convert chars following an underscore to its subscript, \ \like in the chemical formula for dravite: \ \https://en.wikipedia.org/wiki/Tourmaline#Dravite" $ formatSS "NaMg_{3}(Al,Mg)_6B_3Si_6O_{27}(OH)" `shouldBe` "NaMg₃(Al,Mg)₆B₃Si₆O₂₇(OH)" it "should convert chars following a caret to its superscript" $ formatSS "(a^n)^{r+s}" `shouldBe` "(aⁿ)ʳ⁺ˢ" it "should convert strings containing a mixture of \ \underscores and carets" $ formatSS "(x_{12} - x_{21})^{25} + (y_1 - y_2)^2" `shouldBe` "(x₁₂ - x₂₁)²⁵ + (y₁ - y₂)²"
2,013
false
true
0
13
600
300
139
161
null
null
nevrenato/Hets_Fork
Lottery/Test.hs
gpl-2.0
{- delSemis entfernt alle Semikolons aus einem String -} delSemis [] = []
79
delSemis [] = []
22
delSemis [] = []
22
true
false
0
6
18
14
7
7
null
null