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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mrkkrp/stack
|
src/Stack/Docker/GlobalDB.hs
|
bsd-3-clause
|
withGlobalDB :: forall a. Config -> SqlPersistT (NoLoggingT (ResourceT IO)) a -> IO a
withGlobalDB config action =
do let db = dockerDatabasePath (configDocker config)
ensureDir (parent db)
runSqlite (T.pack (toFilePath db))
(do _ <- runMigrationSilent migrateTables
action)
`catch` \ex -> do
let str = show ex
str' = fromMaybe str $ stripPrefix "user error (" $
fromMaybe str $ stripSuffix ")" str
if "ErrorReadOnly" `isInfixOf` str
then throwString $ str' ++
" This likely indicates that your DB file, " ++
toFilePath db ++ ", has incorrect permissions or ownership."
else throwIO (ex :: IOException)
-- | Date and project path where Docker image hash last used.
| 863
|
withGlobalDB :: forall a. Config -> SqlPersistT (NoLoggingT (ResourceT IO)) a -> IO a
withGlobalDB config action =
do let db = dockerDatabasePath (configDocker config)
ensureDir (parent db)
runSqlite (T.pack (toFilePath db))
(do _ <- runMigrationSilent migrateTables
action)
`catch` \ex -> do
let str = show ex
str' = fromMaybe str $ stripPrefix "user error (" $
fromMaybe str $ stripSuffix ")" str
if "ErrorReadOnly" `isInfixOf` str
then throwString $ str' ++
" This likely indicates that your DB file, " ++
toFilePath db ++ ", has incorrect permissions or ownership."
else throwIO (ex :: IOException)
-- | Date and project path where Docker image hash last used.
| 863
|
withGlobalDB config action =
do let db = dockerDatabasePath (configDocker config)
ensureDir (parent db)
runSqlite (T.pack (toFilePath db))
(do _ <- runMigrationSilent migrateTables
action)
`catch` \ex -> do
let str = show ex
str' = fromMaybe str $ stripPrefix "user error (" $
fromMaybe str $ stripSuffix ")" str
if "ErrorReadOnly" `isInfixOf` str
then throwString $ str' ++
" This likely indicates that your DB file, " ++
toFilePath db ++ ", has incorrect permissions or ownership."
else throwIO (ex :: IOException)
-- | Date and project path where Docker image hash last used.
| 777
| false
| true
| 0
| 18
| 306
| 222
| 106
| 116
| null | null |
tomahawkins/atom
|
Language/Atom/Language.hs
|
bsd-3-clause
|
-- | Local float variable declaration.
float :: Name -> Float -> Atom (V Float)
float = var
| 91
|
float :: Name -> Float -> Atom (V Float)
float = var
| 52
|
float = var
| 11
| true
| true
| 0
| 9
| 17
| 29
| 15
| 14
| null | null |
laanwj/Purecoin
|
Purecoin/Core/Signature.hs
|
mit
|
makeHashType :: HashTypeView -> HashType
makeHashType (HashTypeView hk acp) | acp = HashType (setBit (go hk) 7)
| otherwise = HashType (go hk)
where
go SIGHASH_ALL = 1
go SIGHASH_NONE = 2
go SIGHASH_SINGLE = 3
| 251
|
makeHashType :: HashTypeView -> HashType
makeHashType (HashTypeView hk acp) | acp = HashType (setBit (go hk) 7)
| otherwise = HashType (go hk)
where
go SIGHASH_ALL = 1
go SIGHASH_NONE = 2
go SIGHASH_SINGLE = 3
| 251
|
makeHashType (HashTypeView hk acp) | acp = HashType (setBit (go hk) 7)
| otherwise = HashType (go hk)
where
go SIGHASH_ALL = 1
go SIGHASH_NONE = 2
go SIGHASH_SINGLE = 3
| 210
| false
| true
| 2
| 10
| 77
| 94
| 44
| 50
| null | null |
CarstenKoenig/AdventOfCode2016
|
Day12/Main.hs
|
mit
|
getRegister RegD = regD
| 23
|
getRegister RegD = regD
| 23
|
getRegister RegD = regD
| 23
| false
| false
| 0
| 5
| 3
| 9
| 4
| 5
| null | null |
bordaigorl/jamesbound
|
src/Frontend.hs
|
gpl-2.0
|
getWriterOrOut' _ (Just "-") = return ($ stdout)
| 51
|
getWriterOrOut' _ (Just "-") = return ($ stdout)
| 51
|
getWriterOrOut' _ (Just "-") = return ($ stdout)
| 51
| false
| false
| 0
| 7
| 10
| 24
| 12
| 12
| null | null |
dmjio/servant-swagger
|
src/Servant/Swagger/Internal/Test.hs
|
bsd-3-clause
|
maybeCounterExample :: Maybe String -> Property
maybeCounterExample Nothing = property True
| 92
|
maybeCounterExample :: Maybe String -> Property
maybeCounterExample Nothing = property True
| 92
|
maybeCounterExample Nothing = property True
| 44
| false
| true
| 0
| 6
| 11
| 28
| 12
| 16
| null | null |
zsol/hlogster
|
Logster.hs
|
bsd-3-clause
|
isOutputFlag Debug = True
| 25
|
isOutputFlag Debug = True
| 25
|
isOutputFlag Debug = True
| 25
| false
| false
| 0
| 4
| 3
| 10
| 4
| 6
| null | null |
tedkornish/stack
|
src/Stack/Build/ConstructPlan.hs
|
bsd-3-clause
|
markAsDep :: PackageName -> M ()
markAsDep name = tell mempty { wDeps = Set.singleton name }
| 92
|
markAsDep :: PackageName -> M ()
markAsDep name = tell mempty { wDeps = Set.singleton name }
| 92
|
markAsDep name = tell mempty { wDeps = Set.singleton name }
| 59
| false
| true
| 0
| 9
| 16
| 44
| 20
| 24
| null | null |
keera-studios/hsQt
|
Qtc/Enums/Gui/QStyleOption.hs
|
bsd-2-clause
|
eSO_TitleBar :: OptionType
eSO_TitleBar
= ieOptionType $ 983046
| 65
|
eSO_TitleBar :: OptionType
eSO_TitleBar
= ieOptionType $ 983046
| 65
|
eSO_TitleBar
= ieOptionType $ 983046
| 38
| false
| true
| 2
| 6
| 9
| 23
| 9
| 14
| null | null |
tiffany352/permuto
|
src/Lexer.hs
|
mit
|
countSpaces :: [Char] -> (Int, [Char])
countSpaces (c:s) | c == ' ' = let (i, s') = countSpaces s in (i+1, s')
| 110
|
countSpaces :: [Char] -> (Int, [Char])
countSpaces (c:s) | c == ' ' = let (i, s') = countSpaces s in (i+1, s')
| 110
|
countSpaces (c:s) | c == ' ' = let (i, s') = countSpaces s in (i+1, s')
| 71
| false
| true
| 0
| 10
| 22
| 78
| 41
| 37
| null | null |
hausdorff/pyli
|
src/Parser.hs
|
mit
|
str :: Parser String
str = string <~> zeroPlusStrs ==> emitStr
where string = ter "STRING"
| 93
|
str :: Parser String
str = string <~> zeroPlusStrs ==> emitStr
where string = ter "STRING"
| 93
|
str = string <~> zeroPlusStrs ==> emitStr
where string = ter "STRING"
| 72
| false
| true
| 3
| 6
| 18
| 42
| 17
| 25
| null | null |
dorchard/array-memoize
|
unfix-heat-example.hs
|
bsd-2-clause
|
-- Quantized heat function
heatQ :: (Float, Float) -> Float
heatQ = quantMemoFix heat' ((0, 0), (nx, nt)) (delx, delt)
| 118
|
heatQ :: (Float, Float) -> Float
heatQ = quantMemoFix heat' ((0, 0), (nx, nt)) (delx, delt)
| 91
|
heatQ = quantMemoFix heat' ((0, 0), (nx, nt)) (delx, delt)
| 58
| true
| true
| 0
| 7
| 19
| 53
| 32
| 21
| null | null |
Axure/Earley
|
examples/Mixfix.hs
|
bsd-3-clause
|
tokenize ('\n':xs) = tokenize xs
| 32
|
tokenize ('\n':xs) = tokenize xs
| 32
|
tokenize ('\n':xs) = tokenize xs
| 32
| false
| false
| 0
| 7
| 4
| 19
| 9
| 10
| null | null |
caasi/spj-book-student-1992
|
src/Parser.hs
|
bsd-3-clause
|
pThen4 :: (a -> b -> c -> d -> e)
-> Parser a -> Parser b -> Parser c -> Parser d -> Parser e
pThen4 combine p1 p2 p3 p4 = combine `pFmap` p1 `pAp` p2 `pAp` p3 `pAp` p4
| 175
|
pThen4 :: (a -> b -> c -> d -> e)
-> Parser a -> Parser b -> Parser c -> Parser d -> Parser e
pThen4 combine p1 p2 p3 p4 = combine `pFmap` p1 `pAp` p2 `pAp` p3 `pAp` p4
| 175
|
pThen4 combine p1 p2 p3 p4 = combine `pFmap` p1 `pAp` p2 `pAp` p3 `pAp` p4
| 74
| false
| true
| 0
| 10
| 48
| 100
| 52
| 48
| null | null |
glguy/tt-ratings
|
Output/TournamentSummary.hs
|
bsd-3-clause
|
pct :: Int -> Int -> Double
pct x y = 100 * fromIntegral x / fromIntegral y
| 75
|
pct :: Int -> Int -> Double
pct x y = 100 * fromIntegral x / fromIntegral y
| 75
|
pct x y = 100 * fromIntegral x / fromIntegral y
| 47
| false
| true
| 0
| 7
| 17
| 38
| 18
| 20
| null | null |
egruber/haskell
|
chapter2/learn.hs
|
gpl-3.0
|
y = 10
| 6
|
y = 10
| 6
|
y = 10
| 6
| false
| false
| 1
| 5
| 2
| 10
| 3
| 7
| null | null |
qnnguyen/howser
|
test/Property/HTMLProperties.hs
|
bsd-3-clause
|
htmlProperties =
testGroup "HTML Parse Quickcheck Properties"
[ testProperty "Empty Tag Pair" prop_emptyTagParseCorrect
, testProperty "Tag-Only Tree" prop_tagOnlyTreeParseCorrect
, testProperty "Parse Text Node with parseHTML" prop_parseHTMLTextNodeCorrect
, testProperty "Unmatched Tag" prop_unmatchedTagCausesError
, testProperty "Invalid Element Type" prop_invalidElemTypeCausesError
, testProperty "Parse Space-Only with htmlParser" prop_spaceOnlyTextNodeCausesErrorParseHTML
]
| 542
|
htmlProperties =
testGroup "HTML Parse Quickcheck Properties"
[ testProperty "Empty Tag Pair" prop_emptyTagParseCorrect
, testProperty "Tag-Only Tree" prop_tagOnlyTreeParseCorrect
, testProperty "Parse Text Node with parseHTML" prop_parseHTMLTextNodeCorrect
, testProperty "Unmatched Tag" prop_unmatchedTagCausesError
, testProperty "Invalid Element Type" prop_invalidElemTypeCausesError
, testProperty "Parse Space-Only with htmlParser" prop_spaceOnlyTextNodeCausesErrorParseHTML
]
| 542
|
htmlProperties =
testGroup "HTML Parse Quickcheck Properties"
[ testProperty "Empty Tag Pair" prop_emptyTagParseCorrect
, testProperty "Tag-Only Tree" prop_tagOnlyTreeParseCorrect
, testProperty "Parse Text Node with parseHTML" prop_parseHTMLTextNodeCorrect
, testProperty "Unmatched Tag" prop_unmatchedTagCausesError
, testProperty "Invalid Element Type" prop_invalidElemTypeCausesError
, testProperty "Parse Space-Only with htmlParser" prop_spaceOnlyTextNodeCausesErrorParseHTML
]
| 542
| false
| false
| 0
| 6
| 104
| 60
| 29
| 31
| null | null |
ghc-android/ghc
|
testsuite/tests/ghci/should_run/ghcirun004.hs
|
bsd-3-clause
|
706 = 705
| 9
|
706 = 705
| 9
|
706 = 705
| 9
| false
| false
| 1
| 5
| 2
| 10
| 3
| 7
| null | null |
CulpaBS/wbBach
|
src/Futhark/Representation/SOACS/SOAC.hs
|
bsd-3-clause
|
soacType :: SOAC lore -> [ExtType]
soacType (Map _ size f _) =
staticShapes $ mapType size f
| 94
|
soacType :: SOAC lore -> [ExtType]
soacType (Map _ size f _) =
staticShapes $ mapType size f
| 94
|
soacType (Map _ size f _) =
staticShapes $ mapType size f
| 59
| false
| true
| 0
| 7
| 19
| 45
| 22
| 23
| null | null |
UBMLtonGroup/timberc
|
src/Common.hs
|
bsd-3-clause
|
uncurry3 f (x,y,z) = f x y z
| 41
|
uncurry3 f (x,y,z) = f x y z
| 41
|
uncurry3 f (x,y,z) = f x y z
| 41
| false
| false
| 0
| 6
| 20
| 27
| 14
| 13
| null | null |
mcschroeder/ghc
|
compiler/nativeGen/PIC.hs
|
bsd-3-clause
|
howToAccessLabel dflags arch os this_mod CallReference lbl
| osElfTarget os
, labelDynamic dflags (thisPackage dflags) this_mod lbl && not (gopt Opt_PIC dflags)
= AccessDirectly
| osElfTarget os
, arch /= ArchX86
, labelDynamic dflags (thisPackage dflags) this_mod lbl && gopt Opt_PIC dflags
= AccessViaStub
| 364
|
howToAccessLabel dflags arch os this_mod CallReference lbl
| osElfTarget os
, labelDynamic dflags (thisPackage dflags) this_mod lbl && not (gopt Opt_PIC dflags)
= AccessDirectly
| osElfTarget os
, arch /= ArchX86
, labelDynamic dflags (thisPackage dflags) this_mod lbl && gopt Opt_PIC dflags
= AccessViaStub
| 364
|
howToAccessLabel dflags arch os this_mod CallReference lbl
| osElfTarget os
, labelDynamic dflags (thisPackage dflags) this_mod lbl && not (gopt Opt_PIC dflags)
= AccessDirectly
| osElfTarget os
, arch /= ArchX86
, labelDynamic dflags (thisPackage dflags) this_mod lbl && gopt Opt_PIC dflags
= AccessViaStub
| 364
| false
| false
| 0
| 11
| 100
| 117
| 51
| 66
| null | null |
brendanhay/gogol
|
gogol-securitycenter/gen/Network/Google/Resource/SecurityCenter/Organizations/Assets/RunDiscovery.hs
|
mpl-2.0
|
-- | OAuth access token.
oardAccessToken :: Lens' OrganizationsAssetsRunDiscovery (Maybe Text)
oardAccessToken
= lens _oardAccessToken
(\ s a -> s{_oardAccessToken = a})
| 177
|
oardAccessToken :: Lens' OrganizationsAssetsRunDiscovery (Maybe Text)
oardAccessToken
= lens _oardAccessToken
(\ s a -> s{_oardAccessToken = a})
| 152
|
oardAccessToken
= lens _oardAccessToken
(\ s a -> s{_oardAccessToken = a})
| 82
| true
| true
| 0
| 9
| 29
| 48
| 25
| 23
| null | null |
uwap/Idris-dev
|
src/IRTS/CodegenJavaScript.hs
|
bsd-3-clause
|
jsASSIGN :: CompileInfo -> Reg -> Reg -> JS
jsASSIGN _ r1 r2 = JSAssign (translateReg r1) (translateReg r2)
| 107
|
jsASSIGN :: CompileInfo -> Reg -> Reg -> JS
jsASSIGN _ r1 r2 = JSAssign (translateReg r1) (translateReg r2)
| 107
|
jsASSIGN _ r1 r2 = JSAssign (translateReg r1) (translateReg r2)
| 63
| false
| true
| 0
| 7
| 18
| 47
| 23
| 24
| null | null |
mjansen/network-db-parsers
|
Data/NetworkDB/HostsEntry.hs
|
gpl-3.0
|
isNameChar :: Char -> Bool
isNameChar c = isAlphaNumeric c || (c == '-') || (c == '.')
| 86
|
isNameChar :: Char -> Bool
isNameChar c = isAlphaNumeric c || (c == '-') || (c == '.')
| 86
|
isNameChar c = isAlphaNumeric c || (c == '-') || (c == '.')
| 59
| false
| true
| 0
| 8
| 17
| 43
| 22
| 21
| null | null |
haskell/ghc-builder
|
server/ServerMonad.hs
|
bsd-3-clause
|
message' :: Directory -> Verbosity -> Who -> String -> IO ()
message' directory verbosity who str
= do lt <- getLocalTimeInTz directory "UTC"
let fmt = "[%Y-%m-%d %H:%M:%S]"
t = formatTime defaultTimeLocale fmt lt
putMVar (dir_messagerVar directory)
(Message verbosity $ unwords [t, ppr who, str])
| 334
|
message' :: Directory -> Verbosity -> Who -> String -> IO ()
message' directory verbosity who str
= do lt <- getLocalTimeInTz directory "UTC"
let fmt = "[%Y-%m-%d %H:%M:%S]"
t = formatTime defaultTimeLocale fmt lt
putMVar (dir_messagerVar directory)
(Message verbosity $ unwords [t, ppr who, str])
| 334
|
message' directory verbosity who str
= do lt <- getLocalTimeInTz directory "UTC"
let fmt = "[%Y-%m-%d %H:%M:%S]"
t = formatTime defaultTimeLocale fmt lt
putMVar (dir_messagerVar directory)
(Message verbosity $ unwords [t, ppr who, str])
| 273
| false
| true
| 0
| 12
| 82
| 113
| 54
| 59
| null | null |
conal/shady-graphics
|
src/Shady/Image.hs
|
agpl-3.0
|
eqF, neqF :: (IsNat n, IsScalar a, Eq a, Applicative f) =>
f (VecE n a) -> f (VecE n a) -> f BoolE
eqF = liftA2 (==^)
| 132
|
eqF, neqF :: (IsNat n, IsScalar a, Eq a, Applicative f) =>
f (VecE n a) -> f (VecE n a) -> f BoolE
eqF = liftA2 (==^)
| 131
|
eqF = liftA2 (==^)
| 19
| false
| true
| 2
| 11
| 42
| 88
| 41
| 47
| null | null |
ivanperez-keera/SoOSiM-ui
|
src/View/InitAnimationArea.hs
|
bsd-3-clause
|
-- | Initialises the opengl area with a picture
initialiseAnimationArea :: Config -> Builder -> IO (SoOSiMState, GlossIO)
initialiseAnimationArea cfg bldr = do
vp <- animationViewport bldr
fx <- fixed1 bldr
-- Paint animation inside viewport
mainWdgt <- soosimStateNew cfg
containerAdd vp mainWdgt
wdgt <- glossIOThumbnailNew mainWdgt
fixedPut fx wdgt (0,0)
return (mainWdgt, wdgt)
| 400
|
initialiseAnimationArea :: Config -> Builder -> IO (SoOSiMState, GlossIO)
initialiseAnimationArea cfg bldr = do
vp <- animationViewport bldr
fx <- fixed1 bldr
-- Paint animation inside viewport
mainWdgt <- soosimStateNew cfg
containerAdd vp mainWdgt
wdgt <- glossIOThumbnailNew mainWdgt
fixedPut fx wdgt (0,0)
return (mainWdgt, wdgt)
| 352
|
initialiseAnimationArea cfg bldr = do
vp <- animationViewport bldr
fx <- fixed1 bldr
-- Paint animation inside viewport
mainWdgt <- soosimStateNew cfg
containerAdd vp mainWdgt
wdgt <- glossIOThumbnailNew mainWdgt
fixedPut fx wdgt (0,0)
return (mainWdgt, wdgt)
| 278
| true
| true
| 0
| 8
| 72
| 111
| 52
| 59
| null | null |
bitemyapp/ghc
|
compiler/typecheck/TcArrows.hs
|
bsd-3-clause
|
-----------------------------------------------------------------
-- Arrow ``forms'' (| e c1 .. cn |)
--
-- D; G |-a1 c1 : stk1 --> r1
-- ...
-- D; G |-an cn : stkn --> rn
-- D |- e :: forall e. a1 (e, stk1) t1
-- ...
-- -> an (e, stkn) tn
-- -> a (e, stk) t
-- e \not\in (stk, stk1, ..., stkm, t, t1, ..., tn)
-- ----------------------------------------------
-- D; G |-a (| e c1 ... cn |) : stk --> t
tc_cmd env cmd@(HsCmdArrForm expr fixity cmd_args) (cmd_stk, res_ty)
= addErrCtxt (cmdCtxt cmd) $
do { (cmd_args', cmd_tys) <- mapAndUnzipM tc_cmd_arg cmd_args
; let e_ty = mkForAllTy alphaTyVar $ -- We use alphaTyVar for 'w'
mkFunTys cmd_tys $
mkCmdArrTy env (mkPairTy alphaTy cmd_stk) res_ty
; expr' <- tcPolyExpr expr e_ty
; return (HsCmdArrForm expr' fixity cmd_args') }
where
tc_cmd_arg :: LHsCmdTop Name -> TcM (LHsCmdTop TcId, TcType)
tc_cmd_arg cmd
= do { arr_ty <- newFlexiTyVarTy arrowTyConKind
; stk_ty <- newFlexiTyVarTy liftedTypeKind
; res_ty <- newFlexiTyVarTy liftedTypeKind
; let env' = env { cmd_arr = arr_ty }
; cmd' <- tcCmdTop env' cmd (stk_ty, res_ty)
; return (cmd', mkCmdArrTy env' (mkPairTy alphaTy stk_ty) res_ty) }
-----------------------------------------------------------------
-- Base case for illegal commands
-- This is where expressions that aren't commands get rejected
| 1,607
|
tc_cmd env cmd@(HsCmdArrForm expr fixity cmd_args) (cmd_stk, res_ty)
= addErrCtxt (cmdCtxt cmd) $
do { (cmd_args', cmd_tys) <- mapAndUnzipM tc_cmd_arg cmd_args
; let e_ty = mkForAllTy alphaTyVar $ -- We use alphaTyVar for 'w'
mkFunTys cmd_tys $
mkCmdArrTy env (mkPairTy alphaTy cmd_stk) res_ty
; expr' <- tcPolyExpr expr e_ty
; return (HsCmdArrForm expr' fixity cmd_args') }
where
tc_cmd_arg :: LHsCmdTop Name -> TcM (LHsCmdTop TcId, TcType)
tc_cmd_arg cmd
= do { arr_ty <- newFlexiTyVarTy arrowTyConKind
; stk_ty <- newFlexiTyVarTy liftedTypeKind
; res_ty <- newFlexiTyVarTy liftedTypeKind
; let env' = env { cmd_arr = arr_ty }
; cmd' <- tcCmdTop env' cmd (stk_ty, res_ty)
; return (cmd', mkCmdArrTy env' (mkPairTy alphaTy stk_ty) res_ty) }
-----------------------------------------------------------------
-- Base case for illegal commands
-- This is where expressions that aren't commands get rejected
| 1,075
|
tc_cmd env cmd@(HsCmdArrForm expr fixity cmd_args) (cmd_stk, res_ty)
= addErrCtxt (cmdCtxt cmd) $
do { (cmd_args', cmd_tys) <- mapAndUnzipM tc_cmd_arg cmd_args
; let e_ty = mkForAllTy alphaTyVar $ -- We use alphaTyVar for 'w'
mkFunTys cmd_tys $
mkCmdArrTy env (mkPairTy alphaTy cmd_stk) res_ty
; expr' <- tcPolyExpr expr e_ty
; return (HsCmdArrForm expr' fixity cmd_args') }
where
tc_cmd_arg :: LHsCmdTop Name -> TcM (LHsCmdTop TcId, TcType)
tc_cmd_arg cmd
= do { arr_ty <- newFlexiTyVarTy arrowTyConKind
; stk_ty <- newFlexiTyVarTy liftedTypeKind
; res_ty <- newFlexiTyVarTy liftedTypeKind
; let env' = env { cmd_arr = arr_ty }
; cmd' <- tcCmdTop env' cmd (stk_ty, res_ty)
; return (cmd', mkCmdArrTy env' (mkPairTy alphaTy stk_ty) res_ty) }
-----------------------------------------------------------------
-- Base case for illegal commands
-- This is where expressions that aren't commands get rejected
| 1,075
| true
| false
| 3
| 13
| 512
| 300
| 152
| 148
| null | null |
rueshyna/gogol
|
gogol-datastore/gen/Network/Google/Resource/Datastore/Projects/Lookup.hs
|
mpl-2.0
|
-- | Creates a value of 'ProjectsLookup' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'plXgafv'
--
-- * 'plUploadProtocol'
--
-- * 'plPp'
--
-- * 'plAccessToken'
--
-- * 'plUploadType'
--
-- * 'plPayload'
--
-- * 'plBearerToken'
--
-- * 'plProjectId'
--
-- * 'plCallback'
projectsLookup
:: LookupRequest -- ^ 'plPayload'
-> Text -- ^ 'plProjectId'
-> ProjectsLookup
projectsLookup pPlPayload_ pPlProjectId_ =
ProjectsLookup'
{ _plXgafv = Nothing
, _plUploadProtocol = Nothing
, _plPp = True
, _plAccessToken = Nothing
, _plUploadType = Nothing
, _plPayload = pPlPayload_
, _plBearerToken = Nothing
, _plProjectId = pPlProjectId_
, _plCallback = Nothing
}
| 798
|
projectsLookup
:: LookupRequest -- ^ 'plPayload'
-> Text -- ^ 'plProjectId'
-> ProjectsLookup
projectsLookup pPlPayload_ pPlProjectId_ =
ProjectsLookup'
{ _plXgafv = Nothing
, _plUploadProtocol = Nothing
, _plPp = True
, _plAccessToken = Nothing
, _plUploadType = Nothing
, _plPayload = pPlPayload_
, _plBearerToken = Nothing
, _plProjectId = pPlProjectId_
, _plCallback = Nothing
}
| 438
|
projectsLookup pPlPayload_ pPlProjectId_ =
ProjectsLookup'
{ _plXgafv = Nothing
, _plUploadProtocol = Nothing
, _plPp = True
, _plAccessToken = Nothing
, _plUploadType = Nothing
, _plPayload = pPlPayload_
, _plBearerToken = Nothing
, _plProjectId = pPlProjectId_
, _plCallback = Nothing
}
| 332
| true
| true
| 0
| 6
| 176
| 103
| 72
| 31
| null | null |
tpsinnem/Idris-dev
|
src/IRTS/CodegenC.hs
|
bsd-3-clause
|
irts_c FFunction x = wrapped x
| 30
|
irts_c FFunction x = wrapped x
| 30
|
irts_c FFunction x = wrapped x
| 30
| false
| false
| 1
| 5
| 5
| 18
| 6
| 12
| null | null |
FranklinChen/Idris-dev
|
src/IRTS/CodegenJavaScript.hs
|
bsd-3-clause
|
jsOP :: CompileInfo -> Reg -> PrimFn -> [Reg] -> JS
jsOP _ reg op args = JSAssign (translateReg reg) jsOP'
where
jsOP' :: JS
jsOP'
| LNoOp <- op = translateReg (last args)
| LWriteStr <- op,
(_:str:_) <- args = JSApp (JSIdent "i$putStr") [translateReg str]
| LReadStr <- op = JSApp (JSIdent "i$getLine") []
| (LZExt (ITFixed IT8) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt (ITFixed IT16) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt (ITFixed IT32) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt _ ITBig) <- op = jsBigInt $ JSApp (JSIdent "String") [translateReg (last args)]
| (LPlus (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "add" [rhs]
| (LMinus (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "subtract" [rhs]
| (LTimes (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "multiply" [rhs]
| (LSDiv (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSRem (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "mod" [rhs]
| (LEq (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "equals" [rhs]
| (LSLt (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesser" [rhs]
| (LSLe (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesserOrEquals" [rhs]
| (LSGt (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greater" [rhs]
| (LSGe (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greaterOrEquals" [rhs]
| (LPlus ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| (LMinus ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "-" lhs rhs
| (LTimes ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "*" lhs rhs
| (LSDiv ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "/" lhs rhs
| (LEq ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| (LSLt ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| (LSLe ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<=" lhs rhs
| (LSGt ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">" lhs rhs
| (LSGe ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">=" lhs rhs
| (LPlus (ATInt ITChar)) <- op
, (lhs:rhs:_) <- args =
jsCall "i$fromCharCode" [
JSBinOp "+" (
jsCall "i$charCode" [translateReg lhs]
) (
jsCall "i$charCode" [translateReg rhs]
)
]
| (LTrunc (ITFixed _from) (ITFixed IT8)) <- op
, (arg:_) <- args =
jsPackUBits8 (
JSBinOp "&" (jsUnPackBits $ translateReg arg) (JSNum (JSInt 0xFF))
)
| (LTrunc (ITFixed _from) (ITFixed IT16)) <- op
, (arg:_) <- args =
jsPackUBits16 (
JSBinOp "&" (jsUnPackBits $ translateReg arg) (JSNum (JSInt 0xFFFF))
)
| (LTrunc (ITFixed _from) (ITFixed IT32)) <- op
, (arg:_) <- args =
jsPackUBits32 (
jsMeth (jsMeth (translateReg arg) "and" [
jsBigInt (JSString $ show 0xFFFFFFFF)
]) "intValue" []
)
| (LTrunc ITBig (ITFixed IT64)) <- op
, (arg:_) <- args =
jsMeth (translateReg arg) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LLSHR (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "shiftRight" [translateReg rhs]
| (LSHL (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "shiftLeft" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LAnd (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "and" [translateReg rhs]
| (LOr (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "or" [translateReg rhs]
| (LXOr (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "xor" [translateReg rhs]
| (LPlus (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "add" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LMinus (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "subtract" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LTimes (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "multiply" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LEq (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "equals" [rhs]
| (LLt (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesser" [rhs]
| (LLe (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesserOrEquals" [rhs]
| (LGt (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greater" [rhs]
| (LGe (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greaterOrEquals" [rhs]
| (LUDiv (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits8 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits16 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits32 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSDiv (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits8 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits16 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits32 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSRem (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits8 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits16 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits32 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "mod" [rhs]
| (LCompl (ITFixed IT8)) <- op
, (arg:_) <- args =
jsPackSBits8 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT16)) <- op
, (arg:_) <- args =
jsPackSBits16 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT32)) <- op
, (arg:_) <- args =
jsPackSBits32 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT64)) <- op
, (arg:_) <- args = invokeMeth arg "not" []
| (LPlus _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| (LMinus _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "-" lhs rhs
| (LTimes _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "*" lhs rhs
| (LSDiv _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "/" lhs rhs
| (LSRem _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "%" lhs rhs
| (LEq _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| (LSLt _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| (LSLe _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<=" lhs rhs
| (LSGt _) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">" lhs rhs
| (LSGe _) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">=" lhs rhs
| (LAnd _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "&" lhs rhs
| (LOr _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "|" lhs rhs
| (LXOr _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "^" lhs rhs
| (LSHL _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "<<" rhs lhs
| (LASHR _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp ">>" rhs lhs
| (LCompl _) <- op
, (arg:_) <- args = JSPreOp "~" (translateReg arg)
| LStrConcat <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| LStrEq <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| LStrLt <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| LStrLen <- op
, (arg:_) <- args = JSProj (translateReg arg) "length"
| (LStrInt ITNative) <- op
, (arg:_) <- args = jsCall "parseInt" [translateReg arg]
| (LIntStr ITNative) <- op
, (arg:_) <- args = jsCall "String" [translateReg arg]
| (LSExt ITNative ITBig) <- op
, (arg:_) <- args = jsBigInt $ jsCall "String" [translateReg arg]
| (LTrunc ITBig ITNative) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "intValue" []
| (LIntStr ITBig) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "toString" []
| (LStrInt ITBig) <- op
, (arg:_) <- args = jsBigInt $ translateReg arg
| LFloatStr <- op
, (arg:_) <- args = jsCall "String" [translateReg arg]
| LStrFloat <- op
, (arg:_) <- args = jsCall "parseFloat" [translateReg arg]
| (LIntFloat ITNative) <- op
, (arg:_) <- args = translateReg arg
| (LIntFloat ITBig) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "intValue" []
| (LFloatInt ITNative) <- op
, (arg:_) <- args = translateReg arg
| (LChInt ITNative) <- op
, (arg:_) <- args = jsCall "i$charCode" [translateReg arg]
| (LIntCh ITNative) <- op
, (arg:_) <- args = jsCall "i$fromCharCode" [translateReg arg]
| LFExp <- op
, (arg:_) <- args = jsCall "Math.exp" [translateReg arg]
| LFLog <- op
, (arg:_) <- args = jsCall "Math.log" [translateReg arg]
| LFSin <- op
, (arg:_) <- args = jsCall "Math.sin" [translateReg arg]
| LFCos <- op
, (arg:_) <- args = jsCall "Math.cos" [translateReg arg]
| LFTan <- op
, (arg:_) <- args = jsCall "Math.tan" [translateReg arg]
| LFASin <- op
, (arg:_) <- args = jsCall "Math.asin" [translateReg arg]
| LFACos <- op
, (arg:_) <- args = jsCall "Math.acos" [translateReg arg]
| LFATan <- op
, (arg:_) <- args = jsCall "Math.atan" [translateReg arg]
| LFSqrt <- op
, (arg:_) <- args = jsCall "Math.sqrt" [translateReg arg]
| LFFloor <- op
, (arg:_) <- args = jsCall "Math.floor" [translateReg arg]
| LFCeil <- op
, (arg:_) <- args = jsCall "Math.ceil" [translateReg arg]
| LFNegate <- op
, (arg:_) <- args = JSPreOp "-" (translateReg arg)
| LStrCons <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "concat" [rhs]
| LStrHead <- op
, (arg:_) <- args = JSIndex (translateReg arg) (JSNum (JSInt 0))
| LStrRev <- op
, (arg:_) <- args = JSProj (translateReg arg) "split('').reverse().join('')"
| LStrIndex <- op
, (lhs:rhs:_) <- args = JSIndex (translateReg lhs) (translateReg rhs)
| LStrTail <- op
, (arg:_) <- args =
let v = translateReg arg in
JSApp (JSProj v "substr") [
JSNum (JSInt 1),
JSBinOp "-" (JSProj v "length") (JSNum (JSInt 1))
]
| LStrSubstr <- op
, (offset:length:string:_) <- args =
let off = translateReg offset
len = translateReg length
str = translateReg string
in JSApp (JSProj str "substr") [
jsCall "Math.max" [JSNum (JSInt 0), off],
jsCall "Math.max" [JSNum (JSInt 0), len]
]
| LSystemInfo <- op
, (arg:_) <- args = jsCall "i$systemInfo" [translateReg arg]
| LExternal nul <- op
, nul == sUN "prim__null"
, _ <- args = JSNull
| LExternal ex <- op
, ex == sUN "prim__eqPtr"
, [lhs, rhs] <- args = translateCompareOp "==" lhs rhs
| otherwise = JSError $ "Not implemented: " ++ show op
where
translateBinaryOp :: String -> Reg -> Reg -> JS
translateBinaryOp op lhs rhs =
JSBinOp op (translateReg lhs) (translateReg rhs)
translateCompareOp :: String -> Reg -> Reg -> JS
translateCompareOp op lhs rhs =
JSPreOp "+" $ translateBinaryOp op lhs rhs
bitsBinaryOp :: String -> Reg -> Reg -> JS
bitsBinaryOp op lhs rhs =
JSBinOp op (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
bitsCompareOp :: String -> Reg -> Reg -> JS
bitsCompareOp op lhs rhs =
JSPreOp "+" $ bitsBinaryOp op lhs rhs
invokeMeth :: Reg -> String -> [Reg] -> JS
invokeMeth obj meth args =
JSApp (JSProj (translateReg obj) meth) $ map translateReg args
| 20,826
|
jsOP :: CompileInfo -> Reg -> PrimFn -> [Reg] -> JS
jsOP _ reg op args = JSAssign (translateReg reg) jsOP'
where
jsOP' :: JS
jsOP'
| LNoOp <- op = translateReg (last args)
| LWriteStr <- op,
(_:str:_) <- args = JSApp (JSIdent "i$putStr") [translateReg str]
| LReadStr <- op = JSApp (JSIdent "i$getLine") []
| (LZExt (ITFixed IT8) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt (ITFixed IT16) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt (ITFixed IT32) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt _ ITBig) <- op = jsBigInt $ JSApp (JSIdent "String") [translateReg (last args)]
| (LPlus (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "add" [rhs]
| (LMinus (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "subtract" [rhs]
| (LTimes (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "multiply" [rhs]
| (LSDiv (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSRem (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "mod" [rhs]
| (LEq (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "equals" [rhs]
| (LSLt (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesser" [rhs]
| (LSLe (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesserOrEquals" [rhs]
| (LSGt (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greater" [rhs]
| (LSGe (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greaterOrEquals" [rhs]
| (LPlus ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| (LMinus ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "-" lhs rhs
| (LTimes ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "*" lhs rhs
| (LSDiv ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "/" lhs rhs
| (LEq ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| (LSLt ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| (LSLe ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<=" lhs rhs
| (LSGt ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">" lhs rhs
| (LSGe ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">=" lhs rhs
| (LPlus (ATInt ITChar)) <- op
, (lhs:rhs:_) <- args =
jsCall "i$fromCharCode" [
JSBinOp "+" (
jsCall "i$charCode" [translateReg lhs]
) (
jsCall "i$charCode" [translateReg rhs]
)
]
| (LTrunc (ITFixed _from) (ITFixed IT8)) <- op
, (arg:_) <- args =
jsPackUBits8 (
JSBinOp "&" (jsUnPackBits $ translateReg arg) (JSNum (JSInt 0xFF))
)
| (LTrunc (ITFixed _from) (ITFixed IT16)) <- op
, (arg:_) <- args =
jsPackUBits16 (
JSBinOp "&" (jsUnPackBits $ translateReg arg) (JSNum (JSInt 0xFFFF))
)
| (LTrunc (ITFixed _from) (ITFixed IT32)) <- op
, (arg:_) <- args =
jsPackUBits32 (
jsMeth (jsMeth (translateReg arg) "and" [
jsBigInt (JSString $ show 0xFFFFFFFF)
]) "intValue" []
)
| (LTrunc ITBig (ITFixed IT64)) <- op
, (arg:_) <- args =
jsMeth (translateReg arg) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LLSHR (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "shiftRight" [translateReg rhs]
| (LSHL (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "shiftLeft" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LAnd (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "and" [translateReg rhs]
| (LOr (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "or" [translateReg rhs]
| (LXOr (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "xor" [translateReg rhs]
| (LPlus (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "add" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LMinus (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "subtract" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LTimes (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "multiply" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LEq (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "equals" [rhs]
| (LLt (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesser" [rhs]
| (LLe (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesserOrEquals" [rhs]
| (LGt (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greater" [rhs]
| (LGe (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greaterOrEquals" [rhs]
| (LUDiv (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits8 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits16 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits32 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSDiv (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits8 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits16 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits32 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSRem (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits8 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits16 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits32 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "mod" [rhs]
| (LCompl (ITFixed IT8)) <- op
, (arg:_) <- args =
jsPackSBits8 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT16)) <- op
, (arg:_) <- args =
jsPackSBits16 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT32)) <- op
, (arg:_) <- args =
jsPackSBits32 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT64)) <- op
, (arg:_) <- args = invokeMeth arg "not" []
| (LPlus _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| (LMinus _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "-" lhs rhs
| (LTimes _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "*" lhs rhs
| (LSDiv _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "/" lhs rhs
| (LSRem _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "%" lhs rhs
| (LEq _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| (LSLt _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| (LSLe _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<=" lhs rhs
| (LSGt _) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">" lhs rhs
| (LSGe _) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">=" lhs rhs
| (LAnd _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "&" lhs rhs
| (LOr _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "|" lhs rhs
| (LXOr _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "^" lhs rhs
| (LSHL _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "<<" rhs lhs
| (LASHR _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp ">>" rhs lhs
| (LCompl _) <- op
, (arg:_) <- args = JSPreOp "~" (translateReg arg)
| LStrConcat <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| LStrEq <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| LStrLt <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| LStrLen <- op
, (arg:_) <- args = JSProj (translateReg arg) "length"
| (LStrInt ITNative) <- op
, (arg:_) <- args = jsCall "parseInt" [translateReg arg]
| (LIntStr ITNative) <- op
, (arg:_) <- args = jsCall "String" [translateReg arg]
| (LSExt ITNative ITBig) <- op
, (arg:_) <- args = jsBigInt $ jsCall "String" [translateReg arg]
| (LTrunc ITBig ITNative) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "intValue" []
| (LIntStr ITBig) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "toString" []
| (LStrInt ITBig) <- op
, (arg:_) <- args = jsBigInt $ translateReg arg
| LFloatStr <- op
, (arg:_) <- args = jsCall "String" [translateReg arg]
| LStrFloat <- op
, (arg:_) <- args = jsCall "parseFloat" [translateReg arg]
| (LIntFloat ITNative) <- op
, (arg:_) <- args = translateReg arg
| (LIntFloat ITBig) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "intValue" []
| (LFloatInt ITNative) <- op
, (arg:_) <- args = translateReg arg
| (LChInt ITNative) <- op
, (arg:_) <- args = jsCall "i$charCode" [translateReg arg]
| (LIntCh ITNative) <- op
, (arg:_) <- args = jsCall "i$fromCharCode" [translateReg arg]
| LFExp <- op
, (arg:_) <- args = jsCall "Math.exp" [translateReg arg]
| LFLog <- op
, (arg:_) <- args = jsCall "Math.log" [translateReg arg]
| LFSin <- op
, (arg:_) <- args = jsCall "Math.sin" [translateReg arg]
| LFCos <- op
, (arg:_) <- args = jsCall "Math.cos" [translateReg arg]
| LFTan <- op
, (arg:_) <- args = jsCall "Math.tan" [translateReg arg]
| LFASin <- op
, (arg:_) <- args = jsCall "Math.asin" [translateReg arg]
| LFACos <- op
, (arg:_) <- args = jsCall "Math.acos" [translateReg arg]
| LFATan <- op
, (arg:_) <- args = jsCall "Math.atan" [translateReg arg]
| LFSqrt <- op
, (arg:_) <- args = jsCall "Math.sqrt" [translateReg arg]
| LFFloor <- op
, (arg:_) <- args = jsCall "Math.floor" [translateReg arg]
| LFCeil <- op
, (arg:_) <- args = jsCall "Math.ceil" [translateReg arg]
| LFNegate <- op
, (arg:_) <- args = JSPreOp "-" (translateReg arg)
| LStrCons <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "concat" [rhs]
| LStrHead <- op
, (arg:_) <- args = JSIndex (translateReg arg) (JSNum (JSInt 0))
| LStrRev <- op
, (arg:_) <- args = JSProj (translateReg arg) "split('').reverse().join('')"
| LStrIndex <- op
, (lhs:rhs:_) <- args = JSIndex (translateReg lhs) (translateReg rhs)
| LStrTail <- op
, (arg:_) <- args =
let v = translateReg arg in
JSApp (JSProj v "substr") [
JSNum (JSInt 1),
JSBinOp "-" (JSProj v "length") (JSNum (JSInt 1))
]
| LStrSubstr <- op
, (offset:length:string:_) <- args =
let off = translateReg offset
len = translateReg length
str = translateReg string
in JSApp (JSProj str "substr") [
jsCall "Math.max" [JSNum (JSInt 0), off],
jsCall "Math.max" [JSNum (JSInt 0), len]
]
| LSystemInfo <- op
, (arg:_) <- args = jsCall "i$systemInfo" [translateReg arg]
| LExternal nul <- op
, nul == sUN "prim__null"
, _ <- args = JSNull
| LExternal ex <- op
, ex == sUN "prim__eqPtr"
, [lhs, rhs] <- args = translateCompareOp "==" lhs rhs
| otherwise = JSError $ "Not implemented: " ++ show op
where
translateBinaryOp :: String -> Reg -> Reg -> JS
translateBinaryOp op lhs rhs =
JSBinOp op (translateReg lhs) (translateReg rhs)
translateCompareOp :: String -> Reg -> Reg -> JS
translateCompareOp op lhs rhs =
JSPreOp "+" $ translateBinaryOp op lhs rhs
bitsBinaryOp :: String -> Reg -> Reg -> JS
bitsBinaryOp op lhs rhs =
JSBinOp op (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
bitsCompareOp :: String -> Reg -> Reg -> JS
bitsCompareOp op lhs rhs =
JSPreOp "+" $ bitsBinaryOp op lhs rhs
invokeMeth :: Reg -> String -> [Reg] -> JS
invokeMeth obj meth args =
JSApp (JSProj (translateReg obj) meth) $ map translateReg args
| 20,826
|
jsOP _ reg op args = JSAssign (translateReg reg) jsOP'
where
jsOP' :: JS
jsOP'
| LNoOp <- op = translateReg (last args)
| LWriteStr <- op,
(_:str:_) <- args = JSApp (JSIdent "i$putStr") [translateReg str]
| LReadStr <- op = JSApp (JSIdent "i$getLine") []
| (LZExt (ITFixed IT8) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt (ITFixed IT16) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt (ITFixed IT32) ITNative) <- op = jsUnPackBits $ translateReg (last args)
| (LZExt _ ITBig) <- op = jsBigInt $ JSApp (JSIdent "String") [translateReg (last args)]
| (LPlus (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "add" [rhs]
| (LMinus (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "subtract" [rhs]
| (LTimes (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "multiply" [rhs]
| (LSDiv (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSRem (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "mod" [rhs]
| (LEq (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "equals" [rhs]
| (LSLt (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesser" [rhs]
| (LSLe (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesserOrEquals" [rhs]
| (LSGt (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greater" [rhs]
| (LSGe (ATInt ITBig)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greaterOrEquals" [rhs]
| (LPlus ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| (LMinus ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "-" lhs rhs
| (LTimes ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "*" lhs rhs
| (LSDiv ATFloat) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "/" lhs rhs
| (LEq ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| (LSLt ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| (LSLe ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<=" lhs rhs
| (LSGt ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">" lhs rhs
| (LSGe ATFloat) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">=" lhs rhs
| (LPlus (ATInt ITChar)) <- op
, (lhs:rhs:_) <- args =
jsCall "i$fromCharCode" [
JSBinOp "+" (
jsCall "i$charCode" [translateReg lhs]
) (
jsCall "i$charCode" [translateReg rhs]
)
]
| (LTrunc (ITFixed _from) (ITFixed IT8)) <- op
, (arg:_) <- args =
jsPackUBits8 (
JSBinOp "&" (jsUnPackBits $ translateReg arg) (JSNum (JSInt 0xFF))
)
| (LTrunc (ITFixed _from) (ITFixed IT16)) <- op
, (arg:_) <- args =
jsPackUBits16 (
JSBinOp "&" (jsUnPackBits $ translateReg arg) (JSNum (JSInt 0xFFFF))
)
| (LTrunc (ITFixed _from) (ITFixed IT32)) <- op
, (arg:_) <- args =
jsPackUBits32 (
jsMeth (jsMeth (translateReg arg) "and" [
jsBigInt (JSString $ show 0xFFFFFFFF)
]) "intValue" []
)
| (LTrunc ITBig (ITFixed IT64)) <- op
, (arg:_) <- args =
jsMeth (translateReg arg) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LLSHR (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp ">>" lhs rhs
| (LLSHR (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "shiftRight" [translateReg rhs]
| (LSHL (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "<<" lhs rhs
| (LSHL (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "shiftLeft" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LAnd (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "&" lhs rhs
| (LAnd (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "and" [translateReg rhs]
| (LOr (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "|" lhs rhs
| (LOr (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "or" [translateReg rhs]
| (LXOr (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "^" lhs rhs
| (LXOr (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args =
jsMeth (translateReg lhs) "xor" [translateReg rhs]
| (LPlus (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "+" lhs rhs
| (LPlus (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "add" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LMinus (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "-" lhs rhs
| (LMinus (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "subtract" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LTimes (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = jsPackUBits8 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = jsPackUBits16 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = jsPackUBits32 $ bitsBinaryOp "*" lhs rhs
| (LTimes (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args =
jsMeth (jsMeth (translateReg lhs) "multiply" [translateReg rhs]) "and" [
jsBigInt (JSString $ show 0xFFFFFFFFFFFFFFFF)
]
| (LEq (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "==" lhs rhs
| (LEq (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "equals" [rhs]
| (LLt (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<" lhs rhs
| (LLt (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesser" [rhs]
| (LLe (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp "<=" lhs rhs
| (LLe (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "lesserOrEquals" [rhs]
| (LGt (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">" lhs rhs
| (LGt (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greater" [rhs]
| (LGe (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args = bitsCompareOp ">=" lhs rhs
| (LGe (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = JSPreOp "+" $ invokeMeth lhs "greaterOrEquals" [rhs]
| (LUDiv (ITFixed IT8)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits8 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT16)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits16 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT32)) <- op
, (lhs:rhs:_) <- args =
jsPackUBits32 (
JSBinOp "/" (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
)
| (LUDiv (ITFixed IT64)) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSDiv (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits8 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits16 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits32 (
JSBinOp "/" (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg rhs)
)
)
| (LSDiv (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "divide" [rhs]
| (LSRem (ATInt (ITFixed IT8))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits8 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits8 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT16))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits16 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits16 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT32))) <- op
, (lhs:rhs:_) <- args =
jsPackSBits32 (
JSBinOp "%" (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg lhs)
) (
jsUnPackBits $ jsPackSBits32 $ jsUnPackBits (translateReg rhs)
)
)
| (LSRem (ATInt (ITFixed IT64))) <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "mod" [rhs]
| (LCompl (ITFixed IT8)) <- op
, (arg:_) <- args =
jsPackSBits8 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT16)) <- op
, (arg:_) <- args =
jsPackSBits16 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT32)) <- op
, (arg:_) <- args =
jsPackSBits32 $ JSPreOp "~" $ jsUnPackBits (translateReg arg)
| (LCompl (ITFixed IT64)) <- op
, (arg:_) <- args = invokeMeth arg "not" []
| (LPlus _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| (LMinus _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "-" lhs rhs
| (LTimes _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "*" lhs rhs
| (LSDiv _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "/" lhs rhs
| (LSRem _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "%" lhs rhs
| (LEq _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| (LSLt _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| (LSLe _) <- op
, (lhs:rhs:_) <- args = translateCompareOp "<=" lhs rhs
| (LSGt _) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">" lhs rhs
| (LSGe _) <- op
, (lhs:rhs:_) <- args = translateCompareOp ">=" lhs rhs
| (LAnd _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "&" lhs rhs
| (LOr _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "|" lhs rhs
| (LXOr _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "^" lhs rhs
| (LSHL _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp "<<" rhs lhs
| (LASHR _) <- op
, (lhs:rhs:_) <- args = translateBinaryOp ">>" rhs lhs
| (LCompl _) <- op
, (arg:_) <- args = JSPreOp "~" (translateReg arg)
| LStrConcat <- op
, (lhs:rhs:_) <- args = translateBinaryOp "+" lhs rhs
| LStrEq <- op
, (lhs:rhs:_) <- args = translateCompareOp "==" lhs rhs
| LStrLt <- op
, (lhs:rhs:_) <- args = translateCompareOp "<" lhs rhs
| LStrLen <- op
, (arg:_) <- args = JSProj (translateReg arg) "length"
| (LStrInt ITNative) <- op
, (arg:_) <- args = jsCall "parseInt" [translateReg arg]
| (LIntStr ITNative) <- op
, (arg:_) <- args = jsCall "String" [translateReg arg]
| (LSExt ITNative ITBig) <- op
, (arg:_) <- args = jsBigInt $ jsCall "String" [translateReg arg]
| (LTrunc ITBig ITNative) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "intValue" []
| (LIntStr ITBig) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "toString" []
| (LStrInt ITBig) <- op
, (arg:_) <- args = jsBigInt $ translateReg arg
| LFloatStr <- op
, (arg:_) <- args = jsCall "String" [translateReg arg]
| LStrFloat <- op
, (arg:_) <- args = jsCall "parseFloat" [translateReg arg]
| (LIntFloat ITNative) <- op
, (arg:_) <- args = translateReg arg
| (LIntFloat ITBig) <- op
, (arg:_) <- args = jsMeth (translateReg arg) "intValue" []
| (LFloatInt ITNative) <- op
, (arg:_) <- args = translateReg arg
| (LChInt ITNative) <- op
, (arg:_) <- args = jsCall "i$charCode" [translateReg arg]
| (LIntCh ITNative) <- op
, (arg:_) <- args = jsCall "i$fromCharCode" [translateReg arg]
| LFExp <- op
, (arg:_) <- args = jsCall "Math.exp" [translateReg arg]
| LFLog <- op
, (arg:_) <- args = jsCall "Math.log" [translateReg arg]
| LFSin <- op
, (arg:_) <- args = jsCall "Math.sin" [translateReg arg]
| LFCos <- op
, (arg:_) <- args = jsCall "Math.cos" [translateReg arg]
| LFTan <- op
, (arg:_) <- args = jsCall "Math.tan" [translateReg arg]
| LFASin <- op
, (arg:_) <- args = jsCall "Math.asin" [translateReg arg]
| LFACos <- op
, (arg:_) <- args = jsCall "Math.acos" [translateReg arg]
| LFATan <- op
, (arg:_) <- args = jsCall "Math.atan" [translateReg arg]
| LFSqrt <- op
, (arg:_) <- args = jsCall "Math.sqrt" [translateReg arg]
| LFFloor <- op
, (arg:_) <- args = jsCall "Math.floor" [translateReg arg]
| LFCeil <- op
, (arg:_) <- args = jsCall "Math.ceil" [translateReg arg]
| LFNegate <- op
, (arg:_) <- args = JSPreOp "-" (translateReg arg)
| LStrCons <- op
, (lhs:rhs:_) <- args = invokeMeth lhs "concat" [rhs]
| LStrHead <- op
, (arg:_) <- args = JSIndex (translateReg arg) (JSNum (JSInt 0))
| LStrRev <- op
, (arg:_) <- args = JSProj (translateReg arg) "split('').reverse().join('')"
| LStrIndex <- op
, (lhs:rhs:_) <- args = JSIndex (translateReg lhs) (translateReg rhs)
| LStrTail <- op
, (arg:_) <- args =
let v = translateReg arg in
JSApp (JSProj v "substr") [
JSNum (JSInt 1),
JSBinOp "-" (JSProj v "length") (JSNum (JSInt 1))
]
| LStrSubstr <- op
, (offset:length:string:_) <- args =
let off = translateReg offset
len = translateReg length
str = translateReg string
in JSApp (JSProj str "substr") [
jsCall "Math.max" [JSNum (JSInt 0), off],
jsCall "Math.max" [JSNum (JSInt 0), len]
]
| LSystemInfo <- op
, (arg:_) <- args = jsCall "i$systemInfo" [translateReg arg]
| LExternal nul <- op
, nul == sUN "prim__null"
, _ <- args = JSNull
| LExternal ex <- op
, ex == sUN "prim__eqPtr"
, [lhs, rhs] <- args = translateCompareOp "==" lhs rhs
| otherwise = JSError $ "Not implemented: " ++ show op
where
translateBinaryOp :: String -> Reg -> Reg -> JS
translateBinaryOp op lhs rhs =
JSBinOp op (translateReg lhs) (translateReg rhs)
translateCompareOp :: String -> Reg -> Reg -> JS
translateCompareOp op lhs rhs =
JSPreOp "+" $ translateBinaryOp op lhs rhs
bitsBinaryOp :: String -> Reg -> Reg -> JS
bitsBinaryOp op lhs rhs =
JSBinOp op (jsUnPackBits (translateReg lhs)) (jsUnPackBits (translateReg rhs))
bitsCompareOp :: String -> Reg -> Reg -> JS
bitsCompareOp op lhs rhs =
JSPreOp "+" $ bitsBinaryOp op lhs rhs
invokeMeth :: Reg -> String -> [Reg] -> JS
invokeMeth obj meth args =
JSApp (JSProj (translateReg obj) meth) $ map translateReg args
| 20,774
| false
| true
| 2
| 15
| 7,711
| 9,141
| 4,475
| 4,666
| null | null |
mhcurylo/scheme-haskell-tutorial
|
src/Environment.hs
|
bsd-3-clause
|
liftThrows (Right val) = return val
| 35
|
liftThrows (Right val) = return val
| 35
|
liftThrows (Right val) = return val
| 35
| false
| false
| 0
| 7
| 5
| 18
| 8
| 10
| null | null |
mcjohnalds/jumpy
|
src/Blocks.hs
|
mit
|
firstBlock = Hitbox 0 (screenHeight - 20) screenWidth 15
| 56
|
firstBlock = Hitbox 0 (screenHeight - 20) screenWidth 15
| 56
|
firstBlock = Hitbox 0 (screenHeight - 20) screenWidth 15
| 56
| false
| false
| 0
| 7
| 8
| 22
| 11
| 11
| null | null |
39aldo39/klfc
|
src/KlcParse.hs
|
gpl-3.0
|
deadKey ∷ (Logger m, Parser m, MonadFail m) ⇒ m [(Char, ActionMap)]
deadKey = do
["DEADKEY", s] ← readLine
let i = maybeToList (readMaybe ('0':'x':s))
c ← chr <$> i <$ when (null i) (tell ["unknown dead key ‘" ⊕ s ⊕ "’"])
m ← many (isHex *> deadPair)
pure (zip c [m])
| 287
|
deadKey ∷ (Logger m, Parser m, MonadFail m) ⇒ m [(Char, ActionMap)]
deadKey = do
["DEADKEY", s] ← readLine
let i = maybeToList (readMaybe ('0':'x':s))
c ← chr <$> i <$ when (null i) (tell ["unknown dead key ‘" ⊕ s ⊕ "’"])
m ← many (isHex *> deadPair)
pure (zip c [m])
| 287
|
deadKey = do
["DEADKEY", s] ← readLine
let i = maybeToList (readMaybe ('0':'x':s))
c ← chr <$> i <$ when (null i) (tell ["unknown dead key ‘" ⊕ s ⊕ "’"])
m ← many (isHex *> deadPair)
pure (zip c [m])
| 219
| false
| true
| 0
| 16
| 72
| 169
| 83
| 86
| null | null |
projedi/type-inference-rank2
|
src/Term.hs
|
bsd-3-clause
|
parse :: String -> Either ParseError Term
parse = Parsec.parse fullExpr ""
| 74
|
parse :: String -> Either ParseError Term
parse = Parsec.parse fullExpr ""
| 74
|
parse = Parsec.parse fullExpr ""
| 32
| false
| true
| 0
| 7
| 11
| 32
| 14
| 18
| null | null |
Hodapp87/ivory
|
ivory-serialize/src/Ivory/Serialize/Atoms.hs
|
bsd-3-clause
|
float :: WrappedPackRep (Stored IFloat)
float = mkPackRep "float" 4
| 67
|
float :: WrappedPackRep (Stored IFloat)
float = mkPackRep "float" 4
| 67
|
float = mkPackRep "float" 4
| 27
| false
| true
| 1
| 7
| 9
| 28
| 12
| 16
| null | null |
sgillespie/ghc
|
libraries/base/Control/Monad.hs
|
bsd-3-clause
|
guard False = empty
| 24
|
guard False = empty
| 24
|
guard False = empty
| 24
| false
| false
| 0
| 5
| 8
| 9
| 4
| 5
| null | null |
dalaing/sdl2
|
src/SDL/Raw/Thread.hs
|
bsd-3-clause
|
semWait :: MonadIO m => Ptr Sem -> m CInt
semWait v1 = liftIO $ semWaitFFI v1
| 77
|
semWait :: MonadIO m => Ptr Sem -> m CInt
semWait v1 = liftIO $ semWaitFFI v1
| 77
|
semWait v1 = liftIO $ semWaitFFI v1
| 35
| false
| true
| 2
| 8
| 16
| 43
| 18
| 25
| null | null |
sdiehl/ghc
|
compiler/GHC/HsToCore/PmCheck.hs
|
bsd-3-clause
|
mkPmLitGrds :: Id -> PmLit -> DsM GrdVec
mkPmLitGrds x (PmLit _ (PmLitString s)) = do
-- We translate String literals to list literals for better overlap reasoning.
-- It's a little unfortunate we do this here rather than in
-- 'GHC.HsToCore.PmCheck.Oracle.trySolve' and
-- 'GHC.HsToCore.PmCheck.Oracle.addRefutableAltCon', but it's so much simpler
-- here. See Note [Representation of Strings in TmState] in
-- GHC.HsToCore.PmCheck.Oracle
vars <- traverse mkPmId (take (lengthFS s) (repeat charTy))
let mk_char_lit y c = mkPmLitGrds y (PmLit charTy (PmLitChar c))
char_grdss <- zipWithM mk_char_lit vars (unpackFS s)
mkListGrds x (zip vars char_grdss)
| 672
|
mkPmLitGrds :: Id -> PmLit -> DsM GrdVec
mkPmLitGrds x (PmLit _ (PmLitString s)) = do
-- We translate String literals to list literals for better overlap reasoning.
-- It's a little unfortunate we do this here rather than in
-- 'GHC.HsToCore.PmCheck.Oracle.trySolve' and
-- 'GHC.HsToCore.PmCheck.Oracle.addRefutableAltCon', but it's so much simpler
-- here. See Note [Representation of Strings in TmState] in
-- GHC.HsToCore.PmCheck.Oracle
vars <- traverse mkPmId (take (lengthFS s) (repeat charTy))
let mk_char_lit y c = mkPmLitGrds y (PmLit charTy (PmLitChar c))
char_grdss <- zipWithM mk_char_lit vars (unpackFS s)
mkListGrds x (zip vars char_grdss)
| 672
|
mkPmLitGrds x (PmLit _ (PmLitString s)) = do
-- We translate String literals to list literals for better overlap reasoning.
-- It's a little unfortunate we do this here rather than in
-- 'GHC.HsToCore.PmCheck.Oracle.trySolve' and
-- 'GHC.HsToCore.PmCheck.Oracle.addRefutableAltCon', but it's so much simpler
-- here. See Note [Representation of Strings in TmState] in
-- GHC.HsToCore.PmCheck.Oracle
vars <- traverse mkPmId (take (lengthFS s) (repeat charTy))
let mk_char_lit y c = mkPmLitGrds y (PmLit charTy (PmLitChar c))
char_grdss <- zipWithM mk_char_lit vars (unpackFS s)
mkListGrds x (zip vars char_grdss)
| 631
| false
| true
| 0
| 14
| 113
| 153
| 73
| 80
| null | null |
literate-unitb/literate-unitb
|
src/Code/Synthesis.hs
|
mit
|
indent :: Int -> M a -> M a
indent n = local $ first (n+)
| 57
|
indent :: Int -> M a -> M a
indent n = local $ first (n+)
| 57
|
indent n = local $ first (n+)
| 29
| false
| true
| 0
| 7
| 15
| 39
| 19
| 20
| null | null |
NCrashed/PowerCom
|
src/powercom/Benchmark.hs
|
gpl-3.0
|
userDisconnectHandler :: (ProcessId, String, String) -> Process Bool
userDisconnectHandler (_, _, name) = do
liftIO $ putStrLn $ "User disconnected: " ++ name
return True
-- | Main benchmark function.
| 209
|
userDisconnectHandler :: (ProcessId, String, String) -> Process Bool
userDisconnectHandler (_, _, name) = do
liftIO $ putStrLn $ "User disconnected: " ++ name
return True
-- | Main benchmark function.
| 209
|
userDisconnectHandler (_, _, name) = do
liftIO $ putStrLn $ "User disconnected: " ++ name
return True
-- | Main benchmark function.
| 140
| false
| true
| 0
| 9
| 38
| 61
| 32
| 29
| null | null |
phaazon/OpenGLRaw
|
src/Graphics/Rendering/OpenGL/Raw/Tokens.hs
|
bsd-3-clause
|
gl_INTERLACE_READ_OML :: GLenum
gl_INTERLACE_READ_OML = 0x8981
| 62
|
gl_INTERLACE_READ_OML :: GLenum
gl_INTERLACE_READ_OML = 0x8981
| 62
|
gl_INTERLACE_READ_OML = 0x8981
| 30
| false
| true
| 0
| 4
| 5
| 11
| 6
| 5
| null | null |
kawu/nerf-proto
|
src/NLP/Nerf2/Forest/SubTree.hs
|
bsd-2-clause
|
-- | A set of forests with a 'Fork' spanned over the given range and symbol.
forestWith'' :: Env.InSent e => e -> N -> Pos -> Pos -> [Forest]
forestWith'' e x i j = filter (isJust . subTree'' e x i j) (forestSet e)
| 214
|
forestWith'' :: Env.InSent e => e -> N -> Pos -> Pos -> [Forest]
forestWith'' e x i j = filter (isJust . subTree'' e x i j) (forestSet e)
| 137
|
forestWith'' e x i j = filter (isJust . subTree'' e x i j) (forestSet e)
| 72
| true
| true
| 0
| 10
| 45
| 76
| 38
| 38
| null | null |
ulricha/dsh
|
src/Database/DSH/FKL/Lang.hs
|
bsd-3-clause
|
subscript 6 = char '₆'
| 22
|
subscript 6 = char '₆'
| 22
|
subscript 6 = char '₆'
| 22
| false
| false
| 0
| 5
| 4
| 12
| 5
| 7
| null | null |
eklavya/Idris-dev
|
src/Idris/Core/Typecheck.hs
|
bsd-3-clause
|
recheck :: String -> Context -> Env -> Raw -> Term -> TC (Term, Type, UCs)
recheck = recheck_borrowing False []
| 111
|
recheck :: String -> Context -> Env -> Raw -> Term -> TC (Term, Type, UCs)
recheck = recheck_borrowing False []
| 111
|
recheck = recheck_borrowing False []
| 36
| false
| true
| 0
| 12
| 20
| 56
| 27
| 29
| null | null |
hiratara/TypedPerl
|
src/TypedPerl/Types.hs
|
bsd-3-clause
|
showPerlTypeVars :: PerlTypeVars -> String
showPerlTypeVars (TypeNamed x) = x
| 77
|
showPerlTypeVars :: PerlTypeVars -> String
showPerlTypeVars (TypeNamed x) = x
| 77
|
showPerlTypeVars (TypeNamed x) = x
| 34
| false
| true
| 0
| 7
| 9
| 24
| 12
| 12
| null | null |
nkpart/score-writer
|
src/Score/Prelude.hs
|
bsd-3-clause
|
r16 = rn (1/16)
| 15
|
r16 = rn (1/16)
| 15
|
r16 = rn (1/16)
| 15
| false
| false
| 1
| 7
| 3
| 20
| 8
| 12
| null | null |
hkupty/aura
|
src/Aura/Packages/AUR.hs
|
gpl-3.0
|
sourceTarball :: FilePath -- ^ Where to save the tarball.
-> T.Text -- ^ Package name.
-> IO (Maybe FilePath) -- ^ Saved tarball location.
sourceTarball path = fmap join . (info >=> Traversable.mapM f)
where f = saveUrlContents path . (++) aurLink . T.unpack . urlPathOf
------------
-- RPC CALLS
------------
| 366
|
sourceTarball :: FilePath -- ^ Where to save the tarball.
-> T.Text -- ^ Package name.
-> IO (Maybe FilePath)
sourceTarball path = fmap join . (info >=> Traversable.mapM f)
where f = saveUrlContents path . (++) aurLink . T.unpack . urlPathOf
------------
-- RPC CALLS
------------
| 337
|
sourceTarball path = fmap join . (info >=> Traversable.mapM f)
where f = saveUrlContents path . (++) aurLink . T.unpack . urlPathOf
------------
-- RPC CALLS
------------
| 175
| true
| true
| 0
| 10
| 108
| 87
| 46
| 41
| null | null |
joshcough/Scrabble
|
test/TestHelpers.hs
|
mit
|
roundTripJSON :: (FromJSON a, ToJSON a, Eq a, Show a) => a -> Bool
roundTripJSON a = fromJSON (toJSON a) == Success a &&
(eitherDecode $ encode a) == Right a
| 181
|
roundTripJSON :: (FromJSON a, ToJSON a, Eq a, Show a) => a -> Bool
roundTripJSON a = fromJSON (toJSON a) == Success a &&
(eitherDecode $ encode a) == Right a
| 181
|
roundTripJSON a = fromJSON (toJSON a) == Success a &&
(eitherDecode $ encode a) == Right a
| 114
| false
| true
| 0
| 10
| 54
| 82
| 40
| 42
| null | null |
leshchevds/ganeti
|
src/Ganeti/HTools/Cluster.hs
|
bsd-2-clause
|
-- | The default network bandwidth value in Mbit/s
defaultBandwidth :: Int
defaultBandwidth = 100
| 97
|
defaultBandwidth :: Int
defaultBandwidth = 100
| 46
|
defaultBandwidth = 100
| 22
| true
| true
| 0
| 4
| 14
| 12
| 7
| 5
| null | null |
nevrenato/Hets_Fork
|
CASL/ATC_CASL.hs
|
gpl-2.0
|
_tcCASL_FormulasTc :: TyCon
_tcCASL_FormulasTc = mkTyCon "CASL.Sublogic.CASL_Formulas"
| 86
|
_tcCASL_FormulasTc :: TyCon
_tcCASL_FormulasTc = mkTyCon "CASL.Sublogic.CASL_Formulas"
| 86
|
_tcCASL_FormulasTc = mkTyCon "CASL.Sublogic.CASL_Formulas"
| 58
| false
| true
| 0
| 5
| 6
| 14
| 7
| 7
| null | null |
cabrera/ghc-mod
|
Language/Haskell/GhcMod/SrcUtils.hs
|
bsd-3-clause
|
-- Check whether (line,col) is inside a given SrcSpanInfo
typeSigInRangeHE :: Int -> Int -> HE.Decl HE.SrcSpanInfo -> Bool
typeSigInRangeHE lineNo colNo (HE.TypeSig (HE.SrcSpanInfo s _) _ _) =
HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo)
| 269
|
typeSigInRangeHE :: Int -> Int -> HE.Decl HE.SrcSpanInfo -> Bool
typeSigInRangeHE lineNo colNo (HE.TypeSig (HE.SrcSpanInfo s _) _ _) =
HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo)
| 211
|
typeSigInRangeHE lineNo colNo (HE.TypeSig (HE.SrcSpanInfo s _) _ _) =
HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo)
| 146
| true
| true
| 0
| 10
| 41
| 94
| 48
| 46
| null | null |
arirahikkala/straylight-divergence
|
src/Util.hs
|
gpl-3.0
|
none :: (a -> Bool) -> [a] -> Bool
none = (not .) . any
| 55
|
none :: (a -> Bool) -> [a] -> Bool
none = (not .) . any
| 55
|
none = (not .) . any
| 20
| false
| true
| 0
| 7
| 14
| 37
| 21
| 16
| null | null |
vTurbine/ghc
|
compiler/simplCore/OccurAnal.hs
|
bsd-3-clause
|
occAnal _ expr@(Lit _) = (emptyDetails, expr)
| 56
|
occAnal _ expr@(Lit _) = (emptyDetails, expr)
| 56
|
occAnal _ expr@(Lit _) = (emptyDetails, expr)
| 56
| false
| false
| 1
| 7
| 17
| 29
| 14
| 15
| null | null |
LinusU/fbthrift
|
thrift/compiler/test/fixtures/namespace/gen-hs/My/Namespacing/Extend/Test/ExtendTestService_Fuzzer.hs
|
apache-2.0
|
check_fuzzOnce (a1) client = Client.check client a1 >> return ()
| 64
|
check_fuzzOnce (a1) client = Client.check client a1 >> return ()
| 64
|
check_fuzzOnce (a1) client = Client.check client a1 >> return ()
| 64
| false
| false
| 0
| 7
| 9
| 30
| 14
| 16
| null | null |
seL4/capDL-tool
|
CapDL/PrintIsabelle.hs
|
bsd-2-clause
|
lemma :: String -> String -> String -> Doc
lemma name statement proof =
text ("lemma " ++ name ++ ": ") <> doubleQuotes (text statement) $$
nest 2 (text proof)
| 163
|
lemma :: String -> String -> String -> Doc
lemma name statement proof =
text ("lemma " ++ name ++ ": ") <> doubleQuotes (text statement) $$
nest 2 (text proof)
| 163
|
lemma name statement proof =
text ("lemma " ++ name ++ ": ") <> doubleQuotes (text statement) $$
nest 2 (text proof)
| 120
| false
| true
| 0
| 10
| 34
| 72
| 35
| 37
| null | null |
MarcusVoelker/LParse
|
src/Text/LParse/Parser.hs
|
mit
|
-- | Runs the parser and prints the results
debugParse :: (Show a) => Parser (IO ()) t a -> t -> IO ()
debugParse p s = debugParse' p s (putStr . (\x -> show x ++ "\n"))
| 169
|
debugParse :: (Show a) => Parser (IO ()) t a -> t -> IO ()
debugParse p s = debugParse' p s (putStr . (\x -> show x ++ "\n"))
| 125
|
debugParse p s = debugParse' p s (putStr . (\x -> show x ++ "\n"))
| 66
| true
| true
| 0
| 11
| 38
| 83
| 42
| 41
| null | null |
danchoi/imapget
|
src/Network/HaskellNet/SMTP.hs
|
bsd-3-clause
|
bsPutCrLf :: BSStream -> ByteString -> IO ()
bsPutCrLf h s = bsPut h s >> bsPut h crlf >> bsFlush h
| 99
|
bsPutCrLf :: BSStream -> ByteString -> IO ()
bsPutCrLf h s = bsPut h s >> bsPut h crlf >> bsFlush h
| 99
|
bsPutCrLf h s = bsPut h s >> bsPut h crlf >> bsFlush h
| 54
| false
| true
| 0
| 8
| 21
| 50
| 23
| 27
| null | null |
Alexander-Ignatyev/morpheus
|
hmatrix-morpheus/src/Numeric/Morpheus/Statistics.hs
|
bsd-3-clause
|
columnStddev_m :: Vector R -> Matrix R -> Vector R
columnStddev_m means m = unsafePerformIO $ do
v <- createVector (cols m)
apply means (apply m (apply v id)) call_morpheus_column_stddev_m
return v
{- morpheus_row_stddev_m -}
| 239
|
columnStddev_m :: Vector R -> Matrix R -> Vector R
columnStddev_m means m = unsafePerformIO $ do
v <- createVector (cols m)
apply means (apply m (apply v id)) call_morpheus_column_stddev_m
return v
{- morpheus_row_stddev_m -}
| 239
|
columnStddev_m means m = unsafePerformIO $ do
v <- createVector (cols m)
apply means (apply m (apply v id)) call_morpheus_column_stddev_m
return v
{- morpheus_row_stddev_m -}
| 188
| false
| true
| 0
| 12
| 48
| 86
| 39
| 47
| null | null |
AlexanderPankiv/ghc
|
compiler/prelude/TysPrim.hs
|
bsd-3-clause
|
{-
************************************************************************
* *
\subsection[TysPrim-basic]{Basic primitive types (@Char#@, @Int#@, etc.)}
* *
************************************************************************
-}
-- only used herein
pcPrimTyCon :: Name -> [Role] -> PrimRep -> TyCon
pcPrimTyCon name roles rep
= mkPrimTyCon name kind roles rep
where
kind = mkArrowKinds (map (const liftedTypeKind) roles) result_kind
result_kind = unliftedTypeKind
| 626
|
pcPrimTyCon :: Name -> [Role] -> PrimRep -> TyCon
pcPrimTyCon name roles rep
= mkPrimTyCon name kind roles rep
where
kind = mkArrowKinds (map (const liftedTypeKind) roles) result_kind
result_kind = unliftedTypeKind
| 233
|
pcPrimTyCon name roles rep
= mkPrimTyCon name kind roles rep
where
kind = mkArrowKinds (map (const liftedTypeKind) roles) result_kind
result_kind = unliftedTypeKind
| 183
| true
| true
| 1
| 9
| 206
| 84
| 40
| 44
| null | null |
aelve/json-x
|
tests/DataFamilies/Encoders.hs
|
bsd-3-clause
|
thNullaryToJsonTaggedObject, gNullaryToJsonTaggedObject :: Nullary Int -> Json
thNullaryToJsonTaggedObject = $(mkToJson optsTaggedObject 'C1)
| 141
|
thNullaryToJsonTaggedObject, gNullaryToJsonTaggedObject :: Nullary Int -> Json
thNullaryToJsonTaggedObject = $(mkToJson optsTaggedObject 'C1)
| 141
|
thNullaryToJsonTaggedObject = $(mkToJson optsTaggedObject 'C1)
| 62
| false
| true
| 0
| 7
| 11
| 30
| 16
| 14
| null | null |
ComputationWithBoundedResources/ara-inference
|
doc/tpdb_trs/Haskell/basic_haskell/LTEQ_4.hs
|
mit
|
primCmpInt (Neg x) (Pos y) = LT
| 31
|
primCmpInt (Neg x) (Pos y) = LT
| 31
|
primCmpInt (Neg x) (Pos y) = LT
| 31
| false
| false
| 0
| 6
| 6
| 25
| 11
| 14
| null | null |
phaazon/quaazar
|
src/Quaazar/Render/GL/Framebuffer.hs
|
bsd-3-clause
|
drawBuffers :: (MonadIO m) => [AttachmentPoint] -> m ()
drawBuffers bufs = liftIO $ withArrayLen (map fromAttachmentPoint bufs) (\s b -> glDrawBuffers (fromIntegral s) b)
| 170
|
drawBuffers :: (MonadIO m) => [AttachmentPoint] -> m ()
drawBuffers bufs = liftIO $ withArrayLen (map fromAttachmentPoint bufs) (\s b -> glDrawBuffers (fromIntegral s) b)
| 170
|
drawBuffers bufs = liftIO $ withArrayLen (map fromAttachmentPoint bufs) (\s b -> glDrawBuffers (fromIntegral s) b)
| 114
| false
| true
| 0
| 11
| 24
| 73
| 37
| 36
| null | null |
gridaphobe/packages-stm
|
tests/stm049.hs
|
bsd-3-clause
|
-- | The number of bank accounts
n_accounts :: Int
n_accounts = 7
| 65
|
n_accounts :: Int
n_accounts = 7
| 32
|
n_accounts = 7
| 14
| true
| true
| 0
| 6
| 12
| 19
| 8
| 11
| null | null |
spacekitteh/smcghc
|
libraries/base/GHC/ForeignPtr.hs
|
bsd-3-clause
|
newConcForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a)
--
-- ^Turns a plain memory reference into a foreign object by
-- associating a finalizer - given by the monadic operation - with the
-- reference. The storage manager will start the finalizer, in a
-- separate thread, some time after the last reference to the
-- @ForeignPtr@ is dropped. There is no guarantee of promptness, and
-- in fact there is no guarantee that the finalizer will eventually
-- run at all.
--
-- Note that references from a finalizer do not necessarily prevent
-- another object from being finalized. If A's finalizer refers to B
-- (perhaps using 'touchForeignPtr', then the only guarantee is that
-- B's finalizer will never be started before A's. If both A and B
-- are unreachable, then both finalizers will start together. See
-- 'touchForeignPtr' for more on finalizer ordering.
--
newConcForeignPtr p finalizer
= do fObj <- newForeignPtr_ p
addForeignPtrConcFinalizer fObj finalizer
return fObj
| 1,002
|
newConcForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a)
newConcForeignPtr p finalizer
= do fObj <- newForeignPtr_ p
addForeignPtrConcFinalizer fObj finalizer
return fObj
| 186
|
newConcForeignPtr p finalizer
= do fObj <- newForeignPtr_ p
addForeignPtrConcFinalizer fObj finalizer
return fObj
| 129
| true
| true
| 0
| 9
| 185
| 81
| 44
| 37
| null | null |
mat8913/haskell-rust-experiments
|
haskell/hsbits/Setup.hs
|
apache-2.0
|
packageLinkerOptions :: InstalledPackageInfo -> [LinkerOption]
packageLinkerOptions InstalledPackageInfo { libraryDirs
, hsLibraries
, extraLibraries
} =
concat [ map LinkPath libraryDirs
, map LinkHs hsLibraries
, map LinkLib extraLibraries
]
| 409
|
packageLinkerOptions :: InstalledPackageInfo -> [LinkerOption]
packageLinkerOptions InstalledPackageInfo { libraryDirs
, hsLibraries
, extraLibraries
} =
concat [ map LinkPath libraryDirs
, map LinkHs hsLibraries
, map LinkLib extraLibraries
]
| 409
|
packageLinkerOptions InstalledPackageInfo { libraryDirs
, hsLibraries
, extraLibraries
} =
concat [ map LinkPath libraryDirs
, map LinkHs hsLibraries
, map LinkLib extraLibraries
]
| 346
| false
| true
| 0
| 7
| 194
| 60
| 31
| 29
| null | null |
yakovs83/Hakerrank-problems
|
src/Palindrome.hs
|
mit
|
longest::String->String->String
longest s1 s2
| length s1 > length s2 = s1
| otherwise = s2
| 99
|
longest::String->String->String
longest s1 s2
| length s1 > length s2 = s1
| otherwise = s2
| 99
|
longest s1 s2
| length s1 > length s2 = s1
| otherwise = s2
| 67
| false
| true
| 0
| 9
| 23
| 49
| 22
| 27
| null | null |
mariefarrell/Hets
|
OWL2/ProveFact.hs
|
gpl-2.0
|
{- |
The Prover implementation. First runs the batch prover (with graphical
feedback), then starts the GUI prover.
-}
factProver :: Prover Sign Axiom OWLMorphism ProfSub ProofTree
factProver = (mkAutomaticProver "java" "Fact" topS factGUI
factCMDLautomaticBatch)
{ proverUsable = checkOWLjar factProverJarS }
| 316
|
factProver :: Prover Sign Axiom OWLMorphism ProfSub ProofTree
factProver = (mkAutomaticProver "java" "Fact" topS factGUI
factCMDLautomaticBatch)
{ proverUsable = checkOWLjar factProverJarS }
| 194
|
factProver = (mkAutomaticProver "java" "Fact" topS factGUI
factCMDLautomaticBatch)
{ proverUsable = checkOWLjar factProverJarS }
| 132
| true
| true
| 0
| 8
| 48
| 52
| 26
| 26
| null | null |
icyfork/shellcheck
|
ShellCheck/Analytics.hs
|
gpl-3.0
|
checkTrapQuotes _ = checkCommand "trap" (const f) where
f (x:_) = checkTrap x
f _ = return ()
checkTrap (T_NormalWord _ [T_DoubleQuoted _ rs]) = mapM_ checkExpansions rs
checkTrap _ = return ()
warning id = warn id 2064 "Use single quotes, otherwise this expands now rather than when signalled."
checkExpansions (T_DollarExpansion id _) = warning id
checkExpansions (T_Backticked id _) = warning id
checkExpansions (T_DollarBraced id _) = warning id
checkExpansions (T_DollarArithmetic id _) = warning id
checkExpansions _ = return ()
| 574
|
checkTrapQuotes _ = checkCommand "trap" (const f) where
f (x:_) = checkTrap x
f _ = return ()
checkTrap (T_NormalWord _ [T_DoubleQuoted _ rs]) = mapM_ checkExpansions rs
checkTrap _ = return ()
warning id = warn id 2064 "Use single quotes, otherwise this expands now rather than when signalled."
checkExpansions (T_DollarExpansion id _) = warning id
checkExpansions (T_Backticked id _) = warning id
checkExpansions (T_DollarBraced id _) = warning id
checkExpansions (T_DollarArithmetic id _) = warning id
checkExpansions _ = return ()
| 574
|
checkTrapQuotes _ = checkCommand "trap" (const f) where
f (x:_) = checkTrap x
f _ = return ()
checkTrap (T_NormalWord _ [T_DoubleQuoted _ rs]) = mapM_ checkExpansions rs
checkTrap _ = return ()
warning id = warn id 2064 "Use single quotes, otherwise this expands now rather than when signalled."
checkExpansions (T_DollarExpansion id _) = warning id
checkExpansions (T_Backticked id _) = warning id
checkExpansions (T_DollarBraced id _) = warning id
checkExpansions (T_DollarArithmetic id _) = warning id
checkExpansions _ = return ()
| 574
| false
| false
| 0
| 11
| 122
| 200
| 94
| 106
| null | null |
phadej/stack
|
src/Stack/Upload.hs
|
bsd-3-clause
|
-- | Change the upload URL.
--
-- Default: "https://hackage.haskell.org/packages/"
--
-- Since 0.1.0.0
setUploadUrl :: String -> UploadSettings -> UploadSettings
setUploadUrl x us = us { usUploadUrl = x }
| 204
|
setUploadUrl :: String -> UploadSettings -> UploadSettings
setUploadUrl x us = us { usUploadUrl = x }
| 101
|
setUploadUrl x us = us { usUploadUrl = x }
| 42
| true
| true
| 0
| 8
| 30
| 46
| 24
| 22
| null | null |
SamirTalwar/advent-of-code
|
2021/AOC_20_2.hs
|
mit
|
toBool :: Pixel -> Bool
toBool Dark = False
| 43
|
toBool :: Pixel -> Bool
toBool Dark = False
| 43
|
toBool Dark = False
| 19
| false
| true
| 0
| 5
| 8
| 18
| 9
| 9
| null | null |
bumptech/riak-haskell-client
|
src/Network/Riak/Connection/Internal.hs
|
apache-2.0
|
pipe receive conn@Connection{..} reqs = do
ch <- newChan
let numReqs = length reqs
_ <- forkIO . replicateM_ numReqs $ writeChan ch =<< receive conn
let tag = show (messageTag (head reqs))
if Debug.level > 1
then forM_ reqs $ \req -> debug "pipe" $ ">>> " ++ showM req
else debug "pipe" $ ">>> " ++ show numReqs ++ "x " ++ tag
onIOException ("pipe " ++ tag) .
sendAll connSock . runPut . mapM_ putRequest $ reqs
replicateM numReqs $ readChan ch
-- | Send a series of requests to the server, back to back, and
-- receive a response for each request sent. The sending and
-- receiving will be overlapped if possible, to improve concurrency
-- and reduce latency.
| 688
|
pipe receive conn@Connection{..} reqs = do
ch <- newChan
let numReqs = length reqs
_ <- forkIO . replicateM_ numReqs $ writeChan ch =<< receive conn
let tag = show (messageTag (head reqs))
if Debug.level > 1
then forM_ reqs $ \req -> debug "pipe" $ ">>> " ++ showM req
else debug "pipe" $ ">>> " ++ show numReqs ++ "x " ++ tag
onIOException ("pipe " ++ tag) .
sendAll connSock . runPut . mapM_ putRequest $ reqs
replicateM numReqs $ readChan ch
-- | Send a series of requests to the server, back to back, and
-- receive a response for each request sent. The sending and
-- receiving will be overlapped if possible, to improve concurrency
-- and reduce latency.
| 688
|
pipe receive conn@Connection{..} reqs = do
ch <- newChan
let numReqs = length reqs
_ <- forkIO . replicateM_ numReqs $ writeChan ch =<< receive conn
let tag = show (messageTag (head reqs))
if Debug.level > 1
then forM_ reqs $ \req -> debug "pipe" $ ">>> " ++ showM req
else debug "pipe" $ ">>> " ++ show numReqs ++ "x " ++ tag
onIOException ("pipe " ++ tag) .
sendAll connSock . runPut . mapM_ putRequest $ reqs
replicateM numReqs $ readChan ch
-- | Send a series of requests to the server, back to back, and
-- receive a response for each request sent. The sending and
-- receiving will be overlapped if possible, to improve concurrency
-- and reduce latency.
| 688
| false
| false
| 0
| 15
| 151
| 218
| 99
| 119
| null | null |
sujeet4github/MyLangUtils
|
CategoryTheory_BartoszMilewsky/PI_10_Natural_Transformations/Ex_1.hs
|
gpl-3.0
|
success = all (to_assert test_func alpha alpha) [Nothing, Just 1]
| 65
|
success = all (to_assert test_func alpha alpha) [Nothing, Just 1]
| 65
|
success = all (to_assert test_func alpha alpha) [Nothing, Just 1]
| 65
| false
| false
| 1
| 7
| 9
| 33
| 15
| 18
| null | null |
gatlin/psilo
|
src/Lib/Preprocessor.hs
|
gpl-3.0
|
lookupDefinition :: Symbol -> Preprocess (Maybe (AnnotatedExpr (Maybe Type)))
lookupDefinition sym = do
tl <- gets toplevel
return $ M.lookup sym (definitions tl)
| 170
|
lookupDefinition :: Symbol -> Preprocess (Maybe (AnnotatedExpr (Maybe Type)))
lookupDefinition sym = do
tl <- gets toplevel
return $ M.lookup sym (definitions tl)
| 170
|
lookupDefinition sym = do
tl <- gets toplevel
return $ M.lookup sym (definitions tl)
| 92
| false
| true
| 0
| 13
| 30
| 74
| 33
| 41
| null | null |
urbanslug/ghc
|
compiler/deSugar/Coverage.hs
|
bsd-3-clause
|
addTickCmdGRHS :: GRHS Id (LHsCmd Id) -> TM (GRHS Id (LHsCmd Id))
-- The *guards* are *not* Cmds, although the body is
-- C.f. addTickGRHS for the BinBox stuff
addTickCmdGRHS (GRHS stmts cmd)
= do { (stmts',expr') <- addTickLStmts' (Just $ BinBox $ GuardBinBox)
stmts (addTickLHsCmd cmd)
; return $ GRHS stmts' expr' }
| 362
|
addTickCmdGRHS :: GRHS Id (LHsCmd Id) -> TM (GRHS Id (LHsCmd Id))
addTickCmdGRHS (GRHS stmts cmd)
= do { (stmts',expr') <- addTickLStmts' (Just $ BinBox $ GuardBinBox)
stmts (addTickLHsCmd cmd)
; return $ GRHS stmts' expr' }
| 268
|
addTickCmdGRHS (GRHS stmts cmd)
= do { (stmts',expr') <- addTickLStmts' (Just $ BinBox $ GuardBinBox)
stmts (addTickLHsCmd cmd)
; return $ GRHS stmts' expr' }
| 202
| true
| true
| 0
| 11
| 97
| 108
| 55
| 53
| null | null |
foreverbell/unlimited-plt-toys
|
tapl/simplesub/Runner.hs
|
bsd-3-clause
|
run :: String -> Meow ()
run str = do
let t = parseTree str
let ty = t `deepseq` typeOf t
case ty of
TypeTop -> meow "warning: typechecker detects Top type"
_ -> return ()
let val = ty `deepseq` evaluate t
meow $ pprint val ++ " : " ++ pprintType ty
| 267
|
run :: String -> Meow ()
run str = do
let t = parseTree str
let ty = t `deepseq` typeOf t
case ty of
TypeTop -> meow "warning: typechecker detects Top type"
_ -> return ()
let val = ty `deepseq` evaluate t
meow $ pprint val ++ " : " ++ pprintType ty
| 267
|
run str = do
let t = parseTree str
let ty = t `deepseq` typeOf t
case ty of
TypeTop -> meow "warning: typechecker detects Top type"
_ -> return ()
let val = ty `deepseq` evaluate t
meow $ pprint val ++ " : " ++ pprintType ty
| 242
| false
| true
| 5
| 10
| 72
| 102
| 52
| 50
| null | null |
f1u77y/xmonad-contrib
|
XMonad/Actions/Navigation2D.hs
|
bsd-3-clause
|
-- | Hybrid navigation. This attempts Line navigation, then falls back on Center
-- navigation if it does not find any suitable target windows. This is useful since
-- Line navigation tends to fail on gaps, but provides more intuitive motions
-- when it succeeds—provided there are no floating windows.
hybridNavigation :: Navigation2D
hybridNavigation = N 2 doHybridNavigation
| 377
|
hybridNavigation :: Navigation2D
hybridNavigation = N 2 doHybridNavigation
| 74
|
hybridNavigation = N 2 doHybridNavigation
| 41
| true
| true
| 0
| 5
| 57
| 20
| 12
| 8
| null | null |
sdiehl/ghc
|
compiler/coreSyn/CoreFVs.hs
|
bsd-3-clause
|
-- | Finds free variables in several expressions selected by a predicate
-- returning a deterministic set.
exprsSomeFreeVarsDSet :: InterestingVarFun -- ^ Says which 'Var's are interesting
-> [CoreExpr]
-> DVarSet
exprsSomeFreeVarsDSet fv_cand e =
fvDVarSet $ filterFV fv_cand $ mapUnionFV expr_fvs e
| 346
|
exprsSomeFreeVarsDSet :: InterestingVarFun -- ^ Says which 'Var's are interesting
-> [CoreExpr]
-> DVarSet
exprsSomeFreeVarsDSet fv_cand e =
fvDVarSet $ filterFV fv_cand $ mapUnionFV expr_fvs e
| 239
|
exprsSomeFreeVarsDSet fv_cand e =
fvDVarSet $ filterFV fv_cand $ mapUnionFV expr_fvs e
| 88
| true
| true
| 0
| 7
| 88
| 46
| 24
| 22
| null | null |
scott-fleischman/greek-grammar
|
haskell/greek-grammar/src/Data/Unicode/DecomposeChar.hs
|
mit
|
decomposeChar '\x1F2C' = "\x0397\x0313\x0301"
| 45
|
decomposeChar '\x1F2C' = "\x0397\x0313\x0301"
| 45
|
decomposeChar '\x1F2C' = "\x0397\x0313\x0301"
| 45
| false
| false
| 0
| 4
| 3
| 10
| 4
| 6
| null | null |
m4lvin/robbed
|
src/Data/ROBDD/Types.hs
|
bsd-3-clause
|
-- | Return the unique ID of a BDD node.
nodeUID :: BDD -> Int
nodeUID Zero = -1
| 80
|
nodeUID :: BDD -> Int
nodeUID Zero = -1
| 39
|
nodeUID Zero = -1
| 17
| true
| true
| 0
| 7
| 18
| 26
| 12
| 14
| null | null |
JacquesCarette/literate-scientific-software
|
code/drasil-example/Drasil/SSP/Defs.hs
|
bsd-2-clause
|
itslPrpty = compoundNC intrslce property
| 40
|
itslPrpty = compoundNC intrslce property
| 40
|
itslPrpty = compoundNC intrslce property
| 40
| false
| false
| 0
| 5
| 4
| 11
| 5
| 6
| null | null |
christiaanb/ghc
|
compiler/cmm/CmmContFlowOpt.hs
|
bsd-3-clause
|
mkCmmCondBranch :: CmmExpr -> Label -> Label -> CmmNode O C
mkCmmCondBranch p t f = if t == f then CmmBranch t else CmmCondBranch p t f
| 135
|
mkCmmCondBranch :: CmmExpr -> Label -> Label -> CmmNode O C
mkCmmCondBranch p t f = if t == f then CmmBranch t else CmmCondBranch p t f
| 135
|
mkCmmCondBranch p t f = if t == f then CmmBranch t else CmmCondBranch p t f
| 75
| false
| true
| 0
| 8
| 27
| 57
| 28
| 29
| null | null |
unisonweb/platform
|
codebase2/util/U/Util/Hash.hs
|
mit
|
toBase32Hex :: Hash -> Base32Hex
toBase32Hex = Base32Hex.fromByteString . toBytes
| 81
|
toBase32Hex :: Hash -> Base32Hex
toBase32Hex = Base32Hex.fromByteString . toBytes
| 81
|
toBase32Hex = Base32Hex.fromByteString . toBytes
| 48
| false
| true
| 0
| 6
| 9
| 21
| 11
| 10
| null | null |
ihc/futhark
|
src/Futhark/CodeGen/ImpGen/Kernels.hs
|
isc
|
compileKernelBody :: ImpGen.Destination
-> KernelConstants
-> KernelBody InKernel
-> InKernelGen ()
compileKernelBody (ImpGen.Destination dest) constants kbody =
compileKernelStms constants (kernelBodyStms kbody) $
zipWithM_ (compileKernelResult constants) dest $
kernelBodyResult kbody
| 346
|
compileKernelBody :: ImpGen.Destination
-> KernelConstants
-> KernelBody InKernel
-> InKernelGen ()
compileKernelBody (ImpGen.Destination dest) constants kbody =
compileKernelStms constants (kernelBodyStms kbody) $
zipWithM_ (compileKernelResult constants) dest $
kernelBodyResult kbody
| 346
|
compileKernelBody (ImpGen.Destination dest) constants kbody =
compileKernelStms constants (kernelBodyStms kbody) $
zipWithM_ (compileKernelResult constants) dest $
kernelBodyResult kbody
| 192
| false
| true
| 0
| 9
| 88
| 82
| 38
| 44
| null | null |
drhodes/jade2hdl
|
src/Jade/Vhdl.hs
|
bsd-3-clause
|
mkAssert m modt testline = "Vhdl.mkAssert" <? do
-- a <= '0'; b <= '0'; c <= '0'; d <= '0';
asserts <- ModTest.assertBitVals modt testline
Inputs bundles <- Module.getInputs m
let tgts = concatMap Bundle.getVals bundles
if (length tgts == length tgts)
then return $ map sigAssert (zip tgts asserts)
else die "expecteds not the same length as lits."
| 368
|
mkAssert m modt testline = "Vhdl.mkAssert" <? do
-- a <= '0'; b <= '0'; c <= '0'; d <= '0';
asserts <- ModTest.assertBitVals modt testline
Inputs bundles <- Module.getInputs m
let tgts = concatMap Bundle.getVals bundles
if (length tgts == length tgts)
then return $ map sigAssert (zip tgts asserts)
else die "expecteds not the same length as lits."
| 368
|
mkAssert m modt testline = "Vhdl.mkAssert" <? do
-- a <= '0'; b <= '0'; c <= '0'; d <= '0';
asserts <- ModTest.assertBitVals modt testline
Inputs bundles <- Module.getInputs m
let tgts = concatMap Bundle.getVals bundles
if (length tgts == length tgts)
then return $ map sigAssert (zip tgts asserts)
else die "expecteds not the same length as lits."
| 368
| false
| false
| 0
| 12
| 79
| 107
| 49
| 58
| null | null |
SamirTalwar/Smoke
|
src/app/Test/Smoke/App/Print.hs
|
mit
|
nestedOutputIndentation :: Int
nestedOutputIndentation = outputIndentation + 2
| 78
|
nestedOutputIndentation :: Int
nestedOutputIndentation = outputIndentation + 2
| 78
|
nestedOutputIndentation = outputIndentation + 2
| 47
| false
| true
| 0
| 5
| 7
| 15
| 8
| 7
| null | null |
josuf107/Adverb
|
Adverb/Common.hs
|
gpl-3.0
|
fatally = id
| 12
|
fatally = id
| 12
|
fatally = id
| 12
| false
| false
| 0
| 4
| 2
| 6
| 3
| 3
| null | null |
np/hlatex
|
Language/LaTeX/Builder/Color.hs
|
bsd-3-clause
|
-- | 'textcolor' sets the text of its argument in the given colour
textcolor :: Color -> LatexItem -> LatexItem
textcolor c x = BI.latexCmdAnyArgs "textcolor" (colorArgs c ++ [BI.mandatoryLatexItem x])
| 201
|
textcolor :: Color -> LatexItem -> LatexItem
textcolor c x = BI.latexCmdAnyArgs "textcolor" (colorArgs c ++ [BI.mandatoryLatexItem x])
| 134
|
textcolor c x = BI.latexCmdAnyArgs "textcolor" (colorArgs c ++ [BI.mandatoryLatexItem x])
| 89
| true
| true
| 0
| 10
| 30
| 55
| 26
| 29
| null | null |
ambiata/highlighting-kate
|
Text/Highlighting/Kate/Syntax/Bibtex.hs
|
gpl-2.0
|
-- | Full name of language.
syntaxName :: String
syntaxName = "BibTeX"
| 70
|
syntaxName :: String
syntaxName = "BibTeX"
| 42
|
syntaxName = "BibTeX"
| 21
| true
| true
| 0
| 4
| 11
| 12
| 7
| 5
| null | null |
beni55/haste-compiler
|
src/Haste/Module.hs
|
bsd-3-clause
|
readModule :: FilePath -> String -> String -> IO (Maybe Module)
readModule basepath pkgid modname = fromRight "readModule" . shell $ do
libfile <- (basepath </>) `fmap` jslibFileName basepath pkgid
mmlib <- liftIO $ JSLib.readModule libfile modname
mm <- readMod basepath pkgid modname False
mmboot <- readMod basepath pkgid modname True
case (mmlib, mm, mmboot) of
(Just m, _, _) -> return $ Just m
(_, Just m, Nothing) -> return $ Just m
(_, Just m, Just mboot) -> return . Just $ merge mboot m
_ -> return Nothing
-- | Get the file name for a given package identifier.
| 632
|
readModule :: FilePath -> String -> String -> IO (Maybe Module)
readModule basepath pkgid modname = fromRight "readModule" . shell $ do
libfile <- (basepath </>) `fmap` jslibFileName basepath pkgid
mmlib <- liftIO $ JSLib.readModule libfile modname
mm <- readMod basepath pkgid modname False
mmboot <- readMod basepath pkgid modname True
case (mmlib, mm, mmboot) of
(Just m, _, _) -> return $ Just m
(_, Just m, Nothing) -> return $ Just m
(_, Just m, Just mboot) -> return . Just $ merge mboot m
_ -> return Nothing
-- | Get the file name for a given package identifier.
| 632
|
readModule basepath pkgid modname = fromRight "readModule" . shell $ do
libfile <- (basepath </>) `fmap` jslibFileName basepath pkgid
mmlib <- liftIO $ JSLib.readModule libfile modname
mm <- readMod basepath pkgid modname False
mmboot <- readMod basepath pkgid modname True
case (mmlib, mm, mmboot) of
(Just m, _, _) -> return $ Just m
(_, Just m, Nothing) -> return $ Just m
(_, Just m, Just mboot) -> return . Just $ merge mboot m
_ -> return Nothing
-- | Get the file name for a given package identifier.
| 568
| false
| true
| 0
| 12
| 162
| 232
| 115
| 117
| null | null |
abresas/ai
|
AI.hs
|
mit
|
-- |Run layer and return output.
runNNLayer :: [Double] -> NeuralLayer -> [Double]
runNNLayer = zipWith activate . repeat
| 121
|
runNNLayer :: [Double] -> NeuralLayer -> [Double]
runNNLayer = zipWith activate . repeat
| 88
|
runNNLayer = zipWith activate . repeat
| 38
| true
| true
| 0
| 7
| 18
| 33
| 18
| 15
| null | null |
Hodapp87/ivory
|
ivory-examples/examples/Alloc.hs
|
bsd-3-clause
|
ptrstrcpy :: Def ('[Ref s (CArray (Stored IChar)), IString, Uint32] :-> ())
ptrstrcpy = proc "ptrstrcpy" $ \ _ _ _ -> body $ do
retVoid
| 138
|
ptrstrcpy :: Def ('[Ref s (CArray (Stored IChar)), IString, Uint32] :-> ())
ptrstrcpy = proc "ptrstrcpy" $ \ _ _ _ -> body $ do
retVoid
| 138
|
ptrstrcpy = proc "ptrstrcpy" $ \ _ _ _ -> body $ do
retVoid
| 62
| false
| true
| 0
| 15
| 28
| 80
| 39
| 41
| null | null |
NicolasDP/hs-memory
|
Data/ByteArray/Bytes.hs
|
bsd-3-clause
|
bytesCompare :: Bytes -> Bytes -> Ordering
bytesCompare b1@(Bytes m1) b2@(Bytes m2) = unsafeDoIO $ IO $ \s -> loop 0# s
where
!l1 = bytesLength b1
!l2 = bytesLength b2
!(I# len) = min l1 l2
loop i s1
| booleanPrim (i ==# len) =
if l1 == l2
then (# s1, EQ #)
else if l1 > l2 then (# s1, GT #)
else (# s1, LT #)
| otherwise =
case readWord8Array# m1 i s1 of
(# s2, e1 #) -> case readWord8Array# m2 i s2 of
(# s3, e2 #) ->
if booleanPrim (eqWord# e1 e2)
then loop (i +# 1#) s3
else if booleanPrim (ltWord# e1 e2) then (# s3, LT #)
else (# s3, GT #)
| 874
|
bytesCompare :: Bytes -> Bytes -> Ordering
bytesCompare b1@(Bytes m1) b2@(Bytes m2) = unsafeDoIO $ IO $ \s -> loop 0# s
where
!l1 = bytesLength b1
!l2 = bytesLength b2
!(I# len) = min l1 l2
loop i s1
| booleanPrim (i ==# len) =
if l1 == l2
then (# s1, EQ #)
else if l1 > l2 then (# s1, GT #)
else (# s1, LT #)
| otherwise =
case readWord8Array# m1 i s1 of
(# s2, e1 #) -> case readWord8Array# m2 i s2 of
(# s3, e2 #) ->
if booleanPrim (eqWord# e1 e2)
then loop (i +# 1#) s3
else if booleanPrim (ltWord# e1 e2) then (# s3, LT #)
else (# s3, GT #)
| 874
|
bytesCompare b1@(Bytes m1) b2@(Bytes m2) = unsafeDoIO $ IO $ \s -> loop 0# s
where
!l1 = bytesLength b1
!l2 = bytesLength b2
!(I# len) = min l1 l2
loop i s1
| booleanPrim (i ==# len) =
if l1 == l2
then (# s1, EQ #)
else if l1 > l2 then (# s1, GT #)
else (# s1, LT #)
| otherwise =
case readWord8Array# m1 i s1 of
(# s2, e1 #) -> case readWord8Array# m2 i s2 of
(# s3, e2 #) ->
if booleanPrim (eqWord# e1 e2)
then loop (i +# 1#) s3
else if booleanPrim (ltWord# e1 e2) then (# s3, LT #)
else (# s3, GT #)
| 831
| false
| true
| 0
| 16
| 450
| 279
| 141
| 138
| null | null |
juanmab37/HOpenCV-0.5.0.1
|
src/HOpenCV/CV/ImgProc.hs
|
gpl-2.0
|
fromCvtColorFlag :: CvtColorFlag -> CInt
fromCvtColorFlag BGR2BGRA = 0
| 73
|
fromCvtColorFlag :: CvtColorFlag -> CInt
fromCvtColorFlag BGR2BGRA = 0
| 73
|
fromCvtColorFlag BGR2BGRA = 0
| 32
| false
| true
| 0
| 5
| 11
| 18
| 9
| 9
| null | null |
mtesseract/ingscale-yesod
|
Application.hs
|
bsd-3-clause
|
-- | main function for use by yesod devel
develMain :: IO ()
develMain = develMainHelper getApplicationDev
| 106
|
develMain :: IO ()
develMain = develMainHelper getApplicationDev
| 64
|
develMain = develMainHelper getApplicationDev
| 45
| true
| true
| 0
| 6
| 16
| 20
| 10
| 10
| null | null |
kim/amazonka
|
amazonka-cloudwatch/gen/Network/AWS/CloudWatch/DeleteAlarms.hs
|
mpl-2.0
|
deleteAlarms :: DeleteAlarms
deleteAlarms = DeleteAlarms
{ _da1AlarmNames = mempty
}
| 92
|
deleteAlarms :: DeleteAlarms
deleteAlarms = DeleteAlarms
{ _da1AlarmNames = mempty
}
| 92
|
deleteAlarms = DeleteAlarms
{ _da1AlarmNames = mempty
}
| 63
| false
| true
| 0
| 6
| 18
| 22
| 12
| 10
| null | null |
amccausl/Swish
|
Swish/HaskellUtils/LookupMapTest.hs
|
lgpl-2.1
|
lm08 = mapDelete lm07 3
| 23
|
lm08 = mapDelete lm07 3
| 23
|
lm08 = mapDelete lm07 3
| 23
| false
| false
| 1
| 5
| 4
| 16
| 5
| 11
| null | null |
rahulmutt/ghcvm
|
compiler/Eta/Utils/GraphOps.hs
|
bsd-3-clause
|
addExclusion
:: (Uniquable k, Uniquable color)
=> k -> (k -> cls) -> color
-> Graph k cls color -> Graph k cls color
addExclusion u getClass color
= graphMapModify
$ adjustWithDefaultUFM
(\node -> node { nodeExclusions = addOneToUniqSet (nodeExclusions node) color })
(newNode u (getClass u)) { nodeExclusions = unitUniqSet color }
u
| 446
|
addExclusion
:: (Uniquable k, Uniquable color)
=> k -> (k -> cls) -> color
-> Graph k cls color -> Graph k cls color
addExclusion u getClass color
= graphMapModify
$ adjustWithDefaultUFM
(\node -> node { nodeExclusions = addOneToUniqSet (nodeExclusions node) color })
(newNode u (getClass u)) { nodeExclusions = unitUniqSet color }
u
| 445
|
addExclusion u getClass color
= graphMapModify
$ adjustWithDefaultUFM
(\node -> node { nodeExclusions = addOneToUniqSet (nodeExclusions node) color })
(newNode u (getClass u)) { nodeExclusions = unitUniqSet color }
u
| 304
| false
| true
| 0
| 13
| 166
| 133
| 68
| 65
| null | null |
fmapfmapfmap/amazonka
|
amazonka-cloudformation/gen/Network/AWS/CloudFormation/UpdateStack.hs
|
mpl-2.0
|
-- | Location of a file containing the temporary overriding stack policy. The
-- URL must point to a policy (max size: 16KB) located in an S3 bucket in
-- the same region as the stack. You can specify either the
-- 'StackPolicyDuringUpdateBody' or the 'StackPolicyDuringUpdateURL'
-- parameter, but not both.
--
-- If you want to update protected resources, specify a temporary
-- overriding stack policy during this update. If you do not specify a
-- stack policy, the current policy that is associated with the stack will
-- be used.
usStackPolicyDuringUpdateURL :: Lens' UpdateStack (Maybe Text)
usStackPolicyDuringUpdateURL = lens _usStackPolicyDuringUpdateURL (\ s a -> s{_usStackPolicyDuringUpdateURL = a})
| 712
|
usStackPolicyDuringUpdateURL :: Lens' UpdateStack (Maybe Text)
usStackPolicyDuringUpdateURL = lens _usStackPolicyDuringUpdateURL (\ s a -> s{_usStackPolicyDuringUpdateURL = a})
| 176
|
usStackPolicyDuringUpdateURL = lens _usStackPolicyDuringUpdateURL (\ s a -> s{_usStackPolicyDuringUpdateURL = a})
| 113
| true
| true
| 0
| 9
| 108
| 55
| 34
| 21
| null | null |
forked-upstream-packages-for-ghcjs/ghc
|
testsuite/tests/generics/GFunctor/Main.hs
|
bsd-3-clause
|
d1 = D1 (Just 'p') D0
| 21
|
d1 = D1 (Just 'p') D0
| 21
|
d1 = D1 (Just 'p') D0
| 21
| false
| false
| 1
| 7
| 5
| 20
| 8
| 12
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.