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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
da-x/lamdu
|
Lamdu/Expr/IRef/Infer.hs
|
gpl-3.0
|
loadInferScope ::
Monad m => Infer.Scope -> Val a -> M m (Val (Infer.Payload, a))
loadInferScope scope val =
InferLoad.loadInfer loader scope val & lift >>= liftInfer
| 174
|
loadInferScope ::
Monad m => Infer.Scope -> Val a -> M m (Val (Infer.Payload, a))
loadInferScope scope val =
InferLoad.loadInfer loader scope val & lift >>= liftInfer
| 174
|
loadInferScope scope val =
InferLoad.loadInfer loader scope val & lift >>= liftInfer
| 88
| false
| true
| 0
| 12
| 34
| 72
| 35
| 37
| null | null |
alphaHeavy/cabal
|
cabal-install/Distribution/Client/Tar.hs
|
bsd-3-clause
|
putEntry :: Entry -> ByteString
putEntry entry = case entryContent entry of
NormalFile content size -> BS.concat [ header, content, padding size ]
OtherEntryType _ content size -> BS.concat [ header, content, padding size ]
_ -> header
where
header = putHeader entry
padding size = BS.replicate paddingSize 0
where paddingSize = fromIntegral (negate size `mod` 512)
| 427
|
putEntry :: Entry -> ByteString
putEntry entry = case entryContent entry of
NormalFile content size -> BS.concat [ header, content, padding size ]
OtherEntryType _ content size -> BS.concat [ header, content, padding size ]
_ -> header
where
header = putHeader entry
padding size = BS.replicate paddingSize 0
where paddingSize = fromIntegral (negate size `mod` 512)
| 427
|
putEntry entry = case entryContent entry of
NormalFile content size -> BS.concat [ header, content, padding size ]
OtherEntryType _ content size -> BS.concat [ header, content, padding size ]
_ -> header
where
header = putHeader entry
padding size = BS.replicate paddingSize 0
where paddingSize = fromIntegral (negate size `mod` 512)
| 395
| false
| true
| 3
| 10
| 118
| 154
| 69
| 85
| null | null |
rjohnsondev/haskellshop
|
src/Frontend/Frontend.hs
|
bsd-2-clause
|
handlePaymentPost :: AppHandler ()
handlePaymentPost = do
-- do some form validation and add values to the session
let fields = ["shipping_full_name", "billing_full_name",
"shipping_address_1", "billing_address_1",
"shipping_address_2", "billing_address_2",
"shipping_city", "billing_city", "shipping_state",
"billing_state", "shipping_postcode",
"billing_postcode", "shipping_country",
"billing_country", "email", "phone"] :: [BS.ByteString]
mapM_ setSessionFromForm fields
let req_fields = ["billing_full_name", "billing_address_1",
"billing_city", "billing_country",
"shipping_full_name", "shipping_address_1",
"shipping_city", "shipping_country", "email",
"phone"]
isValid <- validateFields req_fields
if isValid == False
then do
dangerRedirect "/payment" "Please complete all required fields"
else do
now <- liftIO $ DTC.getCurrentTime
email <- getFormByteString "email" ""
phone <- getFormByteString "phone" ""
bvms <- basketViewModels
let total = foldr (\(_, _, t, _, _, _) out -> t + out) 0 bvms
let o = O.Order 0 now total (DTE.decodeUtf8 email) (DTE.decodeUtf8 phone) Nothing
let ois = map (\(_, p, lt, q, pvost, _) -> OI.OrderItem 0 0 (P.productId p) pvost lt q) bvms
billing <- billingAddress
shipping <- shippingAddress
oid <- with db $ O.placeOrder o ois [billing, shipping]
with sess $ mapM_ deleteFromSession (map DTE.decodeUtf8 fields)
with sess $ deleteFromSession "basket"
with sess commitSession
redirect $ C8.concat ["/order_confirmation?order_id=", C8.pack $ show oid]
| 1,907
|
handlePaymentPost :: AppHandler ()
handlePaymentPost = do
-- do some form validation and add values to the session
let fields = ["shipping_full_name", "billing_full_name",
"shipping_address_1", "billing_address_1",
"shipping_address_2", "billing_address_2",
"shipping_city", "billing_city", "shipping_state",
"billing_state", "shipping_postcode",
"billing_postcode", "shipping_country",
"billing_country", "email", "phone"] :: [BS.ByteString]
mapM_ setSessionFromForm fields
let req_fields = ["billing_full_name", "billing_address_1",
"billing_city", "billing_country",
"shipping_full_name", "shipping_address_1",
"shipping_city", "shipping_country", "email",
"phone"]
isValid <- validateFields req_fields
if isValid == False
then do
dangerRedirect "/payment" "Please complete all required fields"
else do
now <- liftIO $ DTC.getCurrentTime
email <- getFormByteString "email" ""
phone <- getFormByteString "phone" ""
bvms <- basketViewModels
let total = foldr (\(_, _, t, _, _, _) out -> t + out) 0 bvms
let o = O.Order 0 now total (DTE.decodeUtf8 email) (DTE.decodeUtf8 phone) Nothing
let ois = map (\(_, p, lt, q, pvost, _) -> OI.OrderItem 0 0 (P.productId p) pvost lt q) bvms
billing <- billingAddress
shipping <- shippingAddress
oid <- with db $ O.placeOrder o ois [billing, shipping]
with sess $ mapM_ deleteFromSession (map DTE.decodeUtf8 fields)
with sess $ deleteFromSession "basket"
with sess commitSession
redirect $ C8.concat ["/order_confirmation?order_id=", C8.pack $ show oid]
| 1,907
|
handlePaymentPost = do
-- do some form validation and add values to the session
let fields = ["shipping_full_name", "billing_full_name",
"shipping_address_1", "billing_address_1",
"shipping_address_2", "billing_address_2",
"shipping_city", "billing_city", "shipping_state",
"billing_state", "shipping_postcode",
"billing_postcode", "shipping_country",
"billing_country", "email", "phone"] :: [BS.ByteString]
mapM_ setSessionFromForm fields
let req_fields = ["billing_full_name", "billing_address_1",
"billing_city", "billing_country",
"shipping_full_name", "shipping_address_1",
"shipping_city", "shipping_country", "email",
"phone"]
isValid <- validateFields req_fields
if isValid == False
then do
dangerRedirect "/payment" "Please complete all required fields"
else do
now <- liftIO $ DTC.getCurrentTime
email <- getFormByteString "email" ""
phone <- getFormByteString "phone" ""
bvms <- basketViewModels
let total = foldr (\(_, _, t, _, _, _) out -> t + out) 0 bvms
let o = O.Order 0 now total (DTE.decodeUtf8 email) (DTE.decodeUtf8 phone) Nothing
let ois = map (\(_, p, lt, q, pvost, _) -> OI.OrderItem 0 0 (P.productId p) pvost lt q) bvms
billing <- billingAddress
shipping <- shippingAddress
oid <- with db $ O.placeOrder o ois [billing, shipping]
with sess $ mapM_ deleteFromSession (map DTE.decodeUtf8 fields)
with sess $ deleteFromSession "basket"
with sess commitSession
redirect $ C8.concat ["/order_confirmation?order_id=", C8.pack $ show oid]
| 1,872
| false
| true
| 13
| 11
| 597
| 445
| 241
| 204
| null | null |
mcmaniac/ghc
|
compiler/cmm/PprC.hs
|
bsd-3-clause
|
pprDataExterns :: Platform -> [CmmStatic] -> SDoc
pprDataExterns platform statics
= vcat (map (pprExternDecl platform False{-ToDo-}) (Map.keys lbls))
where (_, lbls) = runTE (mapM_ te_Static statics)
| 203
|
pprDataExterns :: Platform -> [CmmStatic] -> SDoc
pprDataExterns platform statics
= vcat (map (pprExternDecl platform False{-ToDo-}) (Map.keys lbls))
where (_, lbls) = runTE (mapM_ te_Static statics)
| 203
|
pprDataExterns platform statics
= vcat (map (pprExternDecl platform False{-ToDo-}) (Map.keys lbls))
where (_, lbls) = runTE (mapM_ te_Static statics)
| 153
| false
| true
| 0
| 10
| 29
| 80
| 41
| 39
| null | null |
armoredsoftware/protocol
|
tpm/mainline/src/TPM/Utils.hs
|
bsd-3-clause
|
tohex 5 = '5'
| 14
|
tohex 5 = '5'
| 14
|
tohex 5 = '5'
| 14
| false
| false
| 0
| 4
| 4
| 10
| 4
| 6
| null | null |
Shakadak/tinker
|
split.hs
|
mit
|
split :: Eq a => a -> [a] -> [[a]]
split sep xs = case dropWhile (==sep) xs of
[] -> []
xs' -> x : split sep xs''
where (x, xs'') = break (==sep) xs'
| 205
|
split :: Eq a => a -> [a] -> [[a]]
split sep xs = case dropWhile (==sep) xs of
[] -> []
xs' -> x : split sep xs''
where (x, xs'') = break (==sep) xs'
| 205
|
split sep xs = case dropWhile (==sep) xs of
[] -> []
xs' -> x : split sep xs''
where (x, xs'') = break (==sep) xs'
| 170
| false
| true
| 0
| 11
| 91
| 101
| 53
| 48
| null | null |
ducis/haAni
|
hs/common/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs
|
gpl-2.0
|
--------------------------------------------------------------------------------
pokeFoldable :: (Foldable t, Storable a) => Ptr (t a) -> t a -> IO ()
pokeFoldable ptr xs = foldlM pokeAndAdvance (castPtr ptr) xs >> return ()
| 225
|
pokeFoldable :: (Foldable t, Storable a) => Ptr (t a) -> t a -> IO ()
pokeFoldable ptr xs = foldlM pokeAndAdvance (castPtr ptr) xs >> return ()
| 143
|
pokeFoldable ptr xs = foldlM pokeAndAdvance (castPtr ptr) xs >> return ()
| 73
| true
| true
| 0
| 10
| 29
| 84
| 39
| 45
| null | null |
prl-tokyo/MAPE-knowledge-base
|
Haskell/bx/ExecutionBX.hs
|
mit
|
sInstListUpd :: BiGUL S.Model [S.Instance]
sInstListUpd = $(update [p| S.Model {
S.instances = instances
}|]
[p| instances |]
[d| instances = Replace |])
| 257
|
sInstListUpd :: BiGUL S.Model [S.Instance]
sInstListUpd = $(update [p| S.Model {
S.instances = instances
}|]
[p| instances |]
[d| instances = Replace |])
| 257
|
sInstListUpd = $(update [p| S.Model {
S.instances = instances
}|]
[p| instances |]
[d| instances = Replace |])
| 214
| false
| true
| 1
| 8
| 126
| 51
| 29
| 22
| null | null |
gridaphobe/ghc
|
compiler/simplCore/SetLevels.hs
|
bsd-3-clause
|
-- isFunction (_, AnnTick _ e) = isFunction e -- dubious
isFunction _ = False
| 113
|
isFunction _ = False
| 46
|
isFunction _ = False
| 46
| true
| false
| 0
| 4
| 50
| 11
| 5
| 6
| null | null |
frontrowed/stratosphere
|
library-gen/Stratosphere/Resources/GlueJob.hs
|
mit
|
-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-job.html#cfn-glue-job-role
gjRole :: Lens' GlueJob (Val Text)
gjRole = lens _glueJobRole (\s a -> s { _glueJobRole = a })
| 206
|
gjRole :: Lens' GlueJob (Val Text)
gjRole = lens _glueJobRole (\s a -> s { _glueJobRole = a })
| 94
|
gjRole = lens _glueJobRole (\s a -> s { _glueJobRole = a })
| 59
| true
| true
| 0
| 9
| 21
| 46
| 25
| 21
| null | null |
brendanhay/gogol
|
gogol-gmail/gen/Network/Google/Resource/Gmail/Users/Stop.hs
|
mpl-2.0
|
-- | V1 error format.
usXgafv :: Lens' UsersStop (Maybe Xgafv)
usXgafv = lens _usXgafv (\ s a -> s{_usXgafv = a})
| 113
|
usXgafv :: Lens' UsersStop (Maybe Xgafv)
usXgafv = lens _usXgafv (\ s a -> s{_usXgafv = a})
| 91
|
usXgafv = lens _usXgafv (\ s a -> s{_usXgafv = a})
| 50
| true
| true
| 1
| 9
| 21
| 49
| 25
| 24
| null | null |
patperry/hs-linear-algebra
|
lib/Data/Matrix/Class/MSolveBase.hs
|
bsd-3-clause
|
unsafeGetSSolveVector :: (MSolve a m, ReadVector y m, WriteVector x m, BLAS2 e) =>
e -> a e -> y e -> m (x e)
unsafeGetSSolveVector alpha a y = do
x <- newVector_ (numCols a)
unsafeDoSSolveVector alpha a y x
return x
| 235
|
unsafeGetSSolveVector :: (MSolve a m, ReadVector y m, WriteVector x m, BLAS2 e) =>
e -> a e -> y e -> m (x e)
unsafeGetSSolveVector alpha a y = do
x <- newVector_ (numCols a)
unsafeDoSSolveVector alpha a y x
return x
| 235
|
unsafeGetSSolveVector alpha a y = do
x <- newVector_ (numCols a)
unsafeDoSSolveVector alpha a y x
return x
| 120
| false
| true
| 0
| 12
| 61
| 116
| 53
| 63
| null | null |
keithodulaigh/Hets
|
CSMOF/Parser.hs
|
gpl-2.0
|
createLink :: Metamodel -> Model -> Map.Map String String -> Element -> Link
createLink metamodel mode keyMap eleme =
let typ = parseStringAttribute eleme linkTypeK
sour = parseStringAttribute eleme linkSourceK
targ = parseStringAttribute eleme linkTargetK
sourObj = linkObject keyMap metamodel sour
tarObj = linkObject keyMap metamodel targ
souObjTyp = objectType sourObj
tarObjTyp = objectType tarObj
in Link { linkType = linkProperty keyMap metamodel typ souObjTyp tarObjTyp
, source = sourObj
, target = tarObj
, linkOwner = mode
}
| 615
|
createLink :: Metamodel -> Model -> Map.Map String String -> Element -> Link
createLink metamodel mode keyMap eleme =
let typ = parseStringAttribute eleme linkTypeK
sour = parseStringAttribute eleme linkSourceK
targ = parseStringAttribute eleme linkTargetK
sourObj = linkObject keyMap metamodel sour
tarObj = linkObject keyMap metamodel targ
souObjTyp = objectType sourObj
tarObjTyp = objectType tarObj
in Link { linkType = linkProperty keyMap metamodel typ souObjTyp tarObjTyp
, source = sourObj
, target = tarObj
, linkOwner = mode
}
| 615
|
createLink metamodel mode keyMap eleme =
let typ = parseStringAttribute eleme linkTypeK
sour = parseStringAttribute eleme linkSourceK
targ = parseStringAttribute eleme linkTargetK
sourObj = linkObject keyMap metamodel sour
tarObj = linkObject keyMap metamodel targ
souObjTyp = objectType sourObj
tarObjTyp = objectType tarObj
in Link { linkType = linkProperty keyMap metamodel typ souObjTyp tarObjTyp
, source = sourObj
, target = tarObj
, linkOwner = mode
}
| 538
| false
| true
| 0
| 9
| 158
| 156
| 80
| 76
| null | null |
jeffreyrosenbluth/Othello
|
src/BitBoard.hs
|
bsd-3-clause
|
legalMoves :: Board -> Board -> Board
legalMoves p o = foldr1 (.|.) ms
where
dfuns = [shiftN, shiftNE, shiftE, shiftSE, shiftS, shiftSW, shiftW, shiftNW]
ms = map (legalMovesDir p o) dfuns
-- | Transformations to bring the principal diagnals and the first column
-- to the first row and back.
-- 'col0row0 . row0col0 == A1..A8 = row0col0 . col0row0'
-- A1..A8 to H1..A1
| 389
|
legalMoves :: Board -> Board -> Board
legalMoves p o = foldr1 (.|.) ms
where
dfuns = [shiftN, shiftNE, shiftE, shiftSE, shiftS, shiftSW, shiftW, shiftNW]
ms = map (legalMovesDir p o) dfuns
-- | Transformations to bring the principal diagnals and the first column
-- to the first row and back.
-- 'col0row0 . row0col0 == A1..A8 = row0col0 . col0row0'
-- A1..A8 to H1..A1
| 389
|
legalMoves p o = foldr1 (.|.) ms
where
dfuns = [shiftN, shiftNE, shiftE, shiftSE, shiftS, shiftSW, shiftW, shiftNW]
ms = map (legalMovesDir p o) dfuns
-- | Transformations to bring the principal diagnals and the first column
-- to the first row and back.
-- 'col0row0 . row0col0 == A1..A8 = row0col0 . col0row0'
-- A1..A8 to H1..A1
| 351
| false
| true
| 2
| 8
| 84
| 98
| 50
| 48
| null | null |
ulricha/dsh-sql
|
src/Database/DSH/Backend/Sql/HDBC.hs
|
bsd-3-clause
|
hdbcBool (H.SqlWord32 !i) = i /= 0
| 38
|
hdbcBool (H.SqlWord32 !i) = i /= 0
| 38
|
hdbcBool (H.SqlWord32 !i) = i /= 0
| 38
| false
| false
| 0
| 8
| 10
| 22
| 10
| 12
| null | null |
willprice/dotfiles-xmonad
|
lib/SessionType.hs
|
mit
|
getSessionType :: IO SessionType
getSessionType = getEnv "DESKTOP_SESSION" >>= return . sessionIdentifierToDesktopType
| 119
|
getSessionType :: IO SessionType
getSessionType = getEnv "DESKTOP_SESSION" >>= return . sessionIdentifierToDesktopType
| 119
|
getSessionType = getEnv "DESKTOP_SESSION" >>= return . sessionIdentifierToDesktopType
| 85
| false
| true
| 0
| 7
| 12
| 25
| 12
| 13
| null | null |
tel/oauthenticated
|
src/Network/OAuth/Signing.hs
|
mit
|
oauthParams :: Oa ty -> Server -> H.Query
oauthParams (Oa {..}) (Server {..}) =
let
OaPin {..} = pin
infix 8 -:
s -: v = (s, H.toQueryValue v)
-- **NOTE** dfithian: It worked for my use case to move oauth_token into these params. From the
-- PR:
--
-- I presume one very controversial thing I did was to move `oauth_token` into `workflowParams`.
-- I came to this conclusion by skimming through the [RFC](https://tools.ietf.org/html/rfc5849)
-- and deciding that since I only ever saw `oauth_token` in conjunction with either
-- `oauth_callback` or `oauth_verifier` that they should go together. I'd be perfectly happy to
-- instead pass in some function of the settings telling it whether or not to include
-- `oauth_token` for a given request. Whatever the conclusion, the service I'm integrating to
-- specifically does NOT want the `oauth_token` so that was the motivation.
workflowParams Standard = []
workflowParams (TemporaryTokenRequest callback) =
[ "oauth_callback" -: callback
, "oauth_token" -: (getResourceTokenDef credentials ^. key) ]
workflowParams (PermanentTokenRequest verifier) =
[ "oauth_verifier" -: verifier
, "oauth_token" -: (getResourceTokenDef credentials ^. key) ]
in
[ "oauth_version" -: oAuthVersion
, "oauth_consumer_key" -: (credentials ^. clientToken . key)
, "oauth_signature_method" -: signatureMethod
, "oauth_timestamp" -: timestamp
, "oauth_nonce" -: nonce
] ++ workflowParams workflow
| 1,575
|
oauthParams :: Oa ty -> Server -> H.Query
oauthParams (Oa {..}) (Server {..}) =
let
OaPin {..} = pin
infix 8 -:
s -: v = (s, H.toQueryValue v)
-- **NOTE** dfithian: It worked for my use case to move oauth_token into these params. From the
-- PR:
--
-- I presume one very controversial thing I did was to move `oauth_token` into `workflowParams`.
-- I came to this conclusion by skimming through the [RFC](https://tools.ietf.org/html/rfc5849)
-- and deciding that since I only ever saw `oauth_token` in conjunction with either
-- `oauth_callback` or `oauth_verifier` that they should go together. I'd be perfectly happy to
-- instead pass in some function of the settings telling it whether or not to include
-- `oauth_token` for a given request. Whatever the conclusion, the service I'm integrating to
-- specifically does NOT want the `oauth_token` so that was the motivation.
workflowParams Standard = []
workflowParams (TemporaryTokenRequest callback) =
[ "oauth_callback" -: callback
, "oauth_token" -: (getResourceTokenDef credentials ^. key) ]
workflowParams (PermanentTokenRequest verifier) =
[ "oauth_verifier" -: verifier
, "oauth_token" -: (getResourceTokenDef credentials ^. key) ]
in
[ "oauth_version" -: oAuthVersion
, "oauth_consumer_key" -: (credentials ^. clientToken . key)
, "oauth_signature_method" -: signatureMethod
, "oauth_timestamp" -: timestamp
, "oauth_nonce" -: nonce
] ++ workflowParams workflow
| 1,575
|
oauthParams (Oa {..}) (Server {..}) =
let
OaPin {..} = pin
infix 8 -:
s -: v = (s, H.toQueryValue v)
-- **NOTE** dfithian: It worked for my use case to move oauth_token into these params. From the
-- PR:
--
-- I presume one very controversial thing I did was to move `oauth_token` into `workflowParams`.
-- I came to this conclusion by skimming through the [RFC](https://tools.ietf.org/html/rfc5849)
-- and deciding that since I only ever saw `oauth_token` in conjunction with either
-- `oauth_callback` or `oauth_verifier` that they should go together. I'd be perfectly happy to
-- instead pass in some function of the settings telling it whether or not to include
-- `oauth_token` for a given request. Whatever the conclusion, the service I'm integrating to
-- specifically does NOT want the `oauth_token` so that was the motivation.
workflowParams Standard = []
workflowParams (TemporaryTokenRequest callback) =
[ "oauth_callback" -: callback
, "oauth_token" -: (getResourceTokenDef credentials ^. key) ]
workflowParams (PermanentTokenRequest verifier) =
[ "oauth_verifier" -: verifier
, "oauth_token" -: (getResourceTokenDef credentials ^. key) ]
in
[ "oauth_version" -: oAuthVersion
, "oauth_consumer_key" -: (credentials ^. clientToken . key)
, "oauth_signature_method" -: signatureMethod
, "oauth_timestamp" -: timestamp
, "oauth_nonce" -: nonce
] ++ workflowParams workflow
| 1,533
| false
| true
| 0
| 13
| 361
| 241
| 130
| 111
| null | null |
nushio3/ghc
|
libraries/base/Foreign/C/Error.hs
|
bsd-3-clause
|
eNOMEM = Errno (CONST_ENOMEM)
| 38
|
eNOMEM = Errno (CONST_ENOMEM)
| 38
|
eNOMEM = Errno (CONST_ENOMEM)
| 38
| false
| false
| 0
| 6
| 12
| 12
| 6
| 6
| null | null |
bacher09/hostandport
|
benchmarks/Benchmark.hs
|
mit
|
main :: IO ()
main = defaultMain [
bgroup "ipv4" [ bench "127.0.0.1" $ whnf isIPv4Address "127.0.0.1"
, bench "bad" $ whnf isIPv4Address "22222.2222.222.22"]
, bgroup "ipv6" [ bench "::1" $ whnf isIPv6Address "::1"
, bench "vinnica.in" $ whnf isIPv6Address "2605:2700:0:2::4713:9eef"
, bench "full" $ whnf isIPv6Address "1:2:3:4:5:6:7:8"
, bench "with-ipv4" $ whnf isIPv6Address "1:2:3:4:5:6:127.0.0.1"
, bench "bad" $ whnf isIPv6Address "2605:2700:0:2::4713:9eef"]
, bgroup "HostAndPort" [ bench "127.0.0.1" $ nf hostAndPort "127.0.0.1"
, bench "localhost:9090" $ nf hostAndPort "localhost:9090"
, bench "ipv6-and-port" $ nf hostAndPort "[2605:2700:0:2::4713:9eef]:26000"]
]
| 887
|
main :: IO ()
main = defaultMain [
bgroup "ipv4" [ bench "127.0.0.1" $ whnf isIPv4Address "127.0.0.1"
, bench "bad" $ whnf isIPv4Address "22222.2222.222.22"]
, bgroup "ipv6" [ bench "::1" $ whnf isIPv6Address "::1"
, bench "vinnica.in" $ whnf isIPv6Address "2605:2700:0:2::4713:9eef"
, bench "full" $ whnf isIPv6Address "1:2:3:4:5:6:7:8"
, bench "with-ipv4" $ whnf isIPv6Address "1:2:3:4:5:6:127.0.0.1"
, bench "bad" $ whnf isIPv6Address "2605:2700:0:2::4713:9eef"]
, bgroup "HostAndPort" [ bench "127.0.0.1" $ nf hostAndPort "127.0.0.1"
, bench "localhost:9090" $ nf hostAndPort "localhost:9090"
, bench "ipv6-and-port" $ nf hostAndPort "[2605:2700:0:2::4713:9eef]:26000"]
]
| 887
|
main = defaultMain [
bgroup "ipv4" [ bench "127.0.0.1" $ whnf isIPv4Address "127.0.0.1"
, bench "bad" $ whnf isIPv4Address "22222.2222.222.22"]
, bgroup "ipv6" [ bench "::1" $ whnf isIPv6Address "::1"
, bench "vinnica.in" $ whnf isIPv6Address "2605:2700:0:2::4713:9eef"
, bench "full" $ whnf isIPv6Address "1:2:3:4:5:6:7:8"
, bench "with-ipv4" $ whnf isIPv6Address "1:2:3:4:5:6:127.0.0.1"
, bench "bad" $ whnf isIPv6Address "2605:2700:0:2::4713:9eef"]
, bgroup "HostAndPort" [ bench "127.0.0.1" $ nf hostAndPort "127.0.0.1"
, bench "localhost:9090" $ nf hostAndPort "localhost:9090"
, bench "ipv6-and-port" $ nf hostAndPort "[2605:2700:0:2::4713:9eef]:26000"]
]
| 873
| false
| true
| 0
| 10
| 298
| 193
| 91
| 102
| null | null |
JacquesCarette/literate-scientific-software
|
code/drasil-code/Language/Drasil/Code/ExtLibImport.hs
|
bsd-2-clause
|
genStep :: Step -> StepFill -> State ExtLibState FuncStmt
genStep (Call rs fi) (CallF fif) = do
modify (addImports rs)
genFI fi fif
| 136
|
genStep :: Step -> StepFill -> State ExtLibState FuncStmt
genStep (Call rs fi) (CallF fif) = do
modify (addImports rs)
genFI fi fif
| 136
|
genStep (Call rs fi) (CallF fif) = do
modify (addImports rs)
genFI fi fif
| 78
| false
| true
| 0
| 10
| 27
| 68
| 30
| 38
| null | null |
mettekou/ghc
|
compiler/hsSyn/HsExpr.hs
|
bsd-3-clause
|
ppr_cmd (HsCmdArrApp arrow arg _ HsFirstOrderApp False)
= hsep [ppr_lexpr arg, arrowt, ppr_lexpr arrow]
| 105
|
ppr_cmd (HsCmdArrApp arrow arg _ HsFirstOrderApp False)
= hsep [ppr_lexpr arg, arrowt, ppr_lexpr arrow]
| 105
|
ppr_cmd (HsCmdArrApp arrow arg _ HsFirstOrderApp False)
= hsep [ppr_lexpr arg, arrowt, ppr_lexpr arrow]
| 105
| false
| false
| 0
| 6
| 15
| 42
| 20
| 22
| null | null |
isido/functional-morphology-for-koine-greek
|
greek/RulesGreek.hs
|
gpl-3.0
|
endingsImperfectW :: String -> (Person, Number, Voice) -> String
endingsImperfectW prStem (p, n, v) =
case v of
Active ->
case (n,p) of
(Singular,First) -> prStem ++ "ον"
(Singular,Second) -> prStem ++ "ες"
(Singular,Third) -> prStem ++ "ε"
(Plural,First) -> prStem ++ "ομεν"
(Plural,Second) -> prStem ++ "ετε"
(Plural,Third) -> prStem ++ "ον"
_ ->
case (n,p) of
(Singular,First) -> prStem ++ "ομην"
(Singular,Second) -> prStem ++ "ου"
(Singular,Third) -> prStem ++ "ετο"
(Plural,First) -> prStem ++ "ομεθα"
(Plural,Second) -> prStem ++ "εσθε"
(Plural,Third) -> prStem ++ "οντο"
-- personal endings for optative (present, future, perfect)
| 827
|
endingsImperfectW :: String -> (Person, Number, Voice) -> String
endingsImperfectW prStem (p, n, v) =
case v of
Active ->
case (n,p) of
(Singular,First) -> prStem ++ "ον"
(Singular,Second) -> prStem ++ "ες"
(Singular,Third) -> prStem ++ "ε"
(Plural,First) -> prStem ++ "ομεν"
(Plural,Second) -> prStem ++ "ετε"
(Plural,Third) -> prStem ++ "ον"
_ ->
case (n,p) of
(Singular,First) -> prStem ++ "ομην"
(Singular,Second) -> prStem ++ "ου"
(Singular,Third) -> prStem ++ "ετο"
(Plural,First) -> prStem ++ "ομεθα"
(Plural,Second) -> prStem ++ "εσθε"
(Plural,Third) -> prStem ++ "οντο"
-- personal endings for optative (present, future, perfect)
| 827
|
endingsImperfectW prStem (p, n, v) =
case v of
Active ->
case (n,p) of
(Singular,First) -> prStem ++ "ον"
(Singular,Second) -> prStem ++ "ες"
(Singular,Third) -> prStem ++ "ε"
(Plural,First) -> prStem ++ "ομεν"
(Plural,Second) -> prStem ++ "ετε"
(Plural,Third) -> prStem ++ "ον"
_ ->
case (n,p) of
(Singular,First) -> prStem ++ "ομην"
(Singular,Second) -> prStem ++ "ου"
(Singular,Third) -> prStem ++ "ετο"
(Plural,First) -> prStem ++ "ομεθα"
(Plural,Second) -> prStem ++ "εσθε"
(Plural,Third) -> prStem ++ "οντο"
-- personal endings for optative (present, future, perfect)
| 762
| false
| true
| 0
| 11
| 284
| 271
| 153
| 118
| null | null |
romanb/amazonka
|
amazonka-redshift/gen/Network/AWS/Redshift/Types.hs
|
mpl-2.0
|
-- | The status of the EC2 security group.
ecsgStatus :: Lens' EC2SecurityGroup (Maybe Text)
ecsgStatus = lens _ecsgStatus (\s a -> s { _ecsgStatus = a })
| 154
|
ecsgStatus :: Lens' EC2SecurityGroup (Maybe Text)
ecsgStatus = lens _ecsgStatus (\s a -> s { _ecsgStatus = a })
| 111
|
ecsgStatus = lens _ecsgStatus (\s a -> s { _ecsgStatus = a })
| 61
| true
| true
| 0
| 9
| 27
| 46
| 25
| 21
| null | null |
netvl/udisksevt
|
UDisksEvt/Config.hs
|
gpl-2.0
|
paces :: ConfParser Char
spaces = oneOf " \t"
| 46
|
spaces :: ConfParser Char
spaces = oneOf " \t"
| 46
|
spaces = oneOf " \t"
| 20
| false
| true
| 0
| 5
| 9
| 17
| 8
| 9
| null | null |
DavidAlphaFox/ghc
|
libraries/Cabal/cabal-install/Distribution/Client/Tar.hs
|
bsd-3-clause
|
putChar8 :: Char -> String
putChar8 c = [c]
| 43
|
putChar8 :: Char -> String
putChar8 c = [c]
| 43
|
putChar8 c = [c]
| 16
| false
| true
| 0
| 5
| 8
| 21
| 11
| 10
| null | null |
JacquesCarette/literate-scientific-software
|
code/drasil-example/Drasil/GamePhysics/Requirements.hs
|
bsd-2-clause
|
-- | without added constraint
requirementS' :: (NamedIdea a, NamedIdea b) => a -> b -> Sentence
requirementS' a b = requirementS a b EmptyS
| 139
|
requirementS' :: (NamedIdea a, NamedIdea b) => a -> b -> Sentence
requirementS' a b = requirementS a b EmptyS
| 109
|
requirementS' a b = requirementS a b EmptyS
| 43
| true
| true
| 0
| 7
| 24
| 47
| 24
| 23
| null | null |
mrkkrp/stack
|
src/Stack/Coverage.hs
|
bsd-3-clause
|
displayReportPath :: (StackM env m, HasAnsiAnn (Ann a), Display a)
=> Text -> a -> m ()
displayReportPath report reportPath =
$prettyInfo $ "The" <+> fromString (T.unpack report) <+> "is available at" <+> display reportPath
| 246
|
displayReportPath :: (StackM env m, HasAnsiAnn (Ann a), Display a)
=> Text -> a -> m ()
displayReportPath report reportPath =
$prettyInfo $ "The" <+> fromString (T.unpack report) <+> "is available at" <+> display reportPath
| 246
|
displayReportPath report reportPath =
$prettyInfo $ "The" <+> fromString (T.unpack report) <+> "is available at" <+> display reportPath
| 140
| false
| true
| 0
| 11
| 57
| 89
| 43
| 46
| null | null |
vTurbine/ghc
|
compiler/main/DynFlags.hs
|
bsd-3-clause
|
standardWarnings :: [WarningFlag]
standardWarnings -- see Note [Documenting warning flags]
= [ Opt_WarnOverlappingPatterns,
Opt_WarnWarningsDeprecations,
Opt_WarnDeprecatedFlags,
Opt_WarnDeferredTypeErrors,
Opt_WarnTypedHoles,
Opt_WarnPartialTypeSignatures,
Opt_WarnUnrecognisedPragmas,
Opt_WarnDuplicateExports,
Opt_WarnOverflowedLiterals,
Opt_WarnEmptyEnumerations,
Opt_WarnMissingFields,
Opt_WarnMissingMethods,
Opt_WarnWrongDoBind,
Opt_WarnUnsupportedCallingConventions,
Opt_WarnDodgyForeignImports,
Opt_WarnInlineRuleShadowing,
Opt_WarnAlternativeLayoutRuleTransitional,
Opt_WarnUnsupportedLlvmVersion,
Opt_WarnTabs,
Opt_WarnUnrecognisedWarningFlags,
Opt_WarnSimplifiableClassConstraints
]
| 864
|
standardWarnings :: [WarningFlag]
standardWarnings -- see Note [Documenting warning flags]
= [ Opt_WarnOverlappingPatterns,
Opt_WarnWarningsDeprecations,
Opt_WarnDeprecatedFlags,
Opt_WarnDeferredTypeErrors,
Opt_WarnTypedHoles,
Opt_WarnPartialTypeSignatures,
Opt_WarnUnrecognisedPragmas,
Opt_WarnDuplicateExports,
Opt_WarnOverflowedLiterals,
Opt_WarnEmptyEnumerations,
Opt_WarnMissingFields,
Opt_WarnMissingMethods,
Opt_WarnWrongDoBind,
Opt_WarnUnsupportedCallingConventions,
Opt_WarnDodgyForeignImports,
Opt_WarnInlineRuleShadowing,
Opt_WarnAlternativeLayoutRuleTransitional,
Opt_WarnUnsupportedLlvmVersion,
Opt_WarnTabs,
Opt_WarnUnrecognisedWarningFlags,
Opt_WarnSimplifiableClassConstraints
]
| 864
|
standardWarnings -- see Note [Documenting warning flags]
= [ Opt_WarnOverlappingPatterns,
Opt_WarnWarningsDeprecations,
Opt_WarnDeprecatedFlags,
Opt_WarnDeferredTypeErrors,
Opt_WarnTypedHoles,
Opt_WarnPartialTypeSignatures,
Opt_WarnUnrecognisedPragmas,
Opt_WarnDuplicateExports,
Opt_WarnOverflowedLiterals,
Opt_WarnEmptyEnumerations,
Opt_WarnMissingFields,
Opt_WarnMissingMethods,
Opt_WarnWrongDoBind,
Opt_WarnUnsupportedCallingConventions,
Opt_WarnDodgyForeignImports,
Opt_WarnInlineRuleShadowing,
Opt_WarnAlternativeLayoutRuleTransitional,
Opt_WarnUnsupportedLlvmVersion,
Opt_WarnTabs,
Opt_WarnUnrecognisedWarningFlags,
Opt_WarnSimplifiableClassConstraints
]
| 830
| false
| true
| 0
| 7
| 203
| 81
| 51
| 30
| null | null |
azhai/hsDump
|
hsdump.hs
|
mit
|
concatSql :: Yaml.Config -> String
concatSql sqlconf =
"SELECT " ++ (Utils.join "," fields) ++ " FROM " ++ table
++ " WHERE " ++ index ++ ">=? AND " ++ index ++ "<? ORDER BY " ++ order
where
(table:_) = Yaml.lookup "table" sqlconf :: [String]
(index:_) = Yaml.lookup "index" sqlconf :: [String]
(order:_) = Yaml.lookup "order" sqlconf :: [String]
fields = Yaml.lookupDefault "fields" ["*"] sqlconf :: [String]
| 457
|
concatSql :: Yaml.Config -> String
concatSql sqlconf =
"SELECT " ++ (Utils.join "," fields) ++ " FROM " ++ table
++ " WHERE " ++ index ++ ">=? AND " ++ index ++ "<? ORDER BY " ++ order
where
(table:_) = Yaml.lookup "table" sqlconf :: [String]
(index:_) = Yaml.lookup "index" sqlconf :: [String]
(order:_) = Yaml.lookup "order" sqlconf :: [String]
fields = Yaml.lookupDefault "fields" ["*"] sqlconf :: [String]
| 457
|
concatSql sqlconf =
"SELECT " ++ (Utils.join "," fields) ++ " FROM " ++ table
++ " WHERE " ++ index ++ ">=? AND " ++ index ++ "<? ORDER BY " ++ order
where
(table:_) = Yaml.lookup "table" sqlconf :: [String]
(index:_) = Yaml.lookup "index" sqlconf :: [String]
(order:_) = Yaml.lookup "order" sqlconf :: [String]
fields = Yaml.lookupDefault "fields" ["*"] sqlconf :: [String]
| 422
| false
| true
| 0
| 16
| 116
| 169
| 89
| 80
| null | null |
ghcjs/jsaddle-dom
|
src/JSDOM/Generated/MediaControlsHost.hs
|
mit
|
-- | <https://developer.mozilla.org/en-US/docs/Web/API/MediaControlsHost.controlsDependOnPageScaleFactor Mozilla MediaControlsHost.controlsDependOnPageScaleFactor documentation>
setControlsDependOnPageScaleFactor ::
(MonadDOM m) => MediaControlsHost -> Bool -> m ()
setControlsDependOnPageScaleFactor self val
= liftDOM
(self ^. jss "controlsDependOnPageScaleFactor" (toJSVal val))
| 425
|
setControlsDependOnPageScaleFactor ::
(MonadDOM m) => MediaControlsHost -> Bool -> m ()
setControlsDependOnPageScaleFactor self val
= liftDOM
(self ^. jss "controlsDependOnPageScaleFactor" (toJSVal val))
| 246
|
setControlsDependOnPageScaleFactor self val
= liftDOM
(self ^. jss "controlsDependOnPageScaleFactor" (toJSVal val))
| 123
| true
| true
| 0
| 10
| 71
| 60
| 30
| 30
| null | null |
ipuustin/propositional-planning
|
AI/Planning.hs
|
bsd-3-clause
|
-- | replace biconditionals and implications, push negations
cnfReplace :: Expr -> Expr
cnfReplace e = cnfPushNegation $ cnfLimit e
| 133
|
cnfReplace :: Expr -> Expr
cnfReplace e = cnfPushNegation $ cnfLimit e
| 70
|
cnfReplace e = cnfPushNegation $ cnfLimit e
| 43
| true
| true
| 0
| 6
| 21
| 26
| 13
| 13
| null | null |
iain-logan/MU-Puzzle
|
p1.hs
|
mit
|
dLSearch ((miu:ys):xs) target depthLim tries | miu == target = (miu:ys, tries, length xs)
| length ys == depthLim = dLSearch xs target depthLim tries
| otherwise = dLSearch ([(x:miu:ys) | x <- (nextStates miu)] ++ xs) target depthLim (tries+1)
| 341
|
dLSearch ((miu:ys):xs) target depthLim tries | miu == target = (miu:ys, tries, length xs)
| length ys == depthLim = dLSearch xs target depthLim tries
| otherwise = dLSearch ([(x:miu:ys) | x <- (nextStates miu)] ++ xs) target depthLim (tries+1)
| 341
|
dLSearch ((miu:ys):xs) target depthLim tries | miu == target = (miu:ys, tries, length xs)
| length ys == depthLim = dLSearch xs target depthLim tries
| otherwise = dLSearch ([(x:miu:ys) | x <- (nextStates miu)] ++ xs) target depthLim (tries+1)
| 341
| false
| false
| 0
| 13
| 137
| 140
| 70
| 70
| null | null |
cartazio/arithmoi
|
Math/NumberTheory/DirichletCharacters.hs
|
mit
|
makePrimitive :: DirichletCharacter n -> WithNat PrimitiveCharacter
makePrimitive (Generated xs) =
case someNatVal (product mods) of
SomeNat (Proxy :: Proxy m) -> WithNat (PrimitiveCharacter (Generated ys) :: PrimitiveCharacter m)
where (mods,ys) = unzip (mapMaybe prim xs)
prim :: DirichletFactor -> Maybe (Natural, DirichletFactor)
prim Two = Nothing
prim (OddPrime p' k g a) = case find works options of
Nothing -> error "invalid character"
Just (0,_) -> Nothing
Just (i,_) -> Just (p^i, OddPrime p' i g a)
where options = (0,1): [(i,p^(i-1)*(p-1)) | i <- [1..k]]
works (_,phi) = phi `stimes` a == mempty
p = unPrime p'
prim (TwoPower k a b) = case find worksb options of
Nothing -> error "invalid character"
Just (2,_) | a == mempty -> Nothing
Just (i,_) -> Just (bit i :: Natural, TwoPower i a b)
where options = [(i, bit (i-2) :: Natural) | i <- [2..k]]
worksb (_,phi) = phi `stimes` b == mempty
#if !MIN_VERSION_base(4,12,0)
| 1,253
|
makePrimitive :: DirichletCharacter n -> WithNat PrimitiveCharacter
makePrimitive (Generated xs) =
case someNatVal (product mods) of
SomeNat (Proxy :: Proxy m) -> WithNat (PrimitiveCharacter (Generated ys) :: PrimitiveCharacter m)
where (mods,ys) = unzip (mapMaybe prim xs)
prim :: DirichletFactor -> Maybe (Natural, DirichletFactor)
prim Two = Nothing
prim (OddPrime p' k g a) = case find works options of
Nothing -> error "invalid character"
Just (0,_) -> Nothing
Just (i,_) -> Just (p^i, OddPrime p' i g a)
where options = (0,1): [(i,p^(i-1)*(p-1)) | i <- [1..k]]
works (_,phi) = phi `stimes` a == mempty
p = unPrime p'
prim (TwoPower k a b) = case find worksb options of
Nothing -> error "invalid character"
Just (2,_) | a == mempty -> Nothing
Just (i,_) -> Just (bit i :: Natural, TwoPower i a b)
where options = [(i, bit (i-2) :: Natural) | i <- [2..k]]
worksb (_,phi) = phi `stimes` b == mempty
#if !MIN_VERSION_base(4,12,0)
| 1,253
|
makePrimitive (Generated xs) =
case someNatVal (product mods) of
SomeNat (Proxy :: Proxy m) -> WithNat (PrimitiveCharacter (Generated ys) :: PrimitiveCharacter m)
where (mods,ys) = unzip (mapMaybe prim xs)
prim :: DirichletFactor -> Maybe (Natural, DirichletFactor)
prim Two = Nothing
prim (OddPrime p' k g a) = case find works options of
Nothing -> error "invalid character"
Just (0,_) -> Nothing
Just (i,_) -> Just (p^i, OddPrime p' i g a)
where options = (0,1): [(i,p^(i-1)*(p-1)) | i <- [1..k]]
works (_,phi) = phi `stimes` a == mempty
p = unPrime p'
prim (TwoPower k a b) = case find worksb options of
Nothing -> error "invalid character"
Just (2,_) | a == mempty -> Nothing
Just (i,_) -> Just (bit i :: Natural, TwoPower i a b)
where options = [(i, bit (i-2) :: Natural) | i <- [2..k]]
worksb (_,phi) = phi `stimes` b == mempty
#if !MIN_VERSION_base(4,12,0)
| 1,185
| false
| true
| 1
| 12
| 478
| 500
| 253
| 247
| null | null |
HIPERFIT/futhark
|
src/Futhark/Optimise/Fusion.hs
|
isc
|
fuseInStms :: Stms SOACS -> FusionGM (Stms SOACS)
fuseInStms stms
| Just (Let pat aux e, stms') <- stmsHead stms = do
stms'' <- bindingPat pat $ fuseInStms stms'
soac_stms <- replaceSOAC pat aux e
pure $ soac_stms <> stms''
| otherwise =
pure mempty
| 269
|
fuseInStms :: Stms SOACS -> FusionGM (Stms SOACS)
fuseInStms stms
| Just (Let pat aux e, stms') <- stmsHead stms = do
stms'' <- bindingPat pat $ fuseInStms stms'
soac_stms <- replaceSOAC pat aux e
pure $ soac_stms <> stms''
| otherwise =
pure mempty
| 269
|
fuseInStms stms
| Just (Let pat aux e, stms') <- stmsHead stms = do
stms'' <- bindingPat pat $ fuseInStms stms'
soac_stms <- replaceSOAC pat aux e
pure $ soac_stms <> stms''
| otherwise =
pure mempty
| 219
| false
| true
| 0
| 11
| 64
| 121
| 52
| 69
| null | null |
thlorenz/WebToInk
|
webtoink-converter/WebToInk/Converter/Logger.hs
|
bsd-2-clause
|
warningColor = 94
| 18
|
warningColor = 94
| 18
|
warningColor = 94
| 18
| false
| false
| 0
| 4
| 3
| 6
| 3
| 3
| null | null |
teuffy/min-var-ci
|
src/FP/ImportWizard/SourceWizard.hs
|
mit
|
optionsListSum :: (Bounded a, Enum a) => (a -> Text) -> [(Text, a)]
optionsListSum n = map (\x -> (n x, x)) [minBound .. maxBound]
| 130
|
optionsListSum :: (Bounded a, Enum a) => (a -> Text) -> [(Text, a)]
optionsListSum n = map (\x -> (n x, x)) [minBound .. maxBound]
| 130
|
optionsListSum n = map (\x -> (n x, x)) [minBound .. maxBound]
| 62
| false
| true
| 0
| 9
| 24
| 77
| 43
| 34
| null | null |
tel/saltine
|
src/Crypto/Saltine/Core/Password.hs
|
mit
|
opslimitModerate Argon2id13 = Opslimit (fromIntegral Bytes.pwhash_argon2id_opslimit_moderate)
| 101
|
opslimitModerate Argon2id13 = Opslimit (fromIntegral Bytes.pwhash_argon2id_opslimit_moderate)
| 101
|
opslimitModerate Argon2id13 = Opslimit (fromIntegral Bytes.pwhash_argon2id_opslimit_moderate)
| 101
| false
| false
| 0
| 8
| 13
| 20
| 9
| 11
| null | null |
piyush-kurur/sample-code
|
haskell/TryGen.hs
|
unlicense
|
-- | This is like the join for the monad but lifts a Maybe.
joinMaybe :: RecParser (Maybe a) -> RecParser a
joinMaybe rp = RecParser $ \ kvs -> do (maybeV,rest) <- runRecParser rp kvs
x <- maybeV
return (x, rest)
| 290
|
joinMaybe :: RecParser (Maybe a) -> RecParser a
joinMaybe rp = RecParser $ \ kvs -> do (maybeV,rest) <- runRecParser rp kvs
x <- maybeV
return (x, rest)
| 230
|
joinMaybe rp = RecParser $ \ kvs -> do (maybeV,rest) <- runRecParser rp kvs
x <- maybeV
return (x, rest)
| 182
| true
| true
| 0
| 10
| 119
| 77
| 38
| 39
| null | null |
slpopejoy/fadno-braids
|
src/Fadno/Braids/Internal.hs
|
bsd-2-clause
|
insertWithS f (Gen k p) s@(Step (Gen hi hp) sgs)
| invalid hi = s
| k < hi = Step (Gen k p) (Gen (fromIntegral $ hi - k - 2) hp:sgs)
| k == hi = set (sHead.gPol) (f p hp) s
| otherwise = set sOffsets (ins hi sgs) s
where invalid i = k + 1 == i || i + 1 == k
ins :: a -> [Gen Natural] -> [Gen Natural]
ins i [] = [Gen (fromIntegral $ k - i - 2) p]
ins i gss@(g@(Gen gi gp):gs)
| invalid i' = gss
| k < i' = Gen (fromIntegral $ k - i - 2) p:
Gen (fromIntegral $ i' - k - 2) gp:gs
| k == i' = set gPol (f p gp) g:gs
| otherwise = g:ins i' gs
where i' = i + fromIntegral gi + 2
-- | Insert a gen at absolute index into a 'Step'.
-- Ignores invalid indices, overwrites on update.
| 820
|
insertWithS f (Gen k p) s@(Step (Gen hi hp) sgs)
| invalid hi = s
| k < hi = Step (Gen k p) (Gen (fromIntegral $ hi - k - 2) hp:sgs)
| k == hi = set (sHead.gPol) (f p hp) s
| otherwise = set sOffsets (ins hi sgs) s
where invalid i = k + 1 == i || i + 1 == k
ins :: a -> [Gen Natural] -> [Gen Natural]
ins i [] = [Gen (fromIntegral $ k - i - 2) p]
ins i gss@(g@(Gen gi gp):gs)
| invalid i' = gss
| k < i' = Gen (fromIntegral $ k - i - 2) p:
Gen (fromIntegral $ i' - k - 2) gp:gs
| k == i' = set gPol (f p gp) g:gs
| otherwise = g:ins i' gs
where i' = i + fromIntegral gi + 2
-- | Insert a gen at absolute index into a 'Step'.
-- Ignores invalid indices, overwrites on update.
| 820
|
insertWithS f (Gen k p) s@(Step (Gen hi hp) sgs)
| invalid hi = s
| k < hi = Step (Gen k p) (Gen (fromIntegral $ hi - k - 2) hp:sgs)
| k == hi = set (sHead.gPol) (f p hp) s
| otherwise = set sOffsets (ins hi sgs) s
where invalid i = k + 1 == i || i + 1 == k
ins :: a -> [Gen Natural] -> [Gen Natural]
ins i [] = [Gen (fromIntegral $ k - i - 2) p]
ins i gss@(g@(Gen gi gp):gs)
| invalid i' = gss
| k < i' = Gen (fromIntegral $ k - i - 2) p:
Gen (fromIntegral $ i' - k - 2) gp:gs
| k == i' = set gPol (f p gp) g:gs
| otherwise = g:ins i' gs
where i' = i + fromIntegral gi + 2
-- | Insert a gen at absolute index into a 'Step'.
-- Ignores invalid indices, overwrites on update.
| 820
| false
| false
| 5
| 12
| 312
| 424
| 206
| 218
| null | null |
danidiaz/lens
|
src/Control/Exception/Lens.hs
|
bsd-3-clause
|
-- $setup
-- >>> :set -XNoOverloadedStrings
-- >>> :m + Control.Exception Control.Monad Data.List Prelude
------------------------------------------------------------------------------
-- Exceptions as Prisms
------------------------------------------------------------------------------
-- | Traverse the strongly typed 'Exception' contained in 'SomeException' where the type of your function matches
-- the desired 'Exception'.
--
-- @
-- 'exception' :: ('Applicative' f, 'Exception' a)
-- => (a -> f a) -> 'SomeException' -> f 'SomeException'
-- @
exception :: Exception a => Prism' SomeException a
exception = prism' toException fromException
| 658
|
exception :: Exception a => Prism' SomeException a
exception = prism' toException fromException
| 95
|
exception = prism' toException fromException
| 44
| true
| true
| 0
| 6
| 88
| 41
| 26
| 15
| null | null |
jfischoff/hs-mitsuba
|
tests/VerifyData.hs
|
bsd-3-clause
|
defaultVerifiedTexture'
= TCheckerboard
$ Checkerboard
{ checkerboardColor0 = SUniform 1
, checkerboardColor1 = SUniform 0
, checkerboardUoffset = 0
, checkerboardVoffset = 0
, checkerboardUscale = 1
, checkerboardVscale = 1
}
| 276
|
defaultVerifiedTexture'
= TCheckerboard
$ Checkerboard
{ checkerboardColor0 = SUniform 1
, checkerboardColor1 = SUniform 0
, checkerboardUoffset = 0
, checkerboardVoffset = 0
, checkerboardUscale = 1
, checkerboardVscale = 1
}
| 276
|
defaultVerifiedTexture'
= TCheckerboard
$ Checkerboard
{ checkerboardColor0 = SUniform 1
, checkerboardColor1 = SUniform 0
, checkerboardUoffset = 0
, checkerboardVoffset = 0
, checkerboardUscale = 1
, checkerboardVscale = 1
}
| 276
| false
| false
| 3
| 8
| 81
| 62
| 33
| 29
| null | null |
alphalambda/codeworld
|
codeworld-prediction/tests/prediction-paper.hs
|
apache-2.0
|
reportFailedCheck :: CheckReport -> IO ()
reportFailedCheck (c, before, expected, actual) = do
putStrLn "Failed Check"
putStrLn "History:"
putStr $ showHistory (fst c)
putStrLn "Event:"
print (snd c)
putStrLn "Before:"
print before
putStrLn "Expected:"
print expected
putStrLn "Actual:"
print actual
putStrLn ""
| 359
|
reportFailedCheck :: CheckReport -> IO ()
reportFailedCheck (c, before, expected, actual) = do
putStrLn "Failed Check"
putStrLn "History:"
putStr $ showHistory (fst c)
putStrLn "Event:"
print (snd c)
putStrLn "Before:"
print before
putStrLn "Expected:"
print expected
putStrLn "Actual:"
print actual
putStrLn ""
| 359
|
reportFailedCheck (c, before, expected, actual) = do
putStrLn "Failed Check"
putStrLn "History:"
putStr $ showHistory (fst c)
putStrLn "Event:"
print (snd c)
putStrLn "Before:"
print before
putStrLn "Expected:"
print expected
putStrLn "Actual:"
print actual
putStrLn ""
| 317
| false
| true
| 0
| 10
| 89
| 123
| 51
| 72
| null | null |
ShellShoccar-jpn/Open-usp-Tukubai
|
COMMANDS.HS/kasan.hs
|
mit
|
readF f = BS.readFile f
| 25
|
readF f = BS.readFile f
| 25
|
readF f = BS.readFile f
| 25
| false
| false
| 1
| 6
| 6
| 17
| 6
| 11
| null | null |
dogweather/nevada-revised-statutes-parser
|
src/Models/Section.hs
|
bsd-3-clause
|
toSectionNumber :: Text -> Text -> Either String SectionNumber
toSectionNumber n context
| actualLen > maxNumberLen || actualLen == 0 || not (T.isInfixOf "." n) = Left
[qq| Section number must be 1..$maxNumberLen characters and have a dot: "$n" context: $context |]
| otherwise = Right $ MakeSectionNumber n
where
actualLen = T.length n
| 352
|
toSectionNumber :: Text -> Text -> Either String SectionNumber
toSectionNumber n context
| actualLen > maxNumberLen || actualLen == 0 || not (T.isInfixOf "." n) = Left
[qq| Section number must be 1..$maxNumberLen characters and have a dot: "$n" context: $context |]
| otherwise = Right $ MakeSectionNumber n
where
actualLen = T.length n
| 352
|
toSectionNumber n context
| actualLen > maxNumberLen || actualLen == 0 || not (T.isInfixOf "." n) = Left
[qq| Section number must be 1..$maxNumberLen characters and have a dot: "$n" context: $context |]
| otherwise = Right $ MakeSectionNumber n
where
actualLen = T.length n
| 289
| false
| true
| 1
| 12
| 69
| 109
| 50
| 59
| null | null |
nevrenato/Hets_Fork
|
Common/Doc.hs
|
gpl-2.0
|
sepByCommas :: [Doc] -> Doc
sepByCommas = fsep . punctuate comma
| 64
|
sepByCommas :: [Doc] -> Doc
sepByCommas = fsep . punctuate comma
| 64
|
sepByCommas = fsep . punctuate comma
| 36
| false
| true
| 1
| 7
| 10
| 32
| 14
| 18
| null | null |
bkoropoff/Idris-dev
|
src/Idris/AbsSyntaxTree.hs
|
bsd-3-clause
|
highestFC (PDisamb _ opts) = highestFC opts
| 43
|
highestFC (PDisamb _ opts) = highestFC opts
| 43
|
highestFC (PDisamb _ opts) = highestFC opts
| 43
| false
| false
| 0
| 7
| 6
| 20
| 9
| 11
| null | null |
takano-akio/time
|
test/TestParseTime.hs
|
bsd-3-clause
|
partialLocalTimeFormats :: [FormatString LocalTime]
partialLocalTimeFormats = map FormatString
[
-- %c does not include second decimals
"%c"
]
| 163
|
partialLocalTimeFormats :: [FormatString LocalTime]
partialLocalTimeFormats = map FormatString
[
-- %c does not include second decimals
"%c"
]
| 163
|
partialLocalTimeFormats = map FormatString
[
-- %c does not include second decimals
"%c"
]
| 111
| false
| true
| 0
| 8
| 38
| 33
| 15
| 18
| null | null |
brendanhay/gogol
|
gogol-file/gen/Network/Google/Resource/File/Projects/Locations/Operations/Get.hs
|
mpl-2.0
|
-- | JSONP
plogCallback :: Lens' ProjectsLocationsOperationsGet (Maybe Text)
plogCallback
= lens _plogCallback (\ s a -> s{_plogCallback = a})
| 144
|
plogCallback :: Lens' ProjectsLocationsOperationsGet (Maybe Text)
plogCallback
= lens _plogCallback (\ s a -> s{_plogCallback = a})
| 133
|
plogCallback
= lens _plogCallback (\ s a -> s{_plogCallback = a})
| 67
| true
| true
| 0
| 9
| 21
| 48
| 25
| 23
| null | null |
d-rive/rivers
|
Data/Rivers/Ecology.hs
|
bsd-3-clause
|
proy (_,_,_,_,_,x,_,_) 5 = x
| 28
|
proy (_,_,_,_,_,x,_,_) 5 = x
| 28
|
proy (_,_,_,_,_,x,_,_) 5 = x
| 28
| false
| false
| 0
| 6
| 4
| 35
| 21
| 14
| null | null |
csabahruska/gpipe-quake3
|
Main.hs
|
bsd-3-clause
|
main :: IO ()
main = do
ar <- loadArchive
let imageShader txName = defaultCommonAttrs {caStages = sa:saLM:[]}
where
sa = defaultStageAttrs
{ saTexture = ST_Map txName
, saBlend = Nothing
, saTCGen = TG_Base
, saDepthWrite = True
, saRGBGen = RGB_IdentityLighting
}
saLM = defaultStageAttrs
{ saTexture = ST_Lightmap
, saBlend = Just (B_DstColor,B_Zero)
, saTCGen = TG_Lightmap
, saRGBGen = RGB_IdentityLighting
}
args <- getArgs
let bspMap = T.fromList [(SB.pack $ takeBaseName n, decompress' e) | e <- ar, let n = eFilePath e, ".bsp" == takeExtensionCI n, isPrefixOfCI "maps" n]
bspName = case args of
[] -> head $ T.keys bspMap
(n:xs) -> SB.pack n
bspData = case T.lookup bspName bspMap of
Nothing -> error "You need to put pk3 file into your current directory"
Just bspd -> bspd
bsp = readBSP bspData
shNames = Set.fromList $ map shName $ V.toList $ blShaders bsp
shMap' = shaderMap ar
(normalShNames,textureShNames) = partition (\n -> T.member n shMap') $ Set.toList shNames
normalShNameSet = Set.fromList normalShNames
textureShNameSet = Set.fromList textureShNames
normalShMap = T.mapBy (\n sh -> if Set.member n normalShNameSet then Just sh else Nothing) shMap'
--textureShMap = T.fromList [(n,defaultCommonAttrs {caStages = [defaultStageAttrs {saTexture = ST_Map n, saDepthWrite = True}]}) | n <- Set.toList textureShNameSet]
textureShMap = T.fromList [(n,imageShader n) | n <- Set.toList textureShNameSet]
shMap = T.unionL normalShMap textureShMap
-- extract spawn points
ents = parseEntities (SB.unpack bspName) $ blEntities bsp
spawn e = case T.lookup "classname" e of
Just "info_player_deathmatch" -> True
Just "info_player_start" -> True
Just "info_player_intermission" -> True
_ -> False
Just sp0 = T.lookup "origin" $ head $ filter spawn ents
[x0,y0,z0] = map read $ words $ SB.unpack sp0 :: [Float]
p0 = V3 x0 y0 z0
-- load textures
textureSet = foldMap (mconcat . map stageTex . caStages) shMap
stageTex sa = case saTexture sa of
ST_Map n -> Set.singleton n
ST_ClampMap n -> Set.singleton n
ST_AnimMap _ l -> mconcat $ map Set.singleton l
_ -> mempty
archiveTrie = T.fromList [(SB.pack $ eFilePath a,a) | a <- ar]
textureMap = T.fromList [(n, i) | n <- Set.toList textureSet, i <- maybeToList $ loadQ3Texture archiveTrie n]
{-
animTex <- fmap concat $ forM (Set.toList $ Set.fromList $ map (\(s,m) -> (saTexture s,m)) $
concatMap (\sh -> [(s,caNoMipMaps sh) | s <- caStages sh]) $ T.elems shMap) $ \(stageTex,noMip) -> do
let texSlotName = SB.pack $ "Tex_" ++ show (crc32 $ SB.pack $ show stageTex)
setTex isClamped img = uniformFTexture2D texSlotName slotU =<< loadQ3Texture (not noMip) isClamped defaultTexture archiveTrie img
case stageTex of
ST_Map img -> setTex False img >> return []
ST_ClampMap img -> setTex True img >> return []
ST_AnimMap t imgs -> do
txList <- mapM (loadQ3Texture (not noMip) False defaultTexture archiveTrie) imgs
--return [(1 / t / fromIntegral (length imgs),cycle $ zip (repeat (uniformFTexture2D texSlotName slotU)) txList)]
return [(1/t,cycle $ zip (repeat (uniformFTexture2D texSlotName slotU)) txList)]
_ -> return []
-}
putStrLn $ "loading: " ++ show bspName
renderQuake p0 bsp shMap textureMap
-- pk3 handling
| 3,980
|
main :: IO ()
main = do
ar <- loadArchive
let imageShader txName = defaultCommonAttrs {caStages = sa:saLM:[]}
where
sa = defaultStageAttrs
{ saTexture = ST_Map txName
, saBlend = Nothing
, saTCGen = TG_Base
, saDepthWrite = True
, saRGBGen = RGB_IdentityLighting
}
saLM = defaultStageAttrs
{ saTexture = ST_Lightmap
, saBlend = Just (B_DstColor,B_Zero)
, saTCGen = TG_Lightmap
, saRGBGen = RGB_IdentityLighting
}
args <- getArgs
let bspMap = T.fromList [(SB.pack $ takeBaseName n, decompress' e) | e <- ar, let n = eFilePath e, ".bsp" == takeExtensionCI n, isPrefixOfCI "maps" n]
bspName = case args of
[] -> head $ T.keys bspMap
(n:xs) -> SB.pack n
bspData = case T.lookup bspName bspMap of
Nothing -> error "You need to put pk3 file into your current directory"
Just bspd -> bspd
bsp = readBSP bspData
shNames = Set.fromList $ map shName $ V.toList $ blShaders bsp
shMap' = shaderMap ar
(normalShNames,textureShNames) = partition (\n -> T.member n shMap') $ Set.toList shNames
normalShNameSet = Set.fromList normalShNames
textureShNameSet = Set.fromList textureShNames
normalShMap = T.mapBy (\n sh -> if Set.member n normalShNameSet then Just sh else Nothing) shMap'
--textureShMap = T.fromList [(n,defaultCommonAttrs {caStages = [defaultStageAttrs {saTexture = ST_Map n, saDepthWrite = True}]}) | n <- Set.toList textureShNameSet]
textureShMap = T.fromList [(n,imageShader n) | n <- Set.toList textureShNameSet]
shMap = T.unionL normalShMap textureShMap
-- extract spawn points
ents = parseEntities (SB.unpack bspName) $ blEntities bsp
spawn e = case T.lookup "classname" e of
Just "info_player_deathmatch" -> True
Just "info_player_start" -> True
Just "info_player_intermission" -> True
_ -> False
Just sp0 = T.lookup "origin" $ head $ filter spawn ents
[x0,y0,z0] = map read $ words $ SB.unpack sp0 :: [Float]
p0 = V3 x0 y0 z0
-- load textures
textureSet = foldMap (mconcat . map stageTex . caStages) shMap
stageTex sa = case saTexture sa of
ST_Map n -> Set.singleton n
ST_ClampMap n -> Set.singleton n
ST_AnimMap _ l -> mconcat $ map Set.singleton l
_ -> mempty
archiveTrie = T.fromList [(SB.pack $ eFilePath a,a) | a <- ar]
textureMap = T.fromList [(n, i) | n <- Set.toList textureSet, i <- maybeToList $ loadQ3Texture archiveTrie n]
{-
animTex <- fmap concat $ forM (Set.toList $ Set.fromList $ map (\(s,m) -> (saTexture s,m)) $
concatMap (\sh -> [(s,caNoMipMaps sh) | s <- caStages sh]) $ T.elems shMap) $ \(stageTex,noMip) -> do
let texSlotName = SB.pack $ "Tex_" ++ show (crc32 $ SB.pack $ show stageTex)
setTex isClamped img = uniformFTexture2D texSlotName slotU =<< loadQ3Texture (not noMip) isClamped defaultTexture archiveTrie img
case stageTex of
ST_Map img -> setTex False img >> return []
ST_ClampMap img -> setTex True img >> return []
ST_AnimMap t imgs -> do
txList <- mapM (loadQ3Texture (not noMip) False defaultTexture archiveTrie) imgs
--return [(1 / t / fromIntegral (length imgs),cycle $ zip (repeat (uniformFTexture2D texSlotName slotU)) txList)]
return [(1/t,cycle $ zip (repeat (uniformFTexture2D texSlotName slotU)) txList)]
_ -> return []
-}
putStrLn $ "loading: " ++ show bspName
renderQuake p0 bsp shMap textureMap
-- pk3 handling
| 3,980
|
main = do
ar <- loadArchive
let imageShader txName = defaultCommonAttrs {caStages = sa:saLM:[]}
where
sa = defaultStageAttrs
{ saTexture = ST_Map txName
, saBlend = Nothing
, saTCGen = TG_Base
, saDepthWrite = True
, saRGBGen = RGB_IdentityLighting
}
saLM = defaultStageAttrs
{ saTexture = ST_Lightmap
, saBlend = Just (B_DstColor,B_Zero)
, saTCGen = TG_Lightmap
, saRGBGen = RGB_IdentityLighting
}
args <- getArgs
let bspMap = T.fromList [(SB.pack $ takeBaseName n, decompress' e) | e <- ar, let n = eFilePath e, ".bsp" == takeExtensionCI n, isPrefixOfCI "maps" n]
bspName = case args of
[] -> head $ T.keys bspMap
(n:xs) -> SB.pack n
bspData = case T.lookup bspName bspMap of
Nothing -> error "You need to put pk3 file into your current directory"
Just bspd -> bspd
bsp = readBSP bspData
shNames = Set.fromList $ map shName $ V.toList $ blShaders bsp
shMap' = shaderMap ar
(normalShNames,textureShNames) = partition (\n -> T.member n shMap') $ Set.toList shNames
normalShNameSet = Set.fromList normalShNames
textureShNameSet = Set.fromList textureShNames
normalShMap = T.mapBy (\n sh -> if Set.member n normalShNameSet then Just sh else Nothing) shMap'
--textureShMap = T.fromList [(n,defaultCommonAttrs {caStages = [defaultStageAttrs {saTexture = ST_Map n, saDepthWrite = True}]}) | n <- Set.toList textureShNameSet]
textureShMap = T.fromList [(n,imageShader n) | n <- Set.toList textureShNameSet]
shMap = T.unionL normalShMap textureShMap
-- extract spawn points
ents = parseEntities (SB.unpack bspName) $ blEntities bsp
spawn e = case T.lookup "classname" e of
Just "info_player_deathmatch" -> True
Just "info_player_start" -> True
Just "info_player_intermission" -> True
_ -> False
Just sp0 = T.lookup "origin" $ head $ filter spawn ents
[x0,y0,z0] = map read $ words $ SB.unpack sp0 :: [Float]
p0 = V3 x0 y0 z0
-- load textures
textureSet = foldMap (mconcat . map stageTex . caStages) shMap
stageTex sa = case saTexture sa of
ST_Map n -> Set.singleton n
ST_ClampMap n -> Set.singleton n
ST_AnimMap _ l -> mconcat $ map Set.singleton l
_ -> mempty
archiveTrie = T.fromList [(SB.pack $ eFilePath a,a) | a <- ar]
textureMap = T.fromList [(n, i) | n <- Set.toList textureSet, i <- maybeToList $ loadQ3Texture archiveTrie n]
{-
animTex <- fmap concat $ forM (Set.toList $ Set.fromList $ map (\(s,m) -> (saTexture s,m)) $
concatMap (\sh -> [(s,caNoMipMaps sh) | s <- caStages sh]) $ T.elems shMap) $ \(stageTex,noMip) -> do
let texSlotName = SB.pack $ "Tex_" ++ show (crc32 $ SB.pack $ show stageTex)
setTex isClamped img = uniformFTexture2D texSlotName slotU =<< loadQ3Texture (not noMip) isClamped defaultTexture archiveTrie img
case stageTex of
ST_Map img -> setTex False img >> return []
ST_ClampMap img -> setTex True img >> return []
ST_AnimMap t imgs -> do
txList <- mapM (loadQ3Texture (not noMip) False defaultTexture archiveTrie) imgs
--return [(1 / t / fromIntegral (length imgs),cycle $ zip (repeat (uniformFTexture2D texSlotName slotU)) txList)]
return [(1/t,cycle $ zip (repeat (uniformFTexture2D texSlotName slotU)) txList)]
_ -> return []
-}
putStrLn $ "loading: " ++ show bspName
renderQuake p0 bsp shMap textureMap
-- pk3 handling
| 3,966
| false
| true
| 0
| 16
| 1,313
| 847
| 427
| 420
| null | null |
NorfairKing/eden
|
src/Publish.hs
|
gpl-2.0
|
generateLibraryImports :: EdenPublish ()
generateLibraryImports = do
ld <- libDir
cts <- liftIO $ getDirectoryContents ld
let files = filter (\f -> takeExtension f == ".tex") cts
let str = unlines . sort $ map makeImport files
dir <- publishDir
liftIO $ writeFile (dir </> publishLibraryImportsFileName) str
where
makeImport :: FilePath -> String
makeImport f = "\\subfile{../lib/" ++ f ++"}"
| 426
|
generateLibraryImports :: EdenPublish ()
generateLibraryImports = do
ld <- libDir
cts <- liftIO $ getDirectoryContents ld
let files = filter (\f -> takeExtension f == ".tex") cts
let str = unlines . sort $ map makeImport files
dir <- publishDir
liftIO $ writeFile (dir </> publishLibraryImportsFileName) str
where
makeImport :: FilePath -> String
makeImport f = "\\subfile{../lib/" ++ f ++"}"
| 426
|
generateLibraryImports = do
ld <- libDir
cts <- liftIO $ getDirectoryContents ld
let files = filter (\f -> takeExtension f == ".tex") cts
let str = unlines . sort $ map makeImport files
dir <- publishDir
liftIO $ writeFile (dir </> publishLibraryImportsFileName) str
where
makeImport :: FilePath -> String
makeImport f = "\\subfile{../lib/" ++ f ++"}"
| 385
| false
| true
| 0
| 14
| 93
| 142
| 67
| 75
| null | null |
da-x/ghc
|
libraries/base/GHC/Enum.hs
|
bsd-3-clause
|
-- Requires x2 >= x1
efdtIntUp :: Int# -> Int# -> Int# -> [Int]
efdtIntUp x1 x2 y -- Be careful about overflow!
| isTrue# (y <# x2) = if isTrue# (y <# x1) then [] else [I# x1]
| otherwise = -- Common case: x1 <= x2 <= y
let !delta = x2 -# x1 -- >= 0
!y' = y -# delta -- x1 <= y' <= y; hence y' is representable
-- Invariant: x <= y
-- Note that: z <= y' => z + delta won't overflow
-- so we are guaranteed not to overflow if/when we recurse
go_up x | isTrue# (x ># y') = [I# x]
| otherwise = I# x : go_up (x +# delta)
in I# x1 : go_up x2
| 704
|
efdtIntUp :: Int# -> Int# -> Int# -> [Int]
efdtIntUp x1 x2 y -- Be careful about overflow!
| isTrue# (y <# x2) = if isTrue# (y <# x1) then [] else [I# x1]
| otherwise = -- Common case: x1 <= x2 <= y
let !delta = x2 -# x1 -- >= 0
!y' = y -# delta -- x1 <= y' <= y; hence y' is representable
-- Invariant: x <= y
-- Note that: z <= y' => z + delta won't overflow
-- so we are guaranteed not to overflow if/when we recurse
go_up x | isTrue# (x ># y') = [I# x]
| otherwise = I# x : go_up (x +# delta)
in I# x1 : go_up x2
| 683
|
efdtIntUp x1 x2 y -- Be careful about overflow!
| isTrue# (y <# x2) = if isTrue# (y <# x1) then [] else [I# x1]
| otherwise = -- Common case: x1 <= x2 <= y
let !delta = x2 -# x1 -- >= 0
!y' = y -# delta -- x1 <= y' <= y; hence y' is representable
-- Invariant: x <= y
-- Note that: z <= y' => z + delta won't overflow
-- so we are guaranteed not to overflow if/when we recurse
go_up x | isTrue# (x ># y') = [I# x]
| otherwise = I# x : go_up (x +# delta)
in I# x1 : go_up x2
| 640
| true
| true
| 1
| 14
| 294
| 184
| 92
| 92
| null | null |
laser/cis-194-spring-2017
|
src/Homework/Week10/Assignment.hs
|
mit
|
-- Exercise 1
-- instance Arbitrary a => Arbitrary (Tree a) where
-- Exercise 2
size :: Tree a -> Int
size = undefined
| 121
|
size :: Tree a -> Int
size = undefined
| 38
|
size = undefined
| 16
| true
| true
| 0
| 7
| 26
| 28
| 13
| 15
| null | null |
pparkkin/eta
|
libraries/base/System/IO.hs
|
bsd-3-clause
|
openTempFile :: FilePath -- ^ Directory in which to create the file
-> String -- ^ File name template. If the template is \"foo.ext\" then
-- the created file will be \"fooXXX.ext\" where XXX is some
-- random number.
-> IO (FilePath, Handle)
openTempFile tmp_dir template
= openTempFile' "openTempFile" tmp_dir template False 0o600
| 422
|
openTempFile :: FilePath -- ^ Directory in which to create the file
-> String -- ^ File name template. If the template is \"foo.ext\" then
-- the created file will be \"fooXXX.ext\" where XXX is some
-- random number.
-> IO (FilePath, Handle)
openTempFile tmp_dir template
= openTempFile' "openTempFile" tmp_dir template False 0o600
| 422
|
openTempFile tmp_dir template
= openTempFile' "openTempFile" tmp_dir template False 0o600
| 93
| false
| true
| 0
| 9
| 142
| 53
| 27
| 26
| null | null |
massysett/quickpull
|
genCabal.hs
|
bsd-3-clause
|
filepath :: C.Package
filepath = C.closedOpen "filepath" [1,3,0,0] [1,5]
| 72
|
filepath :: C.Package
filepath = C.closedOpen "filepath" [1,3,0,0] [1,5]
| 72
|
filepath = C.closedOpen "filepath" [1,3,0,0] [1,5]
| 50
| false
| true
| 0
| 6
| 8
| 40
| 23
| 17
| null | null |
AndrewRademacher/coinbase-exchange
|
src/Coinbase/Exchange/Private.hs
|
mit
|
-- Reports
createReport :: (MonadResource m, MonadReader ExchangeConf m, MonadError ExchangeFailure m)
=> ReportRequest -> m ReportInfo
createReport = coinbasePost True "/reports" . Just
| 200
|
createReport :: (MonadResource m, MonadReader ExchangeConf m, MonadError ExchangeFailure m)
=> ReportRequest -> m ReportInfo
createReport = coinbasePost True "/reports" . Just
| 188
|
createReport = coinbasePost True "/reports" . Just
| 50
| true
| true
| 0
| 7
| 37
| 53
| 27
| 26
| null | null |
batterseapower/supercompilation-by-evaluation
|
Core/Syntax.hs
|
bsd-3-clause
|
detagValue :: TaggedValue -> Value
detagValue (Lambda x e) = Lambda x (detagTerm e)
| 83
|
detagValue :: TaggedValue -> Value
detagValue (Lambda x e) = Lambda x (detagTerm e)
| 83
|
detagValue (Lambda x e) = Lambda x (detagTerm e)
| 48
| false
| true
| 0
| 7
| 13
| 41
| 19
| 22
| null | null |
Mahdi89/eTeak
|
src/ParseTree.hs
|
bsd-3-clause
|
isSharedDecl :: Decl -> Bool
isSharedDecl (SharedDecl {}) = True
| 68
|
isSharedDecl :: Decl -> Bool
isSharedDecl (SharedDecl {}) = True
| 64
|
isSharedDecl (SharedDecl {}) = True
| 35
| false
| true
| 0
| 7
| 13
| 25
| 13
| 12
| null | null |
kolmodin/cabal
|
Cabal/Distribution/Version.hs
|
bsd-3-clause
|
-- | The empty version range, that is a version range containing no versions.
--
-- This can be constructed using any unsatisfiable version range expression,
-- for example @> 1 && < 1@.
--
-- > withinRange v noVersion = False
--
noVersion :: VersionRange
noVersion = IntersectVersionRanges (LaterVersion v) (EarlierVersion v)
where v = Version [1] []
-- | The version range @== v@
--
-- > withinRange v' (thisVersion v) = v' == v
--
| 436
|
noVersion :: VersionRange
noVersion = IntersectVersionRanges (LaterVersion v) (EarlierVersion v)
where v = Version [1] []
-- | The version range @== v@
--
-- > withinRange v' (thisVersion v) = v' == v
--
| 206
|
noVersion = IntersectVersionRanges (LaterVersion v) (EarlierVersion v)
where v = Version [1] []
-- | The version range @== v@
--
-- > withinRange v' (thisVersion v) = v' == v
--
| 180
| true
| true
| 0
| 7
| 80
| 57
| 34
| 23
| null | null |
lukexi/gl-pal
|
src/Graphics/GL/Pal/ArrayBuffer.hs
|
bsd-3-clause
|
-- | Buffers a list of floats using the given draw hint, e.g. GL_STATIC_DRAW
-- and returns a reference to the ArrayBuffer where the data is stored
bufferData :: forall a m. (Storable a, MonadIO m) => GLenum -> [a] -> m (ArrayBuffer a)
bufferData drawType values = do
buffer <- newArrayBuffer
withArrayBuffer buffer $ do
let valuesSize = fromIntegral (sizeOf (undefined :: a) * length values)
liftIO . withArray values $
\valuesPtr ->
glBufferData GL_ARRAY_BUFFER valuesSize (castPtr valuesPtr) drawType
return buffer
| 578
|
bufferData :: forall a m. (Storable a, MonadIO m) => GLenum -> [a] -> m (ArrayBuffer a)
bufferData drawType values = do
buffer <- newArrayBuffer
withArrayBuffer buffer $ do
let valuesSize = fromIntegral (sizeOf (undefined :: a) * length values)
liftIO . withArray values $
\valuesPtr ->
glBufferData GL_ARRAY_BUFFER valuesSize (castPtr valuesPtr) drawType
return buffer
| 430
|
bufferData drawType values = do
buffer <- newArrayBuffer
withArrayBuffer buffer $ do
let valuesSize = fromIntegral (sizeOf (undefined :: a) * length values)
liftIO . withArray values $
\valuesPtr ->
glBufferData GL_ARRAY_BUFFER valuesSize (castPtr valuesPtr) drawType
return buffer
| 342
| true
| true
| 0
| 18
| 142
| 152
| 73
| 79
| null | null |
hemslo/seven-in-seven
|
haskell/day2/day2.hs
|
mit
|
qsort (p:xs) = (qsort [x | x <- xs, x < p]) ++ [p] ++ (qsort [x | x <- xs, x >= p])
| 83
|
qsort (p:xs) = (qsort [x | x <- xs, x < p]) ++ [p] ++ (qsort [x | x <- xs, x >= p])
| 83
|
qsort (p:xs) = (qsort [x | x <- xs, x < p]) ++ [p] ++ (qsort [x | x <- xs, x >= p])
| 83
| false
| false
| 0
| 11
| 23
| 77
| 40
| 37
| null | null |
juodaspaulius/clafer
|
src/Language/Clafer/Intermediate/Desugarer.hs
|
mit
|
sugarGCard :: Maybe IGCard -> GCard
sugarGCard x = case x of
Nothing -> GCardEmpty noSpan
Just (IGCard _ (i, ex)) -> GCardInterval noSpan $ NCard noSpan (PosInteger ((0, 0), show i)) (sugarExInteger ex)
| 206
|
sugarGCard :: Maybe IGCard -> GCard
sugarGCard x = case x of
Nothing -> GCardEmpty noSpan
Just (IGCard _ (i, ex)) -> GCardInterval noSpan $ NCard noSpan (PosInteger ((0, 0), show i)) (sugarExInteger ex)
| 206
|
sugarGCard x = case x of
Nothing -> GCardEmpty noSpan
Just (IGCard _ (i, ex)) -> GCardInterval noSpan $ NCard noSpan (PosInteger ((0, 0), show i)) (sugarExInteger ex)
| 170
| false
| true
| 0
| 13
| 37
| 103
| 50
| 53
| null | null |
PipocaQuemada/ermine
|
src/Ermine/Syntax/Pattern.hs
|
bsd-2-clause
|
patternHead f (StrictP p) = patternHead f p
| 45
|
patternHead f (StrictP p) = patternHead f p
| 45
|
patternHead f (StrictP p) = patternHead f p
| 45
| false
| false
| 0
| 7
| 9
| 22
| 10
| 12
| null | null |
keithodulaigh/Hets
|
HasCASL/ClassAna.hs
|
gpl-2.0
|
cyclicClassId :: ClassMap -> Id -> Kind -> Bool
cyclicClassId cm ci k = case k of
FunKind _ k1 k2 _ -> cyclicClassId cm ci k1 || cyclicClassId cm ci k2
ClassKind cj -> cj /= universeId &&
(cj == ci || not (Set.null $ Set.filter (cyclicClassId cm ci)
$ classKinds $ Map.findWithDefault (error "cyclicClassId") cj cm))
-- * subkinding
-- | keep only minimal elements according to 'lesserKind'
| 416
|
cyclicClassId :: ClassMap -> Id -> Kind -> Bool
cyclicClassId cm ci k = case k of
FunKind _ k1 k2 _ -> cyclicClassId cm ci k1 || cyclicClassId cm ci k2
ClassKind cj -> cj /= universeId &&
(cj == ci || not (Set.null $ Set.filter (cyclicClassId cm ci)
$ classKinds $ Map.findWithDefault (error "cyclicClassId") cj cm))
-- * subkinding
-- | keep only minimal elements according to 'lesserKind'
| 416
|
cyclicClassId cm ci k = case k of
FunKind _ k1 k2 _ -> cyclicClassId cm ci k1 || cyclicClassId cm ci k2
ClassKind cj -> cj /= universeId &&
(cj == ci || not (Set.null $ Set.filter (cyclicClassId cm ci)
$ classKinds $ Map.findWithDefault (error "cyclicClassId") cj cm))
-- * subkinding
-- | keep only minimal elements according to 'lesserKind'
| 368
| false
| true
| 4
| 15
| 95
| 133
| 68
| 65
| null | null |
pjones/xmonad-test
|
vendor/xmonad-contrib/XMonad/Layout/WindowNavigation.hs
|
bsd-2-clause
|
center :: Rectangle -> Point
center (Rectangle x y w h) = P (fromIntegral x + fromIntegral w/2) (fromIntegral y + fromIntegral h/2)
| 132
|
center :: Rectangle -> Point
center (Rectangle x y w h) = P (fromIntegral x + fromIntegral w/2) (fromIntegral y + fromIntegral h/2)
| 132
|
center (Rectangle x y w h) = P (fromIntegral x + fromIntegral w/2) (fromIntegral y + fromIntegral h/2)
| 103
| false
| true
| 0
| 9
| 23
| 69
| 33
| 36
| null | null |
triplepointfive/Youtan
|
examples/Parser/JSON.hs
|
bsd-3-clause
|
isNum, isStr :: Token -> Bool
isNum s = case s of
Number _ -> True
_ -> False
| 81
|
isNum, isStr :: Token -> Bool
isNum s = case s of
Number _ -> True
_ -> False
| 81
|
isNum s = case s of
Number _ -> True
_ -> False
| 51
| false
| true
| 2
| 8
| 22
| 49
| 21
| 28
| null | null |
brendanhay/gogol
|
gogol-bigquerydatatransfer/gen/Network/Google/Resource/BigQueryDataTransfer/Projects/Locations/DataSources/List.hs
|
mpl-2.0
|
-- | Legacy upload protocol for media (e.g. \"media\", \"multipart\").
pldslUploadType :: Lens' ProjectsLocationsDataSourcesList (Maybe Text)
pldslUploadType
= lens _pldslUploadType
(\ s a -> s{_pldslUploadType = a})
| 224
|
pldslUploadType :: Lens' ProjectsLocationsDataSourcesList (Maybe Text)
pldslUploadType
= lens _pldslUploadType
(\ s a -> s{_pldslUploadType = a})
| 153
|
pldslUploadType
= lens _pldslUploadType
(\ s a -> s{_pldslUploadType = a})
| 82
| true
| true
| 0
| 9
| 34
| 48
| 25
| 23
| null | null |
CloudI/CloudI
|
src/api/haskell/external/binary-0.8.7.0/benchmarks/Benchmark.hs
|
mit
|
getWord64N8Host = loop 0
where loop s n | s `seq` n `seq` False = undefined
loop s 0 = return s
loop s n = do
s0 <- getWord64host
s1 <- getWord64host
s2 <- getWord64host
s3 <- getWord64host
s4 <- getWord64host
s5 <- getWord64host
s6 <- getWord64host
s7 <- getWord64host
loop (s+s0+s1+s2+s3+s4+s5+s6+s7) (n-8)
| 416
|
getWord64N8Host = loop 0
where loop s n | s `seq` n `seq` False = undefined
loop s 0 = return s
loop s n = do
s0 <- getWord64host
s1 <- getWord64host
s2 <- getWord64host
s3 <- getWord64host
s4 <- getWord64host
s5 <- getWord64host
s6 <- getWord64host
s7 <- getWord64host
loop (s+s0+s1+s2+s3+s4+s5+s6+s7) (n-8)
| 416
|
getWord64N8Host = loop 0
where loop s n | s `seq` n `seq` False = undefined
loop s 0 = return s
loop s n = do
s0 <- getWord64host
s1 <- getWord64host
s2 <- getWord64host
s3 <- getWord64host
s4 <- getWord64host
s5 <- getWord64host
s6 <- getWord64host
s7 <- getWord64host
loop (s+s0+s1+s2+s3+s4+s5+s6+s7) (n-8)
| 416
| false
| false
| 3
| 17
| 161
| 185
| 81
| 104
| null | null |
ghc-android/ghc
|
testsuite/tests/ghci/should_run/ghcirun004.hs
|
bsd-3-clause
|
3019 = 3018
| 11
|
3019 = 3018
| 11
|
3019 = 3018
| 11
| false
| false
| 1
| 5
| 2
| 10
| 3
| 7
| null | null |
burz/Feval
|
FVL/Type.hs
|
mit
|
choose n e (FVar n', FArrow x y) (FVar n'') = if n' == n
then FArrow (substitute x e) (substitute y e)
else FVar n''
| 124
|
choose n e (FVar n', FArrow x y) (FVar n'') = if n' == n
then FArrow (substitute x e) (substitute y e)
else FVar n''
| 124
|
choose n e (FVar n', FArrow x y) (FVar n'') = if n' == n
then FArrow (substitute x e) (substitute y e)
else FVar n''
| 124
| false
| false
| 1
| 9
| 33
| 77
| 35
| 42
| null | null |
sgillespie/ghc
|
testsuite/mk/ghc-config.hs
|
bsd-3-clause
|
fixTopdir t (c:s) = c : fixTopdir t s
| 37
|
fixTopdir t (c:s) = c : fixTopdir t s
| 37
|
fixTopdir t (c:s) = c : fixTopdir t s
| 37
| false
| false
| 0
| 7
| 8
| 27
| 13
| 14
| null | null |
ancientlanguage/haskell-analysis
|
prepare/src/Prepare/Decompose.hs
|
mit
|
decomposeChar '\x0400' = "\x0415\x0300"
| 39
|
decomposeChar '\x0400' = "\x0415\x0300"
| 39
|
decomposeChar '\x0400' = "\x0415\x0300"
| 39
| false
| false
| 1
| 5
| 3
| 13
| 4
| 9
| null | null |
mathfur/Treemap-Directory-Viewer
|
src/Types.hs
|
bsd-3-clause
|
floatAlpha :: Color -> Float
floatAlpha color = (fromIntegral $ a color) / 255.0
| 80
|
floatAlpha :: Color -> Float
floatAlpha color = (fromIntegral $ a color) / 255.0
| 80
|
floatAlpha color = (fromIntegral $ a color) / 255.0
| 51
| false
| true
| 0
| 8
| 13
| 32
| 16
| 16
| null | null |
byorgey/Idris-dev
|
src/Idris/REPL.hs
|
bsd-3-clause
|
process fn (Defn n) = do i <- getIState
iputStrLn "Compiled patterns:\n"
iputStrLn $ show (lookupDef n (tt_ctxt i))
case lookupCtxt n (idris_patdefs i) of
[] -> return ()
[(d, _)] -> do iputStrLn "Original definiton:\n"
mapM_ (printCase i) d
case lookupTotal n (tt_ctxt i) of
[t] -> iputStrLn (showTotal t i)
_ -> return ()
where printCase i (_, lhs, rhs)
= do iputStrLn (showImp True (delab i lhs) ++ " = " ++
showImp True (delab i rhs))
| 739
|
process fn (Defn n) = do i <- getIState
iputStrLn "Compiled patterns:\n"
iputStrLn $ show (lookupDef n (tt_ctxt i))
case lookupCtxt n (idris_patdefs i) of
[] -> return ()
[(d, _)] -> do iputStrLn "Original definiton:\n"
mapM_ (printCase i) d
case lookupTotal n (tt_ctxt i) of
[t] -> iputStrLn (showTotal t i)
_ -> return ()
where printCase i (_, lhs, rhs)
= do iputStrLn (showImp True (delab i lhs) ++ " = " ++
showImp True (delab i rhs))
| 739
|
process fn (Defn n) = do i <- getIState
iputStrLn "Compiled patterns:\n"
iputStrLn $ show (lookupDef n (tt_ctxt i))
case lookupCtxt n (idris_patdefs i) of
[] -> return ()
[(d, _)] -> do iputStrLn "Original definiton:\n"
mapM_ (printCase i) d
case lookupTotal n (tt_ctxt i) of
[t] -> iputStrLn (showTotal t i)
_ -> return ()
where printCase i (_, lhs, rhs)
= do iputStrLn (showImp True (delab i lhs) ++ " = " ++
showImp True (delab i rhs))
| 739
| false
| false
| 0
| 14
| 380
| 233
| 110
| 123
| null | null |
Batou99/pivot_table
|
src/Lib.hs
|
bsd-3-clause
|
ratingsDimension:: Dimension
ratingsDimension = map Header [
"Alto",
"Medio",
"Bajo",
"Negativo"
]
| 108
|
ratingsDimension:: Dimension
ratingsDimension = map Header [
"Alto",
"Medio",
"Bajo",
"Negativo"
]
| 108
|
ratingsDimension = map Header [
"Alto",
"Medio",
"Bajo",
"Negativo"
]
| 79
| false
| true
| 0
| 6
| 21
| 28
| 16
| 12
| null | null |
chrisdone/ghc-server
|
src/GHC/Server/Model/Ghc.hs
|
bsd-3-clause
|
loadedImports :: [ModuleName] -> [String]
loadedImports = map (\m -> "import " <> moduleNameString m)
| 101
|
loadedImports :: [ModuleName] -> [String]
loadedImports = map (\m -> "import " <> moduleNameString m)
| 101
|
loadedImports = map (\m -> "import " <> moduleNameString m)
| 59
| false
| true
| 0
| 9
| 14
| 46
| 22
| 24
| null | null |
sdiehl/ghc
|
compiler/simplCore/SimplEnv.hs
|
bsd-3-clause
|
mkSimplEnv :: SimplMode -> SimplEnv
mkSimplEnv mode
= SimplEnv { seMode = mode
, seInScope = init_in_scope
, seTvSubst = emptyVarEnv
, seCvSubst = emptyVarEnv
, seIdSubst = emptyVarEnv }
| 240
|
mkSimplEnv :: SimplMode -> SimplEnv
mkSimplEnv mode
= SimplEnv { seMode = mode
, seInScope = init_in_scope
, seTvSubst = emptyVarEnv
, seCvSubst = emptyVarEnv
, seIdSubst = emptyVarEnv }
| 240
|
mkSimplEnv mode
= SimplEnv { seMode = mode
, seInScope = init_in_scope
, seTvSubst = emptyVarEnv
, seCvSubst = emptyVarEnv
, seIdSubst = emptyVarEnv }
| 204
| false
| true
| 0
| 6
| 83
| 50
| 30
| 20
| null | null |
BartAdv/Idris-dev
|
src/Idris/DSL.hs
|
bsd-3-clause
|
expandSugar dsl (PGoal fc r n sc)
= PGoal fc (expandSugar dsl r) n (expandSugar dsl sc)
| 91
|
expandSugar dsl (PGoal fc r n sc)
= PGoal fc (expandSugar dsl r) n (expandSugar dsl sc)
| 91
|
expandSugar dsl (PGoal fc r n sc)
= PGoal fc (expandSugar dsl r) n (expandSugar dsl sc)
| 91
| false
| false
| 0
| 7
| 20
| 48
| 23
| 25
| null | null |
mtolly/rhythm
|
src/Data/Rhythm/Status.hs
|
gpl-3.0
|
applyTime :: (NN.C t, NN.C u) => T t (t -> u) -> RTB.T t a -> RTB.T u a
applyTime (Stay f) rtb = RTB.mapTime f rtb
| 114
|
applyTime :: (NN.C t, NN.C u) => T t (t -> u) -> RTB.T t a -> RTB.T u a
applyTime (Stay f) rtb = RTB.mapTime f rtb
| 114
|
applyTime (Stay f) rtb = RTB.mapTime f rtb
| 42
| false
| true
| 0
| 9
| 27
| 82
| 40
| 42
| null | null |
kowey/GenI
|
src/NLP/GenI.hs
|
gpl-2.0
|
-- --------------------------------------------------------------------
-- Interface
-- Loading and parsing
-- --------------------------------------------------------------------
-- | We have one master function that loads all the files GenI is expected to
-- use. This just calls the sub-loaders below, some of which are exported
-- for use by the graphical interface. The master function also makes sure
-- to complain intelligently if some of the required files are missing.
loadEverything :: ProgStateRef -> CustomSem sem -> IO()
loadEverything pstRef wrangler = do
pst <- readIORef pstRef
--
let isMissing f = not $ hasFlag f pst
-- grammar type
grammarType = getGrammarType (flags pst)
isNotPreanchored = grammarType /= PreAnchored
isNotPrecompiled = grammarType /= PreCompiled
useTestSuite = isMissing FromStdinFlg
&& isMissing NoLoadTestSuiteFlg
-- display
let errormsg =
concat $ intersperse ", " [ msg | (con, msg) <- errorlst, con ]
errorlst =
[ (isMissing RootFeatureFlg,
"a root feature [empty feature is fine if you are not using polarity filtering]")
, (isNotPrecompiled && isMissing MacrosFlg,
"a tree file")
, (isNotPreanchored && isMissing LexiconFlg,
"a lexicon file")
, (useTestSuite && isMissing TestSuiteFlg,
"a test suite") ]
unless (null errormsg) $ fail ("Please specify: " ++ errormsg)
-- we only have to read in grammars from the simple format
case grammarType of
PreAnchored -> return ()
PreCompiled -> return ()
_ -> loadGeniMacros pstRef >> return ()
-- we don't have to read in the lexicon if it's already pre-anchored
when isNotPreanchored $ loadLexicon pstRef >> return ()
-- in any case, we have to...
loadMorphInfo pstRef
when useTestSuite $ loadTestSuite pst wrangler >> return ()
-- the trace filter file
loadTraces pstRef
-- OT ranking
loadRanking pstRef
-- | The file loading functions all work the same way: we load the file,
-- and try to parse it. If this doesn't work, we just fail in IO, and
-- GenI dies. If we succeed, we update the program state passed in as
-- an IORef.
| 2,329
|
loadEverything :: ProgStateRef -> CustomSem sem -> IO()
loadEverything pstRef wrangler = do
pst <- readIORef pstRef
--
let isMissing f = not $ hasFlag f pst
-- grammar type
grammarType = getGrammarType (flags pst)
isNotPreanchored = grammarType /= PreAnchored
isNotPrecompiled = grammarType /= PreCompiled
useTestSuite = isMissing FromStdinFlg
&& isMissing NoLoadTestSuiteFlg
-- display
let errormsg =
concat $ intersperse ", " [ msg | (con, msg) <- errorlst, con ]
errorlst =
[ (isMissing RootFeatureFlg,
"a root feature [empty feature is fine if you are not using polarity filtering]")
, (isNotPrecompiled && isMissing MacrosFlg,
"a tree file")
, (isNotPreanchored && isMissing LexiconFlg,
"a lexicon file")
, (useTestSuite && isMissing TestSuiteFlg,
"a test suite") ]
unless (null errormsg) $ fail ("Please specify: " ++ errormsg)
-- we only have to read in grammars from the simple format
case grammarType of
PreAnchored -> return ()
PreCompiled -> return ()
_ -> loadGeniMacros pstRef >> return ()
-- we don't have to read in the lexicon if it's already pre-anchored
when isNotPreanchored $ loadLexicon pstRef >> return ()
-- in any case, we have to...
loadMorphInfo pstRef
when useTestSuite $ loadTestSuite pst wrangler >> return ()
-- the trace filter file
loadTraces pstRef
-- OT ranking
loadRanking pstRef
-- | The file loading functions all work the same way: we load the file,
-- and try to parse it. If this doesn't work, we just fail in IO, and
-- GenI dies. If we succeed, we update the program state passed in as
-- an IORef.
| 1,841
|
loadEverything pstRef wrangler = do
pst <- readIORef pstRef
--
let isMissing f = not $ hasFlag f pst
-- grammar type
grammarType = getGrammarType (flags pst)
isNotPreanchored = grammarType /= PreAnchored
isNotPrecompiled = grammarType /= PreCompiled
useTestSuite = isMissing FromStdinFlg
&& isMissing NoLoadTestSuiteFlg
-- display
let errormsg =
concat $ intersperse ", " [ msg | (con, msg) <- errorlst, con ]
errorlst =
[ (isMissing RootFeatureFlg,
"a root feature [empty feature is fine if you are not using polarity filtering]")
, (isNotPrecompiled && isMissing MacrosFlg,
"a tree file")
, (isNotPreanchored && isMissing LexiconFlg,
"a lexicon file")
, (useTestSuite && isMissing TestSuiteFlg,
"a test suite") ]
unless (null errormsg) $ fail ("Please specify: " ++ errormsg)
-- we only have to read in grammars from the simple format
case grammarType of
PreAnchored -> return ()
PreCompiled -> return ()
_ -> loadGeniMacros pstRef >> return ()
-- we don't have to read in the lexicon if it's already pre-anchored
when isNotPreanchored $ loadLexicon pstRef >> return ()
-- in any case, we have to...
loadMorphInfo pstRef
when useTestSuite $ loadTestSuite pst wrangler >> return ()
-- the trace filter file
loadTraces pstRef
-- OT ranking
loadRanking pstRef
-- | The file loading functions all work the same way: we load the file,
-- and try to parse it. If this doesn't work, we just fail in IO, and
-- GenI dies. If we succeed, we update the program state passed in as
-- an IORef.
| 1,785
| true
| true
| 0
| 16
| 627
| 376
| 188
| 188
| null | null |
karamellpelle/grid
|
source/Game/LevelPuzzle/Helpers/Make.hs
|
gpl-3.0
|
levelpuzzleSetLevelIx :: LevelPuzzleWorld -> UInt -> MEnv' LevelPuzzleWorld
levelpuzzleSetLevelIx lvl ix = do
off <- io $ readBinary' (rLevelOffset ix) (levelpuzzleFile lvl)
if off == levelpuzzleFileSize lvl
-- complete
then do
return lvl
{
levelpuzzleIsComplete = True,
levelpuzzleLevelIx = ix
}
else do
-- parse file
(level, ixrooms, off') <- io $ readBinaryAt' rLevel (levelpuzzleFile lvl) off
-- make
destroyContent $ levelpuzzleContent lvl
destroyContent $ levelpuzzleOldContent lvl
cnt <- makeContentEmpty
bonusAdd <- countBonusAdd (map snd ixrooms)
cnt' <- makeContentCamera (levelSegments level + bonusAdd) ixrooms $
makeCameraView valueLevelPuzzleGridView
return lvl
{
levelpuzzleLevelIx = ix,
levelpuzzleLevel = level,
levelpuzzleOldContent = cnt,
levelpuzzleContent = cnt',
levelpuzzleRefOldContent = refOldContent lvl,
levelpuzzleRefSpace = refSpace lvl,
levelpuzzleIsComplete = False,
levelpuzzleEvents = [],
levelpuzzleSegmentsCount = levelSegments level,
levelpuzzleFileDefOffset = off,
levelpuzzleFileDefNextOffset = off'
}
--------------------------------------------------------------------------------
--
| 1,555
|
levelpuzzleSetLevelIx :: LevelPuzzleWorld -> UInt -> MEnv' LevelPuzzleWorld
levelpuzzleSetLevelIx lvl ix = do
off <- io $ readBinary' (rLevelOffset ix) (levelpuzzleFile lvl)
if off == levelpuzzleFileSize lvl
-- complete
then do
return lvl
{
levelpuzzleIsComplete = True,
levelpuzzleLevelIx = ix
}
else do
-- parse file
(level, ixrooms, off') <- io $ readBinaryAt' rLevel (levelpuzzleFile lvl) off
-- make
destroyContent $ levelpuzzleContent lvl
destroyContent $ levelpuzzleOldContent lvl
cnt <- makeContentEmpty
bonusAdd <- countBonusAdd (map snd ixrooms)
cnt' <- makeContentCamera (levelSegments level + bonusAdd) ixrooms $
makeCameraView valueLevelPuzzleGridView
return lvl
{
levelpuzzleLevelIx = ix,
levelpuzzleLevel = level,
levelpuzzleOldContent = cnt,
levelpuzzleContent = cnt',
levelpuzzleRefOldContent = refOldContent lvl,
levelpuzzleRefSpace = refSpace lvl,
levelpuzzleIsComplete = False,
levelpuzzleEvents = [],
levelpuzzleSegmentsCount = levelSegments level,
levelpuzzleFileDefOffset = off,
levelpuzzleFileDefNextOffset = off'
}
--------------------------------------------------------------------------------
--
| 1,555
|
levelpuzzleSetLevelIx lvl ix = do
off <- io $ readBinary' (rLevelOffset ix) (levelpuzzleFile lvl)
if off == levelpuzzleFileSize lvl
-- complete
then do
return lvl
{
levelpuzzleIsComplete = True,
levelpuzzleLevelIx = ix
}
else do
-- parse file
(level, ixrooms, off') <- io $ readBinaryAt' rLevel (levelpuzzleFile lvl) off
-- make
destroyContent $ levelpuzzleContent lvl
destroyContent $ levelpuzzleOldContent lvl
cnt <- makeContentEmpty
bonusAdd <- countBonusAdd (map snd ixrooms)
cnt' <- makeContentCamera (levelSegments level + bonusAdd) ixrooms $
makeCameraView valueLevelPuzzleGridView
return lvl
{
levelpuzzleLevelIx = ix,
levelpuzzleLevel = level,
levelpuzzleOldContent = cnt,
levelpuzzleContent = cnt',
levelpuzzleRefOldContent = refOldContent lvl,
levelpuzzleRefSpace = refSpace lvl,
levelpuzzleIsComplete = False,
levelpuzzleEvents = [],
levelpuzzleSegmentsCount = levelSegments level,
levelpuzzleFileDefOffset = off,
levelpuzzleFileDefNextOffset = off'
}
--------------------------------------------------------------------------------
--
| 1,479
| false
| true
| 0
| 15
| 560
| 290
| 151
| 139
| null | null |
HJvT/hdirect
|
src/Parser.hs
|
bsd-3-clause
|
action_96 x = happyTcHack x happyReduce_310
| 43
|
action_96 x = happyTcHack x happyReduce_310
| 43
|
action_96 x = happyTcHack x happyReduce_310
| 43
| false
| false
| 0
| 5
| 5
| 14
| 6
| 8
| null | null |
adnelson/nix-eval
|
src/Nix/Evaluator/Builtins/NativeFunctions.hs
|
mit
|
-- | Get the type of a value as a string.
builtin_typeOf :: Monad m => WHNFValue m -> LazyValue m
builtin_typeOf v = VString . typeToString <$> typeOf v
| 152
|
builtin_typeOf :: Monad m => WHNFValue m -> LazyValue m
builtin_typeOf v = VString . typeToString <$> typeOf v
| 110
|
builtin_typeOf v = VString . typeToString <$> typeOf v
| 54
| true
| true
| 0
| 7
| 29
| 43
| 20
| 23
| null | null |
gentoo-haskell/haskell-updater
|
Distribution/Gentoo/PkgManager.hs
|
gpl-3.0
|
-- Can't tell how flags would work.
flagRep (InvalidPM _) = undefined
| 69
|
flagRep (InvalidPM _) = undefined
| 33
|
flagRep (InvalidPM _) = undefined
| 33
| true
| false
| 0
| 7
| 11
| 16
| 8
| 8
| null | null |
DavidAlphaFox/ghc
|
libraries/Cabal/Cabal/Distribution/Simple/Build.hs
|
bsd-3-clause
|
-- | Initialize a new package db file for libraries defined
-- internally to the package.
createInternalPackageDB :: Verbosity -> LocalBuildInfo -> FilePath
-> IO PackageDB
createInternalPackageDB verbosity lbi distPref = do
case compilerFlavor (compiler lbi) of
GHC -> createWith $ GHC.hcPkgInfo (withPrograms lbi)
GHCJS -> createWith $ GHCJS.hcPkgInfo (withPrograms lbi)
LHC -> createWith $ LHC.hcPkgInfo (withPrograms lbi)
_ -> return packageDB
where
dbPath = distPref </> "package.conf.inplace"
packageDB = SpecificPackageDB dbPath
createWith hpi = do
dir_exists <- doesDirectoryExist dbPath
if dir_exists
then removeDirectoryRecursive dbPath
else do file_exists <- doesFileExist dbPath
when file_exists $ removeFile dbPath
if HcPkg.useSingleFileDb hpi
then writeFile dbPath "[]"
else HcPkg.init hpi verbosity dbPath
return packageDB
| 1,023
|
createInternalPackageDB :: Verbosity -> LocalBuildInfo -> FilePath
-> IO PackageDB
createInternalPackageDB verbosity lbi distPref = do
case compilerFlavor (compiler lbi) of
GHC -> createWith $ GHC.hcPkgInfo (withPrograms lbi)
GHCJS -> createWith $ GHCJS.hcPkgInfo (withPrograms lbi)
LHC -> createWith $ LHC.hcPkgInfo (withPrograms lbi)
_ -> return packageDB
where
dbPath = distPref </> "package.conf.inplace"
packageDB = SpecificPackageDB dbPath
createWith hpi = do
dir_exists <- doesDirectoryExist dbPath
if dir_exists
then removeDirectoryRecursive dbPath
else do file_exists <- doesFileExist dbPath
when file_exists $ removeFile dbPath
if HcPkg.useSingleFileDb hpi
then writeFile dbPath "[]"
else HcPkg.init hpi verbosity dbPath
return packageDB
| 933
|
createInternalPackageDB verbosity lbi distPref = do
case compilerFlavor (compiler lbi) of
GHC -> createWith $ GHC.hcPkgInfo (withPrograms lbi)
GHCJS -> createWith $ GHCJS.hcPkgInfo (withPrograms lbi)
LHC -> createWith $ LHC.hcPkgInfo (withPrograms lbi)
_ -> return packageDB
where
dbPath = distPref </> "package.conf.inplace"
packageDB = SpecificPackageDB dbPath
createWith hpi = do
dir_exists <- doesDirectoryExist dbPath
if dir_exists
then removeDirectoryRecursive dbPath
else do file_exists <- doesFileExist dbPath
when file_exists $ removeFile dbPath
if HcPkg.useSingleFileDb hpi
then writeFile dbPath "[]"
else HcPkg.init hpi verbosity dbPath
return packageDB
| 826
| true
| true
| 2
| 13
| 295
| 235
| 109
| 126
| null | null |
ilyasergey/GHC-XAppFix
|
compiler/main/DynFlags.hs
|
bsd-3-clause
|
disableGlasgowExts :: DynP ()
disableGlasgowExts = do unSetDynFlag Opt_PrintExplicitForalls
mapM_ unSetExtensionFlag glasgowExtsFlags
| 157
|
disableGlasgowExts :: DynP ()
disableGlasgowExts = do unSetDynFlag Opt_PrintExplicitForalls
mapM_ unSetExtensionFlag glasgowExtsFlags
| 157
|
disableGlasgowExts = do unSetDynFlag Opt_PrintExplicitForalls
mapM_ unSetExtensionFlag glasgowExtsFlags
| 127
| false
| true
| 1
| 8
| 35
| 34
| 13
| 21
| null | null |
mrordinaire/upenn-haskell
|
src/HW07.hs
|
mit
|
-- Exercise 12 ----------------------------------------
getCards :: Int -> Deck -> Maybe ([Card], Deck)
getCards n deck | n == 0 = Just ([], deck)
| otherwise = do
(card, remaining) <- nextCard deck
(cards, remainingDeck) <- getCards (n-1) remaining
return $ (card : cards, remainingDeck)
-- Exercise 13 ----------------------------------------
| 371
|
getCards :: Int -> Deck -> Maybe ([Card], Deck)
getCards n deck | n == 0 = Just ([], deck)
| otherwise = do
(card, remaining) <- nextCard deck
(cards, remainingDeck) <- getCards (n-1) remaining
return $ (card : cards, remainingDeck)
-- Exercise 13 ----------------------------------------
| 314
|
getCards n deck | n == 0 = Just ([], deck)
| otherwise = do
(card, remaining) <- nextCard deck
(cards, remainingDeck) <- getCards (n-1) remaining
return $ (card : cards, remainingDeck)
-- Exercise 13 ----------------------------------------
| 266
| true
| true
| 1
| 10
| 75
| 129
| 66
| 63
| null | null |
spinda/liquidhaskell
|
tests/gsoc15/unknown/pos/OrdList.hs
|
bsd-3-clause
|
--LIQUID this definition requires `foldr` with abstract refinements, which isn't
--LIQUID in our standard set of specs
-- concatOL aas = foldr appOL None aas
concatOL [] = None
| 182
|
concatOL [] = None
| 24
|
concatOL [] = None
| 24
| true
| false
| 0
| 6
| 34
| 14
| 8
| 6
| null | null |
uduki/hsQt
|
Qtc/ClassTypes/Gui.hs
|
bsd-2-clause
|
qCast_QAbstractProxyModel :: Object a -> IO (QAbstractProxyModel ())
qCast_QAbstractProxyModel _qobj
= return (objectCast _qobj)
| 130
|
qCast_QAbstractProxyModel :: Object a -> IO (QAbstractProxyModel ())
qCast_QAbstractProxyModel _qobj
= return (objectCast _qobj)
| 130
|
qCast_QAbstractProxyModel _qobj
= return (objectCast _qobj)
| 61
| false
| true
| 0
| 9
| 15
| 41
| 19
| 22
| null | null |
MichielDerhaeg/stack
|
src/Stack/Types/Config.hs
|
bsd-3-clause
|
packageDatabaseLocal :: (MonadThrow m, MonadReader env m, HasEnvConfig env) => m (Path Abs Dir)
packageDatabaseLocal = do
root <- installationRootLocal
return $ root </> $(mkRelDir "pkgdb")
-- | Extra package databases
| 227
|
packageDatabaseLocal :: (MonadThrow m, MonadReader env m, HasEnvConfig env) => m (Path Abs Dir)
packageDatabaseLocal = do
root <- installationRootLocal
return $ root </> $(mkRelDir "pkgdb")
-- | Extra package databases
| 227
|
packageDatabaseLocal = do
root <- installationRootLocal
return $ root </> $(mkRelDir "pkgdb")
-- | Extra package databases
| 131
| false
| true
| 0
| 11
| 39
| 77
| 36
| 41
| null | null |
BigEndian/tasks
|
src/Tasks/Task.hs
|
gpl-2.0
|
taskPriority = mdPriority . taskMetadata
| 40
|
taskPriority = mdPriority . taskMetadata
| 40
|
taskPriority = mdPriority . taskMetadata
| 40
| false
| false
| 2
| 5
| 4
| 15
| 5
| 10
| null | null |
VictorLoren/quantum-computer-haskell
|
QuantumComputer/Gates.hs
|
mit
|
-- apply Z gate to qbit after measurement
zgateM :: Int -> Int -> Qstate -> Qstate
zgateM target control state = gateAfterMeas (Zgate target) control state
| 155
|
zgateM :: Int -> Int -> Qstate -> Qstate
zgateM target control state = gateAfterMeas (Zgate target) control state
| 113
|
zgateM target control state = gateAfterMeas (Zgate target) control state
| 72
| true
| true
| 0
| 7
| 26
| 48
| 23
| 25
| null | null |
oldmanmike/ghc
|
utils/genapply/Main.hs
|
bsd-3-clause
|
findAvailableReg N (vreg:vregs, fregs, dregs, lregs) =
Just (vreg, (vregs,fregs,dregs,lregs))
| 95
|
findAvailableReg N (vreg:vregs, fregs, dregs, lregs) =
Just (vreg, (vregs,fregs,dregs,lregs))
| 95
|
findAvailableReg N (vreg:vregs, fregs, dregs, lregs) =
Just (vreg, (vregs,fregs,dregs,lregs))
| 95
| false
| false
| 0
| 7
| 11
| 48
| 28
| 20
| null | null |
Hrothen/scripts
|
src/convertPNG/ConvertImage.hs
|
mit
|
imageToList :: (PixelRGBA8 -> String) -> DynamicImage -> Either String ImageString
imageToList dict (ImageRGBA8 img) = Right $ convertVector (imageData img)
where convertVector = csvify (width) . (map ((++ ",") . dict)) . (toPixelList . V.toList)
width = imageWidth img
-- convert list of Word8 values into a list of RGBA8 Pixels
toPixelList [] = []
toPixelList (a:b:c:d:pixels) = (PixelRGBA8 a b c d) : toPixelList pixels
--catch non RGBA8 images and give an error message
| 508
|
imageToList :: (PixelRGBA8 -> String) -> DynamicImage -> Either String ImageString
imageToList dict (ImageRGBA8 img) = Right $ convertVector (imageData img)
where convertVector = csvify (width) . (map ((++ ",") . dict)) . (toPixelList . V.toList)
width = imageWidth img
-- convert list of Word8 values into a list of RGBA8 Pixels
toPixelList [] = []
toPixelList (a:b:c:d:pixels) = (PixelRGBA8 a b c d) : toPixelList pixels
--catch non RGBA8 images and give an error message
| 508
|
imageToList dict (ImageRGBA8 img) = Right $ convertVector (imageData img)
where convertVector = csvify (width) . (map ((++ ",") . dict)) . (toPixelList . V.toList)
width = imageWidth img
-- convert list of Word8 values into a list of RGBA8 Pixels
toPixelList [] = []
toPixelList (a:b:c:d:pixels) = (PixelRGBA8 a b c d) : toPixelList pixels
--catch non RGBA8 images and give an error message
| 425
| false
| true
| 3
| 11
| 110
| 186
| 89
| 97
| null | null |
sordina/bramble
|
src/Bramble/RAML.hs
|
mit
|
emptyLookup :: forall k a. M.Map k a
emptyLookup = M.empty
| 58
|
emptyLookup :: forall k a. M.Map k a
emptyLookup = M.empty
| 58
|
emptyLookup = M.empty
| 21
| false
| true
| 0
| 7
| 10
| 26
| 14
| 12
| null | null |
YoshikuniJujo/sasl
|
src/Network/Sasl/ScramSha1/Hmac.hs
|
bsd-3-clause
|
ipad, opad :: [Word8]
ipad = repeat 0x36
| 40
|
ipad, opad :: [Word8]
ipad = repeat 0x36
| 40
|
ipad = repeat 0x36
| 18
| false
| true
| 0
| 5
| 7
| 19
| 11
| 8
| null | null |
MaxGabriel/yesod
|
yesod-form/Yesod/Form/Bootstrap3.hs
|
mit
|
toOffset (ColSm columns) = "col-sm-offset-" ++ show columns
| 59
|
toOffset (ColSm columns) = "col-sm-offset-" ++ show columns
| 59
|
toOffset (ColSm columns) = "col-sm-offset-" ++ show columns
| 59
| false
| false
| 0
| 7
| 7
| 22
| 10
| 12
| null | null |
brendanhay/gogol
|
gogol-dfareporting/gen/Network/Google/DFAReporting/Types/Product.hs
|
mpl-2.0
|
-- | Name of the seller organization.
oSellerOrganizationName :: Lens' Order (Maybe Text)
oSellerOrganizationName
= lens _oSellerOrganizationName
(\ s a -> s{_oSellerOrganizationName = a})
| 196
|
oSellerOrganizationName :: Lens' Order (Maybe Text)
oSellerOrganizationName
= lens _oSellerOrganizationName
(\ s a -> s{_oSellerOrganizationName = a})
| 158
|
oSellerOrganizationName
= lens _oSellerOrganizationName
(\ s a -> s{_oSellerOrganizationName = a})
| 106
| true
| true
| 0
| 9
| 31
| 46
| 25
| 21
| null | null |
nushio3/ghc
|
compiler/prelude/PrelNames.hs
|
bsd-3-clause
|
eitherTyConKey :: Unique
eitherTyConKey = mkPreludeTyConUnique 84
| 90
|
eitherTyConKey :: Unique
eitherTyConKey = mkPreludeTyConUnique 84
| 90
|
eitherTyConKey = mkPreludeTyConUnique 84
| 65
| false
| true
| 1
| 5
| 31
| 17
| 7
| 10
| null | null |
facebookincubator/duckling
|
Duckling/Time/PT/Corpus.hs
|
bsd-3-clause
|
corpus :: Corpus
corpus = (testContext {locale = makeLocale PT Nothing}, testOptions, allExamples)
| 98
|
corpus :: Corpus
corpus = (testContext {locale = makeLocale PT Nothing}, testOptions, allExamples)
| 98
|
corpus = (testContext {locale = makeLocale PT Nothing}, testOptions, allExamples)
| 81
| false
| true
| 0
| 9
| 12
| 40
| 20
| 20
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.