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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
jmitchell/Idris-dev | src/Idris/IdrisDoc.hs | bsd-3-clause | getNs _ = [] | 20 | getNs _ = [] | 20 | getNs _ = [] | 20 | false | false | 0 | 5 | 11 | 12 | 5 | 7 | null | null |
quchen/shaking-up-ghc | src/Settings/Ways.hs | bsd-3-clause | -- TODO: use a single expression Ways parameterised by package instead of
-- expressions libWays and rtsWays
-- Combining default ways with user modifications
getLibWays :: Expr [Way]
getLibWays = fromDiffExpr $ defaultLibWays <> userLibWays | 242 | getLibWays :: Expr [Way]
getLibWays = fromDiffExpr $ defaultLibWays <> userLibWays | 82 | getLibWays = fromDiffExpr $ defaultLibWays <> userLibWays | 57 | true | true | 0 | 6 | 35 | 28 | 16 | 12 | null | null |
owainlewis/slack | src/Network/Slack/Api.hs | mit | channelsInvite :: Token -> RequestParams -> IO SlackResponse
channelsInvite token params = request token "channels.invite" params | 129 | channelsInvite :: Token -> RequestParams -> IO SlackResponse
channelsInvite token params = request token "channels.invite" params | 129 | channelsInvite token params = request token "channels.invite" params | 68 | false | true | 0 | 7 | 15 | 34 | 16 | 18 | null | null |
qnikst/network-transport-zeromq | benchmarks/Throughput.hs | bsd-3-clause | initialServer :: Process ()
initialServer = do
us <- getSelfPid
liftIO $ BSL.writeFile "counter.pid" (encode us)
counter | 126 | initialServer :: Process ()
initialServer = do
us <- getSelfPid
liftIO $ BSL.writeFile "counter.pid" (encode us)
counter | 126 | initialServer = do
us <- getSelfPid
liftIO $ BSL.writeFile "counter.pid" (encode us)
counter | 98 | false | true | 0 | 10 | 22 | 46 | 21 | 25 | null | null |
lukexi/rumpus | pristine/Intro/Stars.hs | bsd-3-clause | -- Golden Section Spiral (via http://www.softimageblog.com/archives/115)
pointsOnSphere :: Int -> [V3 GLfloat]
pointsOnSphere (fromIntegral -> n) =
map (\k ->
let y = k * off - 1 + (off / 2)
r = sqrt (1 - y*y)
phi = k * inc
in V3 (cos phi * r) y (sin phi * r)
) [0..n]
where inc = pi * (3 - sqrt 5)
off = 2 / n | 386 | pointsOnSphere :: Int -> [V3 GLfloat]
pointsOnSphere (fromIntegral -> n) =
map (\k ->
let y = k * off - 1 + (off / 2)
r = sqrt (1 - y*y)
phi = k * inc
in V3 (cos phi * r) y (sin phi * r)
) [0..n]
where inc = pi * (3 - sqrt 5)
off = 2 / n | 311 | pointsOnSphere (fromIntegral -> n) =
map (\k ->
let y = k * off - 1 + (off / 2)
r = sqrt (1 - y*y)
phi = k * inc
in V3 (cos phi * r) y (sin phi * r)
) [0..n]
where inc = pi * (3 - sqrt 5)
off = 2 / n | 273 | true | true | 2 | 14 | 145 | 177 | 87 | 90 | null | null |
awakenetworks/gRPC-haskell | core/src/Network/GRPC/LowLevel/Call.hs | apache-2.0 | methodHandle (RegisteredMethodServerStreaming _ _ x) = x | 56 | methodHandle (RegisteredMethodServerStreaming _ _ x) = x | 56 | methodHandle (RegisteredMethodServerStreaming _ _ x) = x | 56 | false | false | 0 | 6 | 6 | 20 | 9 | 11 | null | null |
iemxblog/hpcb | examples/atmega328p-dev-board.hs | mit | pinHeaders :: Circuit
pinHeaders =
ftdi_basic "JP1" # translate (V2 (-6.35) (-15.24))
<> pinHeaderLeft "JP7" # rotate 180 # translate (V2 (-7.62) 15.24)
<> pinHeaderRight "JP6" # translate (V2 7.62 (-12.7))
<> offGridHeader1 "JP2" # translate (V2 5.08 (-3.81))
<> offGridHeader2 "JP3" # translate (V2 2.54 15.24) | 322 | pinHeaders :: Circuit
pinHeaders =
ftdi_basic "JP1" # translate (V2 (-6.35) (-15.24))
<> pinHeaderLeft "JP7" # rotate 180 # translate (V2 (-7.62) 15.24)
<> pinHeaderRight "JP6" # translate (V2 7.62 (-12.7))
<> offGridHeader1 "JP2" # translate (V2 5.08 (-3.81))
<> offGridHeader2 "JP3" # translate (V2 2.54 15.24) | 322 | pinHeaders =
ftdi_basic "JP1" # translate (V2 (-6.35) (-15.24))
<> pinHeaderLeft "JP7" # rotate 180 # translate (V2 (-7.62) 15.24)
<> pinHeaderRight "JP6" # translate (V2 7.62 (-12.7))
<> offGridHeader1 "JP2" # translate (V2 5.08 (-3.81))
<> offGridHeader2 "JP3" # translate (V2 2.54 15.24) | 300 | false | true | 8 | 10 | 56 | 159 | 73 | 86 | null | null |
m15k/hs-dtd-text | Data/XML/DTD/Parse.hs | bsd-3-clause | comment :: Parser Text
comment = "<!--" .*> (T.concat . concat <$> manyTillS chunk "--") <*. ">"
where
chunk = list2 . T.singleton <$> anyChar <*> takeTill (== '-')
-- | Definition of white space characters, from the XML specification. | 242 | comment :: Parser Text
comment = "<!--" .*> (T.concat . concat <$> manyTillS chunk "--") <*. ">"
where
chunk = list2 . T.singleton <$> anyChar <*> takeTill (== '-')
-- | Definition of white space characters, from the XML specification. | 242 | comment = "<!--" .*> (T.concat . concat <$> manyTillS chunk "--") <*. ">"
where
chunk = list2 . T.singleton <$> anyChar <*> takeTill (== '-')
-- | Definition of white space characters, from the XML specification. | 219 | false | true | 0 | 10 | 46 | 70 | 36 | 34 | null | null |
hirokai/PaperServer | Parser/Publisher/ACS.hs | bsd-2-clause | -- | otherwise = n
mapAttr' _ _ n = n | 37 | mapAttr' _ _ n = n | 18 | mapAttr' _ _ n = n | 18 | true | false | 0 | 5 | 10 | 14 | 7 | 7 | null | null |
deech/fltkhs-fluid-hello-world | Setup.hs | mit | _PackageName = mkPackageName | 28 | _PackageName = mkPackageName | 28 | _PackageName = mkPackageName | 28 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
nomeata/ghc | compiler/main/DriverPhases.hs | bsd-3-clause | x `happensBefore` y = after_x `eqPhase` y || after_x `happensBefore` y
where
after_x = nextPhase x | 121 | x `happensBefore` y = after_x `eqPhase` y || after_x `happensBefore` y
where
after_x = nextPhase x | 121 | x `happensBefore` y = after_x `eqPhase` y || after_x `happensBefore` y
where
after_x = nextPhase x | 121 | false | false | 0 | 7 | 38 | 40 | 22 | 18 | null | null |
bgold-cosmos/Tidal | tidal-parse/src/Sound/Tidal/Parse.hs | gpl-3.0 | pAB_pA_pB :: H ((Pattern a -> Pattern b) -> Pattern a -> Pattern b)
pAB_pA_pB = pTime_pAB_pA_pB <*!> parser | 107 | pAB_pA_pB :: H ((Pattern a -> Pattern b) -> Pattern a -> Pattern b)
pAB_pA_pB = pTime_pAB_pA_pB <*!> parser | 107 | pAB_pA_pB = pTime_pAB_pA_pB <*!> parser | 39 | false | true | 3 | 11 | 18 | 57 | 26 | 31 | null | null |
isomorphism/Delineate | Control/Delineate/Expon.hs | bsd-3-clause | mkBang :: a -> Bang (Var a) r
mkBang x = Bang . With . Not $ either
(\(Not weak) -> weak Unit)
(\(Not kdc) -> kdc . With . Not $ either
(\(Not der) -> der $ Var x)
(\(Not con) -> con $ Mult (mkBang x, mkBang x))
. getPlus) . getPlus | 264 | mkBang :: a -> Bang (Var a) r
mkBang x = Bang . With . Not $ either
(\(Not weak) -> weak Unit)
(\(Not kdc) -> kdc . With . Not $ either
(\(Not der) -> der $ Var x)
(\(Not con) -> con $ Mult (mkBang x, mkBang x))
. getPlus) . getPlus | 264 | mkBang x = Bang . With . Not $ either
(\(Not weak) -> weak Unit)
(\(Not kdc) -> kdc . With . Not $ either
(\(Not der) -> der $ Var x)
(\(Not con) -> con $ Mult (mkBang x, mkBang x))
. getPlus) . getPlus | 234 | false | true | 0 | 16 | 85 | 162 | 80 | 82 | null | null |
brendanhay/gogol | gogol-spanner/gen/Network/Google/Resource/Spanner/Projects/Instances/Backups/Operations/Cancel.hs | mpl-2.0 | -- | Upload protocol for media (e.g. \"raw\", \"multipart\").
pibocUploadProtocol :: Lens' ProjectsInstancesBackupsOperationsCancel (Maybe Text)
pibocUploadProtocol
= lens _pibocUploadProtocol
(\ s a -> s{_pibocUploadProtocol = a}) | 239 | pibocUploadProtocol :: Lens' ProjectsInstancesBackupsOperationsCancel (Maybe Text)
pibocUploadProtocol
= lens _pibocUploadProtocol
(\ s a -> s{_pibocUploadProtocol = a}) | 177 | pibocUploadProtocol
= lens _pibocUploadProtocol
(\ s a -> s{_pibocUploadProtocol = a}) | 94 | true | true | 0 | 9 | 33 | 48 | 25 | 23 | null | null |
Hara-Laboratory/subleq-mips | TestRFix2.hs | gpl-3.0 | printSubroutine s addr = f loc
where
obj = A.lookupModule s subleqModule
loc = obj >>= A.locate subleqMA addr
f (Just (o, _)) = putStrLn $ render $ A.printObject o
f _ = putStrLn "not found" | 218 | printSubroutine s addr = f loc
where
obj = A.lookupModule s subleqModule
loc = obj >>= A.locate subleqMA addr
f (Just (o, _)) = putStrLn $ render $ A.printObject o
f _ = putStrLn "not found" | 218 | printSubroutine s addr = f loc
where
obj = A.lookupModule s subleqModule
loc = obj >>= A.locate subleqMA addr
f (Just (o, _)) = putStrLn $ render $ A.printObject o
f _ = putStrLn "not found" | 218 | false | false | 0 | 10 | 63 | 88 | 43 | 45 | null | null |
cackharot/heub | src/Api/UserService.hs | mit | userServiceApiInit :: SnapletInit b UserService
userServiceApiInit = makeSnaplet "userService" "User service api" Nothing $ do
addRoutes userApiRoutes
return $ UserService dbConfiguration | 231 | userServiceApiInit :: SnapletInit b UserService
userServiceApiInit = makeSnaplet "userService" "User service api" Nothing $ do
addRoutes userApiRoutes
return $ UserService dbConfiguration | 231 | userServiceApiInit = makeSnaplet "userService" "User service api" Nothing $ do
addRoutes userApiRoutes
return $ UserService dbConfiguration | 183 | false | true | 0 | 9 | 64 | 43 | 19 | 24 | null | null |
shockkolate/containers | Data/Map/Base.hs | bsd-3-clause | {--------------------------------------------------------------------
Indexing
--------------------------------------------------------------------}
-- | /O(log n)/. Return the /index/ of a key, which is its zero-based index in
-- the sequence sorted by keys. The index is a number from /0/ up to, but not
-- including, the 'size' of the map. Calls 'error' when the key is not
-- a 'member' of the map.
--
-- > findIndex 2 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map
-- > findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0
-- > findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1
-- > findIndex 6 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map
-- See Note: Type of local 'go' function
findIndex :: Ord k => k -> Map k a -> Int
findIndex = go 0
where
go :: Ord k => Int -> k -> Map k a -> Int
STRICT_1_OF_3(go)
STRICT_2_OF_3(go)
go _ _ Tip = error "Map.findIndex: element is not in the map"
go idx k (Bin _ kx _ l r) = case compare k kx of
LT -> go idx k l
GT -> go (idx + size l + 1) k r
EQ -> idx + size l
#if __GLASGOW_HASKELL__ >= 700
| 1,116 | findIndex :: Ord k => k -> Map k a -> Int
findIndex = go 0
where
go :: Ord k => Int -> k -> Map k a -> Int
STRICT_1_OF_3(go)
STRICT_2_OF_3(go)
go _ _ Tip = error "Map.findIndex: element is not in the map"
go idx k (Bin _ kx _ l r) = case compare k kx of
LT -> go idx k l
GT -> go (idx + size l + 1) k r
EQ -> idx + size l
#if __GLASGOW_HASKELL__ >= 700
| 396 | findIndex = go 0
where
go :: Ord k => Int -> k -> Map k a -> Int
STRICT_1_OF_3(go)
STRICT_2_OF_3(go)
go _ _ Tip = error "Map.findIndex: element is not in the map"
go idx k (Bin _ kx _ l r) = case compare k kx of
LT -> go idx k l
GT -> go (idx + size l + 1) k r
EQ -> idx + size l
#if __GLASGOW_HASKELL__ >= 700
| 354 | true | true | 3 | 9 | 251 | 202 | 100 | 102 | null | null |
nevrenato/Hets_Fork | CSL/TreePO.hs | gpl-2.0 | -- | If the set is singular, i.e., consists only from one point, then we
-- return this point. Reports error on empty SoI's.
-- Only for continuous types.
toSingular :: (Continuous a, Ord a) => SetOrInterval a -> Maybe a
toSingular d
| nullSoI d = error "toSingular: empty set"
| otherwise =
case d of
Set s
| Set.size s == 1 -> Just $ Set.findMin s
| otherwise -> Nothing
IntVal (a, _) (b, _)
| a == b -> Just a
| otherwise -> Nothing
-- | Transforms a 'SetOrInterval' to a closed representation
-- Only for continuous types. | 619 | toSingular :: (Continuous a, Ord a) => SetOrInterval a -> Maybe a
toSingular d
| nullSoI d = error "toSingular: empty set"
| otherwise =
case d of
Set s
| Set.size s == 1 -> Just $ Set.findMin s
| otherwise -> Nothing
IntVal (a, _) (b, _)
| a == b -> Just a
| otherwise -> Nothing
-- | Transforms a 'SetOrInterval' to a closed representation
-- Only for continuous types. | 464 | toSingular d
| nullSoI d = error "toSingular: empty set"
| otherwise =
case d of
Set s
| Set.size s == 1 -> Just $ Set.findMin s
| otherwise -> Nothing
IntVal (a, _) (b, _)
| a == b -> Just a
| otherwise -> Nothing
-- | Transforms a 'SetOrInterval' to a closed representation
-- Only for continuous types. | 398 | true | true | 0 | 14 | 195 | 156 | 74 | 82 | null | null |
energyflowanalysis/efa-2.1 | src/EFA/Report/Typ.hs | bsd-3-clause | dispPhTyp :: DisplayType -> String
dispPhTyp x = drop 4 (show x) | 65 | dispPhTyp :: DisplayType -> String
dispPhTyp x = drop 4 (show x) | 65 | dispPhTyp x = drop 4 (show x) | 29 | false | true | 0 | 7 | 12 | 36 | 15 | 21 | null | null |
schell/hdevtools | src/Main.hs | mit | pathArg' :: HDevTools -> Maybe String
pathArg' (Admin {}) = Nothing | 72 | pathArg' :: HDevTools -> Maybe String
pathArg' (Admin {}) = Nothing | 72 | pathArg' (Admin {}) = Nothing | 34 | false | true | 0 | 7 | 15 | 28 | 14 | 14 | null | null |
mariefarrell/Hets | OWL2/ShipSyntax.hs | gpl-2.0 | character :: CharParser st Character
character = choice $ map (\ a -> key (showCharacter a) >> return a)
[minBound .. maxBound] | 129 | character :: CharParser st Character
character = choice $ map (\ a -> key (showCharacter a) >> return a)
[minBound .. maxBound] | 129 | character = choice $ map (\ a -> key (showCharacter a) >> return a)
[minBound .. maxBound] | 92 | false | true | 0 | 12 | 23 | 56 | 28 | 28 | null | null |
AlexanderPankiv/ghc | compiler/codeGen/StgCmmPrim.hs | bsd-3-clause | doCopyArrayOp :: CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> WordOff
-> FCode ()
doCopyArrayOp = emitCopyArray copy
where
-- Copy data (we assume the arrays aren't overlapping since
-- they're of different types)
copy _src _dst dst_p src_p bytes =
do dflags <- getDynFlags
emitMemcpyCall dst_p src_p (mkIntExpr dflags bytes)
(wORD_SIZE dflags)
-- | Takes a source 'MutableArray#', an offset in the source array, a
-- destination 'MutableArray#', an offset into the destination array,
-- and the number of elements to copy. Copies the given number of
-- elements from the source array to the destination array. | 674 | doCopyArrayOp :: CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> WordOff
-> FCode ()
doCopyArrayOp = emitCopyArray copy
where
-- Copy data (we assume the arrays aren't overlapping since
-- they're of different types)
copy _src _dst dst_p src_p bytes =
do dflags <- getDynFlags
emitMemcpyCall dst_p src_p (mkIntExpr dflags bytes)
(wORD_SIZE dflags)
-- | Takes a source 'MutableArray#', an offset in the source array, a
-- destination 'MutableArray#', an offset into the destination array,
-- and the number of elements to copy. Copies the given number of
-- elements from the source array to the destination array. | 674 | doCopyArrayOp = emitCopyArray copy
where
-- Copy data (we assume the arrays aren't overlapping since
-- they're of different types)
copy _src _dst dst_p src_p bytes =
do dflags <- getDynFlags
emitMemcpyCall dst_p src_p (mkIntExpr dflags bytes)
(wORD_SIZE dflags)
-- | Takes a source 'MutableArray#', an offset in the source array, a
-- destination 'MutableArray#', an offset into the destination array,
-- and the number of elements to copy. Copies the given number of
-- elements from the source array to the destination array. | 579 | false | true | 0 | 11 | 162 | 97 | 49 | 48 | null | null |
sdiehl/ghc | compiler/GHC/StgToCmm/ExtCode.hs | bsd-3-clause | thenExtFC :: CmmParse a -> (a -> CmmParse b) -> CmmParse b
thenExtFC (EC m) k = EC $ \c e s -> do (s',r) <- m c e s; unEC (k r) c e s' | 134 | thenExtFC :: CmmParse a -> (a -> CmmParse b) -> CmmParse b
thenExtFC (EC m) k = EC $ \c e s -> do (s',r) <- m c e s; unEC (k r) c e s' | 134 | thenExtFC (EC m) k = EC $ \c e s -> do (s',r) <- m c e s; unEC (k r) c e s' | 75 | false | true | 0 | 11 | 35 | 98 | 48 | 50 | null | null |
joevandyk/imgcons | codeView.hs | bsd-2-clause | errorPage :: HTML a => a -> Html
errorPage b = header << indexHeaderRedirect "index.fcgi" +++ body << b | 107 | errorPage :: HTML a => a -> Html
errorPage b = header << indexHeaderRedirect "index.fcgi" +++ body << b | 107 | errorPage b = header << indexHeaderRedirect "index.fcgi" +++ body << b | 72 | false | true | 0 | 8 | 22 | 46 | 20 | 26 | null | null |
meteogrid/sigym-core | tests/TestGeneration.hs | bsd-3-clause | tests :: Test.Framework.Test
tests = $(testGroupGenerator) | 58 | tests :: Test.Framework.Test
tests = $(testGroupGenerator) | 58 | tests = $(testGroupGenerator) | 29 | false | true | 0 | 7 | 5 | 25 | 11 | 14 | null | null |
sdiehl/ghc | compiler/ghci/ByteCodeLink.hs | bsd-3-clause | lookupLiteral hsc_env _ (BCONPtrLbl sym) = do
Ptr a# <- lookupStaticPtr hsc_env sym
return (W# (int2Word# (addr2Int# a#))) | 127 | lookupLiteral hsc_env _ (BCONPtrLbl sym) = do
Ptr a# <- lookupStaticPtr hsc_env sym
return (W# (int2Word# (addr2Int# a#))) | 127 | lookupLiteral hsc_env _ (BCONPtrLbl sym) = do
Ptr a# <- lookupStaticPtr hsc_env sym
return (W# (int2Word# (addr2Int# a#))) | 127 | false | false | 1 | 14 | 22 | 62 | 26 | 36 | null | null |
AlexeyRaga/eta | compiler/ETA/Prelude/PrelNames.hs | bsd-3-clause | isNewtypeName_RDR = varQual_RDR gHC_GENERICS (fsLit "isNewtype") | 64 | isNewtypeName_RDR = varQual_RDR gHC_GENERICS (fsLit "isNewtype") | 64 | isNewtypeName_RDR = varQual_RDR gHC_GENERICS (fsLit "isNewtype") | 64 | false | false | 0 | 7 | 5 | 17 | 8 | 9 | null | null |
rueshyna/gogol | gogol-pubsub/gen/Network/Google/PubSub/Types/Product.hs | mpl-2.0 | -- | The names of the subscriptions that match the request.
ltsrSubscriptions :: Lens' ListTopicSubscriptionsResponse [Text]
ltsrSubscriptions
= lens _ltsrSubscriptions
(\ s a -> s{_ltsrSubscriptions = a})
. _Default
. _Coerce | 246 | ltsrSubscriptions :: Lens' ListTopicSubscriptionsResponse [Text]
ltsrSubscriptions
= lens _ltsrSubscriptions
(\ s a -> s{_ltsrSubscriptions = a})
. _Default
. _Coerce | 186 | ltsrSubscriptions
= lens _ltsrSubscriptions
(\ s a -> s{_ltsrSubscriptions = a})
. _Default
. _Coerce | 121 | true | true | 0 | 11 | 50 | 53 | 28 | 25 | null | null |
ribag/ganeti-experiments | src/Ganeti/WConfd/TempRes.hs | gpl-2.0 | reserveMAC
:: (MonadError GanetiException m, MonadState TempResState m, Functor m)
=> ClientId -> MAC -> ConfigData -> m ()
reserveMAC jobId mac cd = do
let existing = S.fromList $ getAllMACs cd
when (S.member mac existing)
$ resError "MAC already in use"
modifyM $ traverseOf trsMACsL (reserve jobId mac)
-- ** DRBD secrets | 339 | reserveMAC
:: (MonadError GanetiException m, MonadState TempResState m, Functor m)
=> ClientId -> MAC -> ConfigData -> m ()
reserveMAC jobId mac cd = do
let existing = S.fromList $ getAllMACs cd
when (S.member mac existing)
$ resError "MAC already in use"
modifyM $ traverseOf trsMACsL (reserve jobId mac)
-- ** DRBD secrets | 339 | reserveMAC jobId mac cd = do
let existing = S.fromList $ getAllMACs cd
when (S.member mac existing)
$ resError "MAC already in use"
modifyM $ traverseOf trsMACsL (reserve jobId mac)
-- ** DRBD secrets | 211 | false | true | 0 | 12 | 67 | 126 | 59 | 67 | null | null |
pmiddend/tic | lib/Tic/CoordTransform.hs | gpl-3.0 | originRectangle :: Num a => V2 a -> Rectangle a
originRectangle = rectFromPoints (V2 0 0) | 89 | originRectangle :: Num a => V2 a -> Rectangle a
originRectangle = rectFromPoints (V2 0 0) | 89 | originRectangle = rectFromPoints (V2 0 0) | 41 | false | true | 0 | 8 | 15 | 44 | 19 | 25 | null | null |
antalsz/hs-to-coq | src/lib/HsToCoq/ConvertHaskell/Expr.hs | mit | convertExpr_ (HsPar NOEXTP e) =
Parens <$> convertLExpr e | 59 | convertExpr_ (HsPar NOEXTP e) =
Parens <$> convertLExpr e | 59 | convertExpr_ (HsPar NOEXTP e) =
Parens <$> convertLExpr e | 59 | false | false | 2 | 6 | 10 | 27 | 11 | 16 | null | null |
haskell-distributed/distributed-process-platform | src/Control/Distributed/Process/Platform/ManagedProcess/Server/Restricted.hs | bsd-3-clause | handleInfo :: forall s a. (Serializable a)
=> (a -> RestrictedProcess s RestrictedAction)
-> DeferredDispatcher s
-- cast and info look the same to a restricted process
handleInfo h = Server.handleInfo (wrapHandler h) | 239 | handleInfo :: forall s a. (Serializable a)
=> (a -> RestrictedProcess s RestrictedAction)
-> DeferredDispatcher s
handleInfo h = Server.handleInfo (wrapHandler h) | 184 | handleInfo h = Server.handleInfo (wrapHandler h) | 48 | true | true | 0 | 11 | 54 | 64 | 32 | 32 | null | null |
afcowie/pipes-http | tests/MockServer.hs | bsd-3-clause | handleGetMethod :: Snap ()
handleGetMethod = do
r <- getRequest
let mime0 = getHeader "Accept" r
case mime0 of
Just "text/html" -> handleAsBrowser
_ -> handleAsText | 222 | handleGetMethod :: Snap ()
handleGetMethod = do
r <- getRequest
let mime0 = getHeader "Accept" r
case mime0 of
Just "text/html" -> handleAsBrowser
_ -> handleAsText | 222 | handleGetMethod = do
r <- getRequest
let mime0 = getHeader "Accept" r
case mime0 of
Just "text/html" -> handleAsBrowser
_ -> handleAsText | 195 | false | true | 1 | 11 | 83 | 61 | 27 | 34 | null | null |
oulgen/CudaPy | py2cuda/src/Translation/Translate.hs | mit | getCudaVar err = throwError $ "not a CUDA variable: " ++ err | 60 | getCudaVar err = throwError $ "not a CUDA variable: " ++ err | 60 | getCudaVar err = throwError $ "not a CUDA variable: " ++ err | 60 | false | false | 0 | 6 | 11 | 17 | 8 | 9 | null | null |
ivan-m/paraphrase | src/Text/Paraphrase/Examples/XML.hs | bsd-3-clause | -- | Called by 'element'; ends a tag with the specified name.
endTag :: String -> Parse ()
endTag n = addCustomOnFailure (ClosingTag n)
(do m <- bracket (string "</") (token '>') name
if n == m
then pure ()
else failCustom (WrongClose n m))
<?> "endTag" | 334 | endTag :: String -> Parse ()
endTag n = addCustomOnFailure (ClosingTag n)
(do m <- bracket (string "</") (token '>') name
if n == m
then pure ()
else failCustom (WrongClose n m))
<?> "endTag" | 272 | endTag n = addCustomOnFailure (ClosingTag n)
(do m <- bracket (string "</") (token '>') name
if n == m
then pure ()
else failCustom (WrongClose n m))
<?> "endTag" | 243 | true | true | 2 | 11 | 127 | 106 | 49 | 57 | null | null |
lueck/standoff-tools | src/StandOff/Tag.hs | gpl-3.0 | constTagSerializer
:: (ToAttributes a, IdentifiableSplit a) =>
String -- ^ name of element
-> (ExternalAttributes -> [Attribute]) -- ^ a partially evaluated attributes mapping
-> TagSerializer a -- ^ returns a 'TagSerializer'
constTagSerializer elName mapping Open tag =
"<" <> elName
<> (concatMap ((" "<>) . serializeXml) $ mapping $ specialAttrs tag $ attributes tag)
<> ">" | 443 | constTagSerializer
:: (ToAttributes a, IdentifiableSplit a) =>
String -- ^ name of element
-> (ExternalAttributes -> [Attribute]) -- ^ a partially evaluated attributes mapping
-> TagSerializer a
constTagSerializer elName mapping Open tag =
"<" <> elName
<> (concatMap ((" "<>) . serializeXml) $ mapping $ specialAttrs tag $ attributes tag)
<> ">" | 392 | constTagSerializer elName mapping Open tag =
"<" <> elName
<> (concatMap ((" "<>) . serializeXml) $ mapping $ specialAttrs tag $ attributes tag)
<> ">" | 157 | true | true | 4 | 12 | 122 | 113 | 57 | 56 | null | null |
mckeankylej/hchess | src/MoveGeneration.hs | bsd-3-clause | pawnMovement _ _ _ _ = turnNonBinaryError | 41 | pawnMovement _ _ _ _ = turnNonBinaryError | 41 | pawnMovement _ _ _ _ = turnNonBinaryError | 41 | false | false | 0 | 5 | 6 | 15 | 7 | 8 | null | null |
WSCU/JSEuterpea | Euterpea Examples/Basics.hs | gpl-3.0 | el1 = mel11 + mel12
| 20 | mel1 = mel11 + mel12 | 20 | mel1 = mel11 + mel12 | 20 | false | false | 1 | 5 | 5 | 13 | 5 | 8 | null | null |
VoQn/ylang | Ylang/Parser/Atomic.hs | apache-2.0 | int :: Parser Expr
int = Int <$> integer | 40 | int :: Parser Expr
int = Int <$> integer | 40 | int = Int <$> integer | 21 | false | true | 0 | 5 | 8 | 18 | 9 | 9 | null | null |
prashant007/AMPL | myAMPL/src/TEMP/Layoutparser.hs | mit | -- Generated by the BNF Converter
-- local parameters
topLayout = False | 73 | topLayout = False | 17 | topLayout = False | 17 | true | false | 0 | 4 | 13 | 8 | 5 | 3 | null | null |
PseudoPower/AFSM | draft/demo.hs | mit | main :: IO ()
main = do
SDL.initializeAll
window <- SDL.createWindow "Demo" SDL.defaultWindow { SDL.windowInitialSize = V2 800 600 }
SDL.showWindow window
renderer <- SDL.createRenderer window (-1) SDL.defaultRenderer
let loop x = do
events <- SDL.pollEvents
if events /= [] then putStrLn $ show events else return ()
let (Any quit, Last newX) = foldMap (\case
SDL.QuitEvent -> (Any True, mempty)
SDL.KeyboardEvent e ->
if | SDL.keyboardEventKeyMotion e == SDL.Pressed ->
case SDL.keysymScancode (SDL.keyboardEventKeysym e) of
SDL.Scancode1 -> (Any False, Last (Just 0))
SDL.Scancode2 -> (Any False, Last (Just 1))
SDL.Scancode3 -> (Any False, Last (Just 2))
SDL.ScancodeQ -> (Any True, mempty)
_ -> mempty
| otherwise -> mempty
_ -> mempty) $
map SDL.eventPayload events
x' = newX <|> x
SDL.rendererDrawColor renderer $= white
SDL.clear renderer
SDL.rendererDrawColor renderer $= colors!!(fromJust x)
SDL.fillRect renderer (Just (SDL.Rectangle (P (V2 100 100)) (V2 100 200)))
SDL.present renderer
unless quit $ loop x'
loop $ Just 0
SDL.destroyWindow window
SDL.quit | 1,446 | main :: IO ()
main = do
SDL.initializeAll
window <- SDL.createWindow "Demo" SDL.defaultWindow { SDL.windowInitialSize = V2 800 600 }
SDL.showWindow window
renderer <- SDL.createRenderer window (-1) SDL.defaultRenderer
let loop x = do
events <- SDL.pollEvents
if events /= [] then putStrLn $ show events else return ()
let (Any quit, Last newX) = foldMap (\case
SDL.QuitEvent -> (Any True, mempty)
SDL.KeyboardEvent e ->
if | SDL.keyboardEventKeyMotion e == SDL.Pressed ->
case SDL.keysymScancode (SDL.keyboardEventKeysym e) of
SDL.Scancode1 -> (Any False, Last (Just 0))
SDL.Scancode2 -> (Any False, Last (Just 1))
SDL.Scancode3 -> (Any False, Last (Just 2))
SDL.ScancodeQ -> (Any True, mempty)
_ -> mempty
| otherwise -> mempty
_ -> mempty) $
map SDL.eventPayload events
x' = newX <|> x
SDL.rendererDrawColor renderer $= white
SDL.clear renderer
SDL.rendererDrawColor renderer $= colors!!(fromJust x)
SDL.fillRect renderer (Just (SDL.Rectangle (P (V2 100 100)) (V2 100 200)))
SDL.present renderer
unless quit $ loop x'
loop $ Just 0
SDL.destroyWindow window
SDL.quit | 1,446 | main = do
SDL.initializeAll
window <- SDL.createWindow "Demo" SDL.defaultWindow { SDL.windowInitialSize = V2 800 600 }
SDL.showWindow window
renderer <- SDL.createRenderer window (-1) SDL.defaultRenderer
let loop x = do
events <- SDL.pollEvents
if events /= [] then putStrLn $ show events else return ()
let (Any quit, Last newX) = foldMap (\case
SDL.QuitEvent -> (Any True, mempty)
SDL.KeyboardEvent e ->
if | SDL.keyboardEventKeyMotion e == SDL.Pressed ->
case SDL.keysymScancode (SDL.keyboardEventKeysym e) of
SDL.Scancode1 -> (Any False, Last (Just 0))
SDL.Scancode2 -> (Any False, Last (Just 1))
SDL.Scancode3 -> (Any False, Last (Just 2))
SDL.ScancodeQ -> (Any True, mempty)
_ -> mempty
| otherwise -> mempty
_ -> mempty) $
map SDL.eventPayload events
x' = newX <|> x
SDL.rendererDrawColor renderer $= white
SDL.clear renderer
SDL.rendererDrawColor renderer $= colors!!(fromJust x)
SDL.fillRect renderer (Just (SDL.Rectangle (P (V2 100 100)) (V2 100 200)))
SDL.present renderer
unless quit $ loop x'
loop $ Just 0
SDL.destroyWindow window
SDL.quit | 1,432 | false | true | 11 | 20 | 535 | 470 | 233 | 237 | null | null |
pawel-n/syntax | Data/Syntax/Combinator.hs | mit | -- | Tries to apply the actions in the list in order, until one of
-- them succeeds. Returns the value of the succeeding action.
choice :: SIArrow cat => [cat () a] -> cat () a
choice = foldr (/+/) (sifail "choice: all alternatives failed") | 240 | choice :: SIArrow cat => [cat () a] -> cat () a
choice = foldr (/+/) (sifail "choice: all alternatives failed") | 111 | choice = foldr (/+/) (sifail "choice: all alternatives failed") | 63 | true | true | 0 | 9 | 45 | 54 | 28 | 26 | null | null |
dillonhuff/AFL | test/LexerTests.hs | bsd-3-clause | lexCases =
[("\\", [dRes "\\"]),
("->", [dRes "->"]),
("|", [dRes "|"]),
(",", [dRes ","]),
("case", [dRes "case"]),
("of", [dRes "of"]),
("module", [dRes "module"]),
("where", [dRes "where"]),
("let", [dRes "let"]),
("=", [dRes "="]),
("(", [dlp]),
(")", [drp]),
("+", [dVar "+"]),
("-", [dVar "-"]),
("*", [dVar "*"]),
("/", [dVar "/"]),
("&&", [dVar "&&"]),
("||", [dVar "||"]),
("~", [dVar "~"]),
("<", [dVar "<"]),
(">", [dVar ">"]),
("<=", [dVar "<="]),
(">=", [dVar ">="]),
("==", [dVar "=="]),
("Never", [dCon "Never"]),
("nooo", [dVar "nooo"]),
("e34Di3", [dVar "e34Di3"]),
("iflle", [dVar "iflle"]),
("modules", [dVar "modules"]),
("casesof", [dVar "casesof"]),
("1 - 45", [dInt 1, dVar "-", dInt 45]),
("x + 4", [dVar "x", dVar "+", dInt 4])] | 848 | lexCases =
[("\\", [dRes "\\"]),
("->", [dRes "->"]),
("|", [dRes "|"]),
(",", [dRes ","]),
("case", [dRes "case"]),
("of", [dRes "of"]),
("module", [dRes "module"]),
("where", [dRes "where"]),
("let", [dRes "let"]),
("=", [dRes "="]),
("(", [dlp]),
(")", [drp]),
("+", [dVar "+"]),
("-", [dVar "-"]),
("*", [dVar "*"]),
("/", [dVar "/"]),
("&&", [dVar "&&"]),
("||", [dVar "||"]),
("~", [dVar "~"]),
("<", [dVar "<"]),
(">", [dVar ">"]),
("<=", [dVar "<="]),
(">=", [dVar ">="]),
("==", [dVar "=="]),
("Never", [dCon "Never"]),
("nooo", [dVar "nooo"]),
("e34Di3", [dVar "e34Di3"]),
("iflle", [dVar "iflle"]),
("modules", [dVar "modules"]),
("casesof", [dVar "casesof"]),
("1 - 45", [dInt 1, dVar "-", dInt 45]),
("x + 4", [dVar "x", dVar "+", dInt 4])] | 848 | lexCases =
[("\\", [dRes "\\"]),
("->", [dRes "->"]),
("|", [dRes "|"]),
(",", [dRes ","]),
("case", [dRes "case"]),
("of", [dRes "of"]),
("module", [dRes "module"]),
("where", [dRes "where"]),
("let", [dRes "let"]),
("=", [dRes "="]),
("(", [dlp]),
(")", [drp]),
("+", [dVar "+"]),
("-", [dVar "-"]),
("*", [dVar "*"]),
("/", [dVar "/"]),
("&&", [dVar "&&"]),
("||", [dVar "||"]),
("~", [dVar "~"]),
("<", [dVar "<"]),
(">", [dVar ">"]),
("<=", [dVar "<="]),
(">=", [dVar ">="]),
("==", [dVar "=="]),
("Never", [dCon "Never"]),
("nooo", [dVar "nooo"]),
("e34Di3", [dVar "e34Di3"]),
("iflle", [dVar "iflle"]),
("modules", [dVar "modules"]),
("casesof", [dVar "casesof"]),
("1 - 45", [dInt 1, dVar "-", dInt 45]),
("x + 4", [dVar "x", dVar "+", dInt 4])] | 848 | false | false | 0 | 8 | 202 | 504 | 301 | 203 | null | null |
JacksonGariety/euler.hs | 076.hs | bsd-3-clause | main = print $ (sum $ head $ iterate build [] !! 100) - 1 | 57 | main = print $ (sum $ head $ iterate build [] !! 100) - 1 | 57 | main = print $ (sum $ head $ iterate build [] !! 100) - 1 | 57 | false | false | 0 | 11 | 14 | 36 | 18 | 18 | null | null |
elben/typing-haskell-in-haskell | StaticPrelude.hs | bsd-3-clause | scaleFloatMfun
= "scaleFloat" :>: (Forall [Star]
([isIn1 cRealFloat (TGen 0)] :=>
(tInt `fn` TGen 0 `fn` TGen 0))) | 164 | scaleFloatMfun
= "scaleFloat" :>: (Forall [Star]
([isIn1 cRealFloat (TGen 0)] :=>
(tInt `fn` TGen 0 `fn` TGen 0))) | 164 | scaleFloatMfun
= "scaleFloat" :>: (Forall [Star]
([isIn1 cRealFloat (TGen 0)] :=>
(tInt `fn` TGen 0 `fn` TGen 0))) | 164 | false | false | 1 | 14 | 67 | 67 | 34 | 33 | null | null |
mvr/at | src/Math/Algebra/AbGroupPres/IsoClass.hs | bsd-3-clause | splitFactors :: Integer -> [(Integer, Integer)]
splitFactors = fmap (\gp -> (head gp, fromIntegral $ length gp)) . group . factorsOf | 132 | splitFactors :: Integer -> [(Integer, Integer)]
splitFactors = fmap (\gp -> (head gp, fromIntegral $ length gp)) . group . factorsOf | 132 | splitFactors = fmap (\gp -> (head gp, fromIntegral $ length gp)) . group . factorsOf | 84 | false | true | 0 | 12 | 20 | 59 | 32 | 27 | null | null |
brendanhay/gogol | gogol-resourcemanager/gen/Network/Google/Resource/CloudResourceManager/Folders/Patch.hs | mpl-2.0 | -- | Upload protocol for media (e.g. \"raw\", \"multipart\").
fpUploadProtocol :: Lens' FoldersPatch (Maybe Text)
fpUploadProtocol
= lens _fpUploadProtocol
(\ s a -> s{_fpUploadProtocol = a}) | 199 | fpUploadProtocol :: Lens' FoldersPatch (Maybe Text)
fpUploadProtocol
= lens _fpUploadProtocol
(\ s a -> s{_fpUploadProtocol = a}) | 137 | fpUploadProtocol
= lens _fpUploadProtocol
(\ s a -> s{_fpUploadProtocol = a}) | 85 | true | true | 0 | 9 | 33 | 48 | 25 | 23 | null | null |
ekmett/containers | tests/intmap-properties.hs | bsd-3-clause | prop_find :: [(Int, Int)] -> Bool
prop_find xs =
let xs' = List.nubBy ((==) `on` fst) xs
m = fromList xs'
in all (\(k, v) -> m ! k == v) xs' | 150 | prop_find :: [(Int, Int)] -> Bool
prop_find xs =
let xs' = List.nubBy ((==) `on` fst) xs
m = fromList xs'
in all (\(k, v) -> m ! k == v) xs' | 150 | prop_find xs =
let xs' = List.nubBy ((==) `on` fst) xs
m = fromList xs'
in all (\(k, v) -> m ! k == v) xs' | 116 | false | true | 0 | 11 | 41 | 91 | 50 | 41 | null | null |
rueshyna/gogol | gogol-compute/gen/Network/Google/Resource/Compute/InstanceGroups/Get.hs | mpl-2.0 | -- | The name of the instance group.
iggInstanceGroup :: Lens' InstanceGroupsGet Text
iggInstanceGroup
= lens _iggInstanceGroup
(\ s a -> s{_iggInstanceGroup = a}) | 171 | iggInstanceGroup :: Lens' InstanceGroupsGet Text
iggInstanceGroup
= lens _iggInstanceGroup
(\ s a -> s{_iggInstanceGroup = a}) | 134 | iggInstanceGroup
= lens _iggInstanceGroup
(\ s a -> s{_iggInstanceGroup = a}) | 85 | true | true | 0 | 9 | 31 | 42 | 22 | 20 | null | null |
UBMLtonGroup/timberc | src/Kindle.hs | bsd-3-clause | tChar = tId Char | 50 | tChar = tId Char | 50 | tChar = tId Char | 50 | false | false | 0 | 5 | 37 | 9 | 4 | 5 | null | null |
brendanhay/gogol | gogol-adexchange-buyer/gen/Network/Google/AdExchangeBuyer/Types/Product.hs | mpl-2.0 | -- | The version for this creative. Read-only. This field should not be set
-- in requests.
cVersion :: Lens' Creative (Maybe Int32)
cVersion
= lens _cVersion (\ s a -> s{_cVersion = a}) .
mapping _Coerce | 212 | cVersion :: Lens' Creative (Maybe Int32)
cVersion
= lens _cVersion (\ s a -> s{_cVersion = a}) .
mapping _Coerce | 120 | cVersion
= lens _cVersion (\ s a -> s{_cVersion = a}) .
mapping _Coerce | 79 | true | true | 2 | 9 | 44 | 63 | 29 | 34 | null | null |
antalsz/hs-to-coq | examples/graph/graph/test/benchmark.hs | mit | buildFullPatricia :: Int -> Int -> ()
buildFullPatricia = buildFull (Proxy :: PatriciaTreeP) | 92 | buildFullPatricia :: Int -> Int -> ()
buildFullPatricia = buildFull (Proxy :: PatriciaTreeP) | 92 | buildFullPatricia = buildFull (Proxy :: PatriciaTreeP) | 54 | false | true | 0 | 9 | 12 | 36 | 17 | 19 | null | null |
bgold-cosmos/Tidal | src/Sound/Tidal/Params.hs | gpl-3.0 | slider14Count :: String -> ControlPattern
slider14Count name = pStateF "slider14" name (maybe 0 (+1)) | 101 | slider14Count :: String -> ControlPattern
slider14Count name = pStateF "slider14" name (maybe 0 (+1)) | 101 | slider14Count name = pStateF "slider14" name (maybe 0 (+1)) | 59 | false | true | 0 | 8 | 13 | 45 | 20 | 25 | null | null |
oprdyn/redirector | tests/Bindings.hs | gpl-2.0 | test = putStrLn $ fromValue mock | 32 | test = putStrLn $ fromValue mock | 32 | test = putStrLn $ fromValue mock | 32 | false | false | 3 | 5 | 5 | 18 | 6 | 12 | null | null |
rodrigogribeiro/mptc | src/Tc/Kc/KcDriver.hs | bsd-3-clause | kcTy :: Type -> Kc Kind
kcTy (TyForall Nothing ctx ty)
= do
kcContext ctx
kcTy ty | 102 | kcTy :: Type -> Kc Kind
kcTy (TyForall Nothing ctx ty)
= do
kcContext ctx
kcTy ty | 102 | kcTy (TyForall Nothing ctx ty)
= do
kcContext ctx
kcTy ty | 78 | false | true | 0 | 7 | 37 | 43 | 19 | 24 | null | null |
pdmurray/haskell-book-ex | src/ch6/Exercises6.hs | bsd-3-clause | -- 6. works. identity function works fine with Int
freud' :: Int -> Int
freud' x = x | 85 | freud' :: Int -> Int
freud' x = x | 33 | freud' x = x | 12 | true | true | 0 | 5 | 18 | 19 | 10 | 9 | null | null |
mathologist/CTYCrypto | Exercises.hs | gpl-3.0 | dangerousLookup :: (Ord k, Num a) => k -> Map.Map k a -> a
dangerousLookup k m = fromMaybe 0 (Map.lookup k m) | 109 | dangerousLookup :: (Ord k, Num a) => k -> Map.Map k a -> a
dangerousLookup k m = fromMaybe 0 (Map.lookup k m) | 109 | dangerousLookup k m = fromMaybe 0 (Map.lookup k m) | 50 | false | true | 0 | 9 | 22 | 61 | 30 | 31 | null | null |
matonix/pfds | src/PFDS/Sec3/Ex4c.hs | bsd-3-clause | size :: WLHeap e -> Int
size E = 0 | 35 | size :: WLHeap e -> Int
size E = 0 | 34 | size E = 0 | 10 | false | true | 0 | 6 | 10 | 21 | 10 | 11 | null | null |
uduki/hsQt | Qtc/Core/QDataStream.hs | bsd-2-clause | skipRawData :: QDataStream a -> ((Int)) -> IO (Int)
skipRawData x0 (x1)
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QDataStream_skipRawData cobj_x0 (toCInt x1) | 178 | skipRawData :: QDataStream a -> ((Int)) -> IO (Int)
skipRawData x0 (x1)
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QDataStream_skipRawData cobj_x0 (toCInt x1) | 178 | skipRawData x0 (x1)
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QDataStream_skipRawData cobj_x0 (toCInt x1) | 126 | false | true | 0 | 9 | 33 | 69 | 35 | 34 | null | null |
DimaSamoz/mezzo | src/Mezzo/Render/Transform.hs | mit | - | Remove the attribute MIDI messages in the score header.
stripHeader :: Score -> Score
stripHeader [] = []
| 110 | stripHeader :: Score -> Score
stripHeader [] = [] | 49 | stripHeader [] = [] | 19 | true | true | 1 | 8 | 20 | 54 | 24 | 30 | null | null |
pgj/bead | test/Test/Property/Persistence.hs | bsd-3-clause | -- The test will fail with the given message, if the list is null
assertNonEmpty :: (Monad m) => [a] -> String -> m ()
assertNonEmpty [] msg = fail msg | 151 | assertNonEmpty :: (Monad m) => [a] -> String -> m ()
assertNonEmpty [] msg = fail msg | 85 | assertNonEmpty [] msg = fail msg | 32 | true | true | 0 | 9 | 30 | 47 | 24 | 23 | null | null |
fmapfmapfmap/amazonka | amazonka-ses/gen/Network/AWS/SES/VerifyDomainIdentity.hs | mpl-2.0 | -- | The response status code.
vdirsResponseStatus :: Lens' VerifyDomainIdentityResponse Int
vdirsResponseStatus = lens _vdirsResponseStatus (\ s a -> s{_vdirsResponseStatus = a}) | 179 | vdirsResponseStatus :: Lens' VerifyDomainIdentityResponse Int
vdirsResponseStatus = lens _vdirsResponseStatus (\ s a -> s{_vdirsResponseStatus = a}) | 148 | vdirsResponseStatus = lens _vdirsResponseStatus (\ s a -> s{_vdirsResponseStatus = a}) | 86 | true | true | 0 | 9 | 21 | 40 | 22 | 18 | null | null |
robdockins/edison | edison-core/src/Data/Edison/Seq/BankersQueue.hs | mit | foldrWithIndex' = foldrWithIndex'UsingLists | 43 | foldrWithIndex' = foldrWithIndex'UsingLists | 43 | foldrWithIndex' = foldrWithIndex'UsingLists | 43 | false | false | 0 | 4 | 2 | 6 | 3 | 3 | null | null |
brendanhay/gogol | gogol-vision/gen/Network/Google/Vision/Types/Product.hs | mpl-2.0 | -- | Canonical description of the entity, in English.
gcvvwdweDescription :: Lens' GoogleCloudVisionV1p1beta1WebDetectionWebEntity (Maybe Text)
gcvvwdweDescription
= lens _gcvvwdweDescription
(\ s a -> s{_gcvvwdweDescription = a}) | 238 | gcvvwdweDescription :: Lens' GoogleCloudVisionV1p1beta1WebDetectionWebEntity (Maybe Text)
gcvvwdweDescription
= lens _gcvvwdweDescription
(\ s a -> s{_gcvvwdweDescription = a}) | 184 | gcvvwdweDescription
= lens _gcvvwdweDescription
(\ s a -> s{_gcvvwdweDescription = a}) | 94 | true | true | 1 | 9 | 33 | 51 | 25 | 26 | null | null |
swamp-agr/carbuyer-advisor | Settings.hs | mit | fayFile' :: Exp -> FayFile
fayFile' staticR moduleName =
(if appReloadTemplates compileTimeAppSettings
then fayFileReload
else fayFileProd)
settings
where
settings = (yesodFaySettings moduleName)
{ yfsSeparateRuntime = Just ("static", staticR)
-- , yfsPostProcess = readProcess "java" ["-jar", "closure-compiler.jar"]
, yfsExternal = Just ("static", staticR)
, yfsPackages = ["fay-dom"]
, yfsTypecheckDevel = True
}
-- | Raw bytes at compile time of @config/settings.yml@ | 551 | fayFile' :: Exp -> FayFile
fayFile' staticR moduleName =
(if appReloadTemplates compileTimeAppSettings
then fayFileReload
else fayFileProd)
settings
where
settings = (yesodFaySettings moduleName)
{ yfsSeparateRuntime = Just ("static", staticR)
-- , yfsPostProcess = readProcess "java" ["-jar", "closure-compiler.jar"]
, yfsExternal = Just ("static", staticR)
, yfsPackages = ["fay-dom"]
, yfsTypecheckDevel = True
}
-- | Raw bytes at compile time of @config/settings.yml@ | 551 | fayFile' staticR moduleName =
(if appReloadTemplates compileTimeAppSettings
then fayFileReload
else fayFileProd)
settings
where
settings = (yesodFaySettings moduleName)
{ yfsSeparateRuntime = Just ("static", staticR)
-- , yfsPostProcess = readProcess "java" ["-jar", "closure-compiler.jar"]
, yfsExternal = Just ("static", staticR)
, yfsPackages = ["fay-dom"]
, yfsTypecheckDevel = True
}
-- | Raw bytes at compile time of @config/settings.yml@ | 524 | false | true | 0 | 8 | 139 | 100 | 57 | 43 | null | null |
jozefg/cooked-pi | src/LambdaPi/Easy.hs | mit | inf env (Pi l r) = VPi (cnf env l) (\v -> cnf (v : env) r) | 58 | inf env (Pi l r) = VPi (cnf env l) (\v -> cnf (v : env) r) | 58 | inf env (Pi l r) = VPi (cnf env l) (\v -> cnf (v : env) r) | 58 | false | false | 0 | 10 | 16 | 52 | 26 | 26 | null | null |
haskell-distributed/distributed-process-fsm | src/Control/Distributed/Process/FSM.hs | bsd-3-clause | -- | A /safe/ version of 'await'. The FSM will place a @check $ safe@ filter
-- around all messages matching the input type @m@ of the "Event" argument.
-- Should an exit signal interrupt the current pass, the input event will be
-- re-tried if an exit handler can be found for the exit-reason.
--
-- In all other respects, this API behaves exactly like 'await'
safeWait :: forall s d m . (Serializable m) => Event m -> Step s d -> Step s d
safeWait = SafeWait | 460 | safeWait :: forall s d m . (Serializable m) => Event m -> Step s d -> Step s d
safeWait = SafeWait | 98 | safeWait = SafeWait | 19 | true | true | 0 | 9 | 89 | 54 | 31 | 23 | null | null |
robdockins/edison | edison-core/src/Data/Edison/Seq/RevSeq.hs | mit | empty = N (-1) S.empty | 22 | empty = N (-1) S.empty | 22 | empty = N (-1) S.empty | 22 | false | false | 0 | 7 | 4 | 18 | 9 | 9 | null | null |
rahulmutt/ghcvm | compiler/Eta/Prelude/THNames.hs | bsd-3-clause | pragSpecInlDName = libFun (fsLit "pragSpecInlD") pragSpecInlDIdKey | 98 | pragSpecInlDName = libFun (fsLit "pragSpecInlD") pragSpecInlDIdKey | 98 | pragSpecInlDName = libFun (fsLit "pragSpecInlD") pragSpecInlDIdKey | 98 | false | false | 0 | 7 | 37 | 17 | 8 | 9 | null | null |
charles-cooper/modern-fp-architecture | src/Main.hs | cc0-1.0 | -- TODO this would probably be cleaner with FreeT
test :: IORef (Map Path Bytes) -> CloudFiles a -> IO (CloudResult a)
test filesystem program = case runFree program of
Pure last -> return $ CloudSuccess last
Free (SaveFile p b next) -> do
failure <- oneIn 4
if failure
then return PersistError
else do
modifyIORef filesystem (Map.insert p b)
test filesystem (next)
Free (ListFiles next) -> do
-- randomly fail one in four times
failure <- oneIn 4
if failure
then return AccessError
else do
files <- Map.keys <$> readIORef filesystem
test filesystem (next files)
Free (GetFile p next) -> do
mcontents <- Map.lookup p <$> readIORef filesystem
case mcontents of
Nothing -> return NotFound
Just contents -> test filesystem (next contents) | 845 | test :: IORef (Map Path Bytes) -> CloudFiles a -> IO (CloudResult a)
test filesystem program = case runFree program of
Pure last -> return $ CloudSuccess last
Free (SaveFile p b next) -> do
failure <- oneIn 4
if failure
then return PersistError
else do
modifyIORef filesystem (Map.insert p b)
test filesystem (next)
Free (ListFiles next) -> do
-- randomly fail one in four times
failure <- oneIn 4
if failure
then return AccessError
else do
files <- Map.keys <$> readIORef filesystem
test filesystem (next files)
Free (GetFile p next) -> do
mcontents <- Map.lookup p <$> readIORef filesystem
case mcontents of
Nothing -> return NotFound
Just contents -> test filesystem (next contents) | 795 | test filesystem program = case runFree program of
Pure last -> return $ CloudSuccess last
Free (SaveFile p b next) -> do
failure <- oneIn 4
if failure
then return PersistError
else do
modifyIORef filesystem (Map.insert p b)
test filesystem (next)
Free (ListFiles next) -> do
-- randomly fail one in four times
failure <- oneIn 4
if failure
then return AccessError
else do
files <- Map.keys <$> readIORef filesystem
test filesystem (next files)
Free (GetFile p next) -> do
mcontents <- Map.lookup p <$> readIORef filesystem
case mcontents of
Nothing -> return NotFound
Just contents -> test filesystem (next contents) | 726 | true | true | 4 | 13 | 232 | 288 | 130 | 158 | null | null |
patrickherrmann/sudoku | src/Sudoku.hs | mit | solutions :: Board -> [Board]
solutions = findSolutions . setGivens | 67 | solutions :: Board -> [Board]
solutions = findSolutions . setGivens | 67 | solutions = findSolutions . setGivens | 37 | false | true | 1 | 8 | 9 | 30 | 13 | 17 | null | null |
MedeaMelana/custard | With.hs | bsd-3-clause | -- | 'withBy' specialized for 'State'.
with :: Monad m => Accessor a b -> State b () -> StateT a m ()
with field action = field %: execState action | 147 | with :: Monad m => Accessor a b -> State b () -> StateT a m ()
with field action = field %: execState action | 108 | with field action = field %: execState action | 45 | true | true | 0 | 9 | 30 | 64 | 29 | 35 | null | null |
spinda/liquidhaskell | src/Language/Haskell/Liquid/Pipeline/ANFTransform.hs | bsd-3-clause | sortCases = sortBy (\x y -> cmpAltCon (fst3 x) (fst3 y)) | 56 | sortCases = sortBy (\x y -> cmpAltCon (fst3 x) (fst3 y)) | 56 | sortCases = sortBy (\x y -> cmpAltCon (fst3 x) (fst3 y)) | 56 | false | false | 0 | 10 | 10 | 36 | 18 | 18 | null | null |
IreneKnapp/Faction | libfaction/Distribution/Simple/Program/Hpc.hs | bsd-3-clause | union :: ConfiguredProgram
-> Verbosity
-> [FilePath] -- ^ Paths to .tix files
-> FilePath -- ^ Path to resultant .tix file
-> [ModuleName] -- ^ List of modules to exclude from union
-> IO ()
union hpc verbosity tixFiles outFile excluded =
runProgramInvocation verbosity
(unionInvocation hpc tixFiles outFile excluded) | 382 | union :: ConfiguredProgram
-> Verbosity
-> [FilePath] -- ^ Paths to .tix files
-> FilePath -- ^ Path to resultant .tix file
-> [ModuleName] -- ^ List of modules to exclude from union
-> IO ()
union hpc verbosity tixFiles outFile excluded =
runProgramInvocation verbosity
(unionInvocation hpc tixFiles outFile excluded) | 382 | union hpc verbosity tixFiles outFile excluded =
runProgramInvocation verbosity
(unionInvocation hpc tixFiles outFile excluded) | 136 | false | true | 0 | 12 | 113 | 79 | 39 | 40 | null | null |
chreekat/snowdrift | Model/Markdown.hs | agpl-3.0 | renderMarkdown :: Markdown -> Handler Html
renderMarkdown = renderMarkdownWith return | 85 | renderMarkdown :: Markdown -> Handler Html
renderMarkdown = renderMarkdownWith return | 85 | renderMarkdown = renderMarkdownWith return | 42 | false | true | 0 | 7 | 9 | 26 | 11 | 15 | null | null |
vikraman/ghc | compiler/basicTypes/VarEnv.hs | bsd-3-clause | rnOccL_maybe, rnOccR_maybe :: RnEnv2 -> Var -> Maybe Var
-- ^ Look up the renaming of an occurrence in the left or right term
rnOccL_maybe (RV2 { envL = env }) v = lookupVarEnv env v | 182 | rnOccL_maybe, rnOccR_maybe :: RnEnv2 -> Var -> Maybe Var
rnOccL_maybe (RV2 { envL = env }) v = lookupVarEnv env v | 113 | rnOccL_maybe (RV2 { envL = env }) v = lookupVarEnv env v | 56 | true | true | 0 | 9 | 35 | 47 | 25 | 22 | null | null |
fmapfmapfmap/amazonka | amazonka-iam/gen/Network/AWS/IAM/ListServerCertificates.hs | mpl-2.0 | -- | When 'IsTruncated' is 'true', this element is present and contains the
-- value to use for the 'Marker' parameter in a subsequent pagination
-- request.
lscrsMarker :: Lens' ListServerCertificatesResponse (Maybe Text)
lscrsMarker = lens _lscrsMarker (\ s a -> s{_lscrsMarker = a}) | 285 | lscrsMarker :: Lens' ListServerCertificatesResponse (Maybe Text)
lscrsMarker = lens _lscrsMarker (\ s a -> s{_lscrsMarker = a}) | 127 | lscrsMarker = lens _lscrsMarker (\ s a -> s{_lscrsMarker = a}) | 62 | true | true | 0 | 9 | 43 | 48 | 27 | 21 | null | null |
chadbrewbaker/shellcheck | ShellCheck/Analytics.hs | gpl-3.0 | prop_checkBashisms5 = verify checkBashisms "source file" | 56 | prop_checkBashisms5 = verify checkBashisms "source file" | 56 | prop_checkBashisms5 = verify checkBashisms "source file" | 56 | false | false | 0 | 5 | 5 | 11 | 5 | 6 | null | null |
twesterhout/NWI-I00032-2017-Assignments | Exercise_2/Exercise2.hs | mit | -- | Converts a generic representation of a binary tree back to an actual
-- binary tree. This function is inverse of 'fromBin'. It may fail if
-- constructors have wrong names
toBin ∷ BinG a → Maybe (Bin a)
toBin (LEFT (CONS "Leaf" UNIT)) = Just Leaf | 266 | toBin ∷ BinG a → Maybe (Bin a)
toBin (LEFT (CONS "Leaf" UNIT)) = Just Leaf | 89 | toBin (LEFT (CONS "Leaf" UNIT)) = Just Leaf | 58 | true | true | 0 | 9 | 62 | 50 | 25 | 25 | null | null |
termite2/tsl | Frontend/Grammar.hs | bsd-3-clause | portRef = choice [try $ TxLocalRef <$> ident <* dot <*> ident, try $ TxInputRef <$> ident] | 90 | portRef = choice [try $ TxLocalRef <$> ident <* dot <*> ident, try $ TxInputRef <$> ident] | 90 | portRef = choice [try $ TxLocalRef <$> ident <* dot <*> ident, try $ TxInputRef <$> ident] | 90 | false | false | 0 | 10 | 16 | 39 | 20 | 19 | null | null |
np/ling | Ling/Norm.hs | bsd-3-clause | addDec Dat{} = id | 26 | addDec Dat{} = id | 26 | addDec Dat{} = id | 26 | false | false | 0 | 6 | 12 | 13 | 6 | 7 | null | null |
fboyer/craft3e | Chapter3.hs | mit | -- Adding two integers: you can use longer names for variables than x and y!
addTwo :: Integer -> Integer -> Integer
addTwo first second = first+second | 152 | addTwo :: Integer -> Integer -> Integer
addTwo first second = first+second | 74 | addTwo first second = first+second | 34 | true | true | 0 | 6 | 27 | 29 | 15 | 14 | null | null |
input-output-hk/pos-haskell-prototype | wallet/test/unit/Test/Spec/CoinSelection.hs | mit | spec :: Spec
spec =
describe "Coin selection policies unit tests" $ do
withMaxSuccess 5 $ describe "largestFirst" $ do
prop "one payee, SenderPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
-- Minimal fee
prop "one payee, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
withMaxSuccess 5 $ describe "random" $ do
prop "one payee, SenderPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
-- minimal fee. It doesn't make sense to use it for 'ReceiverPaysFee', because
-- rounding will essentially cause the computed @epsilon@ will be 0 for each
-- output. For those cases, we use the 'linear' fee policy.
prop "one payee, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
-- linear fee
prop "one payee, ReceiverPaysFee, fee = linear" $ \pm -> forAll (
payOne pm linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = linear" $ \pm -> forAll (
payBatch pm linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
-- cardano fee. In order for this policy to succeed, we need to
-- have some non-negligible amount of coins in our initial Utxo, as
-- `estimateCardanoFee` works on "real world estimates" for things
-- like attributes, and trying to setup syntetic experiments with
-- less than 1ADA (10^6 lovelaces) is probably counter-productive
prop "one payee, SenderPaysFee, fee = cardano" $ \pm -> forAll (
payOne pm cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, SenderPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFragmentedUtxo genPayees cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "one payee, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
payOne pm cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
payBatch pm cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
withMaxSuccess 5 $ describe "Expected failures" $ do
prop "Paying a redeem address should always be rejected" $ \pm -> forAll (
payOne' pm genRedeemPayee linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentFailedWith utxo payee res [errorWas outputWasRedeem]
prop "Paying somebody not having enough money should fail" $ \pm -> forAll (
payBatch pm linearFee receiverPays (InitialLovelace 10) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas notEnoughMoney]
prop "Restricting too much the number of inputs results in an hard error for a single payee" $ \pm -> forAll (
payRestrictInputsTo pm 1 genUtxoWithAtLeast genPayee freeLunch identity (InitialLovelace 200) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas maxInputsReached]
prop "Restricting too much the number of inputs results in an hard error for multiple payees" $ \pm -> forAll (
payRestrictInputsTo pm 1 genUtxoWithAtLeast genPayees freeLunch identity (InitialLovelace 200) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas maxInputsReached]
-- Tests that the coin selection is unaffected by the size of the
-- Addresses in Cardano, as in the past there was a subtle corner case
-- where coin selection would fail for Addresses of size < 104, which is
-- the average in Cardano.
withMaxSuccess 5 $ describe "Fiddly Addresses" $ do
prop "multiple payees, SenderPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFiddlyUtxo genFiddlyPayees cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFiddlyUtxo genFiddlyPayees cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
-- Tests for the input grouping. By input grouping we mean the
-- circumstance where one user of the wallet used the same 'Address'
-- more than once (which is, technically, considered a bad practice).
-- In case of a security breach (for example if quantum computers will
-- become mainstream and able to brute force the current crypto in a
-- matter of minutes) if a single address is \"cracked\" then all the
-- associated inputs (and their funds) paying into this address would
-- be at risk. This is why we allow an 'InputGrouping' option to be
-- passed, which allows the coin selection to, if needed, pick all
-- the associated inputs paying into the address we just picked.
withMaxSuccess 5 $ describe "Input Grouping" $ do
prop "Require grouping, fee = 0, one big group depletes the Utxo completely" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch requireGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasDepleted]
prop "Require grouping, fee = cardano, one big group depletes the Utxo completely" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch requireGrouping (InitialADA 1000) (PayADA 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasDepleted]
prop "Require grouping, fee = 0, several groups allows the payment to be fullfilled" $ \pm -> forAll (
pay pm (genGroupedUtxo 10) genPayee freeLunch requireGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceeded utxo payee res
prop "Prefer grouping, fee = 0" $ \pm -> forAll (
payOne pm freeLunch preferGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceeded utxo payee res
prop "IgnoreGrouping, fee = 0 must not deplete the utxo" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch ignoreGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasNotDepleted]
describe "Estimating the maximum number of inputs" $ do
prop "estimateMaxTxInputs yields a lower bound." $ \pm ->
forAll (genMaxInputTx pm estimateMaxTxInputsExplicitBounds) $ \case
Left _err -> False
Right (lhs, rhs) -> lhs <= rhs
prop "estimateMaxTxInputs yields a relatively tight bound." $ \pm ->
forAll (genMaxInputTx pm $ \x y z -> 1 + estimateHardMaxTxInputsExplicitBounds x y z) $ \case
Left _err -> False
Right (lhs, rhs) -> lhs > rhs
withMaxSuccess 5 $ prop "estimateHardMaxTxInputs is close to estimateMaxTxInputs." $
forAll ((,) <$> genMaxTxSize
<*> (getAddrAttrSize <$> genOutAux)) $
\(maxTxSize, addrAttrSize) ->
let safeMax = estimateMaxTxInputsExplicitBounds addrAttrSize txAttrSize maxTxSize
hardMax = estimateHardMaxTxInputsExplicitBounds addrAttrSize txAttrSize maxTxSize
threshold = 5 -- percent
in (hardMax * 100) `div` safeMax <= 100 + threshold | 12,390 | spec :: Spec
spec =
describe "Coin selection policies unit tests" $ do
withMaxSuccess 5 $ describe "largestFirst" $ do
prop "one payee, SenderPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
-- Minimal fee
prop "one payee, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
withMaxSuccess 5 $ describe "random" $ do
prop "one payee, SenderPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
-- minimal fee. It doesn't make sense to use it for 'ReceiverPaysFee', because
-- rounding will essentially cause the computed @epsilon@ will be 0 for each
-- output. For those cases, we use the 'linear' fee policy.
prop "one payee, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
-- linear fee
prop "one payee, ReceiverPaysFee, fee = linear" $ \pm -> forAll (
payOne pm linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = linear" $ \pm -> forAll (
payBatch pm linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
-- cardano fee. In order for this policy to succeed, we need to
-- have some non-negligible amount of coins in our initial Utxo, as
-- `estimateCardanoFee` works on "real world estimates" for things
-- like attributes, and trying to setup syntetic experiments with
-- less than 1ADA (10^6 lovelaces) is probably counter-productive
prop "one payee, SenderPaysFee, fee = cardano" $ \pm -> forAll (
payOne pm cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, SenderPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFragmentedUtxo genPayees cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "one payee, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
payOne pm cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
payBatch pm cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
withMaxSuccess 5 $ describe "Expected failures" $ do
prop "Paying a redeem address should always be rejected" $ \pm -> forAll (
payOne' pm genRedeemPayee linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentFailedWith utxo payee res [errorWas outputWasRedeem]
prop "Paying somebody not having enough money should fail" $ \pm -> forAll (
payBatch pm linearFee receiverPays (InitialLovelace 10) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas notEnoughMoney]
prop "Restricting too much the number of inputs results in an hard error for a single payee" $ \pm -> forAll (
payRestrictInputsTo pm 1 genUtxoWithAtLeast genPayee freeLunch identity (InitialLovelace 200) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas maxInputsReached]
prop "Restricting too much the number of inputs results in an hard error for multiple payees" $ \pm -> forAll (
payRestrictInputsTo pm 1 genUtxoWithAtLeast genPayees freeLunch identity (InitialLovelace 200) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas maxInputsReached]
-- Tests that the coin selection is unaffected by the size of the
-- Addresses in Cardano, as in the past there was a subtle corner case
-- where coin selection would fail for Addresses of size < 104, which is
-- the average in Cardano.
withMaxSuccess 5 $ describe "Fiddly Addresses" $ do
prop "multiple payees, SenderPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFiddlyUtxo genFiddlyPayees cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFiddlyUtxo genFiddlyPayees cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
-- Tests for the input grouping. By input grouping we mean the
-- circumstance where one user of the wallet used the same 'Address'
-- more than once (which is, technically, considered a bad practice).
-- In case of a security breach (for example if quantum computers will
-- become mainstream and able to brute force the current crypto in a
-- matter of minutes) if a single address is \"cracked\" then all the
-- associated inputs (and their funds) paying into this address would
-- be at risk. This is why we allow an 'InputGrouping' option to be
-- passed, which allows the coin selection to, if needed, pick all
-- the associated inputs paying into the address we just picked.
withMaxSuccess 5 $ describe "Input Grouping" $ do
prop "Require grouping, fee = 0, one big group depletes the Utxo completely" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch requireGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasDepleted]
prop "Require grouping, fee = cardano, one big group depletes the Utxo completely" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch requireGrouping (InitialADA 1000) (PayADA 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasDepleted]
prop "Require grouping, fee = 0, several groups allows the payment to be fullfilled" $ \pm -> forAll (
pay pm (genGroupedUtxo 10) genPayee freeLunch requireGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceeded utxo payee res
prop "Prefer grouping, fee = 0" $ \pm -> forAll (
payOne pm freeLunch preferGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceeded utxo payee res
prop "IgnoreGrouping, fee = 0 must not deplete the utxo" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch ignoreGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasNotDepleted]
describe "Estimating the maximum number of inputs" $ do
prop "estimateMaxTxInputs yields a lower bound." $ \pm ->
forAll (genMaxInputTx pm estimateMaxTxInputsExplicitBounds) $ \case
Left _err -> False
Right (lhs, rhs) -> lhs <= rhs
prop "estimateMaxTxInputs yields a relatively tight bound." $ \pm ->
forAll (genMaxInputTx pm $ \x y z -> 1 + estimateHardMaxTxInputsExplicitBounds x y z) $ \case
Left _err -> False
Right (lhs, rhs) -> lhs > rhs
withMaxSuccess 5 $ prop "estimateHardMaxTxInputs is close to estimateMaxTxInputs." $
forAll ((,) <$> genMaxTxSize
<*> (getAddrAttrSize <$> genOutAux)) $
\(maxTxSize, addrAttrSize) ->
let safeMax = estimateMaxTxInputsExplicitBounds addrAttrSize txAttrSize maxTxSize
hardMax = estimateHardMaxTxInputsExplicitBounds addrAttrSize txAttrSize maxTxSize
threshold = 5 -- percent
in (hardMax * 100) `div` safeMax <= 100 + threshold | 12,390 | spec =
describe "Coin selection policies unit tests" $ do
withMaxSuccess 5 $ describe "largestFirst" $ do
prop "one payee, SenderPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
-- Minimal fee
prop "one payee, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee identity (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee receiverPays (InitialLovelace 1000) (PayLovelace 100) largestFirst
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
withMaxSuccess 5 $ describe "random" $ do
prop "one payee, SenderPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "one payee, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payOne pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, SenderPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
prop "multiple payees, ReceiverPaysFee, fee = 0" $ \pm -> forAll (
payBatch pm freeLunch receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) -> paymentSucceeded utxo payee res
-- minimal fee. It doesn't make sense to use it for 'ReceiverPaysFee', because
-- rounding will essentially cause the computed @epsilon@ will be 0 for each
-- output. For those cases, we use the 'linear' fee policy.
prop "one payee, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payOne pm minFee identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, SenderPaysFee, fee = 1 Lovelace" $ \pm -> forAll (
payBatch pm minFee identity (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
-- linear fee
prop "one payee, ReceiverPaysFee, fee = linear" $ \pm -> forAll (
payOne pm linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = linear" $ \pm -> forAll (
payBatch pm linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
-- cardano fee. In order for this policy to succeed, we need to
-- have some non-negligible amount of coins in our initial Utxo, as
-- `estimateCardanoFee` works on "real world estimates" for things
-- like attributes, and trying to setup syntetic experiments with
-- less than 1ADA (10^6 lovelaces) is probably counter-productive
prop "one payee, SenderPaysFee, fee = cardano" $ \pm -> forAll (
payOne pm cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, SenderPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFragmentedUtxo genPayees cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "one payee, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
payOne pm cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
payBatch pm cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
withMaxSuccess 5 $ describe "Expected failures" $ do
prop "Paying a redeem address should always be rejected" $ \pm -> forAll (
payOne' pm genRedeemPayee linearFee receiverPays (InitialLovelace 1000) (PayLovelace 100) random
) $ \(utxo, payee, res) ->
paymentFailedWith utxo payee res [errorWas outputWasRedeem]
prop "Paying somebody not having enough money should fail" $ \pm -> forAll (
payBatch pm linearFee receiverPays (InitialLovelace 10) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas notEnoughMoney]
prop "Restricting too much the number of inputs results in an hard error for a single payee" $ \pm -> forAll (
payRestrictInputsTo pm 1 genUtxoWithAtLeast genPayee freeLunch identity (InitialLovelace 200) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas maxInputsReached]
prop "Restricting too much the number of inputs results in an hard error for multiple payees" $ \pm -> forAll (
payRestrictInputsTo pm 1 genUtxoWithAtLeast genPayees freeLunch identity (InitialLovelace 200) (PayLovelace 100) random
) $ \(utxo, payee, res) -> do
paymentFailedWith utxo payee res [errorWas maxInputsReached]
-- Tests that the coin selection is unaffected by the size of the
-- Addresses in Cardano, as in the past there was a subtle corner case
-- where coin selection would fail for Addresses of size < 104, which is
-- the average in Cardano.
withMaxSuccess 5 $ describe "Fiddly Addresses" $ do
prop "multiple payees, SenderPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFiddlyUtxo genFiddlyPayees cardanoFee identity (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed SenderPaysFee]
prop "multiple payees, ReceiverPaysFee, fee = cardano" $ \pm -> forAll (
pay pm genFiddlyUtxo genFiddlyPayees cardanoFee receiverPays (InitialADA 1000) (PayADA 100) random
) $ \(utxo, payee, res) ->
paymentSucceededWith utxo payee res [feeWasPayed ReceiverPaysFee]
-- Tests for the input grouping. By input grouping we mean the
-- circumstance where one user of the wallet used the same 'Address'
-- more than once (which is, technically, considered a bad practice).
-- In case of a security breach (for example if quantum computers will
-- become mainstream and able to brute force the current crypto in a
-- matter of minutes) if a single address is \"cracked\" then all the
-- associated inputs (and their funds) paying into this address would
-- be at risk. This is why we allow an 'InputGrouping' option to be
-- passed, which allows the coin selection to, if needed, pick all
-- the associated inputs paying into the address we just picked.
withMaxSuccess 5 $ describe "Input Grouping" $ do
prop "Require grouping, fee = 0, one big group depletes the Utxo completely" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch requireGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasDepleted]
prop "Require grouping, fee = cardano, one big group depletes the Utxo completely" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch requireGrouping (InitialADA 1000) (PayADA 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasDepleted]
prop "Require grouping, fee = 0, several groups allows the payment to be fullfilled" $ \pm -> forAll (
pay pm (genGroupedUtxo 10) genPayee freeLunch requireGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceeded utxo payee res
prop "Prefer grouping, fee = 0" $ \pm -> forAll (
payOne pm freeLunch preferGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceeded utxo payee res
prop "IgnoreGrouping, fee = 0 must not deplete the utxo" $ \pm -> forAll (
pay pm (genGroupedUtxo 1) genPayee freeLunch ignoreGrouping (InitialLovelace 1000) (PayLovelace 10) random
) $ \(utxo, payee, res) -> do
paymentSucceededWith utxo payee res [utxoWasNotDepleted]
describe "Estimating the maximum number of inputs" $ do
prop "estimateMaxTxInputs yields a lower bound." $ \pm ->
forAll (genMaxInputTx pm estimateMaxTxInputsExplicitBounds) $ \case
Left _err -> False
Right (lhs, rhs) -> lhs <= rhs
prop "estimateMaxTxInputs yields a relatively tight bound." $ \pm ->
forAll (genMaxInputTx pm $ \x y z -> 1 + estimateHardMaxTxInputsExplicitBounds x y z) $ \case
Left _err -> False
Right (lhs, rhs) -> lhs > rhs
withMaxSuccess 5 $ prop "estimateHardMaxTxInputs is close to estimateMaxTxInputs." $
forAll ((,) <$> genMaxTxSize
<*> (getAddrAttrSize <$> genOutAux)) $
\(maxTxSize, addrAttrSize) ->
let safeMax = estimateMaxTxInputsExplicitBounds addrAttrSize txAttrSize maxTxSize
hardMax = estimateHardMaxTxInputsExplicitBounds addrAttrSize txAttrSize maxTxSize
threshold = 5 -- percent
in (hardMax * 100) `div` safeMax <= 100 + threshold | 12,377 | false | true | 0 | 19 | 3,835 | 2,817 | 1,423 | 1,394 | null | null |
vicfryzel/haskell-twitter | Haq.hs | mit | -- |See http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users-search
usersSearch q creds =
getDecode (baseHN ++ "/users/search.json?q=" ++ (urlEncode q)) creds | 169 | usersSearch q creds =
getDecode (baseHN ++ "/users/search.json?q=" ++ (urlEncode q)) creds | 94 | usersSearch q creds =
getDecode (baseHN ++ "/users/search.json?q=" ++ (urlEncode q)) creds | 94 | true | false | 0 | 9 | 18 | 34 | 17 | 17 | null | null |
siddhanathan/ghc | libraries/template-haskell/Language/Haskell/TH/Syntax.hs | bsd-3-clause | -- | Is the list of instances returned by 'reifyInstances' nonempty?
isInstance :: Name -> [Type] -> Q Bool
isInstance nm tys = do { decs <- reifyInstances nm tys
; return (not (null decs)) } | 214 | isInstance :: Name -> [Type] -> Q Bool
isInstance nm tys = do { decs <- reifyInstances nm tys
; return (not (null decs)) } | 145 | isInstance nm tys = do { decs <- reifyInstances nm tys
; return (not (null decs)) } | 106 | true | true | 0 | 12 | 58 | 69 | 33 | 36 | null | null |
ekmett/prelude-extras | src/Prelude/Extras.hs | bsd-3-clause | show2 :: (Show2 f, Show a, Show b) => f a b -> String
show2 x = shows2 x "" | 80 | show2 :: (Show2 f, Show a, Show b) => f a b -> String
show2 x = shows2 x "" | 80 | show2 x = shows2 x "" | 21 | false | true | 0 | 8 | 24 | 56 | 25 | 31 | null | null |
rdnetto/H2V | H2V/GenerateDFD.hs | gpl-2.0 | bindPattern _ p = error $ "Unknown declaration: " ++ pshow p | 60 | bindPattern _ p = error $ "Unknown declaration: " ++ pshow p | 60 | bindPattern _ p = error $ "Unknown declaration: " ++ pshow p | 60 | false | false | 0 | 6 | 11 | 22 | 10 | 12 | null | null |
axch/dysvunctional-language | haskell-fol/FOL/Compiler/JavaScript/Syntax.hs | agpl-3.0 | pp' e@(JsFunctionCall _ _) = parens (pp e) | 50 | pp' e@(JsFunctionCall _ _) = parens (pp e) | 50 | pp' e@(JsFunctionCall _ _) = parens (pp e) | 50 | false | false | 1 | 8 | 15 | 33 | 14 | 19 | null | null |
jacekszymanski/wxHaskell | wxcore/src/haskell/Graphics/UI/WXCore/WxcDefs.hs | lgpl-2.1 | wxSTC_ERR_NET :: Int
wxSTC_ERR_NET = 7 | 38 | wxSTC_ERR_NET :: Int
wxSTC_ERR_NET = 7 | 38 | wxSTC_ERR_NET = 7 | 17 | false | true | 0 | 4 | 5 | 11 | 6 | 5 | null | null |
JoeyEremondi/utrecht-pv | WLP.hs | mit | {-
Use Scrap-Your-Boilerplate to recursively apply our substutitions
to our expression, bottom-up
-}
subExpForArrName :: (Data a) => [(Name, Expression)] -> Expression -> a -> a
subExpForArrName names subExp = let
subAll = everywhere (mkT $ subOneLevelArr names subExp)
fixAllForalls = everywhere (mkT $ fixForall subExp )
in (subAll . fixAllForalls) | 361 | subExpForArrName :: (Data a) => [(Name, Expression)] -> Expression -> a -> a
subExpForArrName names subExp = let
subAll = everywhere (mkT $ subOneLevelArr names subExp)
fixAllForalls = everywhere (mkT $ fixForall subExp )
in (subAll . fixAllForalls) | 260 | subExpForArrName names subExp = let
subAll = everywhere (mkT $ subOneLevelArr names subExp)
fixAllForalls = everywhere (mkT $ fixForall subExp )
in (subAll . fixAllForalls) | 183 | true | true | 0 | 12 | 61 | 103 | 52 | 51 | null | null |
cies/gelatin | gelatin-example/src/Main.hs | bsd-3-clause | isKeyQ _ = False | 16 | isKeyQ _ = False | 16 | isKeyQ _ = False | 16 | false | false | 0 | 5 | 3 | 9 | 4 | 5 | null | null |
sgillespie/ghc | compiler/typecheck/TcGenDeriv.hs | bsd-3-clause | eqResult OrdLE = true_Expr | 31 | eqResult OrdLE = true_Expr | 31 | eqResult OrdLE = true_Expr | 31 | false | false | 0 | 5 | 8 | 9 | 4 | 5 | null | null |
snoyberg/ghc | compiler/typecheck/TcBinds.hs | bsd-3-clause | tc_group top_lvl sig_fn prag_fn (Recursive, binds) closed thing_inside
= -- To maximise polymorphism, we do a new
-- strongly-connected-component analysis, this time omitting
-- any references to variables with type signatures.
-- (This used to be optional, but isn't now.)
-- See Note [Polymorphic recursion] in HsBinds.
do { traceTc "tc_group rec" (pprLHsBinds binds)
; when hasPatSyn $ recursivePatSynErr binds
; (binds1, thing) <- go sccs
; return ([(Recursive, binds1)], thing) }
-- Rec them all together
where
hasPatSyn = anyBag (isPatSyn . unLoc) binds
isPatSyn PatSynBind{} = True
isPatSyn _ = False
sccs :: [SCC (LHsBind Name)]
sccs = stronglyConnCompFromEdgedVerticesUniq (mkEdges sig_fn binds)
go :: [SCC (LHsBind Name)] -> TcM (LHsBinds TcId, thing)
go (scc:sccs) = do { (binds1, ids1) <- tc_scc scc
; (binds2, thing) <- tcExtendLetEnv top_lvl closed ids1
(go sccs)
; return (binds1 `unionBags` binds2, thing) }
go [] = do { thing <- thing_inside; return (emptyBag, thing) }
tc_scc (AcyclicSCC bind) = tc_sub_group NonRecursive [bind]
tc_scc (CyclicSCC binds) = tc_sub_group Recursive binds
tc_sub_group rec_tc binds =
tcPolyBinds top_lvl sig_fn prag_fn Recursive rec_tc closed binds | 1,455 | tc_group top_lvl sig_fn prag_fn (Recursive, binds) closed thing_inside
= -- To maximise polymorphism, we do a new
-- strongly-connected-component analysis, this time omitting
-- any references to variables with type signatures.
-- (This used to be optional, but isn't now.)
-- See Note [Polymorphic recursion] in HsBinds.
do { traceTc "tc_group rec" (pprLHsBinds binds)
; when hasPatSyn $ recursivePatSynErr binds
; (binds1, thing) <- go sccs
; return ([(Recursive, binds1)], thing) }
-- Rec them all together
where
hasPatSyn = anyBag (isPatSyn . unLoc) binds
isPatSyn PatSynBind{} = True
isPatSyn _ = False
sccs :: [SCC (LHsBind Name)]
sccs = stronglyConnCompFromEdgedVerticesUniq (mkEdges sig_fn binds)
go :: [SCC (LHsBind Name)] -> TcM (LHsBinds TcId, thing)
go (scc:sccs) = do { (binds1, ids1) <- tc_scc scc
; (binds2, thing) <- tcExtendLetEnv top_lvl closed ids1
(go sccs)
; return (binds1 `unionBags` binds2, thing) }
go [] = do { thing <- thing_inside; return (emptyBag, thing) }
tc_scc (AcyclicSCC bind) = tc_sub_group NonRecursive [bind]
tc_scc (CyclicSCC binds) = tc_sub_group Recursive binds
tc_sub_group rec_tc binds =
tcPolyBinds top_lvl sig_fn prag_fn Recursive rec_tc closed binds | 1,455 | tc_group top_lvl sig_fn prag_fn (Recursive, binds) closed thing_inside
= -- To maximise polymorphism, we do a new
-- strongly-connected-component analysis, this time omitting
-- any references to variables with type signatures.
-- (This used to be optional, but isn't now.)
-- See Note [Polymorphic recursion] in HsBinds.
do { traceTc "tc_group rec" (pprLHsBinds binds)
; when hasPatSyn $ recursivePatSynErr binds
; (binds1, thing) <- go sccs
; return ([(Recursive, binds1)], thing) }
-- Rec them all together
where
hasPatSyn = anyBag (isPatSyn . unLoc) binds
isPatSyn PatSynBind{} = True
isPatSyn _ = False
sccs :: [SCC (LHsBind Name)]
sccs = stronglyConnCompFromEdgedVerticesUniq (mkEdges sig_fn binds)
go :: [SCC (LHsBind Name)] -> TcM (LHsBinds TcId, thing)
go (scc:sccs) = do { (binds1, ids1) <- tc_scc scc
; (binds2, thing) <- tcExtendLetEnv top_lvl closed ids1
(go sccs)
; return (binds1 `unionBags` binds2, thing) }
go [] = do { thing <- thing_inside; return (emptyBag, thing) }
tc_scc (AcyclicSCC bind) = tc_sub_group NonRecursive [bind]
tc_scc (CyclicSCC binds) = tc_sub_group Recursive binds
tc_sub_group rec_tc binds =
tcPolyBinds top_lvl sig_fn prag_fn Recursive rec_tc closed binds | 1,455 | false | false | 7 | 11 | 438 | 374 | 200 | 174 | null | null |
rjwright/js-typeomatic | TypeRules.hs | apache-2.0 | unDecMakeLabel :: ASTChild -> DeclaredIdentifier
funDecMakeLabel (LabFunctionDeclaration (fid, x) args body, n, sourceFragment) = DeclaredIdentifier fid (IDLabel n)
| 165 | funDecMakeLabel :: ASTChild -> DeclaredIdentifier
funDecMakeLabel (LabFunctionDeclaration (fid, x) args body, n, sourceFragment) = DeclaredIdentifier fid (IDLabel n) | 165 | funDecMakeLabel (LabFunctionDeclaration (fid, x) args body, n, sourceFragment) = DeclaredIdentifier fid (IDLabel n) | 115 | false | true | 0 | 8 | 18 | 51 | 27 | 24 | null | null |
ribag/ganeti-experiments | src/Ganeti/Ssconf.hs | gpl-2.0 | -- | Read the list of IP addresses of the master candidates of the cluster.
getMasterCandidatesIps :: Maybe FilePath -> IO (Result [String])
getMasterCandidatesIps optPath = do
result <- readSSConfFile optPath Nothing SSMasterCandidatesIps
return $ liftM lines result
-- | Read the name of the master node. | 311 | getMasterCandidatesIps :: Maybe FilePath -> IO (Result [String])
getMasterCandidatesIps optPath = do
result <- readSSConfFile optPath Nothing SSMasterCandidatesIps
return $ liftM lines result
-- | Read the name of the master node. | 235 | getMasterCandidatesIps optPath = do
result <- readSSConfFile optPath Nothing SSMasterCandidatesIps
return $ liftM lines result
-- | Read the name of the master node. | 170 | true | true | 0 | 9 | 51 | 61 | 29 | 32 | null | null |
alexander-at-github/eta | compiler/ETA/Prelude/PrimOp.hs | bsd-3-clause | primOpInfo ReadByteArrayOp_Word64 = mkGenPrimOp (fsLit "readWord64Array#") [deltaTyVar] [mkMutableByteArrayPrimTy deltaTy, intPrimTy, mkStatePrimTy deltaTy] ((mkTupleTy UnboxedTuple [mkStatePrimTy deltaTy, word64PrimTy])) | 222 | primOpInfo ReadByteArrayOp_Word64 = mkGenPrimOp (fsLit "readWord64Array#") [deltaTyVar] [mkMutableByteArrayPrimTy deltaTy, intPrimTy, mkStatePrimTy deltaTy] ((mkTupleTy UnboxedTuple [mkStatePrimTy deltaTy, word64PrimTy])) | 222 | primOpInfo ReadByteArrayOp_Word64 = mkGenPrimOp (fsLit "readWord64Array#") [deltaTyVar] [mkMutableByteArrayPrimTy deltaTy, intPrimTy, mkStatePrimTy deltaTy] ((mkTupleTy UnboxedTuple [mkStatePrimTy deltaTy, word64PrimTy])) | 222 | false | false | 0 | 10 | 17 | 62 | 32 | 30 | null | null |
aloiscochard/bound | src/Bound/Scope/Simple.hs | bsd-3-clause | -------------------------------------------------------------------------------
-- Exotic Traversals of Bound Variables (not exported by default)
-------------------------------------------------------------------------------
-- | Perform substitution on both bound and free variables in a 'Scope'.
splat :: Monad f => (a -> f c) -> (b -> f c) -> Scope b f a -> f c
splat f unbind s = unscope s >>= \v -> case v of
B b -> unbind b
F a -> f a
| 447 | splat :: Monad f => (a -> f c) -> (b -> f c) -> Scope b f a -> f c
splat f unbind s = unscope s >>= \v -> case v of
B b -> unbind b
F a -> f a
| 147 | splat f unbind s = unscope s >>= \v -> case v of
B b -> unbind b
F a -> f a
| 80 | true | true | 0 | 11 | 75 | 115 | 55 | 60 | null | null |
keera-studios/hsQt | Qtc/Gui/QHeaderView.hs | bsd-2-clause | defaultAlignment :: QHeaderView a -> (()) -> IO (Alignment)
defaultAlignment x0 ()
= withQFlagsResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QHeaderView_defaultAlignment cobj_x0 | 185 | defaultAlignment :: QHeaderView a -> (()) -> IO (Alignment)
defaultAlignment x0 ()
= withQFlagsResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QHeaderView_defaultAlignment cobj_x0 | 185 | defaultAlignment x0 ()
= withQFlagsResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QHeaderView_defaultAlignment cobj_x0 | 125 | false | true | 0 | 8 | 31 | 59 | 29 | 30 | null | null |
GaloisInc/cryfsm | Cryptol/FSM.hs | bsd-3-clause | toSimpleType :: TC.Schema -> ModuleM SimpleType
toSimpleType schema = do
env <- getEvalEnv
case schema of
TC.Forall [] _ ty -> case evalType env ty of
(E.isTFun -> Just (E.isTSeq -> Just (E.numTValue -> Nat n, E.isTBit -> True), out)) -> do
let simpleTy = SimpleType n out
prettyTy = pretty (fromSimpleType simpleTy)
schema <- tvalueToSchema out
case schema of
Right (P.Forall [] [] pty _) -> simpleTy <$ ensureCmp pty
Left parseError -> fail ("Bug: couldn't parse " ++ prettyTy ++ " as a schema")
Right s -> fail ("Bug: monomorphic type " ++ prettyTy ++ " was parsed as polymorphic")
_ -> fail ("unsupported type " ++ pretty ty)
_ -> fail ("unsupported polymorphic type " ++ pretty schema) | 790 | toSimpleType :: TC.Schema -> ModuleM SimpleType
toSimpleType schema = do
env <- getEvalEnv
case schema of
TC.Forall [] _ ty -> case evalType env ty of
(E.isTFun -> Just (E.isTSeq -> Just (E.numTValue -> Nat n, E.isTBit -> True), out)) -> do
let simpleTy = SimpleType n out
prettyTy = pretty (fromSimpleType simpleTy)
schema <- tvalueToSchema out
case schema of
Right (P.Forall [] [] pty _) -> simpleTy <$ ensureCmp pty
Left parseError -> fail ("Bug: couldn't parse " ++ prettyTy ++ " as a schema")
Right s -> fail ("Bug: monomorphic type " ++ prettyTy ++ " was parsed as polymorphic")
_ -> fail ("unsupported type " ++ pretty ty)
_ -> fail ("unsupported polymorphic type " ++ pretty schema) | 790 | toSimpleType schema = do
env <- getEvalEnv
case schema of
TC.Forall [] _ ty -> case evalType env ty of
(E.isTFun -> Just (E.isTSeq -> Just (E.numTValue -> Nat n, E.isTBit -> True), out)) -> do
let simpleTy = SimpleType n out
prettyTy = pretty (fromSimpleType simpleTy)
schema <- tvalueToSchema out
case schema of
Right (P.Forall [] [] pty _) -> simpleTy <$ ensureCmp pty
Left parseError -> fail ("Bug: couldn't parse " ++ prettyTy ++ " as a schema")
Right s -> fail ("Bug: monomorphic type " ++ prettyTy ++ " was parsed as polymorphic")
_ -> fail ("unsupported type " ++ pretty ty)
_ -> fail ("unsupported polymorphic type " ++ pretty schema) | 742 | false | true | 0 | 21 | 220 | 280 | 133 | 147 | null | null |
bergmark/hlint | data/Default.hs | bsd-3-clause | error = findIndex ((==) a) ==> elemIndex a | 42 | error = findIndex ((==) a) ==> elemIndex a | 42 | error = findIndex ((==) a) ==> elemIndex a | 42 | false | false | 0 | 8 | 7 | 24 | 12 | 12 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.