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
spacekitteh/smcghc
ghc/Main.hs
bsd-3-clause
showPackages, dumpPackages, dumpPackagesSimple :: DynFlags -> IO () showPackages dflags = putStrLn (showSDoc dflags (pprPackages dflags))
143
showPackages, dumpPackages, dumpPackagesSimple :: DynFlags -> IO () showPackages dflags = putStrLn (showSDoc dflags (pprPackages dflags))
143
showPackages dflags = putStrLn (showSDoc dflags (pprPackages dflags))
75
false
true
0
9
21
44
23
21
null
null
ksallberg/valuecalc
Text/HTML/ValueCalc/Scraping.hs
unlicense
getSubId ((TagOpen _ localLs):ts) id err = do let fTags = ["yes" | ("id", x) <- localLs, x == id] case (length fTags) > 0 of True -> do let (TagText toReturn) = head ts return toReturn False -> do getSubId ts id err
263
getSubId ((TagOpen _ localLs):ts) id err = do let fTags = ["yes" | ("id", x) <- localLs, x == id] case (length fTags) > 0 of True -> do let (TagText toReturn) = head ts return toReturn False -> do getSubId ts id err
263
getSubId ((TagOpen _ localLs):ts) id err = do let fTags = ["yes" | ("id", x) <- localLs, x == id] case (length fTags) > 0 of True -> do let (TagText toReturn) = head ts return toReturn False -> do getSubId ts id err
263
false
false
1
17
91
126
59
67
null
null
brendanhay/gogol
gogol-docs/gen/Network/Google/Docs/Types/Product.hs
mpl-2.0
-- | Creates bullets for paragraphs. reqCreateParagraphBullets :: Lens' Request' (Maybe CreateParagraphBulletsRequest) reqCreateParagraphBullets = lens _reqCreateParagraphBullets (\ s a -> s{_reqCreateParagraphBullets = a})
231
reqCreateParagraphBullets :: Lens' Request' (Maybe CreateParagraphBulletsRequest) reqCreateParagraphBullets = lens _reqCreateParagraphBullets (\ s a -> s{_reqCreateParagraphBullets = a})
194
reqCreateParagraphBullets = lens _reqCreateParagraphBullets (\ s a -> s{_reqCreateParagraphBullets = a})
112
true
true
0
9
30
48
25
23
null
null
mightymoose/liquidhaskell
benchmarks/xmonad-0.10/tests/Properties.hs
bsd-3-clause
-- Useful operation, the non-local workspaces hidden_spaces x = map workspace (visible x) ++ hidden x
101
hidden_spaces x = map workspace (visible x) ++ hidden x
55
hidden_spaces x = map workspace (visible x) ++ hidden x
55
true
false
1
8
15
31
13
18
null
null
benkolera/haskell-ldap-classy
LDAP/Classy/Decode.hs
mit
attrNel :: (MonadError e m, AsLdapEntryDecodeError e,FromLdapAttribute a,Applicative m) => String -> LDAPEntry -> m (NonEmpty a) attrNel n e = attrsParse (requireNel n e) n e
182
attrNel :: (MonadError e m, AsLdapEntryDecodeError e,FromLdapAttribute a,Applicative m) => String -> LDAPEntry -> m (NonEmpty a) attrNel n e = attrsParse (requireNel n e) n e
182
attrNel n e = attrsParse (requireNel n e) n e
45
false
true
0
10
34
77
38
39
null
null
csrhodes/pandoc
src/Text/Pandoc/Parsing.hs
gpl-2.0
mathInlineWith :: Stream s m Char => String -> String -> ParserT s st m String mathInlineWith op cl = try $ do string op notFollowedBy space words' <- many1Till (count 1 (noneOf " \t\n\\") <|> (char '\\' >> -- This next clause is needed because \text{..} can -- contain $, \(\), etc. (try (string "text" >> (("\\text" ++) <$> inBalancedBraces 0 "")) <|> (\c -> ['\\',c]) <$> anyChar)) <|> do (blankline <* notFollowedBy' blankline) <|> (oneOf " \t" <* skipMany (oneOf " \t")) notFollowedBy (char '$') return " " ) (try $ string cl) notFollowedBy digit -- to prevent capture of $5 return $ concat words' where inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String inBalancedBraces 0 "" = do c <- anyChar if c == '{' then inBalancedBraces 1 "{" else mzero inBalancedBraces 0 s = return $ reverse s inBalancedBraces numOpen ('\\':xs) = do c <- anyChar inBalancedBraces numOpen (c:'\\':xs) inBalancedBraces numOpen xs = do c <- anyChar case c of '}' -> inBalancedBraces (numOpen - 1) (c:xs) '{' -> inBalancedBraces (numOpen + 1) (c:xs) _ -> inBalancedBraces numOpen (c:xs)
1,464
mathInlineWith :: Stream s m Char => String -> String -> ParserT s st m String mathInlineWith op cl = try $ do string op notFollowedBy space words' <- many1Till (count 1 (noneOf " \t\n\\") <|> (char '\\' >> -- This next clause is needed because \text{..} can -- contain $, \(\), etc. (try (string "text" >> (("\\text" ++) <$> inBalancedBraces 0 "")) <|> (\c -> ['\\',c]) <$> anyChar)) <|> do (blankline <* notFollowedBy' blankline) <|> (oneOf " \t" <* skipMany (oneOf " \t")) notFollowedBy (char '$') return " " ) (try $ string cl) notFollowedBy digit -- to prevent capture of $5 return $ concat words' where inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String inBalancedBraces 0 "" = do c <- anyChar if c == '{' then inBalancedBraces 1 "{" else mzero inBalancedBraces 0 s = return $ reverse s inBalancedBraces numOpen ('\\':xs) = do c <- anyChar inBalancedBraces numOpen (c:'\\':xs) inBalancedBraces numOpen xs = do c <- anyChar case c of '}' -> inBalancedBraces (numOpen - 1) (c:xs) '{' -> inBalancedBraces (numOpen + 1) (c:xs) _ -> inBalancedBraces numOpen (c:xs)
1,464
mathInlineWith op cl = try $ do string op notFollowedBy space words' <- many1Till (count 1 (noneOf " \t\n\\") <|> (char '\\' >> -- This next clause is needed because \text{..} can -- contain $, \(\), etc. (try (string "text" >> (("\\text" ++) <$> inBalancedBraces 0 "")) <|> (\c -> ['\\',c]) <$> anyChar)) <|> do (blankline <* notFollowedBy' blankline) <|> (oneOf " \t" <* skipMany (oneOf " \t")) notFollowedBy (char '$') return " " ) (try $ string cl) notFollowedBy digit -- to prevent capture of $5 return $ concat words' where inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String inBalancedBraces 0 "" = do c <- anyChar if c == '{' then inBalancedBraces 1 "{" else mzero inBalancedBraces 0 s = return $ reverse s inBalancedBraces numOpen ('\\':xs) = do c <- anyChar inBalancedBraces numOpen (c:'\\':xs) inBalancedBraces numOpen xs = do c <- anyChar case c of '}' -> inBalancedBraces (numOpen - 1) (c:xs) '{' -> inBalancedBraces (numOpen + 1) (c:xs) _ -> inBalancedBraces numOpen (c:xs)
1,384
false
true
5
23
562
478
227
251
null
null
ardumont/haskell-lab
src/io/wc.hs
gpl-2.0
countLines :: IO () countLines = do (filename:_) <- getArgs contents <- readFile filename putStrLn $ (show . length . lines) contents
139
countLines :: IO () countLines = do (filename:_) <- getArgs contents <- readFile filename putStrLn $ (show . length . lines) contents
139
countLines = do (filename:_) <- getArgs contents <- readFile filename putStrLn $ (show . length . lines) contents
119
false
true
0
11
27
61
29
32
null
null
eklitzke/Data.ConsistentHash
Data/ConsistentHash.hs
isc
updateHash :: a -> CHash a -> CHash a updateHash x h = addItems items h where x' = fromIntegral $ getHashFunc h $ x items = [CHashItem p x | p <- cHashInt x']
174
updateHash :: a -> CHash a -> CHash a updateHash x h = addItems items h where x' = fromIntegral $ getHashFunc h $ x items = [CHashItem p x | p <- cHashInt x']
174
updateHash x h = addItems items h where x' = fromIntegral $ getHashFunc h $ x items = [CHashItem p x | p <- cHashInt x']
136
false
true
1
10
50
80
37
43
null
null
seagate-ssg/options-schema
src/Options/Schema/Applicative.hs
bsd-3-clause
mkBlockParser n d (Flag active def) = mkFlagParser active def n d
65
mkBlockParser n d (Flag active def) = mkFlagParser active def n d
65
mkBlockParser n d (Flag active def) = mkFlagParser active def n d
65
false
false
0
7
11
30
14
16
null
null
javgh/bitcoin-rpc
Network/BitcoinRPC/MarkerAddressesTest.hs
bsd-3-clause
markerAdressesTests :: [Test] markerAdressesTests = [ testProperty "sums match" propSumsMatch , testProperty "sum size is less or equal" propSizeLessOrEqual , test1, test2, test3, test4, test5 ]
260
markerAdressesTests :: [Test] markerAdressesTests = [ testProperty "sums match" propSumsMatch , testProperty "sum size is less or equal" propSizeLessOrEqual , test1, test2, test3, test4, test5 ]
260
markerAdressesTests = [ testProperty "sums match" propSumsMatch , testProperty "sum size is less or equal" propSizeLessOrEqual , test1, test2, test3, test4, test5 ]
230
false
true
0
7
91
52
27
25
null
null
duairc/opaleye-x
src/Opaleye/X/Transaction.hs
mpl-2.0
------------------------------------------------------------------------------ insert :: (MonadInner IO m, PGIn as ws) => Table ws -> [as] -> TransactionT m Int64 insert table as = TransactionT . ReaderT $ \connection -> liftI $ runInsertMany connection table (map pg as)
279
insert :: (MonadInner IO m, PGIn as ws) => Table ws -> [as] -> TransactionT m Int64 insert table as = TransactionT . ReaderT $ \connection -> liftI $ runInsertMany connection table (map pg as)
200
insert table as = TransactionT . ReaderT $ \connection -> liftI $ runInsertMany connection table (map pg as)
112
true
true
0
10
43
87
44
43
null
null
ghc-android/ghc
testsuite/tests/ghci/should_run/ghcirun004.hs
bsd-3-clause
3632 = 3631
11
3632 = 3631
11
3632 = 3631
11
false
false
1
5
2
10
3
7
null
null
dysinger/amazonka
amazonka-cloudwatch-logs/gen/Network/AWS/CloudWatchLogs/DescribeLogStreams.hs
mpl-2.0
dlsrNextToken :: Lens' DescribeLogStreamsResponse (Maybe Text) dlsrNextToken = lens _dlsrNextToken (\s a -> s { _dlsrNextToken = a })
133
dlsrNextToken :: Lens' DescribeLogStreamsResponse (Maybe Text) dlsrNextToken = lens _dlsrNextToken (\s a -> s { _dlsrNextToken = a })
133
dlsrNextToken = lens _dlsrNextToken (\s a -> s { _dlsrNextToken = a })
70
false
true
0
9
18
45
24
21
null
null
hxw/conlecterm
src/SendControl.hs
bsd-2-clause
sym ':' = (X.shiftMask, X.stringToKeysym "colon")
49
sym ':' = (X.shiftMask, X.stringToKeysym "colon")
49
sym ':' = (X.shiftMask, X.stringToKeysym "colon")
49
false
false
0
7
5
23
11
12
null
null
kazu-yamamoto/test-framework-doctest-prime
Test/Framework/Providers/DocTest/Prime.hs
bsd-3-clause
runDocTest :: CompleteTestOptions -> DocTestAction -> IO (DocTestRunning :~> InteractionResult, IO ()) runDocTest topts (DocTestAction doctest) = runImprovingIO $ do yieldImprovement DocTestRunning mb_result <- maybeTimeoutImprovingIO (unK $ topt_timeout topts) $ liftIO doctest return (mb_result `orElse` Success 0)
328
runDocTest :: CompleteTestOptions -> DocTestAction -> IO (DocTestRunning :~> InteractionResult, IO ()) runDocTest topts (DocTestAction doctest) = runImprovingIO $ do yieldImprovement DocTestRunning mb_result <- maybeTimeoutImprovingIO (unK $ topt_timeout topts) $ liftIO doctest return (mb_result `orElse` Success 0)
328
runDocTest topts (DocTestAction doctest) = runImprovingIO $ do yieldImprovement DocTestRunning mb_result <- maybeTimeoutImprovingIO (unK $ topt_timeout topts) $ liftIO doctest return (mb_result `orElse` Success 0)
225
false
true
0
14
48
108
50
58
null
null
crockeo/tic-taskell
src/Server.hs
mit
server :: IORef Board -> ScottyM () server boardRef = do serveStatic getHomePage getBoardState boardRef postResetBoard boardRef postPerformMove boardRef handle404
176
server :: IORef Board -> ScottyM () server boardRef = do serveStatic getHomePage getBoardState boardRef postResetBoard boardRef postPerformMove boardRef handle404
176
server boardRef = do serveStatic getHomePage getBoardState boardRef postResetBoard boardRef postPerformMove boardRef handle404
140
false
true
0
7
33
53
21
32
null
null
diku-dk/futhark
src/Futhark/CodeGen/Backends/GenericPython.hs
isc
futharkFun :: String -> String futharkFun s = "futhark_" ++ zEncodeString s
75
futharkFun :: String -> String futharkFun s = "futhark_" ++ zEncodeString s
75
futharkFun s = "futhark_" ++ zEncodeString s
44
false
true
2
7
11
31
13
18
null
null
geraldus/yesod
yesod/Yesod/Default/Config.hs
mit
withYamlEnvironment :: Show e => FilePath -- ^ the yaml file -> e -- ^ the environment you want to load -> (Value -> Parser a) -- ^ what to do with the mapping -> IO a withYamlEnvironment fp env f = do mval <- decodeFileEither fp case mval of Left err -> fail $ "Invalid YAML file: " ++ show fp ++ " " ++ prettyPrintParseException err Right (Object obj) | Just v <- M.lookup (T.pack $ show env) obj -> parseMonad f v _ -> fail $ "Could not find environment: " ++ show env
612
withYamlEnvironment :: Show e => FilePath -- ^ the yaml file -> e -- ^ the environment you want to load -> (Value -> Parser a) -- ^ what to do with the mapping -> IO a withYamlEnvironment fp env f = do mval <- decodeFileEither fp case mval of Left err -> fail $ "Invalid YAML file: " ++ show fp ++ " " ++ prettyPrintParseException err Right (Object obj) | Just v <- M.lookup (T.pack $ show env) obj -> parseMonad f v _ -> fail $ "Could not find environment: " ++ show env
612
withYamlEnvironment fp env f = do mval <- decodeFileEither fp case mval of Left err -> fail $ "Invalid YAML file: " ++ show fp ++ " " ++ prettyPrintParseException err Right (Object obj) | Just v <- M.lookup (T.pack $ show env) obj -> parseMonad f v _ -> fail $ "Could not find environment: " ++ show env
357
false
true
0
17
237
170
79
91
null
null
izuk/pwdhash
src/Codec/Pwdhash.hs
bsd-3-clause
replaceNonAlphaNum :: String -> Extra String replaceNonAlphaNum [] = return []
78
replaceNonAlphaNum :: String -> Extra String replaceNonAlphaNum [] = return []
78
replaceNonAlphaNum [] = return []
33
false
true
0
6
10
28
13
15
null
null
open-etcs/openetcs-sdm
src/ETCS/SDM/Stepper.hs
bsd-3-clause
orderedList (a:b:xs) = b > a && orderedList (b:xs)
50
orderedList (a:b:xs) = b > a && orderedList (b:xs)
50
orderedList (a:b:xs) = b > a && orderedList (b:xs)
50
false
false
0
8
8
38
19
19
null
null
forste/haReFork
refactorer/RefacDupTrans.hs
bsd-3-clause
createAbs' (x:y:es) = int : createAbs' (y:es) where int = compareExp [] x y
83
createAbs' (x:y:es) = int : createAbs' (y:es) where int = compareExp [] x y
83
createAbs' (x:y:es) = int : createAbs' (y:es) where int = compareExp [] x y
83
false
false
3
7
21
59
25
34
null
null
robeverest/accelerate
Data/Array/Accelerate/Interpreter.hs
bsd-3-clause
evalPrim (PrimMod ty) = evalMod ty
46
evalPrim (PrimMod ty) = evalMod ty
46
evalPrim (PrimMod ty) = evalMod ty
46
false
false
0
7
17
18
8
10
null
null
lorem-ipsum/adventofcode2015
day06.hs
gpl-2.0
makeGrid = foldl translateCommand start where translateCommand g (ON c) = on c g translateCommand g (OFF c) = off c g translateCommand g (TOGGLE c) = toggle c g
174
makeGrid = foldl translateCommand start where translateCommand g (ON c) = on c g translateCommand g (OFF c) = off c g translateCommand g (TOGGLE c) = toggle c g
174
makeGrid = foldl translateCommand start where translateCommand g (ON c) = on c g translateCommand g (OFF c) = off c g translateCommand g (TOGGLE c) = toggle c g
174
false
false
0
7
43
77
36
41
null
null
sheyll/b9-vm-image-builder
src/lib/B9/Artifact/Readable/Interpreter.hs
mit
prefixExternalSourcesPaths _fromDir sg = sg
43
prefixExternalSourcesPaths _fromDir sg = sg
43
prefixExternalSourcesPaths _fromDir sg = sg
43
false
false
0
5
4
11
5
6
null
null
aleator/simple-dc1394
System/Camera/Firewire/Simple.hs
bsd-3-clause
-- | Set camera shutter speed setFeature :: CUInt -> Camera a -> Word32 -> IO () setFeature f c speed = withCameraPtr c $ \camera -> checking $ c'dc1394_feature_set_value camera f (fromIntegral speed)
365
setFeature :: CUInt -> Camera a -> Word32 -> IO () setFeature f c speed = withCameraPtr c $ \camera -> checking $ c'dc1394_feature_set_value camera f (fromIntegral speed)
334
setFeature f c speed = withCameraPtr c $ \camera -> checking $ c'dc1394_feature_set_value camera f (fromIntegral speed)
283
true
true
0
10
198
72
34
38
null
null
daleooo/barrelfish
tools/mackerel/TypeTable.hs
mit
builtin_size "uint32" = 32
26
builtin_size "uint32" = 32
26
builtin_size "uint32" = 32
26
false
false
0
4
3
10
4
6
null
null
NICTA/lets-lens
src/Lets/GetSetLens.hs
bsd-3-clause
-- | -- -- >>> get (choice fstL sndL) (Left ("abc", 7)) -- "abc" -- -- >>> get (choice fstL sndL) (Right ("abc", 7)) -- 7 -- -- >>> set (choice fstL sndL) (Left ("abc", 7)) "def" -- Left ("def",7) -- -- >>> set (choice fstL sndL) (Right ("abc", 7)) 8 -- Right ("abc",8) choice :: Lens a x -> Lens b x -> Lens (Either a b) x choice = error "todo: choice"
361
choice :: Lens a x -> Lens b x -> Lens (Either a b) x choice = error "todo: choice"
91
choice = error "todo: choice"
31
true
true
0
10
81
60
34
26
null
null
BartAdv/Idris-dev
src/Idris/Reflection.hs
bsd-3-clause
reflectDatatype :: RDatatype -> Raw reflectDatatype (RDatatype tyn tyConArgs tyConRes constrs) = raw_apply (Var $ tacN "MkDatatype") [ reflectName tyn , rawList (Var $ tacN "TyConArg") (map reflectConArg tyConArgs) , reflectRaw tyConRes , rawList (rawPairTy (Var $ reflm "TTName") (Var $ reflm "Raw")) [ rawPair ((Var $ reflm "TTName"), (Var $ reflm "Raw")) (reflectName cn, reflectRaw cty) | (cn, cty) <- constrs ] ] where reflectConArg (RParameter n t) = raw_apply (Var $ tacN "Parameter") [reflectName n, reflectRaw t] reflectConArg (RIndex n t) = raw_apply (Var $ tacN "Index") [reflectName n, reflectRaw t]
1,001
reflectDatatype :: RDatatype -> Raw reflectDatatype (RDatatype tyn tyConArgs tyConRes constrs) = raw_apply (Var $ tacN "MkDatatype") [ reflectName tyn , rawList (Var $ tacN "TyConArg") (map reflectConArg tyConArgs) , reflectRaw tyConRes , rawList (rawPairTy (Var $ reflm "TTName") (Var $ reflm "Raw")) [ rawPair ((Var $ reflm "TTName"), (Var $ reflm "Raw")) (reflectName cn, reflectRaw cty) | (cn, cty) <- constrs ] ] where reflectConArg (RParameter n t) = raw_apply (Var $ tacN "Parameter") [reflectName n, reflectRaw t] reflectConArg (RIndex n t) = raw_apply (Var $ tacN "Index") [reflectName n, reflectRaw t]
1,001
reflectDatatype (RDatatype tyn tyConArgs tyConRes constrs) = raw_apply (Var $ tacN "MkDatatype") [ reflectName tyn , rawList (Var $ tacN "TyConArg") (map reflectConArg tyConArgs) , reflectRaw tyConRes , rawList (rawPairTy (Var $ reflm "TTName") (Var $ reflm "Raw")) [ rawPair ((Var $ reflm "TTName"), (Var $ reflm "Raw")) (reflectName cn, reflectRaw cty) | (cn, cty) <- constrs ] ] where reflectConArg (RParameter n t) = raw_apply (Var $ tacN "Parameter") [reflectName n, reflectRaw t] reflectConArg (RIndex n t) = raw_apply (Var $ tacN "Index") [reflectName n, reflectRaw t]
965
false
true
0
13
482
268
134
134
null
null
chreekat/snowdrift
Application.hs
agpl-3.0
forkEventHandler :: App -> IO () forkEventHandler app@App{..} = void . forkIO . forever $ do threadDelay 1000000 -- Sleep for one second in between runs. handleNEvents 10 -- Handle up to 10 events per run. where handleNEvents :: Int -> IO () handleNEvents 0 = return () handleNEvents n = atomically (tryReadTChan appEventChan) >>= \case Nothing -> return () Just event -> do mapM_ (runDaemon app) (appEventHandlers settings <*> [event]) handleNEvents (n-1)
525
forkEventHandler :: App -> IO () forkEventHandler app@App{..} = void . forkIO . forever $ do threadDelay 1000000 -- Sleep for one second in between runs. handleNEvents 10 -- Handle up to 10 events per run. where handleNEvents :: Int -> IO () handleNEvents 0 = return () handleNEvents n = atomically (tryReadTChan appEventChan) >>= \case Nothing -> return () Just event -> do mapM_ (runDaemon app) (appEventHandlers settings <*> [event]) handleNEvents (n-1)
525
forkEventHandler app@App{..} = void . forkIO . forever $ do threadDelay 1000000 -- Sleep for one second in between runs. handleNEvents 10 -- Handle up to 10 events per run. where handleNEvents :: Int -> IO () handleNEvents 0 = return () handleNEvents n = atomically (tryReadTChan appEventChan) >>= \case Nothing -> return () Just event -> do mapM_ (runDaemon app) (appEventHandlers settings <*> [event]) handleNEvents (n-1)
492
false
true
0
14
141
171
81
90
null
null
karamellpelle/grid
source/Game/Values/Plain.hs
gpl-3.0
valueLevelPuzzlePathRadius :: Float valueLevelPuzzlePathRadius = valueGridPathRadius
89
valueLevelPuzzlePathRadius :: Float valueLevelPuzzlePathRadius = valueGridPathRadius
89
valueLevelPuzzlePathRadius = valueGridPathRadius
53
false
true
0
4
10
11
6
5
null
null
aelve/guide
back/src/Guide/ServerStuff.hs
bsd-3-clause
undoEdit (EditSetCategoryNotes catId old new) = do now <- markdownBlockSource . categoryNotes <$> dbQuery (GetCategory catId) if now /= new then return (Left "notes have been changed further") else Right () <$ dbUpdate (SetCategoryNotes catId old)
259
undoEdit (EditSetCategoryNotes catId old new) = do now <- markdownBlockSource . categoryNotes <$> dbQuery (GetCategory catId) if now /= new then return (Left "notes have been changed further") else Right () <$ dbUpdate (SetCategoryNotes catId old)
259
undoEdit (EditSetCategoryNotes catId old new) = do now <- markdownBlockSource . categoryNotes <$> dbQuery (GetCategory catId) if now /= new then return (Left "notes have been changed further") else Right () <$ dbUpdate (SetCategoryNotes catId old)
259
false
false
0
11
47
87
41
46
null
null
kindohm/Tidal
Sound/Tidal/Params.hs
gpl-3.0
coarse :: Pattern Int -> OscPattern coarse = make' int32 coarse_p
65
coarse :: Pattern Int -> OscPattern coarse = make' int32 coarse_p
65
coarse = make' int32 coarse_p
29
false
true
0
7
10
31
12
19
null
null
IreneKnapp/Faction
libfaction/Distribution/ParseUtils.hs
bsd-3-clause
parseExtensionQ :: ReadP r Extension parseExtensionQ = parseQuoted parse <++ parse
82
parseExtensionQ :: ReadP r Extension parseExtensionQ = parseQuoted parse <++ parse
82
parseExtensionQ = parseQuoted parse <++ parse
45
false
true
0
6
10
28
12
16
null
null
dmort27/WebComparator
PhonData.hs
bsd-3-clause
showTrimmedACT :: ACT -> String showTrimmedACT = intercalate "\n" . map (showACTRow . transformRow trimToCogMorph) . fst
120
showTrimmedACT :: ACT -> String showTrimmedACT = intercalate "\n" . map (showACTRow . transformRow trimToCogMorph) . fst
120
showTrimmedACT = intercalate "\n" . map (showACTRow . transformRow trimToCogMorph) . fst
88
false
true
0
10
16
39
19
20
null
null
neetsdkasu/Paiza-POH-MyAnswers
POH7/Mizugi/Main.hs
mit
gs = getLine
12
gs = getLine
12
gs = getLine
12
false
false
1
5
2
10
3
7
null
null
abhean/phffp-examples
src/Lib.hs
bsd-3-clause
incTimes t n = 1 + incTimes (t - 1) n
37
incTimes t n = 1 + incTimes (t - 1) n
37
incTimes t n = 1 + incTimes (t - 1) n
37
false
false
0
8
10
27
13
14
null
null
forked-upstream-packages-for-ghcjs/ghc
compiler/hsSyn/HsUtils.hs
bsd-3-clause
userHsTyVarBndrs :: SrcSpan -> [name] -> [Located (HsTyVarBndr name)] -- Caller sets location userHsTyVarBndrs loc bndrs = [ L loc (UserTyVar v) | v <- bndrs ]
159
userHsTyVarBndrs :: SrcSpan -> [name] -> [Located (HsTyVarBndr name)] userHsTyVarBndrs loc bndrs = [ L loc (UserTyVar v) | v <- bndrs ]
135
userHsTyVarBndrs loc bndrs = [ L loc (UserTyVar v) | v <- bndrs ]
65
true
true
0
10
26
62
32
30
null
null
taktoa/ghcjs-electron
src/GHCJS/Electron/Accelerator.hs
mit
-- | Compile a 'KeyQuery' to a list of 'Accelerator's. runKeyQuery :: KeyQuery -> [Accelerator] runKeyQuery = undefined
119
runKeyQuery :: KeyQuery -> [Accelerator] runKeyQuery = undefined
64
runKeyQuery = undefined
23
true
true
0
6
17
19
11
8
null
null
tingtun/jmacro
Language/Javascript/JMacro/Base.hs
bsd-3-clause
x $$ y = align (x $+$ y)
25
x $$ y = align (x $+$ y)
25
x $$ y = align (x $+$ y)
25
false
false
2
7
8
21
10
11
null
null
plumlife/cabal
Cabal/Distribution/Simple/BuildTarget.hs
bsd-3-clause
------------------------------ -- Top level match runner -- -- | Given a matcher and a key to look up, use the matcher to find all the -- possible matches. There may be 'None', a single 'Unambiguous' match or -- you may have an 'Ambiguous' match with several possibilities. -- findMatch :: Eq b => Match b -> MaybeAmbiguous b findMatch match = case match of NoMatch _ msgs -> None (nub msgs) ExactMatch _ xs -> checkAmbiguous xs InexactMatch _ xs -> checkAmbiguous xs where checkAmbiguous xs = case nub xs of [x] -> Unambiguous x xs' -> Ambiguous xs'
638
findMatch :: Eq b => Match b -> MaybeAmbiguous b findMatch match = case match of NoMatch _ msgs -> None (nub msgs) ExactMatch _ xs -> checkAmbiguous xs InexactMatch _ xs -> checkAmbiguous xs where checkAmbiguous xs = case nub xs of [x] -> Unambiguous x xs' -> Ambiguous xs'
360
findMatch match = case match of NoMatch _ msgs -> None (nub msgs) ExactMatch _ xs -> checkAmbiguous xs InexactMatch _ xs -> checkAmbiguous xs where checkAmbiguous xs = case nub xs of [x] -> Unambiguous x xs' -> Ambiguous xs'
311
true
true
0
10
186
129
62
67
null
null
brianshourd/adventOfCode2015
test/Day12Spec.hs
mit
main :: IO () main = hspec spec
31
main :: IO () main = hspec spec
31
main = hspec spec
17
false
true
1
6
7
22
9
13
null
null
divayprakash/haskell-course
week7programmingAssignment.hs
mit
lookAndSay :: Integer -> Integer lookAndSay n = read (concatMap describe (group (show n))) where describe run = show (length run) ++ take 1 run
155
lookAndSay :: Integer -> Integer lookAndSay n = read (concatMap describe (group (show n))) where describe run = show (length run) ++ take 1 run
155
lookAndSay n = read (concatMap describe (group (show n))) where describe run = show (length run) ++ take 1 run
122
false
true
0
11
36
70
33
37
null
null
beni55/cgrep
src/CGrep/Filter.hs
gpl-2.0
filterFunctionMap = Map.fromList [ (C, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Cpp, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Cabal, mkFilterFunction [("--", "\n")] [("\"", "\"")] ), (Csharp, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Chapel, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Coffee, mkFilterFunction [("###", "###"), ("#", "\n")] [("\"", "\"")] ), (Conf, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (D, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Go, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Java, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Javascript, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (ObjectiveC, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Scala, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Verilog, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (VHDL, mkFilterFunction [("--", "\n")] [("\"", "\"")] ), (Haskell, mkFilterFunction [("{-", "-}"), ("--", "\n")] [("\"", "\""), ("[r|", "|]"), ("[q|", "|]"), ("[s|", "|]"), ("[here|","|]"), ("[i|", "|]")] ), (Fsharp, mkFilterFunction [("(*", "*)"), ("//", "\n")] [("\"", "\"")] ), (Perl, mkFilterFunction [("=pod", "=cut"), ("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Ruby, mkFilterFunction [("=begin", "=end"), ("#", "\n")] [("'", "'"), ("\"", "\""), ("%|", "|"), ("%q(", ")"), ("%Q(", ")") ]), (CMake, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Awk, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Tcl, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Shell, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Make, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Css, mkFilterFunction [("/*", "*/")] [("\"", "\"")] ), (OCaml, mkFilterFunction [("(*", "*)")] [("\"", "\"")] ), (Python, mkFilterFunction [("#", "\n")] [("\"\"\"", "\"\"\""), ("'''", "'''"), ("'", "'"), ("\"", "\"")] ), (Erlang, mkFilterFunction [("%", "\n")] [("\"", "\"")] ), (Latex, mkFilterFunction [("%", "\n")] [("\"", "\"")] ), (Lua, mkFilterFunction [("--[[","--]]"), ("--", "\n")] [("'", "'"), ("\"", "\""), ("[===[", "]===]"), ("[==[", "]==]"), ("[=[", "]=]"), ("[[", "]]") ] ), (Html, mkFilterFunction [("<!--", "-->")] [("\"", "\"")] ), (Vim, mkFilterFunction [("\"", "\n")] [("'", "'")] ), (PHP, mkFilterFunction [("/*", "*/"), ("//", "\n"), ("#", "\n") ] [("'", "'"), ("\"", "\"")] ) ]
2,926
filterFunctionMap = Map.fromList [ (C, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Cpp, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Cabal, mkFilterFunction [("--", "\n")] [("\"", "\"")] ), (Csharp, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Chapel, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Coffee, mkFilterFunction [("###", "###"), ("#", "\n")] [("\"", "\"")] ), (Conf, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (D, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Go, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Java, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Javascript, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (ObjectiveC, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Scala, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Verilog, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (VHDL, mkFilterFunction [("--", "\n")] [("\"", "\"")] ), (Haskell, mkFilterFunction [("{-", "-}"), ("--", "\n")] [("\"", "\""), ("[r|", "|]"), ("[q|", "|]"), ("[s|", "|]"), ("[here|","|]"), ("[i|", "|]")] ), (Fsharp, mkFilterFunction [("(*", "*)"), ("//", "\n")] [("\"", "\"")] ), (Perl, mkFilterFunction [("=pod", "=cut"), ("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Ruby, mkFilterFunction [("=begin", "=end"), ("#", "\n")] [("'", "'"), ("\"", "\""), ("%|", "|"), ("%q(", ")"), ("%Q(", ")") ]), (CMake, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Awk, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Tcl, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Shell, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Make, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Css, mkFilterFunction [("/*", "*/")] [("\"", "\"")] ), (OCaml, mkFilterFunction [("(*", "*)")] [("\"", "\"")] ), (Python, mkFilterFunction [("#", "\n")] [("\"\"\"", "\"\"\""), ("'''", "'''"), ("'", "'"), ("\"", "\"")] ), (Erlang, mkFilterFunction [("%", "\n")] [("\"", "\"")] ), (Latex, mkFilterFunction [("%", "\n")] [("\"", "\"")] ), (Lua, mkFilterFunction [("--[[","--]]"), ("--", "\n")] [("'", "'"), ("\"", "\""), ("[===[", "]===]"), ("[==[", "]==]"), ("[=[", "]=]"), ("[[", "]]") ] ), (Html, mkFilterFunction [("<!--", "-->")] [("\"", "\"")] ), (Vim, mkFilterFunction [("\"", "\n")] [("'", "'")] ), (PHP, mkFilterFunction [("/*", "*/"), ("//", "\n"), ("#", "\n") ] [("'", "'"), ("\"", "\"")] ) ]
2,926
filterFunctionMap = Map.fromList [ (C, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Cpp, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Cabal, mkFilterFunction [("--", "\n")] [("\"", "\"")] ), (Csharp, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Chapel, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Coffee, mkFilterFunction [("###", "###"), ("#", "\n")] [("\"", "\"")] ), (Conf, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (D, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Go, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Java, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Javascript, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (ObjectiveC, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Scala, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (Verilog, mkFilterFunction [("/*", "*/"), ("//", "\n")] [("\"", "\"")] ), (VHDL, mkFilterFunction [("--", "\n")] [("\"", "\"")] ), (Haskell, mkFilterFunction [("{-", "-}"), ("--", "\n")] [("\"", "\""), ("[r|", "|]"), ("[q|", "|]"), ("[s|", "|]"), ("[here|","|]"), ("[i|", "|]")] ), (Fsharp, mkFilterFunction [("(*", "*)"), ("//", "\n")] [("\"", "\"")] ), (Perl, mkFilterFunction [("=pod", "=cut"), ("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Ruby, mkFilterFunction [("=begin", "=end"), ("#", "\n")] [("'", "'"), ("\"", "\""), ("%|", "|"), ("%q(", ")"), ("%Q(", ")") ]), (CMake, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Awk, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Tcl, mkFilterFunction [("#", "\n")] [("\"", "\"")] ), (Shell, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Make, mkFilterFunction [("#", "\n")] [("'", "'"), ("\"", "\"")] ), (Css, mkFilterFunction [("/*", "*/")] [("\"", "\"")] ), (OCaml, mkFilterFunction [("(*", "*)")] [("\"", "\"")] ), (Python, mkFilterFunction [("#", "\n")] [("\"\"\"", "\"\"\""), ("'''", "'''"), ("'", "'"), ("\"", "\"")] ), (Erlang, mkFilterFunction [("%", "\n")] [("\"", "\"")] ), (Latex, mkFilterFunction [("%", "\n")] [("\"", "\"")] ), (Lua, mkFilterFunction [("--[[","--]]"), ("--", "\n")] [("'", "'"), ("\"", "\""), ("[===[", "]===]"), ("[==[", "]==]"), ("[=[", "]=]"), ("[[", "]]") ] ), (Html, mkFilterFunction [("<!--", "-->")] [("\"", "\"")] ), (Vim, mkFilterFunction [("\"", "\n")] [("'", "'")] ), (PHP, mkFilterFunction [("/*", "*/"), ("//", "\n"), ("#", "\n") ] [("'", "'"), ("\"", "\"")] ) ]
2,926
false
false
1
10
715
1,439
911
528
null
null
vikraman/ghc
compiler/simplCore/OccurAnal.hs
bsd-3-clause
reOrderNodes depth bndr_set weak_fvs (node : nodes) binds = -- pprTrace "reOrderNodes" (text "unchosen" <+> ppr unchosen $$ -- text "chosen" <+> ppr chosen_nodes) $ loopBreakNodes new_depth bndr_set weak_fvs unchosen $ (map mk_loop_breaker chosen_nodes ++ binds) where (chosen_nodes, unchosen) = choose_loop_breaker (score node) [node] [] nodes approximate_loop_breaker = depth >= 2 new_depth | approximate_loop_breaker = 0 | otherwise = depth+1 -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 choose_loop_breaker :: Int -- Best score so far -> [Node Details] -- Nodes with this score -> [Node Details] -- Nodes with higher scores -> [Node Details] -- Unprocessed nodes -> ([Node Details], [Node Details]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in choose_loop_breaker _ loop_nodes acc [] = (loop_nodes, acc) -- Done -- If approximate_loop_breaker is True, we pick *all* -- nodes with lowest score, else just one -- See Note [Complexity of loop breaking] choose_loop_breaker loop_sc loop_nodes acc (node : nodes) | sc < loop_sc -- Lower score so pick this new one = choose_loop_breaker sc [node] (loop_nodes ++ acc) nodes | approximate_loop_breaker && sc == loop_sc = choose_loop_breaker loop_sc (node : loop_nodes) acc nodes | otherwise -- Higher score so don't pick it = choose_loop_breaker loop_sc loop_nodes (node : acc) nodes where sc = score node score :: Node Details -> Int -- Higher score => less likely to be picked as loop breaker score (ND { nd_bndr = bndr, nd_rhs = rhs }, _, _) | not (isId bndr) = 100 -- A type or cercion variable is never a loop breaker | isDFunId bndr = 9 -- Never choose a DFun as a loop breaker -- Note [DFuns should not be loop breakers] | Just be_very_keen <- hasStableCoreUnfolding_maybe (idUnfolding bndr) = if be_very_keen then 6 -- Note [Loop breakers and INLINE/INLINEABLE pragmas] else 3 -- Data structures are more important than INLINE pragmas -- so that dictionary/method recursion unravels -- Note that this case hits all stable unfoldings, so we -- never look at 'rhs' for stable unfoldings. That's right, because -- 'rhs' is irrelevant for inlining things with a stable unfolding | is_con_app rhs = 5 -- Data types help with cases: Note [Constructor applications] | exprIsTrivial rhs = 10 -- Practically certain to be inlined -- Used to have also: && not (isExportedId bndr) -- But I found this sometimes cost an extra iteration when we have -- rec { d = (a,b); a = ...df...; b = ...df...; df = d } -- where df is the exported dictionary. Then df makes a really -- bad choice for loop breaker -- If an Id is marked "never inline" then it makes a great loop breaker -- The only reason for not checking that here is that it is rare -- and I've never seen a situation where it makes a difference, -- so it probably isn't worth the time to test on every binder -- | isNeverActive (idInlinePragma bndr) = -10 | isOneOcc (idOccInfo bndr) = 2 -- Likely to be inlined | canUnfold (realIdUnfolding bndr) = 1 -- The Id has some kind of unfolding -- Ignore loop-breaker-ness here because that is what we are setting! | otherwise = 0 -- Checking for a constructor application -- Cheap and cheerful; the simplifer moves casts out of the way -- The lambda case is important to spot x = /\a. C (f a) -- which comes up when C is a dictionary constructor and -- f is a default method. -- Example: the instance for Show (ST s a) in GHC.ST -- -- However we *also* treat (\x. C p q) as a con-app-like thing, -- Note [Closure conversion] is_con_app (Var v) = isConLikeId v is_con_app (App f _) = is_con_app f is_con_app (Lam _ e) = is_con_app e is_con_app (Tick _ e) = is_con_app e is_con_app _ = False {- Note [Complexity of loop breaking] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The loop-breaking algorithm knocks out one binder at a time, and performs a new SCC analysis on the remaining binders. That can behave very badly in tightly-coupled groups of bindings; in the worst case it can be (N**2)*log N, because it does a full SCC on N, then N-1, then N-2 and so on. To avoid this, we switch plans after 2 (or whatever) attempts: Plan A: pick one binder with the lowest score, make it a loop breaker, and try again Plan B: pick *all* binders with the lowest score, make them all loop breakers, and try again Since there are only a small finite number of scores, this will terminate in a constant number of iterations, rather than O(N) iterations. You might thing that it's very unlikely, but RULES make it much more likely. Here's a real example from Trac #1969: Rec { $dm = \d.\x. op d {-# RULES forall d. $dm Int d = $s$dm1 forall d. $dm Bool d = $s$dm2 #-} dInt = MkD .... opInt ... dInt = MkD .... opBool ... opInt = $dm dInt opBool = $dm dBool $s$dm1 = \x. op dInt $s$dm2 = \x. op dBool } The RULES stuff means that we can't choose $dm as a loop breaker (Note [Choosing loop breakers]), so we must choose at least (say) opInt *and* opBool, and so on. The number of loop breakders is linear in the number of instance declarations. Note [Loop breakers and INLINE/INLINEABLE pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Avoid choosing a function with an INLINE pramga as the loop breaker! If such a function is mutually-recursive with a non-INLINE thing, then the latter should be the loop-breaker. It's vital to distinguish between INLINE and INLINEABLE (the Bool returned by hasStableCoreUnfolding_maybe). If we start with Rec { {-# INLINEABLE f #-} f x = ...f... } and then worker/wrapper it through strictness analysis, we'll get Rec { {-# INLINEABLE $wf #-} $wf p q = let x = (p,q) in ...f... {-# INLINE f #-} f x = case x of (p,q) -> $wf p q } Now it is vital that we choose $wf as the loop breaker, so we can inline 'f' in '$wf'. Note [DFuns should not be loop breakers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's particularly bad to make a DFun into a loop breaker. See Note [How instance declarations are translated] in TcInstDcls We give DFuns a higher score than ordinary CONLIKE things because if there's a choice we want the DFun to be the non-looop breker. Eg rec { sc = /\ a \$dC. $fBWrap (T a) ($fCT @ a $dC) $fCT :: forall a_afE. (Roman.C a_afE) => Roman.C (Roman.T a_afE) {-# DFUN #-} $fCT = /\a \$dC. MkD (T a) ((sc @ a $dC) |> blah) ($ctoF @ a $dC) } Here 'sc' (the superclass) looks CONLIKE, but we'll never get to it if we can't unravel the DFun first. Note [Constructor applications] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's really really important to inline dictionaries. Real example (the Enum Ordering instance from GHC.Base): rec f = \ x -> case d of (p,q,r) -> p x g = \ x -> case d of (p,q,r) -> q x d = (v, f, g) Here, f and g occur just once; but we can't inline them into d. On the other hand we *could* simplify those case expressions if we didn't stupidly choose d as the loop breaker. But we won't because constructor args are marked "Many". Inlining dictionaries is really essential to unravelling the loops in static numeric dictionaries, see GHC.Float. Note [Closure conversion] ~~~~~~~~~~~~~~~~~~~~~~~~~ We treat (\x. C p q) as a high-score candidate in the letrec scoring algorithm. The immediate motivation came from the result of a closure-conversion transformation which generated code like this: data Clo a b = forall c. Clo (c -> a -> b) c ($:) :: Clo a b -> a -> b Clo f env $: x = f env x rec { plus = Clo plus1 () ; plus1 _ n = Clo plus2 n ; plus2 Zero n = n ; plus2 (Succ m) n = Succ (plus $: m $: n) } If we inline 'plus' and 'plus1', everything unravels nicely. But if we choose 'plus1' as the loop breaker (which is entirely possible otherwise), the loop does not unravel nicely. @occAnalRhs@ deals with the question of bindings where the Id is marked by an INLINE pragma. For these we record that anything which occurs in its RHS occurs many times. This pessimistically assumes that ths inlined binder also occurs many times in its scope, but if it doesn't we'll catch it next time round. At worst this costs an extra simplifier pass. ToDo: try using the occurrence info for the inline'd binder. [March 97] We do the same for atomic RHSs. Reason: see notes with loopBreakSCC. [June 98, SLPJ] I've undone this change; I don't understand it. See notes with loopBreakSCC. -}
9,400
reOrderNodes depth bndr_set weak_fvs (node : nodes) binds = -- pprTrace "reOrderNodes" (text "unchosen" <+> ppr unchosen $$ -- text "chosen" <+> ppr chosen_nodes) $ loopBreakNodes new_depth bndr_set weak_fvs unchosen $ (map mk_loop_breaker chosen_nodes ++ binds) where (chosen_nodes, unchosen) = choose_loop_breaker (score node) [node] [] nodes approximate_loop_breaker = depth >= 2 new_depth | approximate_loop_breaker = 0 | otherwise = depth+1 -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 choose_loop_breaker :: Int -- Best score so far -> [Node Details] -- Nodes with this score -> [Node Details] -- Nodes with higher scores -> [Node Details] -- Unprocessed nodes -> ([Node Details], [Node Details]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in choose_loop_breaker _ loop_nodes acc [] = (loop_nodes, acc) -- Done -- If approximate_loop_breaker is True, we pick *all* -- nodes with lowest score, else just one -- See Note [Complexity of loop breaking] choose_loop_breaker loop_sc loop_nodes acc (node : nodes) | sc < loop_sc -- Lower score so pick this new one = choose_loop_breaker sc [node] (loop_nodes ++ acc) nodes | approximate_loop_breaker && sc == loop_sc = choose_loop_breaker loop_sc (node : loop_nodes) acc nodes | otherwise -- Higher score so don't pick it = choose_loop_breaker loop_sc loop_nodes (node : acc) nodes where sc = score node score :: Node Details -> Int -- Higher score => less likely to be picked as loop breaker score (ND { nd_bndr = bndr, nd_rhs = rhs }, _, _) | not (isId bndr) = 100 -- A type or cercion variable is never a loop breaker | isDFunId bndr = 9 -- Never choose a DFun as a loop breaker -- Note [DFuns should not be loop breakers] | Just be_very_keen <- hasStableCoreUnfolding_maybe (idUnfolding bndr) = if be_very_keen then 6 -- Note [Loop breakers and INLINE/INLINEABLE pragmas] else 3 -- Data structures are more important than INLINE pragmas -- so that dictionary/method recursion unravels -- Note that this case hits all stable unfoldings, so we -- never look at 'rhs' for stable unfoldings. That's right, because -- 'rhs' is irrelevant for inlining things with a stable unfolding | is_con_app rhs = 5 -- Data types help with cases: Note [Constructor applications] | exprIsTrivial rhs = 10 -- Practically certain to be inlined -- Used to have also: && not (isExportedId bndr) -- But I found this sometimes cost an extra iteration when we have -- rec { d = (a,b); a = ...df...; b = ...df...; df = d } -- where df is the exported dictionary. Then df makes a really -- bad choice for loop breaker -- If an Id is marked "never inline" then it makes a great loop breaker -- The only reason for not checking that here is that it is rare -- and I've never seen a situation where it makes a difference, -- so it probably isn't worth the time to test on every binder -- | isNeverActive (idInlinePragma bndr) = -10 | isOneOcc (idOccInfo bndr) = 2 -- Likely to be inlined | canUnfold (realIdUnfolding bndr) = 1 -- The Id has some kind of unfolding -- Ignore loop-breaker-ness here because that is what we are setting! | otherwise = 0 -- Checking for a constructor application -- Cheap and cheerful; the simplifer moves casts out of the way -- The lambda case is important to spot x = /\a. C (f a) -- which comes up when C is a dictionary constructor and -- f is a default method. -- Example: the instance for Show (ST s a) in GHC.ST -- -- However we *also* treat (\x. C p q) as a con-app-like thing, -- Note [Closure conversion] is_con_app (Var v) = isConLikeId v is_con_app (App f _) = is_con_app f is_con_app (Lam _ e) = is_con_app e is_con_app (Tick _ e) = is_con_app e is_con_app _ = False {- Note [Complexity of loop breaking] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The loop-breaking algorithm knocks out one binder at a time, and performs a new SCC analysis on the remaining binders. That can behave very badly in tightly-coupled groups of bindings; in the worst case it can be (N**2)*log N, because it does a full SCC on N, then N-1, then N-2 and so on. To avoid this, we switch plans after 2 (or whatever) attempts: Plan A: pick one binder with the lowest score, make it a loop breaker, and try again Plan B: pick *all* binders with the lowest score, make them all loop breakers, and try again Since there are only a small finite number of scores, this will terminate in a constant number of iterations, rather than O(N) iterations. You might thing that it's very unlikely, but RULES make it much more likely. Here's a real example from Trac #1969: Rec { $dm = \d.\x. op d {-# RULES forall d. $dm Int d = $s$dm1 forall d. $dm Bool d = $s$dm2 #-} dInt = MkD .... opInt ... dInt = MkD .... opBool ... opInt = $dm dInt opBool = $dm dBool $s$dm1 = \x. op dInt $s$dm2 = \x. op dBool } The RULES stuff means that we can't choose $dm as a loop breaker (Note [Choosing loop breakers]), so we must choose at least (say) opInt *and* opBool, and so on. The number of loop breakders is linear in the number of instance declarations. Note [Loop breakers and INLINE/INLINEABLE pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Avoid choosing a function with an INLINE pramga as the loop breaker! If such a function is mutually-recursive with a non-INLINE thing, then the latter should be the loop-breaker. It's vital to distinguish between INLINE and INLINEABLE (the Bool returned by hasStableCoreUnfolding_maybe). If we start with Rec { {-# INLINEABLE f #-} f x = ...f... } and then worker/wrapper it through strictness analysis, we'll get Rec { {-# INLINEABLE $wf #-} $wf p q = let x = (p,q) in ...f... {-# INLINE f #-} f x = case x of (p,q) -> $wf p q } Now it is vital that we choose $wf as the loop breaker, so we can inline 'f' in '$wf'. Note [DFuns should not be loop breakers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's particularly bad to make a DFun into a loop breaker. See Note [How instance declarations are translated] in TcInstDcls We give DFuns a higher score than ordinary CONLIKE things because if there's a choice we want the DFun to be the non-looop breker. Eg rec { sc = /\ a \$dC. $fBWrap (T a) ($fCT @ a $dC) $fCT :: forall a_afE. (Roman.C a_afE) => Roman.C (Roman.T a_afE) {-# DFUN #-} $fCT = /\a \$dC. MkD (T a) ((sc @ a $dC) |> blah) ($ctoF @ a $dC) } Here 'sc' (the superclass) looks CONLIKE, but we'll never get to it if we can't unravel the DFun first. Note [Constructor applications] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's really really important to inline dictionaries. Real example (the Enum Ordering instance from GHC.Base): rec f = \ x -> case d of (p,q,r) -> p x g = \ x -> case d of (p,q,r) -> q x d = (v, f, g) Here, f and g occur just once; but we can't inline them into d. On the other hand we *could* simplify those case expressions if we didn't stupidly choose d as the loop breaker. But we won't because constructor args are marked "Many". Inlining dictionaries is really essential to unravelling the loops in static numeric dictionaries, see GHC.Float. Note [Closure conversion] ~~~~~~~~~~~~~~~~~~~~~~~~~ We treat (\x. C p q) as a high-score candidate in the letrec scoring algorithm. The immediate motivation came from the result of a closure-conversion transformation which generated code like this: data Clo a b = forall c. Clo (c -> a -> b) c ($:) :: Clo a b -> a -> b Clo f env $: x = f env x rec { plus = Clo plus1 () ; plus1 _ n = Clo plus2 n ; plus2 Zero n = n ; plus2 (Succ m) n = Succ (plus $: m $: n) } If we inline 'plus' and 'plus1', everything unravels nicely. But if we choose 'plus1' as the loop breaker (which is entirely possible otherwise), the loop does not unravel nicely. @occAnalRhs@ deals with the question of bindings where the Id is marked by an INLINE pragma. For these we record that anything which occurs in its RHS occurs many times. This pessimistically assumes that ths inlined binder also occurs many times in its scope, but if it doesn't we'll catch it next time round. At worst this costs an extra simplifier pass. ToDo: try using the occurrence info for the inline'd binder. [March 97] We do the same for atomic RHSs. Reason: see notes with loopBreakSCC. [June 98, SLPJ] I've undone this change; I don't understand it. See notes with loopBreakSCC. -}
9,400
reOrderNodes depth bndr_set weak_fvs (node : nodes) binds = -- pprTrace "reOrderNodes" (text "unchosen" <+> ppr unchosen $$ -- text "chosen" <+> ppr chosen_nodes) $ loopBreakNodes new_depth bndr_set weak_fvs unchosen $ (map mk_loop_breaker chosen_nodes ++ binds) where (chosen_nodes, unchosen) = choose_loop_breaker (score node) [node] [] nodes approximate_loop_breaker = depth >= 2 new_depth | approximate_loop_breaker = 0 | otherwise = depth+1 -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 choose_loop_breaker :: Int -- Best score so far -> [Node Details] -- Nodes with this score -> [Node Details] -- Nodes with higher scores -> [Node Details] -- Unprocessed nodes -> ([Node Details], [Node Details]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in choose_loop_breaker _ loop_nodes acc [] = (loop_nodes, acc) -- Done -- If approximate_loop_breaker is True, we pick *all* -- nodes with lowest score, else just one -- See Note [Complexity of loop breaking] choose_loop_breaker loop_sc loop_nodes acc (node : nodes) | sc < loop_sc -- Lower score so pick this new one = choose_loop_breaker sc [node] (loop_nodes ++ acc) nodes | approximate_loop_breaker && sc == loop_sc = choose_loop_breaker loop_sc (node : loop_nodes) acc nodes | otherwise -- Higher score so don't pick it = choose_loop_breaker loop_sc loop_nodes (node : acc) nodes where sc = score node score :: Node Details -> Int -- Higher score => less likely to be picked as loop breaker score (ND { nd_bndr = bndr, nd_rhs = rhs }, _, _) | not (isId bndr) = 100 -- A type or cercion variable is never a loop breaker | isDFunId bndr = 9 -- Never choose a DFun as a loop breaker -- Note [DFuns should not be loop breakers] | Just be_very_keen <- hasStableCoreUnfolding_maybe (idUnfolding bndr) = if be_very_keen then 6 -- Note [Loop breakers and INLINE/INLINEABLE pragmas] else 3 -- Data structures are more important than INLINE pragmas -- so that dictionary/method recursion unravels -- Note that this case hits all stable unfoldings, so we -- never look at 'rhs' for stable unfoldings. That's right, because -- 'rhs' is irrelevant for inlining things with a stable unfolding | is_con_app rhs = 5 -- Data types help with cases: Note [Constructor applications] | exprIsTrivial rhs = 10 -- Practically certain to be inlined -- Used to have also: && not (isExportedId bndr) -- But I found this sometimes cost an extra iteration when we have -- rec { d = (a,b); a = ...df...; b = ...df...; df = d } -- where df is the exported dictionary. Then df makes a really -- bad choice for loop breaker -- If an Id is marked "never inline" then it makes a great loop breaker -- The only reason for not checking that here is that it is rare -- and I've never seen a situation where it makes a difference, -- so it probably isn't worth the time to test on every binder -- | isNeverActive (idInlinePragma bndr) = -10 | isOneOcc (idOccInfo bndr) = 2 -- Likely to be inlined | canUnfold (realIdUnfolding bndr) = 1 -- The Id has some kind of unfolding -- Ignore loop-breaker-ness here because that is what we are setting! | otherwise = 0 -- Checking for a constructor application -- Cheap and cheerful; the simplifer moves casts out of the way -- The lambda case is important to spot x = /\a. C (f a) -- which comes up when C is a dictionary constructor and -- f is a default method. -- Example: the instance for Show (ST s a) in GHC.ST -- -- However we *also* treat (\x. C p q) as a con-app-like thing, -- Note [Closure conversion] is_con_app (Var v) = isConLikeId v is_con_app (App f _) = is_con_app f is_con_app (Lam _ e) = is_con_app e is_con_app (Tick _ e) = is_con_app e is_con_app _ = False {- Note [Complexity of loop breaking] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The loop-breaking algorithm knocks out one binder at a time, and performs a new SCC analysis on the remaining binders. That can behave very badly in tightly-coupled groups of bindings; in the worst case it can be (N**2)*log N, because it does a full SCC on N, then N-1, then N-2 and so on. To avoid this, we switch plans after 2 (or whatever) attempts: Plan A: pick one binder with the lowest score, make it a loop breaker, and try again Plan B: pick *all* binders with the lowest score, make them all loop breakers, and try again Since there are only a small finite number of scores, this will terminate in a constant number of iterations, rather than O(N) iterations. You might thing that it's very unlikely, but RULES make it much more likely. Here's a real example from Trac #1969: Rec { $dm = \d.\x. op d {-# RULES forall d. $dm Int d = $s$dm1 forall d. $dm Bool d = $s$dm2 #-} dInt = MkD .... opInt ... dInt = MkD .... opBool ... opInt = $dm dInt opBool = $dm dBool $s$dm1 = \x. op dInt $s$dm2 = \x. op dBool } The RULES stuff means that we can't choose $dm as a loop breaker (Note [Choosing loop breakers]), so we must choose at least (say) opInt *and* opBool, and so on. The number of loop breakders is linear in the number of instance declarations. Note [Loop breakers and INLINE/INLINEABLE pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Avoid choosing a function with an INLINE pramga as the loop breaker! If such a function is mutually-recursive with a non-INLINE thing, then the latter should be the loop-breaker. It's vital to distinguish between INLINE and INLINEABLE (the Bool returned by hasStableCoreUnfolding_maybe). If we start with Rec { {-# INLINEABLE f #-} f x = ...f... } and then worker/wrapper it through strictness analysis, we'll get Rec { {-# INLINEABLE $wf #-} $wf p q = let x = (p,q) in ...f... {-# INLINE f #-} f x = case x of (p,q) -> $wf p q } Now it is vital that we choose $wf as the loop breaker, so we can inline 'f' in '$wf'. Note [DFuns should not be loop breakers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's particularly bad to make a DFun into a loop breaker. See Note [How instance declarations are translated] in TcInstDcls We give DFuns a higher score than ordinary CONLIKE things because if there's a choice we want the DFun to be the non-looop breker. Eg rec { sc = /\ a \$dC. $fBWrap (T a) ($fCT @ a $dC) $fCT :: forall a_afE. (Roman.C a_afE) => Roman.C (Roman.T a_afE) {-# DFUN #-} $fCT = /\a \$dC. MkD (T a) ((sc @ a $dC) |> blah) ($ctoF @ a $dC) } Here 'sc' (the superclass) looks CONLIKE, but we'll never get to it if we can't unravel the DFun first. Note [Constructor applications] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's really really important to inline dictionaries. Real example (the Enum Ordering instance from GHC.Base): rec f = \ x -> case d of (p,q,r) -> p x g = \ x -> case d of (p,q,r) -> q x d = (v, f, g) Here, f and g occur just once; but we can't inline them into d. On the other hand we *could* simplify those case expressions if we didn't stupidly choose d as the loop breaker. But we won't because constructor args are marked "Many". Inlining dictionaries is really essential to unravelling the loops in static numeric dictionaries, see GHC.Float. Note [Closure conversion] ~~~~~~~~~~~~~~~~~~~~~~~~~ We treat (\x. C p q) as a high-score candidate in the letrec scoring algorithm. The immediate motivation came from the result of a closure-conversion transformation which generated code like this: data Clo a b = forall c. Clo (c -> a -> b) c ($:) :: Clo a b -> a -> b Clo f env $: x = f env x rec { plus = Clo plus1 () ; plus1 _ n = Clo plus2 n ; plus2 Zero n = n ; plus2 (Succ m) n = Succ (plus $: m $: n) } If we inline 'plus' and 'plus1', everything unravels nicely. But if we choose 'plus1' as the loop breaker (which is entirely possible otherwise), the loop does not unravel nicely. @occAnalRhs@ deals with the question of bindings where the Id is marked by an INLINE pragma. For these we record that anything which occurs in its RHS occurs many times. This pessimistically assumes that ths inlined binder also occurs many times in its scope, but if it doesn't we'll catch it next time round. At worst this costs an extra simplifier pass. ToDo: try using the occurrence info for the inline'd binder. [March 97] We do the same for atomic RHSs. Reason: see notes with loopBreakSCC. [June 98, SLPJ] I've undone this change; I don't understand it. See notes with loopBreakSCC. -}
9,400
false
false
0
11
2,617
620
330
290
null
null
noteed/scp-streams
Network/SCP/Protocol.hs
bsd-3-clause
startSending :: SCP -> IO Bool startSending SCP{..} = do getFeedback scpOut
77
startSending :: SCP -> IO Bool startSending SCP{..} = do getFeedback scpOut
77
startSending SCP{..} = do getFeedback scpOut
46
false
true
0
8
13
38
16
22
null
null
yiannist/ganeti
src/Ganeti/Confd/Utils.hs
bsd-2-clause
-- | Returns the HMAC key. getClusterHmac :: IO HashKey getClusterHmac = Path.confdHmacKey >>= fmap B.unpack . B.readFile
121
getClusterHmac :: IO HashKey getClusterHmac = Path.confdHmacKey >>= fmap B.unpack . B.readFile
94
getClusterHmac = Path.confdHmacKey >>= fmap B.unpack . B.readFile
65
true
true
0
8
17
32
16
16
null
null
agentm/project-m36
src/lib/ProjectM36/IsomorphicSchema.hs
unlicense
databaseContextExprMorph iso@(IsoUnion (rvTrue, rvFalse) filt rvOut) relExprFunc expr = case expr of --assign: replace all instances in the portion of the target relvar with the new tuples from the relExpr --problem: between the delete->insert, constraints could be violated which would not otherwise be violated in the "in" schema. This implies that there should be a combo operator which can insert/update/delete in a single pass based on relexpr queries, or perhaps MultipleExpr should be the infamous "comma" operator from TutorialD? -- if any tuples are filtered out of the insert/assign, we need to simulate a constraint violation Assign rv relExpr | rv == rvTrue -> relExprFunc relExpr >>= \ex -> pure $ MultipleExpr [Delete rvOut filt, Insert rvOut (Restrict filt ex)] Assign rv relExpr | rv == rvFalse -> relExprFunc relExpr >>= \ex -> pure $ MultipleExpr [Delete rvOut (NotPredicate filt), Insert rvOut (Restrict (NotPredicate filt) ex)] Insert rv relExpr | rv == rvTrue || rv == rvFalse -> relExprFunc relExpr >>= \ex -> pure $ Insert rvOut ex Delete rv delPred | rv == rvTrue -> pure $ Delete rvOut (AndPredicate delPred filt) Delete rv delPred | rv == rvFalse -> pure $ Delete rvOut (AndPredicate delPred (NotPredicate filt)) Update rv attrMap predi | rv == rvTrue -> pure $ Update rvOut attrMap (AndPredicate predi filt) Update rv attrMap predi | rv == rvFalse -> pure $ Update rvOut attrMap (AndPredicate (NotPredicate filt) predi) MultipleExpr exprs -> MultipleExpr <$> mapM (databaseContextExprMorph iso relExprFunc) exprs orig -> pure orig
1,773
databaseContextExprMorph iso@(IsoUnion (rvTrue, rvFalse) filt rvOut) relExprFunc expr = case expr of --assign: replace all instances in the portion of the target relvar with the new tuples from the relExpr --problem: between the delete->insert, constraints could be violated which would not otherwise be violated in the "in" schema. This implies that there should be a combo operator which can insert/update/delete in a single pass based on relexpr queries, or perhaps MultipleExpr should be the infamous "comma" operator from TutorialD? -- if any tuples are filtered out of the insert/assign, we need to simulate a constraint violation Assign rv relExpr | rv == rvTrue -> relExprFunc relExpr >>= \ex -> pure $ MultipleExpr [Delete rvOut filt, Insert rvOut (Restrict filt ex)] Assign rv relExpr | rv == rvFalse -> relExprFunc relExpr >>= \ex -> pure $ MultipleExpr [Delete rvOut (NotPredicate filt), Insert rvOut (Restrict (NotPredicate filt) ex)] Insert rv relExpr | rv == rvTrue || rv == rvFalse -> relExprFunc relExpr >>= \ex -> pure $ Insert rvOut ex Delete rv delPred | rv == rvTrue -> pure $ Delete rvOut (AndPredicate delPred filt) Delete rv delPred | rv == rvFalse -> pure $ Delete rvOut (AndPredicate delPred (NotPredicate filt)) Update rv attrMap predi | rv == rvTrue -> pure $ Update rvOut attrMap (AndPredicate predi filt) Update rv attrMap predi | rv == rvFalse -> pure $ Update rvOut attrMap (AndPredicate (NotPredicate filt) predi) MultipleExpr exprs -> MultipleExpr <$> mapM (databaseContextExprMorph iso relExprFunc) exprs orig -> pure orig
1,773
databaseContextExprMorph iso@(IsoUnion (rvTrue, rvFalse) filt rvOut) relExprFunc expr = case expr of --assign: replace all instances in the portion of the target relvar with the new tuples from the relExpr --problem: between the delete->insert, constraints could be violated which would not otherwise be violated in the "in" schema. This implies that there should be a combo operator which can insert/update/delete in a single pass based on relexpr queries, or perhaps MultipleExpr should be the infamous "comma" operator from TutorialD? -- if any tuples are filtered out of the insert/assign, we need to simulate a constraint violation Assign rv relExpr | rv == rvTrue -> relExprFunc relExpr >>= \ex -> pure $ MultipleExpr [Delete rvOut filt, Insert rvOut (Restrict filt ex)] Assign rv relExpr | rv == rvFalse -> relExprFunc relExpr >>= \ex -> pure $ MultipleExpr [Delete rvOut (NotPredicate filt), Insert rvOut (Restrict (NotPredicate filt) ex)] Insert rv relExpr | rv == rvTrue || rv == rvFalse -> relExprFunc relExpr >>= \ex -> pure $ Insert rvOut ex Delete rv delPred | rv == rvTrue -> pure $ Delete rvOut (AndPredicate delPred filt) Delete rv delPred | rv == rvFalse -> pure $ Delete rvOut (AndPredicate delPred (NotPredicate filt)) Update rv attrMap predi | rv == rvTrue -> pure $ Update rvOut attrMap (AndPredicate predi filt) Update rv attrMap predi | rv == rvFalse -> pure $ Update rvOut attrMap (AndPredicate (NotPredicate filt) predi) MultipleExpr exprs -> MultipleExpr <$> mapM (databaseContextExprMorph iso relExprFunc) exprs orig -> pure orig
1,773
false
false
1
18
463
434
204
230
null
null
christiaanb/ghc
compiler/simplCore/CoreMonad.hs
bsd-3-clause
-- | Outputs a debugging message at verbosity level of @-v@ or higher debugTraceMsg :: SDoc -> CoreM () debugTraceMsg = msg (flip Err.debugTraceMsg 3)
150
debugTraceMsg :: SDoc -> CoreM () debugTraceMsg = msg (flip Err.debugTraceMsg 3)
80
debugTraceMsg = msg (flip Err.debugTraceMsg 3)
46
true
true
0
8
24
34
17
17
null
null
langthom/stats
dist/build/autogen/Paths_stats.hs
bsd-3-clause
libexecdir = "/usr/local/libexec"
33
libexecdir = "/usr/local/libexec"
33
libexecdir = "/usr/local/libexec"
33
false
false
1
5
2
10
3
7
null
null
input-output-hk/pos-haskell-prototype
crypto/Pos/Crypto/SecretSharing.hs
mit
getDhSecret :: Scrape.DhSecret -> ByteString getDhSecret (Scrape.DhSecret s) = s
80
getDhSecret :: Scrape.DhSecret -> ByteString getDhSecret (Scrape.DhSecret s) = s
80
getDhSecret (Scrape.DhSecret s) = s
35
false
true
0
10
9
34
15
19
null
null
dmvianna/haskellbook
src/Ch26-MorraState.hs
unlicense
layer AI2P B = "Person"
24
player AI2P B = "Person"
24
player AI2P B = "Person"
24
false
false
0
5
5
11
5
6
null
null
zoomhub/zoomhub
tests/ZoomHub/Types/DeepZoomImageSpec.hs
mit
main :: IO () main = hspec spec
31
main :: IO () main = hspec spec
31
main = hspec spec
17
false
true
0
7
7
25
10
15
null
null
factisresearch/influx
test/Database/Influx/API/Tests.hs
bsd-3-clause
dropDb :: DatabaseName -> IO () dropDb name = let query = Query $ "DROP DATABASE IF EXISTS " <> name in postQuery testConfig Nothing query
146
dropDb :: DatabaseName -> IO () dropDb name = let query = Query $ "DROP DATABASE IF EXISTS " <> name in postQuery testConfig Nothing query
146
dropDb name = let query = Query $ "DROP DATABASE IF EXISTS " <> name in postQuery testConfig Nothing query
114
false
true
0
10
33
49
23
26
null
null
bos/math-functions
tests/Tests/Sum.hs
bsd-2-clause
trueSum :: (Fractional b, Real a) => [a] -> b trueSum xs = fromRational . Prelude.sum . map toRational $ xs
107
trueSum :: (Fractional b, Real a) => [a] -> b trueSum xs = fromRational . Prelude.sum . map toRational $ xs
107
trueSum xs = fromRational . Prelude.sum . map toRational $ xs
61
false
true
0
8
20
53
27
26
null
null
xmonad/xmonad
src/XMonad/Main.hs
bsd-3-clause
handle (MapRequestEvent {ev_window = w}) = withDisplay $ \dpy -> do withWindowAttributes dpy w $ \wa -> do -- ignore override windows -- need to ignore mapping requests by managed windows not on the current workspace managed <- isClient w when (not (wa_override_redirect wa) && not managed) $ manage w -- window destroyed, unmanage it -- window gone, unmanage it -- broadcast to layouts
417
handle (MapRequestEvent {ev_window = w}) = withDisplay $ \dpy -> do withWindowAttributes dpy w $ \wa -> do -- ignore override windows -- need to ignore mapping requests by managed windows not on the current workspace managed <- isClient w when (not (wa_override_redirect wa) && not managed) $ manage w -- window destroyed, unmanage it -- window gone, unmanage it -- broadcast to layouts
417
handle (MapRequestEvent {ev_window = w}) = withDisplay $ \dpy -> do withWindowAttributes dpy w $ \wa -> do -- ignore override windows -- need to ignore mapping requests by managed windows not on the current workspace managed <- isClient w when (not (wa_override_redirect wa) && not managed) $ manage w -- window destroyed, unmanage it -- window gone, unmanage it -- broadcast to layouts
417
false
false
0
19
94
94
47
47
null
null
brendanhay/gogol
gogol-tagmanager/gen/Network/Google/Resource/TagManager/Accounts/Update.hs
mpl-2.0
-- | OAuth access token. auAccessToken :: Lens' AccountsUpdate (Maybe Text) auAccessToken = lens _auAccessToken (\ s a -> s{_auAccessToken = a})
152
auAccessToken :: Lens' AccountsUpdate (Maybe Text) auAccessToken = lens _auAccessToken (\ s a -> s{_auAccessToken = a})
127
auAccessToken = lens _auAccessToken (\ s a -> s{_auAccessToken = a})
76
true
true
1
9
29
51
25
26
null
null
upsoft/bond
compiler/src/Language/Bond/Syntax/Util.hs
mit
isList (BT_Vector _) = True
27
isList (BT_Vector _) = True
27
isList (BT_Vector _) = True
27
false
false
0
7
4
15
7
8
null
null
athanclark/nested-routes-website
src/Application.hs
bsd-3-clause
contentLayer :: MonadApp m => MiddlewareT m contentLayer = route routes
71
contentLayer :: MonadApp m => MiddlewareT m contentLayer = route routes
71
contentLayer = route routes
27
false
true
0
6
10
24
11
13
null
null
GaloisInc/ivory
ivory-model-check/src/Ivory/ModelCheck/CVC4.hs
bsd-3-clause
mulFunc :: Statement mulFunc = Statement $ B.unwords [ B.pack mulAbs, ":", "(INT, INT)", "->", "INT" ]
104
mulFunc :: Statement mulFunc = Statement $ B.unwords [ B.pack mulAbs, ":", "(INT, INT)", "->", "INT" ]
104
mulFunc = Statement $ B.unwords [ B.pack mulAbs, ":", "(INT, INT)", "->", "INT" ]
83
false
true
0
8
18
47
23
24
null
null
meditans/documentator
src/Documentator/Descriptors.hs
gpl-3.0
resultTyCon t@(TyPromoted _ _) = t
34
resultTyCon t@(TyPromoted _ _) = t
34
resultTyCon t@(TyPromoted _ _) = t
34
false
false
0
8
5
20
10
10
null
null
Erdwolf/autotool-bonn
src/Uni/SS04/Serie6.hs
gpl-2.0
conformwhile bs prog = do builtins bs prog
51
conformwhile bs prog = do builtins bs prog
51
conformwhile bs prog = do builtins bs prog
51
false
false
0
7
16
19
8
11
null
null
koba-e964/hayashii-mcc
llvm/Emit.hs
bsd-3-clause
-- 64-bit integer int64 :: AST.Type int64 = IntegerType 64
58
int64 :: AST.Type int64 = IntegerType 64
40
int64 = IntegerType 64
22
true
true
0
5
9
17
9
8
null
null
xu-hao/QueryArrow
QueryArrow-common/src/QueryArrow/DB/ResultStream.hs
bsd-3-clause
isResultStreamEmpty :: (Monad m) => ResultStream m a -> m Bool isResultStreamEmpty rs = runConduit (rs =$ null)
112
isResultStreamEmpty :: (Monad m) => ResultStream m a -> m Bool isResultStreamEmpty rs = runConduit (rs =$ null)
111
isResultStreamEmpty rs = runConduit (rs =$ null)
48
false
true
0
7
18
45
22
23
null
null
alekar/hugs
packages/base/Data/Map.hs
bsd-3-clause
intersectionWithKey f t Tip = Tip
33
intersectionWithKey f t Tip = Tip
33
intersectionWithKey f t Tip = Tip
33
false
false
0
5
5
13
6
7
null
null
ExpHP/haskell-memory-halp
app/Attempt3.hs
bsd-3-clause
main :: IO () main = doMain $ do _ <- readYaml "band.yaml" :: IO Value pure ()
86
main :: IO () main = doMain $ do _ <- readYaml "band.yaml" :: IO Value pure ()
86
main = doMain $ do _ <- readYaml "band.yaml" :: IO Value pure ()
72
false
true
0
9
25
44
20
24
null
null
SimSaladin/haikubot
Haikubot/Plugins/Runot.hs
bsd-3-clause
implicitMonogatari :: Text -> Action Runot Res implicitMonogatari title = do from <- liftM (fromMaybe "(no-one)") origin iam <- liftM (fromMaybe "(no-one)") whoami haikuFile <- aget rHaikuFile exists <- liftIO $ doesFileExist haikuFile if exists then do haikus <- liftIO $ liftM (map read . reverse . lines) $ readFile haikuFile let ismine (Left (Haiku author _ _)) = iam == author ismine _ = False unLeft (Left x) = x unLeft _ = error "unLeft: not Left" case takeWhile ismine haikus of [] -> reply "Yhtään haikua ei löytynyt monogatariin" xs -> let monog = (from, title, map (either id $ error "Right: monogatari recursive?") xs) rest = reverse (Right monog : drop (length xs) haikus) in do setHaikus rest void $ reply $ "Implisiittinen monogotari: " <> title distributeMonog monog stop else reply "Error: no haiku file(!)"
1,200
implicitMonogatari :: Text -> Action Runot Res implicitMonogatari title = do from <- liftM (fromMaybe "(no-one)") origin iam <- liftM (fromMaybe "(no-one)") whoami haikuFile <- aget rHaikuFile exists <- liftIO $ doesFileExist haikuFile if exists then do haikus <- liftIO $ liftM (map read . reverse . lines) $ readFile haikuFile let ismine (Left (Haiku author _ _)) = iam == author ismine _ = False unLeft (Left x) = x unLeft _ = error "unLeft: not Left" case takeWhile ismine haikus of [] -> reply "Yhtään haikua ei löytynyt monogatariin" xs -> let monog = (from, title, map (either id $ error "Right: monogatari recursive?") xs) rest = reverse (Right monog : drop (length xs) haikus) in do setHaikus rest void $ reply $ "Implisiittinen monogotari: " <> title distributeMonog monog stop else reply "Error: no haiku file(!)"
1,200
implicitMonogatari title = do from <- liftM (fromMaybe "(no-one)") origin iam <- liftM (fromMaybe "(no-one)") whoami haikuFile <- aget rHaikuFile exists <- liftIO $ doesFileExist haikuFile if exists then do haikus <- liftIO $ liftM (map read . reverse . lines) $ readFile haikuFile let ismine (Left (Haiku author _ _)) = iam == author ismine _ = False unLeft (Left x) = x unLeft _ = error "unLeft: not Left" case takeWhile ismine haikus of [] -> reply "Yhtään haikua ei löytynyt monogatariin" xs -> let monog = (from, title, map (either id $ error "Right: monogatari recursive?") xs) rest = reverse (Right monog : drop (length xs) haikus) in do setHaikus rest void $ reply $ "Implisiittinen monogotari: " <> title distributeMonog monog stop else reply "Error: no haiku file(!)"
1,153
false
true
0
23
514
327
150
177
null
null
gcampax/ghc
compiler/rename/RnTypes.hs
bsd-3-clause
mkHsOpTyRn mk1 _ _ ty1 ty2 -- Default case, no rearrangment = return (mk1 ty1 ty2)
97
mkHsOpTyRn mk1 _ _ ty1 ty2 -- Default case, no rearrangment = return (mk1 ty1 ty2)
97
mkHsOpTyRn mk1 _ _ ty1 ty2 -- Default case, no rearrangment = return (mk1 ty1 ty2)
97
false
false
0
7
30
29
14
15
null
null
stevezhee/pec
Pec/PUtil.hs
bsd-3-clause
parse_pec :: FilePath -> IO (P.Module Point) parse_pec = parse_m P.grmLexFilePath (PP.grmParse . layout) modid_p
112
parse_pec :: FilePath -> IO (P.Module Point) parse_pec = parse_m P.grmLexFilePath (PP.grmParse . layout) modid_p
112
parse_pec = parse_m P.grmLexFilePath (PP.grmParse . layout) modid_p
67
false
true
0
9
14
44
22
22
null
null
sw17ch/gator
src/Language/Gator/Logic.hs
bsd-3-clause
initGI :: GateIDs initGI = GateIDs 0 0 0 0 0 0
46
initGI :: GateIDs initGI = GateIDs 0 0 0 0 0 0
46
initGI = GateIDs 0 0 0 0 0 0
28
false
true
0
6
11
31
13
18
null
null
bakineggs/k-framework
tools/language-k/Language/K/Core/Pretty/KMode.hs
gpl-2.0
ppKLabel (KString s) = "String " ++ show s
44
ppKLabel (KString s) = "String " ++ show s
44
ppKLabel (KString s) = "String " ++ show s
44
false
false
2
6
10
24
10
14
null
null
plow-technologies/cabal
cabal-install/Distribution/Client/Dependency/Modular/Dependency.hs
bsd-3-clause
mapCompFlaggedDep g (Simple pn a ) = Simple pn (g a)
59
mapCompFlaggedDep g (Simple pn a ) = Simple pn (g a)
59
mapCompFlaggedDep g (Simple pn a ) = Simple pn (g a)
59
false
false
0
7
17
32
14
18
null
null
kawu/ltag
src/NLP/LTAG/V1.hs
bsd-2-clause
alternate xs = mapMaybe hd xs ++ alternate (mapMaybe tl xs) where hd (x:_) = Just x hd _ = Nothing tl (_:ys) = Just ys tl _ = Nothing -- | Get root non-terminal.
196
alternate xs = mapMaybe hd xs ++ alternate (mapMaybe tl xs) where hd (x:_) = Just x hd _ = Nothing tl (_:ys) = Just ys tl _ = Nothing -- | Get root non-terminal.
196
alternate xs = mapMaybe hd xs ++ alternate (mapMaybe tl xs) where hd (x:_) = Just x hd _ = Nothing tl (_:ys) = Just ys tl _ = Nothing -- | Get root non-terminal.
196
false
false
0
8
69
89
41
48
null
null
ryzhyk/cocoon
cocoon/Boogie/BoogieExpr.hs
apache-2.0
mkExpr' (EBuiltin _ f as) = (bfuncPrintBoogie $ getBuiltin f) ?r ?c as $ map mkExpr' as
93
mkExpr' (EBuiltin _ f as) = (bfuncPrintBoogie $ getBuiltin f) ?r ?c as $ map mkExpr' as
93
mkExpr' (EBuiltin _ f as) = (bfuncPrintBoogie $ getBuiltin f) ?r ?c as $ map mkExpr' as
93
false
false
0
9
22
46
21
25
null
null
ksallberg/valuecalc
Tests/QCTests.hs
unlicense
prop_whiteSpacesDropped x = let ws = [' ','\t','\n','\v','\f','\r','\160'] in dropWhitespace (TagText x) == TagText [c | c <- x, not $ elem c ws]
150
prop_whiteSpacesDropped x = let ws = [' ','\t','\n','\v','\f','\r','\160'] in dropWhitespace (TagText x) == TagText [c | c <- x, not $ elem c ws]
150
prop_whiteSpacesDropped x = let ws = [' ','\t','\n','\v','\f','\r','\160'] in dropWhitespace (TagText x) == TagText [c | c <- x, not $ elem c ws]
150
false
false
3
9
28
69
32
37
null
null
rueshyna/gogol
gogol-books/gen/Network/Google/Resource/Books/MyLibrary/Bookshelves/List.hs
mpl-2.0
-- | Creates a value of 'MyLibraryBookshelvesList' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mlblSource' myLibraryBookshelvesList :: MyLibraryBookshelvesList myLibraryBookshelvesList = MyLibraryBookshelvesList' { _mlblSource = Nothing }
344
myLibraryBookshelvesList :: MyLibraryBookshelvesList myLibraryBookshelvesList = MyLibraryBookshelvesList' { _mlblSource = Nothing }
147
myLibraryBookshelvesList = MyLibraryBookshelvesList' { _mlblSource = Nothing }
90
true
true
0
7
60
34
18
16
null
null
siddhanathan/ghc
compiler/nativeGen/AsmCodeGen.hs
bsd-3-clause
-- The algorithm is very simple (and stupid): we make a graph out of -- the blocks where there is an edge from one block to another iff the -- first block ends by jumping to the second. Then we topologically -- sort this graph. Then traverse the list: for each block, we first -- output the block, then if it has an out edge, we move the -- destination of the out edge to the front of the list, and continue. -- FYI, the classic layout for basic blocks uses postorder DFS; this -- algorithm is implemented in Hoopl. sequenceBlocks :: Instruction instr => BlockEnv i -> [NatBasicBlock instr] -> [NatBasicBlock instr] sequenceBlocks _ [] = []
677
sequenceBlocks :: Instruction instr => BlockEnv i -> [NatBasicBlock instr] -> [NatBasicBlock instr] sequenceBlocks _ [] = []
156
sequenceBlocks _ [] = []
24
true
true
0
9
154
58
32
26
null
null
sboosali/commands-spiros
config/Commands/Plugins/Spiros/Emacs/Config.hs
gpl-2.0
haskell_interactive_bring = W.press "C-`"
41
haskell_interactive_bring = W.press "C-`"
41
haskell_interactive_bring = W.press "C-`"
41
false
false
0
6
3
11
5
6
null
null
shlevy/arithmoi
Math/NumberTheory/Primes/Heap.hs
mit
step :: Integral a => Int -> a -- {-# INLINE step #-} step i = fromIntegral (steps `unsafeAt` i)
96
step :: Integral a => Int -> a step i = fromIntegral (steps `unsafeAt` i)
73
step i = fromIntegral (steps `unsafeAt` i)
42
true
true
0
7
19
41
21
20
null
null
Axiomatic-/nano-md5
Data/Digest/OpenSSL/MD5.hs
bsd-3-clause
-- -- | Fast md5 using OpenSSL. The md5 hash should be referentially transparent.. -- The ByteString is guaranteed not to be copied. -- -- The result string should be identical to the output of MD5(1). -- That is: -- -- > $ md5 /usr/share/dict/words -- > MD5 (/usr/share/dict/words) = e5c152147e93b81424c13772330e74b3 -- -- While this md5sum binding will return: -- md5sum :: B.ByteString -> String md5sum p = unsafePerformIO $ B.unsafeUseAsCStringLen p $ \(ptr,n) -> do allocaBytes md5_digest_length $ \digest_ptr -> do digest <- c_md5 ptr (fromIntegral n) digest_ptr go digest 0 [] where -- print it in 0-padded hex format go :: Ptr Word8 -> Int -> [String] -> IO String #ifndef __HADDOCK__ go q n acc | n `seq` q `seq` False = undefined | n >= 16 = return $ concat (reverse acc) | otherwise = do w <- peekElemOff q n go q (n+1) (draw w : acc) draw w = case showHex w [] of [x] -> ['0', x] x -> x #endif -- -- unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md); --
1,122
md5sum :: B.ByteString -> String md5sum p = unsafePerformIO $ B.unsafeUseAsCStringLen p $ \(ptr,n) -> do allocaBytes md5_digest_length $ \digest_ptr -> do digest <- c_md5 ptr (fromIntegral n) digest_ptr go digest 0 [] where -- print it in 0-padded hex format go :: Ptr Word8 -> Int -> [String] -> IO String #ifndef __HADDOCK__ go q n acc | n `seq` q `seq` False = undefined | n >= 16 = return $ concat (reverse acc) | otherwise = do w <- peekElemOff q n go q (n+1) (draw w : acc) draw w = case showHex w [] of [x] -> ['0', x] x -> x #endif -- -- unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md); --
755
md5sum p = unsafePerformIO $ B.unsafeUseAsCStringLen p $ \(ptr,n) -> do allocaBytes md5_digest_length $ \digest_ptr -> do digest <- c_md5 ptr (fromIntegral n) digest_ptr go digest 0 [] where -- print it in 0-padded hex format go :: Ptr Word8 -> Int -> [String] -> IO String #ifndef __HADDOCK__ go q n acc | n `seq` q `seq` False = undefined | n >= 16 = return $ concat (reverse acc) | otherwise = do w <- peekElemOff q n go q (n+1) (draw w : acc) draw w = case showHex w [] of [x] -> ['0', x] x -> x #endif -- -- unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md); --
722
true
true
5
16
310
301
151
150
null
null
gaborhermann/marvin
src/Marvin/API/Preprocess/FeatureScaling.hs
apache-2.0
-- | Scales the elements of all columns in the table linearly, -- so that every element is between 0 and 1. minMaxScale :: NumericTable -> (NumericTable -> Fallible NumericTable) minMaxScale = transformEveryColumn "While scaling by min-max." $ \x -> return . (minMaxScaleColumn x)
282
minMaxScale :: NumericTable -> (NumericTable -> Fallible NumericTable) minMaxScale = transformEveryColumn "While scaling by min-max." $ \x -> return . (minMaxScaleColumn x)
174
minMaxScale = transformEveryColumn "While scaling by min-max." $ \x -> return . (minMaxScaleColumn x)
103
true
true
0
9
45
49
26
23
null
null
josuf107/Adverb
Adverb/Common.hs
gpl-3.0
ornamentally = id
17
ornamentally = id
17
ornamentally = id
17
false
false
0
4
2
6
3
3
null
null
netom/haskell-ray
src/haskell-ray.hs
lgpl-3.0
-- Takes transformation into account incidence' :: Ray -> Object -> Maybe Incidence incidence' (Ray rv d) (Object s _ t) | isNothing i = Nothing | otherwise = Just $ Incidence (correct $ trans t iv) (correct $ itrans (stripTrans t) n) where i = incidence (Ray (correct $ itrans t rv) (correct $ itrans (stripTrans t) d)) s Just (Incidence iv n) = i
368
incidence' :: Ray -> Object -> Maybe Incidence incidence' (Ray rv d) (Object s _ t) | isNothing i = Nothing | otherwise = Just $ Incidence (correct $ trans t iv) (correct $ itrans (stripTrans t) n) where i = incidence (Ray (correct $ itrans t rv) (correct $ itrans (stripTrans t) d)) s Just (Incidence iv n) = i
331
incidence' (Ray rv d) (Object s _ t) | isNothing i = Nothing | otherwise = Just $ Incidence (correct $ trans t iv) (correct $ itrans (stripTrans t) n) where i = incidence (Ray (correct $ itrans t rv) (correct $ itrans (stripTrans t) d)) s Just (Incidence iv n) = i
284
true
true
3
12
85
183
84
99
null
null
gorkinovich/Haskell
Problems/Problem0010b.hs
mit
sumPrimes :: Integer -> Integer sumPrimes limit = sp limit 2 [] 0 where sp lmt x ps acc | x >= lmt = acc | otherwise = sp lmt y (ps ++ [x]) (acc + x) where y = head [z | z <- [x + 1..], isPrime z ps]
245
sumPrimes :: Integer -> Integer sumPrimes limit = sp limit 2 [] 0 where sp lmt x ps acc | x >= lmt = acc | otherwise = sp lmt y (ps ++ [x]) (acc + x) where y = head [z | z <- [x + 1..], isPrime z ps]
245
sumPrimes limit = sp limit 2 [] 0 where sp lmt x ps acc | x >= lmt = acc | otherwise = sp lmt y (ps ++ [x]) (acc + x) where y = head [z | z <- [x + 1..], isPrime z ps]
213
false
true
1
10
96
151
66
85
null
null
oldmanmike/ghc
compiler/types/Type.hs
bsd-3-clause
mkCastTy :: Type -> Coercion -> Type -- Running example: -- T :: forall k1. k1 -> forall k2. k2 -> Bool -> Maybe k1 -> * -- co :: * ~R X (maybe X is a newtype around *) -- ty = T Nat 3 Symbol "foo" True (Just 2) -- -- We wish to "push" the cast down as far as possible. See also -- Note [Pushing down casts] in TyCoRep. Here is where we end -- up: -- -- (T Nat 3 Symbol |> <Symbol> -> <Bool> -> <Maybe Nat> -> co) -- "foo" True (Just 2) -- mkCastTy ty co | isReflexiveCo co = ty
494
mkCastTy :: Type -> Coercion -> Type mkCastTy ty co | isReflexiveCo co = ty
75
mkCastTy ty co | isReflexiveCo co = ty
38
true
true
0
8
124
51
28
23
null
null
noughtmare/yi
yi-keymap-vim/src/Yi/Keymap/Vim/Digraph.hs
gpl-2.0
-- KATAKANA LETTER DE switch 'T' 'o' = '\x30C8'
47
switch 'T' 'o' = '\x30C8'
25
switch 'T' 'o' = '\x30C8'
25
true
false
0
5
8
12
6
6
null
null
bergmark/hakyll
src/Hakyll/Web/Tags.hs
bsd-3-clause
renderTagCloud :: Double -- ^ Smallest font size, in percent -> Double -- ^ Biggest font size, in percent -> Tags -- ^ Input tags -> Compiler String -- ^ Rendered cloud renderTagCloud minSize maxSize = renderTags makeLink (intercalate " ") where makeLink tag url count min' max' = renderHtml $ H.a ! A.style (toValue $ "font-size: " ++ size count min' max') ! A.href (toValue url) $ toHtml tag -- Show the relative size of one 'count' in percent size count min' max' = let diff = 1 + fromIntegral max' - fromIntegral min' relative = (fromIntegral count - fromIntegral min') / diff size' = floor $ minSize + relative * (maxSize - minSize) in show (size' :: Int) ++ "%" -------------------------------------------------------------------------------- -- | Render a simple tag list in HTML, with the tag count next to the item -- TODO: Maybe produce a Context here
1,055
renderTagCloud :: Double -- ^ Smallest font size, in percent -> Double -- ^ Biggest font size, in percent -> Tags -- ^ Input tags -> Compiler String renderTagCloud minSize maxSize = renderTags makeLink (intercalate " ") where makeLink tag url count min' max' = renderHtml $ H.a ! A.style (toValue $ "font-size: " ++ size count min' max') ! A.href (toValue url) $ toHtml tag -- Show the relative size of one 'count' in percent size count min' max' = let diff = 1 + fromIntegral max' - fromIntegral min' relative = (fromIntegral count - fromIntegral min') / diff size' = floor $ minSize + relative * (maxSize - minSize) in show (size' :: Int) ++ "%" -------------------------------------------------------------------------------- -- | Render a simple tag list in HTML, with the tag count next to the item -- TODO: Maybe produce a Context here
1,020
renderTagCloud minSize maxSize = renderTags makeLink (intercalate " ") where makeLink tag url count min' max' = renderHtml $ H.a ! A.style (toValue $ "font-size: " ++ size count min' max') ! A.href (toValue url) $ toHtml tag -- Show the relative size of one 'count' in percent size count min' max' = let diff = 1 + fromIntegral max' - fromIntegral min' relative = (fromIntegral count - fromIntegral min') / diff size' = floor $ minSize + relative * (maxSize - minSize) in show (size' :: Int) ++ "%" -------------------------------------------------------------------------------- -- | Render a simple tag list in HTML, with the tag count next to the item -- TODO: Maybe produce a Context here
781
true
true
0
12
340
220
111
109
null
null
naohaq/gf256-hs
example/RSdecode.hs
mit
main :: IO () main = do putStrLn $ "RS Code: (" ++ show code_N ++ "," ++ show (code_N - code_2t) ++ ")" putStrLn $ "Received message: " mapM_ (putStrLn . (" " ++)) (dumpMsg rws) let csum = check_ecc200 rws putStrLn $ "Checksum : " ++ showHex csum let synd = calcSyndrome pow2 csum putStrLn $ "Syndromes: " ++ showHex synd let sigma_r = errLocator synd putStrLn $ "Error locator: " ++ showHex sigma_r let locs = solveErrLocations pow2 sigma_r let locs_r = [code_N-1-k | k <- reverse locs] putStrLn $ "Error locations: " ++ show locs_r let mtx = errMatrix pow2 locs synd putStrLn "Error matrix:" mapM_ (putStrLn . (" [ " ++) . (++ " ]") . showHex) mtx let evs = solveErrMatrix mtx let evs_r = reverse evs putStrLn $ "Error values: " ++ showHex evs_r let rws_corr = map toWord8 $ correctErrors (zip locs_r evs_r) $ map fromWord8 rws putStrLn $ "Corrected message: " mapM_ (putStrLn . (" " ++)) (dumpMsg rws_corr) putStrLn $ "Checksum : " ++ showHex (check_ecc200 rws_corr) -- EOF
1,027
main :: IO () main = do putStrLn $ "RS Code: (" ++ show code_N ++ "," ++ show (code_N - code_2t) ++ ")" putStrLn $ "Received message: " mapM_ (putStrLn . (" " ++)) (dumpMsg rws) let csum = check_ecc200 rws putStrLn $ "Checksum : " ++ showHex csum let synd = calcSyndrome pow2 csum putStrLn $ "Syndromes: " ++ showHex synd let sigma_r = errLocator synd putStrLn $ "Error locator: " ++ showHex sigma_r let locs = solveErrLocations pow2 sigma_r let locs_r = [code_N-1-k | k <- reverse locs] putStrLn $ "Error locations: " ++ show locs_r let mtx = errMatrix pow2 locs synd putStrLn "Error matrix:" mapM_ (putStrLn . (" [ " ++) . (++ " ]") . showHex) mtx let evs = solveErrMatrix mtx let evs_r = reverse evs putStrLn $ "Error values: " ++ showHex evs_r let rws_corr = map toWord8 $ correctErrors (zip locs_r evs_r) $ map fromWord8 rws putStrLn $ "Corrected message: " mapM_ (putStrLn . (" " ++)) (dumpMsg rws_corr) putStrLn $ "Checksum : " ++ showHex (check_ecc200 rws_corr) -- EOF
1,027
main = do putStrLn $ "RS Code: (" ++ show code_N ++ "," ++ show (code_N - code_2t) ++ ")" putStrLn $ "Received message: " mapM_ (putStrLn . (" " ++)) (dumpMsg rws) let csum = check_ecc200 rws putStrLn $ "Checksum : " ++ showHex csum let synd = calcSyndrome pow2 csum putStrLn $ "Syndromes: " ++ showHex synd let sigma_r = errLocator synd putStrLn $ "Error locator: " ++ showHex sigma_r let locs = solveErrLocations pow2 sigma_r let locs_r = [code_N-1-k | k <- reverse locs] putStrLn $ "Error locations: " ++ show locs_r let mtx = errMatrix pow2 locs synd putStrLn "Error matrix:" mapM_ (putStrLn . (" [ " ++) . (++ " ]") . showHex) mtx let evs = solveErrMatrix mtx let evs_r = reverse evs putStrLn $ "Error values: " ++ showHex evs_r let rws_corr = map toWord8 $ correctErrors (zip locs_r evs_r) $ map fromWord8 rws putStrLn $ "Corrected message: " mapM_ (putStrLn . (" " ++)) (dumpMsg rws_corr) putStrLn $ "Checksum : " ++ showHex (check_ecc200 rws_corr) -- EOF
1,013
false
true
0
14
229
403
186
217
null
null
sharpjs/haskell-learning
src/Aex/Types.hs
gpl-3.0
i8 = IntT (Just ( 8, 8, True ))
33
i8 = IntT (Just ( 8, 8, True ))
33
i8 = IntT (Just ( 8, 8, True ))
33
false
false
1
7
10
27
13
14
null
null
AndrewRademacher/zotac
lib/Data/Raft/Node/Internal.hs
mit
defaultBallots :: (Ord id) => Peers id -> Ballots id defaultBallots peers = Map.fromList $ zip (Set.toList peers) (repeat def)
126
defaultBallots :: (Ord id) => Peers id -> Ballots id defaultBallots peers = Map.fromList $ zip (Set.toList peers) (repeat def)
126
defaultBallots peers = Map.fromList $ zip (Set.toList peers) (repeat def)
73
false
true
0
9
19
62
29
33
null
null
joelelmercarlson/stack
haskell/travel.hs
mit
display' :: ([Int], Float) -> IO () display' (k, v) = printf "route %s is length %2.2f\n" (show k) v
102
display' :: ([Int], Float) -> IO () display' (k, v) = printf "route %s is length %2.2f\n" (show k) v
100
display' (k, v) = printf "route %s is length %2.2f\n" (show k) v
64
false
true
0
7
21
51
27
24
null
null
cullina/Extractor
src/SortingNetwork.hs
bsd-3-clause
bs = outputs hNet 16
20
bs = outputs hNet 16
20
bs = outputs hNet 16
20
false
false
1
5
4
14
5
9
null
null
ml9951/ghc
libraries/pastm/Control/TL2/STM.hs
bsd-3-clause
newTVar :: a -> STM (TVar a) newTVar x = STM $ \s -> case unsafeCoerce# newTVar# x s of (# s', tv #) -> (# s', TVar tv #)
151
newTVar :: a -> STM (TVar a) newTVar x = STM $ \s -> case unsafeCoerce# newTVar# x s of (# s', tv #) -> (# s', TVar tv #)
151
newTVar x = STM $ \s -> case unsafeCoerce# newTVar# x s of (# s', tv #) -> (# s', TVar tv #)
122
false
true
0
11
59
66
33
33
null
null
andgate/vish
src/Vish/Layout.hs
bsd-3-clause
alignH AlignRight = alignRight
32
alignH AlignRight = alignRight
32
alignH AlignRight = alignRight
32
false
false
0
5
5
9
4
5
null
null
josuf107/Adverb
Adverb/Common.hs
gpl-3.0
wondrously = id
15
wondrously = id
15
wondrously = id
15
false
false
0
4
2
6
3
3
null
null
LTI2000/hinterface
src/Foreign/Erlang/Handshake.hs
bsd-3-clause
checkCookie :: MonadThrow m => BS.ByteString -> Word32 -> BS.ByteString -> m () checkCookie her_digest our_challenge cookie = unless (her_digest == genDigest our_challenge cookie) (throwM CookieMismatch)
218
checkCookie :: MonadThrow m => BS.ByteString -> Word32 -> BS.ByteString -> m () checkCookie her_digest our_challenge cookie = unless (her_digest == genDigest our_challenge cookie) (throwM CookieMismatch)
218
checkCookie her_digest our_challenge cookie = unless (her_digest == genDigest our_challenge cookie) (throwM CookieMismatch)
138
false
true
0
10
40
69
33
36
null
null
ysnrkdm/Hamlet
src/Eval.hs
mit
opennessHelper board bb = fromIntegral opennessAtHead + opennessHelper board newBb where opennessAtHead = BitBoard.numPeripherals board Piece.Empty pos (pos, newBb) = BitBoard.takeOneAndSetZero bb -- Yet implemented but ok
239
opennessHelper board bb = fromIntegral opennessAtHead + opennessHelper board newBb where opennessAtHead = BitBoard.numPeripherals board Piece.Empty pos (pos, newBb) = BitBoard.takeOneAndSetZero bb -- Yet implemented but ok
239
opennessHelper board bb = fromIntegral opennessAtHead + opennessHelper board newBb where opennessAtHead = BitBoard.numPeripherals board Piece.Empty pos (pos, newBb) = BitBoard.takeOneAndSetZero bb -- Yet implemented but ok
239
false
false
0
6
43
60
29
31
null
null
d-rive/rivers
Data/Rivers/Streams.hs
bsd-3-clause
anyA = anyA
40
anyA = anyA
40
anyA = anyA
40
false
false
0
4
31
6
3
3
null
null
govindkrjoshi/darwin
app/Main.hs
bsd-3-clause
main :: IO () main = do args <- getArgs case args of ["train", inputDataDir, outputFile] -> trainClassifier inputDataDir outputFile _ -> notImplemented
171
main :: IO () main = do args <- getArgs case args of ["train", inputDataDir, outputFile] -> trainClassifier inputDataDir outputFile _ -> notImplemented
171
main = do args <- getArgs case args of ["train", inputDataDir, outputFile] -> trainClassifier inputDataDir outputFile _ -> notImplemented
157
false
true
1
11
42
61
28
33
null
null
pparkkin/eta
compiler/ETA/Utils/Util.hs
bsd-3-clause
-- | 'zipLazy' is a kind of 'zip' that is lazy in the second list (observe the ~) zipLazy :: [a] -> [b] -> [(a,b)] zipLazy [] _ = []
142
zipLazy :: [a] -> [b] -> [(a,b)] zipLazy [] _ = []
60
zipLazy [] _ = []
27
true
true
0
10
39
50
26
24
null
null
spechub/Hets
OWL2/OWL22CommonLogic.hs
gpl-2.0
mkEDPairs :: Sign -> [Int] -> Maybe Relation -> [(SENTENCE, SENTENCE)] -> Result ([TEXT], Sign) mkEDPairs s il med pairs = do let ls = case fromMaybe (error "expected EDRelation") med of EDRelation Equivalent -> map (uncurry mkBB) pairs EDRelation Disjoint -> map (\ (x, y) -> mkBN $ mkBC [x, y]) pairs _ -> error "expected EDRelation" return ([eqFB il ls], s) -- | Mapping of ListFrameBit -- mapListFrameBit :: Sign -> Extended -> Maybe Relation -> ListFrameBit -- -> Result ([TEXT], Sign) -- mapListFrameBit cSig ex rel lfb = case lfb of -- AnnotationBit _ -> return ([], cSig) -- ExpressionBit cls -> case ex of -- Misc _ -> let cel = map snd cls in do -- (els, sig) <- mapDescriptionListP cSig 1 $ comPairs cel cel -- mkEDPairs sig [1] rel els -- SimpleEntity (Entity _ ty iri) -> do -- ls <- mapM (\ (_, c) -> mapDescription cSig c (OIndi iri) 1) cls -- case ty of -- NamedIndividual | rel == Just Types -> do -- inD <- mapIndivIRI cSig iri -- let ocls = map (mapClassAssertion inD) -- $ zip (map snd cls) $ map fst ls -- return (ocls, uniteL $ map snd ls) -- DataProperty | rel == (Just $ DRRelation ADomain) -> do -- oEx <- mapDPE cSig iri 1 2 -- return (msen2Txt $ map (mkSent [mk1NAME] [mkNAME 2] oEx -- . fst) ls, uniteL $ map snd ls) -- _ -> failMsg cls -- ObjectEntity oe -> case rel of -- Nothing -> failMsg cls -- Just re -> case re of -- DRRelation r -> do -- tobjP <- mapOPE cSig oe 1 2 -- tdsc <- mapM (\ (_, c) -> mapDescription cSig c (case r of -- ADomain -> OVar 1 -- ARange -> OVar 2) $ case r of -- ADomain -> 1 -- ARange -> 2) cls -- let vars = case r of -- ADomain -> (1, 2) -- ARange -> (2, 1) -- return (msen2Txt $ map (mkSent [mkNAME $ fst vars] -- [mkNAME $ snd vars] tobjP . fst) tdsc, -- uniteL $ map snd tdsc) -- _ -> failMsg cls -- ClassEntity ce -> let cel = map snd cls in case rel of -- Nothing -> failMsg lfb -- Just r -> case r of -- EDRelation _ -> do -- (decrsS, dSig) <- mapDescriptionListP cSig 1 $ mkPairs ce cel -- mkEDPairs dSig [1] rel decrsS -- SubClass -> do -- (domT, dSig) <- mapDescription cSig ce (OVar 1) 1 -- ls <- mapM (\ cd -> mapDescription cSig cd (OVar 1) 1) cel -- rSig <- sigUnion cSig (unite dSig $ uniteL $ map snd ls) -- return (msen2Txt $ map (mk1QU . mkBI domT . fst) ls, rSig) -- _ -> failMsg cls -- ObjectBit anl -> let opl = map snd anl in case rel of -- Nothing -> failMsg lfb -- Just r -> case ex of -- Misc _ -> do -- pairs <- mapObjPropListP cSig 1 2 $ comPairs opl opl -- mkEDPairs cSig [1, 2] rel pairs -- ObjectEntity op -> case r of -- EDRelation _ -> do -- pairs <- mapObjPropListP cSig 1 2 $ mkPairs op opl -- mkEDPairs cSig [1, 2] rel pairs -- SubPropertyOf -> do -- os <- mapM (\ (o1, o2) -> mapSubObjProp cSig o1 o2 3) -- $ mkPairs op opl -- return (msen2Txt os, cSig) -- InverseOf -> do -- os1 <- mapM (\ o1 -> mapOPE cSig o1 1 2) opl -- o2 <- mapOPE cSig op 2 1 -- return (msen2Txt $ map (\ cd -> mkQU (map mkNAME [1, 2]) -- $ mkBB cd o2) os1, cSig) -- _ -> failMsg lfb -- _ -> failMsg lfb -- DataBit anl -> let dl = map snd anl in case rel of -- Nothing -> return ([], cSig) -- Just r -> case ex of -- Misc _ -> do -- pairs <- mapDataPropListP cSig 1 2 $ comPairs dl dl -- mkEDPairs cSig [1, 2] rel pairs -- SimpleEntity (Entity _ DataProperty iri) -> case r of -- EDRelation _ -> do -- pairs <- mapDataPropListP cSig 1 2 $ mkPairs iri dl -- mkEDPairs cSig [1, 2] rel pairs -- SubPropertyOf -> do -- os1 <- mapM (\ o1 -> mapDPE cSig o1 1 2) dl -- o2 <- mapDPE cSig iri 1 2 -- return (msen2Txt $ map (mkQU (map mkNAME [1, 2]) -- . mkBI o2) os1, cSig) -- _ -> failMsg lfb -- _ -> failMsg lfb -- IndividualSameOrDifferent anl -> case rel of -- Nothing -> failMsg lfb -- Just (SDRelation re) -> do -- let SimpleEntity (Entity _ NamedIndividual iri) = ex -- fs <- mapComIndivList cSig re (Just iri) $ map snd anl -- return (msen2Txt fs, cSig) -- _ -> failMsg lfb -- DataPropRange dpr -> case ex of -- SimpleEntity (Entity _ DataProperty iri) -> do -- oEx <- mapDPE cSig iri 1 2 -- ls <- mapM (\ (_, r) -> mapDataRange cSig r $ OVar 2) dpr -- return (msen2Txt $ map (mkSent [mkNAME 1] [mkNAME 2] oEx -- . fst) ls, uniteL $ map snd ls ) -- _ -> failMsg dpr -- IndividualFacts indf -> do -- fl <- mapM (mapFact cSig ex . snd) indf -- return (fl, cSig) -- ObjectCharacteristics ace -> case ex of -- ObjectEntity ope -> do -- cl <- mapM (mapCharact cSig ope . snd) ace -- return (cl, cSig) -- _ -> failMsg ace -- | Mapping of AnnFrameBit -- mapAnnFrameBit :: Sign -> Extended -> AnnFrameBit -> Result ([TEXT], Sign) -- mapAnnFrameBit cSig ex afb = -- let err = fail $ "could not translate " ++ show afb in case afb of -- AnnotationFrameBit _ -> return ([], cSig) -- DataFunctional -> case ex of -- SimpleEntity (Entity _ DataProperty iri) -> do -- so1 <- mapDPE cSig iri 1 2 -- so2 <- mapDPE cSig iri 1 3 -- return ([mkQUBI (map mkNAME [1, 2, 3]) [so1, so2] -- (mkNTERM 2) $ mkNTERM 3], cSig) -- _ -> err -- DatatypeBit dr -> case ex of -- SimpleEntity (Entity _ Datatype iri) -> do -- (odes, dSig) <- mapDataRange cSig dr $ OVar 1 -- let dtp = mkTermAtoms (uriToTok iri) [mkVTerm $ OVar 1] -- return ([senToText $ mk1QU $ mkBB dtp odes], dSig) -- _ -> err -- ClassDisjointUnion clsl -> case ex of -- ClassEntity (Expression iri) -> do -- (decrs, dSig) <- mapDescriptionList cSig 1 clsl -- (decrsS, pSig) <- mapDescriptionListP cSig 1 $ comPairs clsl clsl -- let decrsP = unzip decrsS -- mcls <- mapClassIRI cSig iri $ mkNName 1 -- return ([senToText $ mk1QU $ mkBB mcls $ mkBC -- [mkBD decrs, mkBN $ mkBC $ uncurry (++) decrsP]], -- unite dSig pSig) -- _ -> err -- ClassHasKey opl dpl -> do -- let ClassEntity ce = ex -- lo = length opl -- ld = length dpl -- uptoOP = [2 .. lo + 1] -- uptoDP = [lo + 2 .. lo + ld + 1] -- tl = lo + ld + 2 -- (_, sig) <- mapDescription cSig ce (OVar 1) 1 -- ol <- mapM (\ (n, o) -> mapOPE cSig o 1 n) $ zip uptoOP opl -- nol <- mapM (\ (n, o) -> mapOPE cSig o tl n) $ zip uptoOP opl -- dl <- mapM (\ (n, d) -> mapDPE cSig d 1 n) $ zip uptoDP dpl -- ndl <- mapM (\ (n, d) -> mapDPE cSig d tl n) $ zip uptoDP dpl -- keys <- mapKey cSig ce (ol ++ dl, nol ++ ndl) tl -- $ uptoOP ++ uptoDP -- return ([senToText keys], sig) -- ObjectSubPropertyChain oplst -> case ex of -- ObjectEntity op -> do -- os <- mapSubObjPropChain cSig oplst op 3 -- return ([senToText os], cSig) -- _ -> err -- | Mapping of Axioms -- mapAxioms :: Sign -> Axiom -> Result ([TEXT], Sign) -- mapAxioms cSig (PlainAxiom ex fb) = case fb of -- ListFrameBit rel lfb -> mapListFrameBit cSig ex rel lfb -- AnnFrameBit _ afb -> mapAnnFrameBit cSig ex afb
8,731
mkEDPairs :: Sign -> [Int] -> Maybe Relation -> [(SENTENCE, SENTENCE)] -> Result ([TEXT], Sign) mkEDPairs s il med pairs = do let ls = case fromMaybe (error "expected EDRelation") med of EDRelation Equivalent -> map (uncurry mkBB) pairs EDRelation Disjoint -> map (\ (x, y) -> mkBN $ mkBC [x, y]) pairs _ -> error "expected EDRelation" return ([eqFB il ls], s) -- | Mapping of ListFrameBit -- mapListFrameBit :: Sign -> Extended -> Maybe Relation -> ListFrameBit -- -> Result ([TEXT], Sign) -- mapListFrameBit cSig ex rel lfb = case lfb of -- AnnotationBit _ -> return ([], cSig) -- ExpressionBit cls -> case ex of -- Misc _ -> let cel = map snd cls in do -- (els, sig) <- mapDescriptionListP cSig 1 $ comPairs cel cel -- mkEDPairs sig [1] rel els -- SimpleEntity (Entity _ ty iri) -> do -- ls <- mapM (\ (_, c) -> mapDescription cSig c (OIndi iri) 1) cls -- case ty of -- NamedIndividual | rel == Just Types -> do -- inD <- mapIndivIRI cSig iri -- let ocls = map (mapClassAssertion inD) -- $ zip (map snd cls) $ map fst ls -- return (ocls, uniteL $ map snd ls) -- DataProperty | rel == (Just $ DRRelation ADomain) -> do -- oEx <- mapDPE cSig iri 1 2 -- return (msen2Txt $ map (mkSent [mk1NAME] [mkNAME 2] oEx -- . fst) ls, uniteL $ map snd ls) -- _ -> failMsg cls -- ObjectEntity oe -> case rel of -- Nothing -> failMsg cls -- Just re -> case re of -- DRRelation r -> do -- tobjP <- mapOPE cSig oe 1 2 -- tdsc <- mapM (\ (_, c) -> mapDescription cSig c (case r of -- ADomain -> OVar 1 -- ARange -> OVar 2) $ case r of -- ADomain -> 1 -- ARange -> 2) cls -- let vars = case r of -- ADomain -> (1, 2) -- ARange -> (2, 1) -- return (msen2Txt $ map (mkSent [mkNAME $ fst vars] -- [mkNAME $ snd vars] tobjP . fst) tdsc, -- uniteL $ map snd tdsc) -- _ -> failMsg cls -- ClassEntity ce -> let cel = map snd cls in case rel of -- Nothing -> failMsg lfb -- Just r -> case r of -- EDRelation _ -> do -- (decrsS, dSig) <- mapDescriptionListP cSig 1 $ mkPairs ce cel -- mkEDPairs dSig [1] rel decrsS -- SubClass -> do -- (domT, dSig) <- mapDescription cSig ce (OVar 1) 1 -- ls <- mapM (\ cd -> mapDescription cSig cd (OVar 1) 1) cel -- rSig <- sigUnion cSig (unite dSig $ uniteL $ map snd ls) -- return (msen2Txt $ map (mk1QU . mkBI domT . fst) ls, rSig) -- _ -> failMsg cls -- ObjectBit anl -> let opl = map snd anl in case rel of -- Nothing -> failMsg lfb -- Just r -> case ex of -- Misc _ -> do -- pairs <- mapObjPropListP cSig 1 2 $ comPairs opl opl -- mkEDPairs cSig [1, 2] rel pairs -- ObjectEntity op -> case r of -- EDRelation _ -> do -- pairs <- mapObjPropListP cSig 1 2 $ mkPairs op opl -- mkEDPairs cSig [1, 2] rel pairs -- SubPropertyOf -> do -- os <- mapM (\ (o1, o2) -> mapSubObjProp cSig o1 o2 3) -- $ mkPairs op opl -- return (msen2Txt os, cSig) -- InverseOf -> do -- os1 <- mapM (\ o1 -> mapOPE cSig o1 1 2) opl -- o2 <- mapOPE cSig op 2 1 -- return (msen2Txt $ map (\ cd -> mkQU (map mkNAME [1, 2]) -- $ mkBB cd o2) os1, cSig) -- _ -> failMsg lfb -- _ -> failMsg lfb -- DataBit anl -> let dl = map snd anl in case rel of -- Nothing -> return ([], cSig) -- Just r -> case ex of -- Misc _ -> do -- pairs <- mapDataPropListP cSig 1 2 $ comPairs dl dl -- mkEDPairs cSig [1, 2] rel pairs -- SimpleEntity (Entity _ DataProperty iri) -> case r of -- EDRelation _ -> do -- pairs <- mapDataPropListP cSig 1 2 $ mkPairs iri dl -- mkEDPairs cSig [1, 2] rel pairs -- SubPropertyOf -> do -- os1 <- mapM (\ o1 -> mapDPE cSig o1 1 2) dl -- o2 <- mapDPE cSig iri 1 2 -- return (msen2Txt $ map (mkQU (map mkNAME [1, 2]) -- . mkBI o2) os1, cSig) -- _ -> failMsg lfb -- _ -> failMsg lfb -- IndividualSameOrDifferent anl -> case rel of -- Nothing -> failMsg lfb -- Just (SDRelation re) -> do -- let SimpleEntity (Entity _ NamedIndividual iri) = ex -- fs <- mapComIndivList cSig re (Just iri) $ map snd anl -- return (msen2Txt fs, cSig) -- _ -> failMsg lfb -- DataPropRange dpr -> case ex of -- SimpleEntity (Entity _ DataProperty iri) -> do -- oEx <- mapDPE cSig iri 1 2 -- ls <- mapM (\ (_, r) -> mapDataRange cSig r $ OVar 2) dpr -- return (msen2Txt $ map (mkSent [mkNAME 1] [mkNAME 2] oEx -- . fst) ls, uniteL $ map snd ls ) -- _ -> failMsg dpr -- IndividualFacts indf -> do -- fl <- mapM (mapFact cSig ex . snd) indf -- return (fl, cSig) -- ObjectCharacteristics ace -> case ex of -- ObjectEntity ope -> do -- cl <- mapM (mapCharact cSig ope . snd) ace -- return (cl, cSig) -- _ -> failMsg ace -- | Mapping of AnnFrameBit -- mapAnnFrameBit :: Sign -> Extended -> AnnFrameBit -> Result ([TEXT], Sign) -- mapAnnFrameBit cSig ex afb = -- let err = fail $ "could not translate " ++ show afb in case afb of -- AnnotationFrameBit _ -> return ([], cSig) -- DataFunctional -> case ex of -- SimpleEntity (Entity _ DataProperty iri) -> do -- so1 <- mapDPE cSig iri 1 2 -- so2 <- mapDPE cSig iri 1 3 -- return ([mkQUBI (map mkNAME [1, 2, 3]) [so1, so2] -- (mkNTERM 2) $ mkNTERM 3], cSig) -- _ -> err -- DatatypeBit dr -> case ex of -- SimpleEntity (Entity _ Datatype iri) -> do -- (odes, dSig) <- mapDataRange cSig dr $ OVar 1 -- let dtp = mkTermAtoms (uriToTok iri) [mkVTerm $ OVar 1] -- return ([senToText $ mk1QU $ mkBB dtp odes], dSig) -- _ -> err -- ClassDisjointUnion clsl -> case ex of -- ClassEntity (Expression iri) -> do -- (decrs, dSig) <- mapDescriptionList cSig 1 clsl -- (decrsS, pSig) <- mapDescriptionListP cSig 1 $ comPairs clsl clsl -- let decrsP = unzip decrsS -- mcls <- mapClassIRI cSig iri $ mkNName 1 -- return ([senToText $ mk1QU $ mkBB mcls $ mkBC -- [mkBD decrs, mkBN $ mkBC $ uncurry (++) decrsP]], -- unite dSig pSig) -- _ -> err -- ClassHasKey opl dpl -> do -- let ClassEntity ce = ex -- lo = length opl -- ld = length dpl -- uptoOP = [2 .. lo + 1] -- uptoDP = [lo + 2 .. lo + ld + 1] -- tl = lo + ld + 2 -- (_, sig) <- mapDescription cSig ce (OVar 1) 1 -- ol <- mapM (\ (n, o) -> mapOPE cSig o 1 n) $ zip uptoOP opl -- nol <- mapM (\ (n, o) -> mapOPE cSig o tl n) $ zip uptoOP opl -- dl <- mapM (\ (n, d) -> mapDPE cSig d 1 n) $ zip uptoDP dpl -- ndl <- mapM (\ (n, d) -> mapDPE cSig d tl n) $ zip uptoDP dpl -- keys <- mapKey cSig ce (ol ++ dl, nol ++ ndl) tl -- $ uptoOP ++ uptoDP -- return ([senToText keys], sig) -- ObjectSubPropertyChain oplst -> case ex of -- ObjectEntity op -> do -- os <- mapSubObjPropChain cSig oplst op 3 -- return ([senToText os], cSig) -- _ -> err -- | Mapping of Axioms -- mapAxioms :: Sign -> Axiom -> Result ([TEXT], Sign) -- mapAxioms cSig (PlainAxiom ex fb) = case fb of -- ListFrameBit rel lfb -> mapListFrameBit cSig ex rel lfb -- AnnFrameBit _ afb -> mapAnnFrameBit cSig ex afb
8,731
mkEDPairs s il med pairs = do let ls = case fromMaybe (error "expected EDRelation") med of EDRelation Equivalent -> map (uncurry mkBB) pairs EDRelation Disjoint -> map (\ (x, y) -> mkBN $ mkBC [x, y]) pairs _ -> error "expected EDRelation" return ([eqFB il ls], s) -- | Mapping of ListFrameBit -- mapListFrameBit :: Sign -> Extended -> Maybe Relation -> ListFrameBit -- -> Result ([TEXT], Sign) -- mapListFrameBit cSig ex rel lfb = case lfb of -- AnnotationBit _ -> return ([], cSig) -- ExpressionBit cls -> case ex of -- Misc _ -> let cel = map snd cls in do -- (els, sig) <- mapDescriptionListP cSig 1 $ comPairs cel cel -- mkEDPairs sig [1] rel els -- SimpleEntity (Entity _ ty iri) -> do -- ls <- mapM (\ (_, c) -> mapDescription cSig c (OIndi iri) 1) cls -- case ty of -- NamedIndividual | rel == Just Types -> do -- inD <- mapIndivIRI cSig iri -- let ocls = map (mapClassAssertion inD) -- $ zip (map snd cls) $ map fst ls -- return (ocls, uniteL $ map snd ls) -- DataProperty | rel == (Just $ DRRelation ADomain) -> do -- oEx <- mapDPE cSig iri 1 2 -- return (msen2Txt $ map (mkSent [mk1NAME] [mkNAME 2] oEx -- . fst) ls, uniteL $ map snd ls) -- _ -> failMsg cls -- ObjectEntity oe -> case rel of -- Nothing -> failMsg cls -- Just re -> case re of -- DRRelation r -> do -- tobjP <- mapOPE cSig oe 1 2 -- tdsc <- mapM (\ (_, c) -> mapDescription cSig c (case r of -- ADomain -> OVar 1 -- ARange -> OVar 2) $ case r of -- ADomain -> 1 -- ARange -> 2) cls -- let vars = case r of -- ADomain -> (1, 2) -- ARange -> (2, 1) -- return (msen2Txt $ map (mkSent [mkNAME $ fst vars] -- [mkNAME $ snd vars] tobjP . fst) tdsc, -- uniteL $ map snd tdsc) -- _ -> failMsg cls -- ClassEntity ce -> let cel = map snd cls in case rel of -- Nothing -> failMsg lfb -- Just r -> case r of -- EDRelation _ -> do -- (decrsS, dSig) <- mapDescriptionListP cSig 1 $ mkPairs ce cel -- mkEDPairs dSig [1] rel decrsS -- SubClass -> do -- (domT, dSig) <- mapDescription cSig ce (OVar 1) 1 -- ls <- mapM (\ cd -> mapDescription cSig cd (OVar 1) 1) cel -- rSig <- sigUnion cSig (unite dSig $ uniteL $ map snd ls) -- return (msen2Txt $ map (mk1QU . mkBI domT . fst) ls, rSig) -- _ -> failMsg cls -- ObjectBit anl -> let opl = map snd anl in case rel of -- Nothing -> failMsg lfb -- Just r -> case ex of -- Misc _ -> do -- pairs <- mapObjPropListP cSig 1 2 $ comPairs opl opl -- mkEDPairs cSig [1, 2] rel pairs -- ObjectEntity op -> case r of -- EDRelation _ -> do -- pairs <- mapObjPropListP cSig 1 2 $ mkPairs op opl -- mkEDPairs cSig [1, 2] rel pairs -- SubPropertyOf -> do -- os <- mapM (\ (o1, o2) -> mapSubObjProp cSig o1 o2 3) -- $ mkPairs op opl -- return (msen2Txt os, cSig) -- InverseOf -> do -- os1 <- mapM (\ o1 -> mapOPE cSig o1 1 2) opl -- o2 <- mapOPE cSig op 2 1 -- return (msen2Txt $ map (\ cd -> mkQU (map mkNAME [1, 2]) -- $ mkBB cd o2) os1, cSig) -- _ -> failMsg lfb -- _ -> failMsg lfb -- DataBit anl -> let dl = map snd anl in case rel of -- Nothing -> return ([], cSig) -- Just r -> case ex of -- Misc _ -> do -- pairs <- mapDataPropListP cSig 1 2 $ comPairs dl dl -- mkEDPairs cSig [1, 2] rel pairs -- SimpleEntity (Entity _ DataProperty iri) -> case r of -- EDRelation _ -> do -- pairs <- mapDataPropListP cSig 1 2 $ mkPairs iri dl -- mkEDPairs cSig [1, 2] rel pairs -- SubPropertyOf -> do -- os1 <- mapM (\ o1 -> mapDPE cSig o1 1 2) dl -- o2 <- mapDPE cSig iri 1 2 -- return (msen2Txt $ map (mkQU (map mkNAME [1, 2]) -- . mkBI o2) os1, cSig) -- _ -> failMsg lfb -- _ -> failMsg lfb -- IndividualSameOrDifferent anl -> case rel of -- Nothing -> failMsg lfb -- Just (SDRelation re) -> do -- let SimpleEntity (Entity _ NamedIndividual iri) = ex -- fs <- mapComIndivList cSig re (Just iri) $ map snd anl -- return (msen2Txt fs, cSig) -- _ -> failMsg lfb -- DataPropRange dpr -> case ex of -- SimpleEntity (Entity _ DataProperty iri) -> do -- oEx <- mapDPE cSig iri 1 2 -- ls <- mapM (\ (_, r) -> mapDataRange cSig r $ OVar 2) dpr -- return (msen2Txt $ map (mkSent [mkNAME 1] [mkNAME 2] oEx -- . fst) ls, uniteL $ map snd ls ) -- _ -> failMsg dpr -- IndividualFacts indf -> do -- fl <- mapM (mapFact cSig ex . snd) indf -- return (fl, cSig) -- ObjectCharacteristics ace -> case ex of -- ObjectEntity ope -> do -- cl <- mapM (mapCharact cSig ope . snd) ace -- return (cl, cSig) -- _ -> failMsg ace -- | Mapping of AnnFrameBit -- mapAnnFrameBit :: Sign -> Extended -> AnnFrameBit -> Result ([TEXT], Sign) -- mapAnnFrameBit cSig ex afb = -- let err = fail $ "could not translate " ++ show afb in case afb of -- AnnotationFrameBit _ -> return ([], cSig) -- DataFunctional -> case ex of -- SimpleEntity (Entity _ DataProperty iri) -> do -- so1 <- mapDPE cSig iri 1 2 -- so2 <- mapDPE cSig iri 1 3 -- return ([mkQUBI (map mkNAME [1, 2, 3]) [so1, so2] -- (mkNTERM 2) $ mkNTERM 3], cSig) -- _ -> err -- DatatypeBit dr -> case ex of -- SimpleEntity (Entity _ Datatype iri) -> do -- (odes, dSig) <- mapDataRange cSig dr $ OVar 1 -- let dtp = mkTermAtoms (uriToTok iri) [mkVTerm $ OVar 1] -- return ([senToText $ mk1QU $ mkBB dtp odes], dSig) -- _ -> err -- ClassDisjointUnion clsl -> case ex of -- ClassEntity (Expression iri) -> do -- (decrs, dSig) <- mapDescriptionList cSig 1 clsl -- (decrsS, pSig) <- mapDescriptionListP cSig 1 $ comPairs clsl clsl -- let decrsP = unzip decrsS -- mcls <- mapClassIRI cSig iri $ mkNName 1 -- return ([senToText $ mk1QU $ mkBB mcls $ mkBC -- [mkBD decrs, mkBN $ mkBC $ uncurry (++) decrsP]], -- unite dSig pSig) -- _ -> err -- ClassHasKey opl dpl -> do -- let ClassEntity ce = ex -- lo = length opl -- ld = length dpl -- uptoOP = [2 .. lo + 1] -- uptoDP = [lo + 2 .. lo + ld + 1] -- tl = lo + ld + 2 -- (_, sig) <- mapDescription cSig ce (OVar 1) 1 -- ol <- mapM (\ (n, o) -> mapOPE cSig o 1 n) $ zip uptoOP opl -- nol <- mapM (\ (n, o) -> mapOPE cSig o tl n) $ zip uptoOP opl -- dl <- mapM (\ (n, d) -> mapDPE cSig d 1 n) $ zip uptoDP dpl -- ndl <- mapM (\ (n, d) -> mapDPE cSig d tl n) $ zip uptoDP dpl -- keys <- mapKey cSig ce (ol ++ dl, nol ++ ndl) tl -- $ uptoOP ++ uptoDP -- return ([senToText keys], sig) -- ObjectSubPropertyChain oplst -> case ex of -- ObjectEntity op -> do -- os <- mapSubObjPropChain cSig oplst op 3 -- return ([senToText os], cSig) -- _ -> err -- | Mapping of Axioms -- mapAxioms :: Sign -> Axiom -> Result ([TEXT], Sign) -- mapAxioms cSig (PlainAxiom ex fb) = case fb of -- ListFrameBit rel lfb -> mapListFrameBit cSig ex rel lfb -- AnnFrameBit _ afb -> mapAnnFrameBit cSig ex afb
8,631
false
true
0
18
3,581
342
254
88
null
null