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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TomMD/cryptol
|
src/Cryptol/Parser/NoInclude.hs
|
bsd-3-clause
|
noIncludeModule :: Module -> NoIncM Module
noIncludeModule m = update `fmap` collectErrors noIncTopDecl (mDecls m)
where
update tds = m { mDecls = concat tds }
-- | Remove includes from a program.
| 201 |
noIncludeModule :: Module -> NoIncM Module
noIncludeModule m = update `fmap` collectErrors noIncTopDecl (mDecls m)
where
update tds = m { mDecls = concat tds }
-- | Remove includes from a program.
| 201 |
noIncludeModule m = update `fmap` collectErrors noIncTopDecl (mDecls m)
where
update tds = m { mDecls = concat tds }
-- | Remove includes from a program.
| 158 | false | true | 1 | 8 | 37 | 72 | 33 | 39 | null | null |
forked-upstream-packages-for-ghcjs/ghc
|
compiler/hsSyn/HsExpr.hs
|
bsd-3-clause
|
ppr_expr (HsMultiIf _ alts)
= sep $ ptext (sLit "if") : map ppr_alt alts
where ppr_alt (L _ (GRHS guards expr)) =
sep [ char '|' <+> interpp'SP guards
, ptext (sLit "->") <+> pprDeeper (ppr expr) ]
-- special case: let ... in let ...
| 262 |
ppr_expr (HsMultiIf _ alts)
= sep $ ptext (sLit "if") : map ppr_alt alts
where ppr_alt (L _ (GRHS guards expr)) =
sep [ char '|' <+> interpp'SP guards
, ptext (sLit "->") <+> pprDeeper (ppr expr) ]
-- special case: let ... in let ...
| 262 |
ppr_expr (HsMultiIf _ alts)
= sep $ ptext (sLit "if") : map ppr_alt alts
where ppr_alt (L _ (GRHS guards expr)) =
sep [ char '|' <+> interpp'SP guards
, ptext (sLit "->") <+> pprDeeper (ppr expr) ]
-- special case: let ... in let ...
| 262 | false | false | 2 | 10 | 74 | 112 | 51 | 61 | null | null |
brendanhay/gogol
|
gogol-indexing/gen/Network/Google/Indexing/Types/Product.hs
|
mpl-2.0
|
-- | The URL life cycle event that Google is being notified about.
unType :: Lens' URLNotification (Maybe URLNotificationType)
unType = lens _unType (\ s a -> s{_unType = a})
| 174 |
unType :: Lens' URLNotification (Maybe URLNotificationType)
unType = lens _unType (\ s a -> s{_unType = a})
| 107 |
unType = lens _unType (\ s a -> s{_unType = a})
| 47 | true | true | 0 | 9 | 29 | 46 | 25 | 21 | null | null |
brendanhay/gogol
|
gogol-adexchange-buyer/gen/Network/Google/AdExchangeBuyer/Types/Product.hs
|
mpl-2.0
|
ppfapName :: Lens' PublisherProFileAPIProto (Maybe Text)
ppfapName
= lens _ppfapName (\ s a -> s{_ppfapName = a})
| 115 |
ppfapName :: Lens' PublisherProFileAPIProto (Maybe Text)
ppfapName
= lens _ppfapName (\ s a -> s{_ppfapName = a})
| 115 |
ppfapName
= lens _ppfapName (\ s a -> s{_ppfapName = a})
| 58 | false | true | 1 | 9 | 18 | 51 | 24 | 27 | null | null |
holzensp/ghc
|
compiler/nativeGen/X86/Ppr.hs
|
bsd-3-clause
|
pprData (CmmUninitialised bytes)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin then ptext (sLit ".space ") <> int bytes
else ptext (sLit ".skip ") <> int bytes
| 225 |
pprData (CmmUninitialised bytes)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin then ptext (sLit ".space ") <> int bytes
else ptext (sLit ".skip ") <> int bytes
| 225 |
pprData (CmmUninitialised bytes)
= sdocWithPlatform $ \platform ->
if platformOS platform == OSDarwin then ptext (sLit ".space ") <> int bytes
else ptext (sLit ".skip ") <> int bytes
| 225 | false | false | 0 | 11 | 71 | 71 | 34 | 37 | null | null |
lukexi/rumpus
|
pristine/CubeSea/Platform.hs
|
bsd-3-clause
|
start :: Start
start = do
spawnChild_ $ do
myPose ==> position (V3 0 (-d/2) 0)
myShape ==> Cube
myBody ==> Animated
myBodyFlags ==> [Ungrabbable, Teleportable]
mySize ==> V3 w d w
myColor ==> colorHSL 0.25 0.8 0.2
| 304 |
start :: Start
start = do
spawnChild_ $ do
myPose ==> position (V3 0 (-d/2) 0)
myShape ==> Cube
myBody ==> Animated
myBodyFlags ==> [Ungrabbable, Teleportable]
mySize ==> V3 w d w
myColor ==> colorHSL 0.25 0.8 0.2
| 303 |
start = do
spawnChild_ $ do
myPose ==> position (V3 0 (-d/2) 0)
myShape ==> Cube
myBody ==> Animated
myBodyFlags ==> [Ungrabbable, Teleportable]
mySize ==> V3 w d w
myColor ==> colorHSL 0.25 0.8 0.2
| 288 | false | true | 0 | 17 | 128 | 109 | 49 | 60 | null | null |
elieux/ghc
|
compiler/prelude/PrelNames.hs
|
bsd-3-clause
|
-- Annotation type checking
toAnnotationWrapperName :: Name
toAnnotationWrapperName = varQual gHC_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey
| 160 |
toAnnotationWrapperName :: Name
toAnnotationWrapperName = varQual gHC_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey
| 132 |
toAnnotationWrapperName = varQual gHC_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey
| 100 | true | true | 0 | 7 | 13 | 25 | 13 | 12 | null | null |
cpettitt/haskell-ptree
|
test/qc/Main.hs
|
mit
|
prop_insertWith' (t :: T) k v v2 = P.insertWith' (+) k v2 (P.insert k v t) P.! k == v + v2
| 90 |
prop_insertWith' (t :: T) k v v2 = P.insertWith' (+) k v2 (P.insert k v t) P.! k == v + v2
| 90 |
prop_insertWith' (t :: T) k v v2 = P.insertWith' (+) k v2 (P.insert k v t) P.! k == v + v2
| 90 | false | false | 0 | 11 | 21 | 61 | 31 | 30 | null | null |
dgonyeo/brandskell
|
Handler/ModSources.hs
|
mit
|
newSourceAForm :: AForm Handler PSource
newSourceAForm = PSource <$> areq textField "New Source" Nothing
<* bootstrapSubmit ("Submit" :: BootstrapSubmit Text)
| 182 |
newSourceAForm :: AForm Handler PSource
newSourceAForm = PSource <$> areq textField "New Source" Nothing
<* bootstrapSubmit ("Submit" :: BootstrapSubmit Text)
| 182 |
newSourceAForm = PSource <$> areq textField "New Source" Nothing
<* bootstrapSubmit ("Submit" :: BootstrapSubmit Text)
| 142 | false | true | 0 | 8 | 43 | 43 | 21 | 22 | null | null |
mgrabmueller/harpy
|
examples/evaluator/ArithParser.hs
|
bsd-3-clause
|
semi = P.semi lexer
| 24 |
semi = P.semi lexer
| 24 |
semi = P.semi lexer
| 24 | false | false | 1 | 5 | 8 | 15 | 5 | 10 | null | null |
ghcjs/ghcjs
|
src/Compiler/JMacro/Base.hs
|
mit
|
jsv :: Text -> JExpr
jsv = ValExpr . JVar . TxtI
| 48 |
jsv :: Text -> JExpr
jsv = ValExpr . JVar . TxtI
| 48 |
jsv = ValExpr . JVar . TxtI
| 27 | false | true | 1 | 7 | 11 | 30 | 13 | 17 | null | null |
faylang/fay-server
|
modules/library/Language/Fay/Three.hs
|
bsd-3-clause
|
mkScene :: Fay Object3D
mkScene = ffi "new THREE.Scene()"
| 57 |
mkScene :: Fay Object3D
mkScene = ffi "new THREE.Scene()"
| 57 |
mkScene = ffi "new THREE.Scene()"
| 33 | false | true | 0 | 5 | 8 | 17 | 8 | 9 | null | null |
DavidAlphaFox/ghc
|
utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
|
bsd-3-clause
|
ppr_tylit :: HsTyLit -> Html
ppr_tylit (HsNumTy _ n) = toHtml (show n)
| 70 |
ppr_tylit :: HsTyLit -> Html
ppr_tylit (HsNumTy _ n) = toHtml (show n)
| 70 |
ppr_tylit (HsNumTy _ n) = toHtml (show n)
| 41 | false | true | 0 | 7 | 12 | 35 | 17 | 18 | null | null |
lgeorget/ogmarkup
|
src/Text/Ogmarkup/Private/Generator.hs
|
mit
|
sections :: (Monoid a, GenConf c a)
=> [Ast.Section a]
-> Generator c a ()
sections (s:r) = do section s
sections r
| 153 |
sections :: (Monoid a, GenConf c a)
=> [Ast.Section a]
-> Generator c a ()
sections (s:r) = do section s
sections r
| 153 |
sections (s:r) = do section s
sections r
| 60 | false | true | 0 | 9 | 60 | 71 | 34 | 37 | null | null |
athanclark/rose-trees
|
src/Data/Tree/Set.hs
|
bsd-3-clause
|
eqHead :: Eq a => SetTree a -> SetTree a -> Bool
eqHead (SetTree x _) (SetTree y _) = x == y
| 92 |
eqHead :: Eq a => SetTree a -> SetTree a -> Bool
eqHead (SetTree x _) (SetTree y _) = x == y
| 92 |
eqHead (SetTree x _) (SetTree y _) = x == y
| 43 | false | true | 0 | 8 | 22 | 57 | 27 | 30 | null | null |
mettekou/ghc
|
compiler/prelude/TysWiredIn.hs
|
bsd-3-clause
|
falseDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "False") falseDataConKey falseDataCon
| 106 |
falseDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "False") falseDataConKey falseDataCon
| 106 |
falseDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "False") falseDataConKey falseDataCon
| 106 | false | false | 0 | 7 | 9 | 23 | 11 | 12 | null | null |
ddssff/pandoc
|
src/Text/Pandoc/Writers/RST.hs
|
gpl-2.0
|
escapeString :: String -> String
escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
| 93 |
escapeString :: String -> String
escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
| 93 |
escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
| 60 | false | true | 0 | 7 | 9 | 24 | 12 | 12 | null | null |
bravit/Idris-dev
|
src/Idris/Core/TT.hs
|
bsd-3-clause
|
failMsg :: String -> TC a
failMsg str = Error (Msg str)
| 55 |
failMsg :: String -> TC a
failMsg str = Error (Msg str)
| 55 |
failMsg str = Error (Msg str)
| 29 | false | true | 0 | 7 | 11 | 34 | 15 | 19 | null | null |
rootzlevel/hledger-add
|
tests/ConfigParserSpec.hs
|
bsd-3-clause
|
exampleParseableProp :: TestData -> Property
exampleParseableProp testData =
let parser = TestData <$> option "someInt" (someInt testData) "help"
<*> option "someInteger" (someInteger testData) "help"
<*> option "someString" (someString testData) "help"
<*> option "someText" (someText testData) "help"
in parseConfig "" (parserExample parser) parser === Right testData
| 445 |
exampleParseableProp :: TestData -> Property
exampleParseableProp testData =
let parser = TestData <$> option "someInt" (someInt testData) "help"
<*> option "someInteger" (someInteger testData) "help"
<*> option "someString" (someString testData) "help"
<*> option "someText" (someText testData) "help"
in parseConfig "" (parserExample parser) parser === Right testData
| 445 |
exampleParseableProp testData =
let parser = TestData <$> option "someInt" (someInt testData) "help"
<*> option "someInteger" (someInteger testData) "help"
<*> option "someString" (someString testData) "help"
<*> option "someText" (someText testData) "help"
in parseConfig "" (parserExample parser) parser === Right testData
| 400 | false | true | 0 | 15 | 120 | 122 | 56 | 66 | null | null |
Numberartificial/workflow
|
snipets/src/Craft/Set.hs
|
mit
|
subSet :: Ord a => Set a -> Set a -> Bool
subSet (Set xs) (Set ys) = subS xs ys
| 79 |
subSet :: Ord a => Set a -> Set a -> Bool
subSet (Set xs) (Set ys) = subS xs ys
| 79 |
subSet (Set xs) (Set ys) = subS xs ys
| 37 | false | true | 0 | 8 | 20 | 54 | 25 | 29 | null | null |
apoco/wave-machine
|
src/WaveMachine/Audio/Sequencing.hs
|
unlicense
|
delay :: Double -> WaveFunction -> WaveFunction
delay delayTime waveFunc t = if t < delayTime then 0 else waveFunc (t - delayTime)
| 130 |
delay :: Double -> WaveFunction -> WaveFunction
delay delayTime waveFunc t = if t < delayTime then 0 else waveFunc (t - delayTime)
| 130 |
delay delayTime waveFunc t = if t < delayTime then 0 else waveFunc (t - delayTime)
| 82 | false | true | 0 | 8 | 22 | 48 | 25 | 23 | null | null |
DougBurke/swish
|
src/Swish/RDF/Graph.hs
|
lgpl-2.1
|
textToDouble :: T.Text -> Maybe Double
textToDouble = textToRealFloat Just
| 80 |
textToDouble :: T.Text -> Maybe Double
textToDouble = textToRealFloat Just
| 74 |
textToDouble = textToRealFloat Just
| 35 | false | true | 0 | 7 | 15 | 28 | 12 | 16 | null | null |
rrnewton/pcg-random
|
src/System/Random/PCG/Class.hs
|
bsd-3-clause
|
wordToBool :: Word32 -> Bool
wordToBool i = (i .&. 1) /= 0
| 58 |
wordToBool :: Word32 -> Bool
wordToBool i = (i .&. 1) /= 0
| 58 |
wordToBool i = (i .&. 1) /= 0
| 29 | false | true | 2 | 7 | 12 | 37 | 17 | 20 | null | null |
michalkonecny/aern2
|
aern2-mp/bench/old/Values.hs
|
bsd-3-clause
|
ballsSmallExact :: [MPBall]
ballsSmallExact = map centreAsBall ballsSmall
| 73 |
ballsSmallExact :: [MPBall]
ballsSmallExact = map centreAsBall ballsSmall
| 73 |
ballsSmallExact = map centreAsBall ballsSmall
| 45 | false | true | 0 | 5 | 7 | 19 | 10 | 9 | null | null |
Rufflewind/sci-ratio
|
src/Data/SciRatio.hs
|
mit
|
-- | Same as @'factorizeBase'@ but doesn't validate the arguments, so it might
-- loop forever or return something nonsensical.
_factorizeBase :: (Integral a, Integral b) => a -> a -> (a, b)
_factorizeBase b n | r /= 0 = (n, 0)
| r' /= 0 = (n'', e2 + 1)
| otherwise = (n''', e2 + 2)
where (n', r) = n `quotRem` b
(n'', e) = _factorizeBase (b * b) n'
(n''', r') = n'' `quotRem` b
e2 = e * 2
-- | Alias of @'factorizeBase'@.
--
-- Note: Despite what the name suggests, the function does /not/ compute the
-- floored logarithm.
| 626 |
_factorizeBase :: (Integral a, Integral b) => a -> a -> (a, b)
_factorizeBase b n | r /= 0 = (n, 0)
| r' /= 0 = (n'', e2 + 1)
| otherwise = (n''', e2 + 2)
where (n', r) = n `quotRem` b
(n'', e) = _factorizeBase (b * b) n'
(n''', r') = n'' `quotRem` b
e2 = e * 2
-- | Alias of @'factorizeBase'@.
--
-- Note: Despite what the name suggests, the function does /not/ compute the
-- floored logarithm.
| 496 |
_factorizeBase b n | r /= 0 = (n, 0)
| r' /= 0 = (n'', e2 + 1)
| otherwise = (n''', e2 + 2)
where (n', r) = n `quotRem` b
(n'', e) = _factorizeBase (b * b) n'
(n''', r') = n'' `quotRem` b
e2 = e * 2
-- | Alias of @'factorizeBase'@.
--
-- Note: Despite what the name suggests, the function does /not/ compute the
-- floored logarithm.
| 433 | true | true | 3 | 10 | 208 | 196 | 105 | 91 | null | null |
fmapfmapfmap/amazonka
|
amazonka-opsworks/gen/Network/AWS/OpsWorks/Types/Product.hs
|
mpl-2.0
|
-- | A JSON object that contains user-defined attributes to be added to the
-- stack configuration and deployment attributes. You can use custom JSON
-- to override the corresponding default stack configuration attribute
-- values or to pass data to recipes. The string should be in the following
-- format and must escape characters such as \'\"\':
--
-- '\"{\\\"key1\\\": \\\"value1\\\", \\\"key2\\\": \\\"value2\\\",...}\"'
--
-- For more information on custom JSON, see
-- <http://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-json.html Use Custom JSON to Modify the Stack Configuration Attributes>.
sCustomJSON :: Lens' Stack (Maybe Text)
sCustomJSON = lens _sCustomJSON (\ s a -> s{_sCustomJSON = a})
| 720 |
sCustomJSON :: Lens' Stack (Maybe Text)
sCustomJSON = lens _sCustomJSON (\ s a -> s{_sCustomJSON = a})
| 102 |
sCustomJSON = lens _sCustomJSON (\ s a -> s{_sCustomJSON = a})
| 62 | true | true | 0 | 9 | 100 | 55 | 34 | 21 | null | null |
tchoutri/Hexon
|
src/Shell.hs
|
bsd-3-clause
|
parse :: String -> IO (Either String Response)
parse kmd =
eval command arguments
where
textCommand = Text.pack kmd
(command:arguments) = Text.split (== ' ') textCommand
| 193 |
parse :: String -> IO (Either String Response)
parse kmd =
eval command arguments
where
textCommand = Text.pack kmd
(command:arguments) = Text.split (== ' ') textCommand
| 193 |
parse kmd =
eval command arguments
where
textCommand = Text.pack kmd
(command:arguments) = Text.split (== ' ') textCommand
| 146 | false | true | 1 | 9 | 49 | 79 | 36 | 43 | null | null |
dillonhuff/Folly
|
src/Folly/Lexer.hs
|
bsd-3-clause
|
separator = do
pos <- getPosition
name <- choice $ map string ["(", ")", "]", "[", ",", "."]
return $ Sep name pos
| 120 |
separator = do
pos <- getPosition
name <- choice $ map string ["(", ")", "]", "[", ",", "."]
return $ Sep name pos
| 120 |
separator = do
pos <- getPosition
name <- choice $ map string ["(", ")", "]", "[", ",", "."]
return $ Sep name pos
| 120 | false | false | 0 | 10 | 28 | 59 | 30 | 29 | null | null |
bravit/Idris-dev
|
src/Idris/Core/Evaluate.hs
|
bsd-3-clause
|
-- | Evaluate in a context of locally named things (i.e. not de Bruijn indexed,
-- such as we might have during construction of a proof)
-- The (Name, Int) pair in the arguments is the maximum depth of unfolding of
-- a name. The corresponding pair in the state is the maximum number of
-- unfoldings overall.
eval :: Bool -> Context -> [(Name, Int)] -> Env -> TT Name ->
[EvalOpt] -> Eval Value
eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
spec = Spec `elem` opts
simpl = Simplify True `elem` opts || Simplify False `elem` opts
simpl_inline = Simplify False `elem` opts
runtime = RunTT `elem` opts
atRepl = AtREPL `elem` opts
unfold = Unfold `elem` opts
noFree = all canonical . map snd
-- returns 'True' if the function should block
-- normal evaluation should return false
blockSimplify (CaseInfo inl always dict) n stk
| runtime
= if always then False
else not (inl || dict) || elem n stk
| simpl
= (not inl || elem n stk)
|| (n == sUN "prim__syntactic_eq")
| otherwise = False
getCases cd | simpl = cases_compiletime cd
| runtime = cases_runtime cd
| otherwise = cases_compiletime cd
ev ntimes stk top env (P _ n ty)
| Just (Let t v) <- lookupBinder n genv = ev ntimes stk top env v
ev ntimes_in stk top env (P Ref n ty)
= do let limit = if simpl then 100 else 10000
(u, ntimes) <- usable spec unfold limit n ntimes_in
let red = u && (tcReducible n ctxt || spec || (atRepl && noFree env)
|| runtime || unfold
|| sUN "assert_total" `elem` stk)
if red then
do let val = lookupDefAccExact n (spec || unfold || (atRepl && noFree env) || runtime) ctxt
case val of
Just (Function _ tm, Public) ->
ev ntimes (n:stk) True env tm
Just (TyDecl nt ty, _) -> do vty <- ev ntimes stk True env ty
return $ VP nt n vty
Just (CaseOp ci _ _ _ _ cd, acc)
| (acc == Public || acc == Hidden) &&
-- || sUN "assert_total" `elem` stk) &&
null (fst (cases_compiletime cd)) -> -- unoptimised version
let (ns, tree) = getCases cd in
if blockSimplify ci n stk
then liftM (VP Ref n) (ev ntimes stk top env ty)
else -- traceWhen runtime (show (n, ns, tree)) $
do c <- evCase ntimes n (n:stk) top env ns [] tree
case c of
(Nothing, _) -> liftM (VP Ref n) (ev ntimes stk top env ty)
(Just v, _) -> return v
_ -> liftM (VP Ref n) (ev ntimes stk top env ty)
else liftM (VP Ref n) (ev ntimes stk top env ty)
ev ntimes stk top env (P nt n ty)
= liftM (VP nt n) (ev ntimes stk top env ty)
ev ntimes stk top env (V i)
| i < length env && i >= 0 = return $ snd (env !! i)
| otherwise = return $ VV i
ev ntimes stk top env (Bind n (Let t v) sc)
| (not (runtime || simpl_inline || unfold)) || occurrences n sc < 2
= do v' <- ev ntimes stk top env v --(finalise v)
sc' <- ev ntimes stk top ((n, v') : env) sc
wknV (-1) sc'
| otherwise
= do t' <- ev ntimes stk top env t
v' <- ev ntimes stk top env v --(finalise v)
-- use Tmp as a placeholder, then make it a variable reference
-- again when evaluation finished
hs <- get
let vd = nexthole hs
put (hs { nexthole = vd + 1 })
sc' <- ev ntimes stk top ((n, VP Bound (sMN vd "vlet") VErased) : env) sc
return $ VBLet vd n t' v' sc'
ev ntimes stk top env (Bind n (NLet t v) sc)
= do t' <- ev ntimes stk top env (finalise t)
v' <- ev ntimes stk top env (finalise v)
sc' <- ev ntimes stk top ((n, v') : env) sc
return $ VBind True n (Let t' v') (\x -> return sc')
ev ntimes stk top env (Bind n b sc)
= do b' <- vbind env b
let n' = uniqueName n (map fstEnv genv ++ map fst env)
return $ VBind True -- (vinstances 0 sc < 2)
n' b' (\x -> ev ntimes stk False ((n', x):env) sc)
where vbind env t
= fmapMB (\tm -> ev ntimes stk top env (finalise tm)) t
-- block reduction immediately under codata (and not forced)
ev ntimes stk top env
(App _ (App _ (App _ d@(P _ (UN dly) _) l@(P _ (UN lco) _)) t) arg)
| dly == txt "Delay" && lco == txt "Infinite" && not (unfold || simpl)
= do let (f, _) = unApply arg
let ntimes' = case f of
P _ fn _ -> (fn, 0) : ntimes
_ -> ntimes
when spec $ setBlock True
d' <- ev ntimes' stk False env d
l' <- ev ntimes' stk False env l
t' <- ev ntimes' stk False env t
arg' <- ev ntimes' stk False env arg
when spec $ setBlock False
evApply ntimes' stk top env [l',t',arg'] d'
-- Treat "assert_total" specially, as long as it's defined!
ev ntimes stk top env (App _ (App _ (P _ n@(UN at) _) _) arg)
| Just (CaseOp _ _ _ _ _ _, _) <- lookupDefAccExact n (spec || (atRepl && noFree env)|| runtime) ctxt,
at == txt "assert_total" && not (simpl || unfold)
= ev ntimes (n : stk) top env arg
ev ntimes stk top env (App _ f a)
= do f' <- ev ntimes stk False env f
a' <- ev ntimes stk False env a
evApply ntimes stk top env [a'] f'
ev ntimes stk top env (Proj t i)
= do -- evaluate dictionaries if it means the projection works
t' <- ev ntimes stk top env t
-- tfull' <- reapply ntimes stk top env t' []
return (doProj t' (getValArgs t'))
where doProj t' (VP (DCon _ _ _) _ _, args)
| i >= 0 && i < length args = args!!i
doProj t' _ = VProj t' i
ev ntimes stk top env (Constant c) = return $ VConstant c
ev ntimes stk top env Erased = return VErased
ev ntimes stk top env Impossible = return VImpossible
ev ntimes stk top env (Inferred tm) = ev ntimes stk top env tm
ev ntimes stk top env (TType i) = return $ VType i
ev ntimes stk top env (UType u) = return $ VUType u
evApply ntimes stk top env args (VApp f a)
= evApply ntimes stk top env (a:args) f
evApply ntimes stk top env args f
= apply ntimes stk top env f args
reapply ntimes stk top env f@(VP Ref n ty) args
= let val = lookupDefAccExact n (spec || (atRepl && noFree env) || runtime) ctxt in
case val of
Just (CaseOp ci _ _ _ _ cd, acc) ->
let (ns, tree) = getCases cd in
do c <- evCase ntimes n (n:stk) top env ns args tree
case c of
(Nothing, _) -> return $ unload env (VP Ref n ty) args
(Just v, rest) -> evApply ntimes stk top env rest v
_ -> case args of
(a : as) -> return $ unload env f (a : as)
[] -> return f
reapply ntimes stk top env (VApp f a) args
= reapply ntimes stk top env f (a : args)
reapply ntimes stk top env v args = return v
apply ntimes stk top env (VBind True n (Lam _ t) sc) (a:as)
= do a' <- sc a
app <- apply ntimes stk top env a' as
wknV 1 app
apply ntimes_in stk top env f@(VP Ref n ty) args
= do let limit = if simpl then 100 else 10000
(u, ntimes) <- usable spec unfold limit n ntimes_in
let red = u && (tcReducible n ctxt || spec || (atRepl && noFree env)
|| unfold || runtime
|| sUN "assert_total" `elem` stk)
if red then
do let val = lookupDefAccExact n (spec || unfold || (atRepl && noFree env) || runtime) ctxt
case val of
Just (CaseOp ci _ _ _ _ cd, acc)
| acc == Public || acc == Hidden ->
-- unoptimised version
let (ns, tree) = getCases cd in
if blockSimplify ci n stk
then return $ unload env (VP Ref n ty) args
else -- traceWhen runtime (show (n, ns, tree)) $
do c <- evCase ntimes n (n:stk) top env ns args tree
case c of
(Nothing, _) -> return $ unload env (VP Ref n ty) args
(Just v, rest) -> evApply ntimes stk top env rest v
Just (Operator _ i op, _) ->
if (i <= length args)
then case op (take i args) of
Nothing -> return $ unload env (VP Ref n ty) args
Just v -> evApply ntimes stk top env (drop i args) v
else return $ unload env (VP Ref n ty) args
_ -> case args of
[] -> return f
_ -> return $ unload env f args
else case args of
(a : as) -> return $ unload env f (a:as)
[] -> return f
apply ntimes stk top env f (a:as) = return $ unload env f (a:as)
apply ntimes stk top env f [] = return f
-- specApply stk env f@(VP Ref n ty) args
-- = case lookupCtxt n statics of
-- [as] -> if or as
-- then trace (show (n, map fst (filter (\ (_, s) -> s) (zip args as)))) $
-- return $ unload env f args
-- else return $ unload env f args
-- _ -> return $ unload env f args
-- specApply stk env f args = return $ unload env f args
unload :: [(Name, Value)] -> Value -> [Value] -> Value
unload env f [] = f
unload env f (a:as) = unload env (VApp f a) as
evCase ntimes n stk top env ns args tree
| length ns <= length args
= do let args' = take (length ns) args
let rest = drop (length ns) args
when spec $ deduct n
t <- evTree ntimes stk top env (zip ns args') tree
when spec $ case t of
Nothing -> reinstate n -- Blocked, count n again
Just _ -> return ()
-- (zipWith (\n , t) -> (n, t)) ns args') tree
return (t, rest)
| otherwise = return (Nothing, args)
evTree :: [(Name, Int)] -> [Name] -> Bool ->
[(Name, Value)] -> [(Name, Value)] -> SC -> Eval (Maybe Value)
evTree ntimes stk top env amap (UnmatchedCase str) = return Nothing
evTree ntimes stk top env amap (STerm tm)
= do let etm = pToVs (map fst amap) tm
etm' <- ev ntimes stk (not (conHeaded tm))
(amap ++ env) etm
return $ Just etm'
evTree ntimes stk top env amap (ProjCase t alts)
= do t' <- ev ntimes stk top env t
doCase ntimes stk top env amap t' alts
evTree ntimes stk top env amap (Case _ n alts)
= case lookup n amap of
Just v -> doCase ntimes stk top env amap v alts
_ -> return Nothing
evTree ntimes stk top env amap ImpossibleCase = return Nothing
doCase ntimes stk top env amap v alts =
do c <- chooseAlt env v (getValArgs v) alts amap
case c of
Just (altmap, sc) -> evTree ntimes stk top env altmap sc
_ -> do c' <- chooseAlt' ntimes stk env v (getValArgs v) alts amap
case c' of
Just (altmap, sc) -> evTree ntimes stk top env altmap sc
_ -> return Nothing
conHeaded tm@(App _ _ _)
| (P (DCon _ _ _) _ _, args) <- unApply tm = True
conHeaded t = False
chooseAlt' ntimes stk env _ (f, args) alts amap
= do f' <- apply ntimes stk True env f args
chooseAlt env f' (getValArgs f')
alts amap
chooseAlt :: [(Name, Value)] -> Value -> (Value, [Value]) -> [CaseAlt] ->
[(Name, Value)] ->
Eval (Maybe ([(Name, Value)], SC))
chooseAlt env _ (VP (DCon i a _) _ _, args) alts amap
| Just (ns, sc) <- findTag i alts = return $ Just (updateAmap (zip ns args) amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VP (TCon i a) _ _, args) alts amap
| Just (ns, sc) <- findTag i alts
= return $ Just (updateAmap (zip ns args) amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VConstant c, []) alts amap
| Just v <- findConst c alts = return $ Just (amap, v)
| Just (n', sub, sc) <- findSuc c alts
= return $ Just (updateAmap [(n',sub)] amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VP _ n _, args) alts amap
| Just (ns, sc) <- findFn n alts = return $ Just (updateAmap (zip ns args) amap, sc)
chooseAlt env _ (VBind _ _ (Pi _ i s k) t, []) alts amap
| Just (ns, sc) <- findFn (sUN "->") alts
= do t' <- t (VV 0) -- we know it's not in scope or it's not a pattern
return $ Just (updateAmap (zip ns [s, t']) amap, sc)
chooseAlt _ _ _ alts amap
| Just v <- findDefault alts
= if (any fnCase alts)
then return $ Just (amap, v)
else return Nothing
| otherwise = return Nothing
fnCase (FnCase _ _ _) = True
fnCase _ = False
-- Replace old variable names in the map with new matches
-- (This is possibly unnecessary since we make unique names and don't
-- allow repeated variables...?)
updateAmap newm amap
= newm ++ filter (\ (x, _) -> not (elem x (map fst newm))) amap
findTag i [] = Nothing
findTag i (ConCase n j ns sc : xs) | i == j = Just (ns, sc)
findTag i (_ : xs) = findTag i xs
findFn fn [] = Nothing
findFn fn (FnCase n ns sc : xs) | fn == n = Just (ns, sc)
findFn fn (_ : xs) = findFn fn xs
findDefault [] = Nothing
findDefault (DefaultCase sc : xs) = Just sc
findDefault (_ : xs) = findDefault xs
findSuc c [] = Nothing
findSuc (BI val) (SucCase n sc : _)
| val /= 0 = Just (n, VConstant (BI (val - 1)), sc)
findSuc c (_ : xs) = findSuc c xs
findConst c [] = Nothing
findConst c (ConstCase c' v : xs) | c == c' = Just v
findConst (AType (ATInt ITNative)) (ConCase n 1 [] v : xs) = Just v
findConst (AType ATFloat) (ConCase n 2 [] v : xs) = Just v
findConst (AType (ATInt ITChar)) (ConCase n 3 [] v : xs) = Just v
findConst StrType (ConCase n 4 [] v : xs) = Just v
findConst (AType (ATInt ITBig)) (ConCase n 6 [] v : xs) = Just v
findConst (AType (ATInt (ITFixed ity))) (ConCase n tag [] v : xs)
| tag == 7 + fromEnum ity = Just v
findConst c (_ : xs) = findConst c xs
getValArgs tm = getValArgs' tm []
getValArgs' (VApp f a) as = getValArgs' f (a:as)
getValArgs' f as = (f, as)
-- tmpToV i vd (VLetHole j) | vd == j = return $ VV i
-- tmpToV i vd (VP nt n v) = liftM (VP nt n) (tmpToV i vd v)
-- tmpToV i vd (VBind n b sc) = do b' <- fmapMB (tmpToV i vd) b
-- let sc' = \x -> do x' <- sc x
-- tmpToV (i + 1) vd x'
-- return (VBind n b' sc')
-- tmpToV i vd (VApp f a) = liftM2 VApp (tmpToV i vd f) (tmpToV i vd a)
-- tmpToV i vd x = return x
| 16,616 |
eval :: Bool -> Context -> [(Name, Int)] -> Env -> TT Name ->
[EvalOpt] -> Eval Value
eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
spec = Spec `elem` opts
simpl = Simplify True `elem` opts || Simplify False `elem` opts
simpl_inline = Simplify False `elem` opts
runtime = RunTT `elem` opts
atRepl = AtREPL `elem` opts
unfold = Unfold `elem` opts
noFree = all canonical . map snd
-- returns 'True' if the function should block
-- normal evaluation should return false
blockSimplify (CaseInfo inl always dict) n stk
| runtime
= if always then False
else not (inl || dict) || elem n stk
| simpl
= (not inl || elem n stk)
|| (n == sUN "prim__syntactic_eq")
| otherwise = False
getCases cd | simpl = cases_compiletime cd
| runtime = cases_runtime cd
| otherwise = cases_compiletime cd
ev ntimes stk top env (P _ n ty)
| Just (Let t v) <- lookupBinder n genv = ev ntimes stk top env v
ev ntimes_in stk top env (P Ref n ty)
= do let limit = if simpl then 100 else 10000
(u, ntimes) <- usable spec unfold limit n ntimes_in
let red = u && (tcReducible n ctxt || spec || (atRepl && noFree env)
|| runtime || unfold
|| sUN "assert_total" `elem` stk)
if red then
do let val = lookupDefAccExact n (spec || unfold || (atRepl && noFree env) || runtime) ctxt
case val of
Just (Function _ tm, Public) ->
ev ntimes (n:stk) True env tm
Just (TyDecl nt ty, _) -> do vty <- ev ntimes stk True env ty
return $ VP nt n vty
Just (CaseOp ci _ _ _ _ cd, acc)
| (acc == Public || acc == Hidden) &&
-- || sUN "assert_total" `elem` stk) &&
null (fst (cases_compiletime cd)) -> -- unoptimised version
let (ns, tree) = getCases cd in
if blockSimplify ci n stk
then liftM (VP Ref n) (ev ntimes stk top env ty)
else -- traceWhen runtime (show (n, ns, tree)) $
do c <- evCase ntimes n (n:stk) top env ns [] tree
case c of
(Nothing, _) -> liftM (VP Ref n) (ev ntimes stk top env ty)
(Just v, _) -> return v
_ -> liftM (VP Ref n) (ev ntimes stk top env ty)
else liftM (VP Ref n) (ev ntimes stk top env ty)
ev ntimes stk top env (P nt n ty)
= liftM (VP nt n) (ev ntimes stk top env ty)
ev ntimes stk top env (V i)
| i < length env && i >= 0 = return $ snd (env !! i)
| otherwise = return $ VV i
ev ntimes stk top env (Bind n (Let t v) sc)
| (not (runtime || simpl_inline || unfold)) || occurrences n sc < 2
= do v' <- ev ntimes stk top env v --(finalise v)
sc' <- ev ntimes stk top ((n, v') : env) sc
wknV (-1) sc'
| otherwise
= do t' <- ev ntimes stk top env t
v' <- ev ntimes stk top env v --(finalise v)
-- use Tmp as a placeholder, then make it a variable reference
-- again when evaluation finished
hs <- get
let vd = nexthole hs
put (hs { nexthole = vd + 1 })
sc' <- ev ntimes stk top ((n, VP Bound (sMN vd "vlet") VErased) : env) sc
return $ VBLet vd n t' v' sc'
ev ntimes stk top env (Bind n (NLet t v) sc)
= do t' <- ev ntimes stk top env (finalise t)
v' <- ev ntimes stk top env (finalise v)
sc' <- ev ntimes stk top ((n, v') : env) sc
return $ VBind True n (Let t' v') (\x -> return sc')
ev ntimes stk top env (Bind n b sc)
= do b' <- vbind env b
let n' = uniqueName n (map fstEnv genv ++ map fst env)
return $ VBind True -- (vinstances 0 sc < 2)
n' b' (\x -> ev ntimes stk False ((n', x):env) sc)
where vbind env t
= fmapMB (\tm -> ev ntimes stk top env (finalise tm)) t
-- block reduction immediately under codata (and not forced)
ev ntimes stk top env
(App _ (App _ (App _ d@(P _ (UN dly) _) l@(P _ (UN lco) _)) t) arg)
| dly == txt "Delay" && lco == txt "Infinite" && not (unfold || simpl)
= do let (f, _) = unApply arg
let ntimes' = case f of
P _ fn _ -> (fn, 0) : ntimes
_ -> ntimes
when spec $ setBlock True
d' <- ev ntimes' stk False env d
l' <- ev ntimes' stk False env l
t' <- ev ntimes' stk False env t
arg' <- ev ntimes' stk False env arg
when spec $ setBlock False
evApply ntimes' stk top env [l',t',arg'] d'
-- Treat "assert_total" specially, as long as it's defined!
ev ntimes stk top env (App _ (App _ (P _ n@(UN at) _) _) arg)
| Just (CaseOp _ _ _ _ _ _, _) <- lookupDefAccExact n (spec || (atRepl && noFree env)|| runtime) ctxt,
at == txt "assert_total" && not (simpl || unfold)
= ev ntimes (n : stk) top env arg
ev ntimes stk top env (App _ f a)
= do f' <- ev ntimes stk False env f
a' <- ev ntimes stk False env a
evApply ntimes stk top env [a'] f'
ev ntimes stk top env (Proj t i)
= do -- evaluate dictionaries if it means the projection works
t' <- ev ntimes stk top env t
-- tfull' <- reapply ntimes stk top env t' []
return (doProj t' (getValArgs t'))
where doProj t' (VP (DCon _ _ _) _ _, args)
| i >= 0 && i < length args = args!!i
doProj t' _ = VProj t' i
ev ntimes stk top env (Constant c) = return $ VConstant c
ev ntimes stk top env Erased = return VErased
ev ntimes stk top env Impossible = return VImpossible
ev ntimes stk top env (Inferred tm) = ev ntimes stk top env tm
ev ntimes stk top env (TType i) = return $ VType i
ev ntimes stk top env (UType u) = return $ VUType u
evApply ntimes stk top env args (VApp f a)
= evApply ntimes stk top env (a:args) f
evApply ntimes stk top env args f
= apply ntimes stk top env f args
reapply ntimes stk top env f@(VP Ref n ty) args
= let val = lookupDefAccExact n (spec || (atRepl && noFree env) || runtime) ctxt in
case val of
Just (CaseOp ci _ _ _ _ cd, acc) ->
let (ns, tree) = getCases cd in
do c <- evCase ntimes n (n:stk) top env ns args tree
case c of
(Nothing, _) -> return $ unload env (VP Ref n ty) args
(Just v, rest) -> evApply ntimes stk top env rest v
_ -> case args of
(a : as) -> return $ unload env f (a : as)
[] -> return f
reapply ntimes stk top env (VApp f a) args
= reapply ntimes stk top env f (a : args)
reapply ntimes stk top env v args = return v
apply ntimes stk top env (VBind True n (Lam _ t) sc) (a:as)
= do a' <- sc a
app <- apply ntimes stk top env a' as
wknV 1 app
apply ntimes_in stk top env f@(VP Ref n ty) args
= do let limit = if simpl then 100 else 10000
(u, ntimes) <- usable spec unfold limit n ntimes_in
let red = u && (tcReducible n ctxt || spec || (atRepl && noFree env)
|| unfold || runtime
|| sUN "assert_total" `elem` stk)
if red then
do let val = lookupDefAccExact n (spec || unfold || (atRepl && noFree env) || runtime) ctxt
case val of
Just (CaseOp ci _ _ _ _ cd, acc)
| acc == Public || acc == Hidden ->
-- unoptimised version
let (ns, tree) = getCases cd in
if blockSimplify ci n stk
then return $ unload env (VP Ref n ty) args
else -- traceWhen runtime (show (n, ns, tree)) $
do c <- evCase ntimes n (n:stk) top env ns args tree
case c of
(Nothing, _) -> return $ unload env (VP Ref n ty) args
(Just v, rest) -> evApply ntimes stk top env rest v
Just (Operator _ i op, _) ->
if (i <= length args)
then case op (take i args) of
Nothing -> return $ unload env (VP Ref n ty) args
Just v -> evApply ntimes stk top env (drop i args) v
else return $ unload env (VP Ref n ty) args
_ -> case args of
[] -> return f
_ -> return $ unload env f args
else case args of
(a : as) -> return $ unload env f (a:as)
[] -> return f
apply ntimes stk top env f (a:as) = return $ unload env f (a:as)
apply ntimes stk top env f [] = return f
-- specApply stk env f@(VP Ref n ty) args
-- = case lookupCtxt n statics of
-- [as] -> if or as
-- then trace (show (n, map fst (filter (\ (_, s) -> s) (zip args as)))) $
-- return $ unload env f args
-- else return $ unload env f args
-- _ -> return $ unload env f args
-- specApply stk env f args = return $ unload env f args
unload :: [(Name, Value)] -> Value -> [Value] -> Value
unload env f [] = f
unload env f (a:as) = unload env (VApp f a) as
evCase ntimes n stk top env ns args tree
| length ns <= length args
= do let args' = take (length ns) args
let rest = drop (length ns) args
when spec $ deduct n
t <- evTree ntimes stk top env (zip ns args') tree
when spec $ case t of
Nothing -> reinstate n -- Blocked, count n again
Just _ -> return ()
-- (zipWith (\n , t) -> (n, t)) ns args') tree
return (t, rest)
| otherwise = return (Nothing, args)
evTree :: [(Name, Int)] -> [Name] -> Bool ->
[(Name, Value)] -> [(Name, Value)] -> SC -> Eval (Maybe Value)
evTree ntimes stk top env amap (UnmatchedCase str) = return Nothing
evTree ntimes stk top env amap (STerm tm)
= do let etm = pToVs (map fst amap) tm
etm' <- ev ntimes stk (not (conHeaded tm))
(amap ++ env) etm
return $ Just etm'
evTree ntimes stk top env amap (ProjCase t alts)
= do t' <- ev ntimes stk top env t
doCase ntimes stk top env amap t' alts
evTree ntimes stk top env amap (Case _ n alts)
= case lookup n amap of
Just v -> doCase ntimes stk top env amap v alts
_ -> return Nothing
evTree ntimes stk top env amap ImpossibleCase = return Nothing
doCase ntimes stk top env amap v alts =
do c <- chooseAlt env v (getValArgs v) alts amap
case c of
Just (altmap, sc) -> evTree ntimes stk top env altmap sc
_ -> do c' <- chooseAlt' ntimes stk env v (getValArgs v) alts amap
case c' of
Just (altmap, sc) -> evTree ntimes stk top env altmap sc
_ -> return Nothing
conHeaded tm@(App _ _ _)
| (P (DCon _ _ _) _ _, args) <- unApply tm = True
conHeaded t = False
chooseAlt' ntimes stk env _ (f, args) alts amap
= do f' <- apply ntimes stk True env f args
chooseAlt env f' (getValArgs f')
alts amap
chooseAlt :: [(Name, Value)] -> Value -> (Value, [Value]) -> [CaseAlt] ->
[(Name, Value)] ->
Eval (Maybe ([(Name, Value)], SC))
chooseAlt env _ (VP (DCon i a _) _ _, args) alts amap
| Just (ns, sc) <- findTag i alts = return $ Just (updateAmap (zip ns args) amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VP (TCon i a) _ _, args) alts amap
| Just (ns, sc) <- findTag i alts
= return $ Just (updateAmap (zip ns args) amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VConstant c, []) alts amap
| Just v <- findConst c alts = return $ Just (amap, v)
| Just (n', sub, sc) <- findSuc c alts
= return $ Just (updateAmap [(n',sub)] amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VP _ n _, args) alts amap
| Just (ns, sc) <- findFn n alts = return $ Just (updateAmap (zip ns args) amap, sc)
chooseAlt env _ (VBind _ _ (Pi _ i s k) t, []) alts amap
| Just (ns, sc) <- findFn (sUN "->") alts
= do t' <- t (VV 0) -- we know it's not in scope or it's not a pattern
return $ Just (updateAmap (zip ns [s, t']) amap, sc)
chooseAlt _ _ _ alts amap
| Just v <- findDefault alts
= if (any fnCase alts)
then return $ Just (amap, v)
else return Nothing
| otherwise = return Nothing
fnCase (FnCase _ _ _) = True
fnCase _ = False
-- Replace old variable names in the map with new matches
-- (This is possibly unnecessary since we make unique names and don't
-- allow repeated variables...?)
updateAmap newm amap
= newm ++ filter (\ (x, _) -> not (elem x (map fst newm))) amap
findTag i [] = Nothing
findTag i (ConCase n j ns sc : xs) | i == j = Just (ns, sc)
findTag i (_ : xs) = findTag i xs
findFn fn [] = Nothing
findFn fn (FnCase n ns sc : xs) | fn == n = Just (ns, sc)
findFn fn (_ : xs) = findFn fn xs
findDefault [] = Nothing
findDefault (DefaultCase sc : xs) = Just sc
findDefault (_ : xs) = findDefault xs
findSuc c [] = Nothing
findSuc (BI val) (SucCase n sc : _)
| val /= 0 = Just (n, VConstant (BI (val - 1)), sc)
findSuc c (_ : xs) = findSuc c xs
findConst c [] = Nothing
findConst c (ConstCase c' v : xs) | c == c' = Just v
findConst (AType (ATInt ITNative)) (ConCase n 1 [] v : xs) = Just v
findConst (AType ATFloat) (ConCase n 2 [] v : xs) = Just v
findConst (AType (ATInt ITChar)) (ConCase n 3 [] v : xs) = Just v
findConst StrType (ConCase n 4 [] v : xs) = Just v
findConst (AType (ATInt ITBig)) (ConCase n 6 [] v : xs) = Just v
findConst (AType (ATInt (ITFixed ity))) (ConCase n tag [] v : xs)
| tag == 7 + fromEnum ity = Just v
findConst c (_ : xs) = findConst c xs
getValArgs tm = getValArgs' tm []
getValArgs' (VApp f a) as = getValArgs' f (a:as)
getValArgs' f as = (f, as)
-- tmpToV i vd (VLetHole j) | vd == j = return $ VV i
-- tmpToV i vd (VP nt n v) = liftM (VP nt n) (tmpToV i vd v)
-- tmpToV i vd (VBind n b sc) = do b' <- fmapMB (tmpToV i vd) b
-- let sc' = \x -> do x' <- sc x
-- tmpToV (i + 1) vd x'
-- return (VBind n b' sc')
-- tmpToV i vd (VApp f a) = liftM2 VApp (tmpToV i vd f) (tmpToV i vd a)
-- tmpToV i vd x = return x
| 16,304 |
eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
spec = Spec `elem` opts
simpl = Simplify True `elem` opts || Simplify False `elem` opts
simpl_inline = Simplify False `elem` opts
runtime = RunTT `elem` opts
atRepl = AtREPL `elem` opts
unfold = Unfold `elem` opts
noFree = all canonical . map snd
-- returns 'True' if the function should block
-- normal evaluation should return false
blockSimplify (CaseInfo inl always dict) n stk
| runtime
= if always then False
else not (inl || dict) || elem n stk
| simpl
= (not inl || elem n stk)
|| (n == sUN "prim__syntactic_eq")
| otherwise = False
getCases cd | simpl = cases_compiletime cd
| runtime = cases_runtime cd
| otherwise = cases_compiletime cd
ev ntimes stk top env (P _ n ty)
| Just (Let t v) <- lookupBinder n genv = ev ntimes stk top env v
ev ntimes_in stk top env (P Ref n ty)
= do let limit = if simpl then 100 else 10000
(u, ntimes) <- usable spec unfold limit n ntimes_in
let red = u && (tcReducible n ctxt || spec || (atRepl && noFree env)
|| runtime || unfold
|| sUN "assert_total" `elem` stk)
if red then
do let val = lookupDefAccExact n (spec || unfold || (atRepl && noFree env) || runtime) ctxt
case val of
Just (Function _ tm, Public) ->
ev ntimes (n:stk) True env tm
Just (TyDecl nt ty, _) -> do vty <- ev ntimes stk True env ty
return $ VP nt n vty
Just (CaseOp ci _ _ _ _ cd, acc)
| (acc == Public || acc == Hidden) &&
-- || sUN "assert_total" `elem` stk) &&
null (fst (cases_compiletime cd)) -> -- unoptimised version
let (ns, tree) = getCases cd in
if blockSimplify ci n stk
then liftM (VP Ref n) (ev ntimes stk top env ty)
else -- traceWhen runtime (show (n, ns, tree)) $
do c <- evCase ntimes n (n:stk) top env ns [] tree
case c of
(Nothing, _) -> liftM (VP Ref n) (ev ntimes stk top env ty)
(Just v, _) -> return v
_ -> liftM (VP Ref n) (ev ntimes stk top env ty)
else liftM (VP Ref n) (ev ntimes stk top env ty)
ev ntimes stk top env (P nt n ty)
= liftM (VP nt n) (ev ntimes stk top env ty)
ev ntimes stk top env (V i)
| i < length env && i >= 0 = return $ snd (env !! i)
| otherwise = return $ VV i
ev ntimes stk top env (Bind n (Let t v) sc)
| (not (runtime || simpl_inline || unfold)) || occurrences n sc < 2
= do v' <- ev ntimes stk top env v --(finalise v)
sc' <- ev ntimes stk top ((n, v') : env) sc
wknV (-1) sc'
| otherwise
= do t' <- ev ntimes stk top env t
v' <- ev ntimes stk top env v --(finalise v)
-- use Tmp as a placeholder, then make it a variable reference
-- again when evaluation finished
hs <- get
let vd = nexthole hs
put (hs { nexthole = vd + 1 })
sc' <- ev ntimes stk top ((n, VP Bound (sMN vd "vlet") VErased) : env) sc
return $ VBLet vd n t' v' sc'
ev ntimes stk top env (Bind n (NLet t v) sc)
= do t' <- ev ntimes stk top env (finalise t)
v' <- ev ntimes stk top env (finalise v)
sc' <- ev ntimes stk top ((n, v') : env) sc
return $ VBind True n (Let t' v') (\x -> return sc')
ev ntimes stk top env (Bind n b sc)
= do b' <- vbind env b
let n' = uniqueName n (map fstEnv genv ++ map fst env)
return $ VBind True -- (vinstances 0 sc < 2)
n' b' (\x -> ev ntimes stk False ((n', x):env) sc)
where vbind env t
= fmapMB (\tm -> ev ntimes stk top env (finalise tm)) t
-- block reduction immediately under codata (and not forced)
ev ntimes stk top env
(App _ (App _ (App _ d@(P _ (UN dly) _) l@(P _ (UN lco) _)) t) arg)
| dly == txt "Delay" && lco == txt "Infinite" && not (unfold || simpl)
= do let (f, _) = unApply arg
let ntimes' = case f of
P _ fn _ -> (fn, 0) : ntimes
_ -> ntimes
when spec $ setBlock True
d' <- ev ntimes' stk False env d
l' <- ev ntimes' stk False env l
t' <- ev ntimes' stk False env t
arg' <- ev ntimes' stk False env arg
when spec $ setBlock False
evApply ntimes' stk top env [l',t',arg'] d'
-- Treat "assert_total" specially, as long as it's defined!
ev ntimes stk top env (App _ (App _ (P _ n@(UN at) _) _) arg)
| Just (CaseOp _ _ _ _ _ _, _) <- lookupDefAccExact n (spec || (atRepl && noFree env)|| runtime) ctxt,
at == txt "assert_total" && not (simpl || unfold)
= ev ntimes (n : stk) top env arg
ev ntimes stk top env (App _ f a)
= do f' <- ev ntimes stk False env f
a' <- ev ntimes stk False env a
evApply ntimes stk top env [a'] f'
ev ntimes stk top env (Proj t i)
= do -- evaluate dictionaries if it means the projection works
t' <- ev ntimes stk top env t
-- tfull' <- reapply ntimes stk top env t' []
return (doProj t' (getValArgs t'))
where doProj t' (VP (DCon _ _ _) _ _, args)
| i >= 0 && i < length args = args!!i
doProj t' _ = VProj t' i
ev ntimes stk top env (Constant c) = return $ VConstant c
ev ntimes stk top env Erased = return VErased
ev ntimes stk top env Impossible = return VImpossible
ev ntimes stk top env (Inferred tm) = ev ntimes stk top env tm
ev ntimes stk top env (TType i) = return $ VType i
ev ntimes stk top env (UType u) = return $ VUType u
evApply ntimes stk top env args (VApp f a)
= evApply ntimes stk top env (a:args) f
evApply ntimes stk top env args f
= apply ntimes stk top env f args
reapply ntimes stk top env f@(VP Ref n ty) args
= let val = lookupDefAccExact n (spec || (atRepl && noFree env) || runtime) ctxt in
case val of
Just (CaseOp ci _ _ _ _ cd, acc) ->
let (ns, tree) = getCases cd in
do c <- evCase ntimes n (n:stk) top env ns args tree
case c of
(Nothing, _) -> return $ unload env (VP Ref n ty) args
(Just v, rest) -> evApply ntimes stk top env rest v
_ -> case args of
(a : as) -> return $ unload env f (a : as)
[] -> return f
reapply ntimes stk top env (VApp f a) args
= reapply ntimes stk top env f (a : args)
reapply ntimes stk top env v args = return v
apply ntimes stk top env (VBind True n (Lam _ t) sc) (a:as)
= do a' <- sc a
app <- apply ntimes stk top env a' as
wknV 1 app
apply ntimes_in stk top env f@(VP Ref n ty) args
= do let limit = if simpl then 100 else 10000
(u, ntimes) <- usable spec unfold limit n ntimes_in
let red = u && (tcReducible n ctxt || spec || (atRepl && noFree env)
|| unfold || runtime
|| sUN "assert_total" `elem` stk)
if red then
do let val = lookupDefAccExact n (spec || unfold || (atRepl && noFree env) || runtime) ctxt
case val of
Just (CaseOp ci _ _ _ _ cd, acc)
| acc == Public || acc == Hidden ->
-- unoptimised version
let (ns, tree) = getCases cd in
if blockSimplify ci n stk
then return $ unload env (VP Ref n ty) args
else -- traceWhen runtime (show (n, ns, tree)) $
do c <- evCase ntimes n (n:stk) top env ns args tree
case c of
(Nothing, _) -> return $ unload env (VP Ref n ty) args
(Just v, rest) -> evApply ntimes stk top env rest v
Just (Operator _ i op, _) ->
if (i <= length args)
then case op (take i args) of
Nothing -> return $ unload env (VP Ref n ty) args
Just v -> evApply ntimes stk top env (drop i args) v
else return $ unload env (VP Ref n ty) args
_ -> case args of
[] -> return f
_ -> return $ unload env f args
else case args of
(a : as) -> return $ unload env f (a:as)
[] -> return f
apply ntimes stk top env f (a:as) = return $ unload env f (a:as)
apply ntimes stk top env f [] = return f
-- specApply stk env f@(VP Ref n ty) args
-- = case lookupCtxt n statics of
-- [as] -> if or as
-- then trace (show (n, map fst (filter (\ (_, s) -> s) (zip args as)))) $
-- return $ unload env f args
-- else return $ unload env f args
-- _ -> return $ unload env f args
-- specApply stk env f args = return $ unload env f args
unload :: [(Name, Value)] -> Value -> [Value] -> Value
unload env f [] = f
unload env f (a:as) = unload env (VApp f a) as
evCase ntimes n stk top env ns args tree
| length ns <= length args
= do let args' = take (length ns) args
let rest = drop (length ns) args
when spec $ deduct n
t <- evTree ntimes stk top env (zip ns args') tree
when spec $ case t of
Nothing -> reinstate n -- Blocked, count n again
Just _ -> return ()
-- (zipWith (\n , t) -> (n, t)) ns args') tree
return (t, rest)
| otherwise = return (Nothing, args)
evTree :: [(Name, Int)] -> [Name] -> Bool ->
[(Name, Value)] -> [(Name, Value)] -> SC -> Eval (Maybe Value)
evTree ntimes stk top env amap (UnmatchedCase str) = return Nothing
evTree ntimes stk top env amap (STerm tm)
= do let etm = pToVs (map fst amap) tm
etm' <- ev ntimes stk (not (conHeaded tm))
(amap ++ env) etm
return $ Just etm'
evTree ntimes stk top env amap (ProjCase t alts)
= do t' <- ev ntimes stk top env t
doCase ntimes stk top env amap t' alts
evTree ntimes stk top env amap (Case _ n alts)
= case lookup n amap of
Just v -> doCase ntimes stk top env amap v alts
_ -> return Nothing
evTree ntimes stk top env amap ImpossibleCase = return Nothing
doCase ntimes stk top env amap v alts =
do c <- chooseAlt env v (getValArgs v) alts amap
case c of
Just (altmap, sc) -> evTree ntimes stk top env altmap sc
_ -> do c' <- chooseAlt' ntimes stk env v (getValArgs v) alts amap
case c' of
Just (altmap, sc) -> evTree ntimes stk top env altmap sc
_ -> return Nothing
conHeaded tm@(App _ _ _)
| (P (DCon _ _ _) _ _, args) <- unApply tm = True
conHeaded t = False
chooseAlt' ntimes stk env _ (f, args) alts amap
= do f' <- apply ntimes stk True env f args
chooseAlt env f' (getValArgs f')
alts amap
chooseAlt :: [(Name, Value)] -> Value -> (Value, [Value]) -> [CaseAlt] ->
[(Name, Value)] ->
Eval (Maybe ([(Name, Value)], SC))
chooseAlt env _ (VP (DCon i a _) _ _, args) alts amap
| Just (ns, sc) <- findTag i alts = return $ Just (updateAmap (zip ns args) amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VP (TCon i a) _ _, args) alts amap
| Just (ns, sc) <- findTag i alts
= return $ Just (updateAmap (zip ns args) amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VConstant c, []) alts amap
| Just v <- findConst c alts = return $ Just (amap, v)
| Just (n', sub, sc) <- findSuc c alts
= return $ Just (updateAmap [(n',sub)] amap, sc)
| Just v <- findDefault alts = return $ Just (amap, v)
chooseAlt env _ (VP _ n _, args) alts amap
| Just (ns, sc) <- findFn n alts = return $ Just (updateAmap (zip ns args) amap, sc)
chooseAlt env _ (VBind _ _ (Pi _ i s k) t, []) alts amap
| Just (ns, sc) <- findFn (sUN "->") alts
= do t' <- t (VV 0) -- we know it's not in scope or it's not a pattern
return $ Just (updateAmap (zip ns [s, t']) amap, sc)
chooseAlt _ _ _ alts amap
| Just v <- findDefault alts
= if (any fnCase alts)
then return $ Just (amap, v)
else return Nothing
| otherwise = return Nothing
fnCase (FnCase _ _ _) = True
fnCase _ = False
-- Replace old variable names in the map with new matches
-- (This is possibly unnecessary since we make unique names and don't
-- allow repeated variables...?)
updateAmap newm amap
= newm ++ filter (\ (x, _) -> not (elem x (map fst newm))) amap
findTag i [] = Nothing
findTag i (ConCase n j ns sc : xs) | i == j = Just (ns, sc)
findTag i (_ : xs) = findTag i xs
findFn fn [] = Nothing
findFn fn (FnCase n ns sc : xs) | fn == n = Just (ns, sc)
findFn fn (_ : xs) = findFn fn xs
findDefault [] = Nothing
findDefault (DefaultCase sc : xs) = Just sc
findDefault (_ : xs) = findDefault xs
findSuc c [] = Nothing
findSuc (BI val) (SucCase n sc : _)
| val /= 0 = Just (n, VConstant (BI (val - 1)), sc)
findSuc c (_ : xs) = findSuc c xs
findConst c [] = Nothing
findConst c (ConstCase c' v : xs) | c == c' = Just v
findConst (AType (ATInt ITNative)) (ConCase n 1 [] v : xs) = Just v
findConst (AType ATFloat) (ConCase n 2 [] v : xs) = Just v
findConst (AType (ATInt ITChar)) (ConCase n 3 [] v : xs) = Just v
findConst StrType (ConCase n 4 [] v : xs) = Just v
findConst (AType (ATInt ITBig)) (ConCase n 6 [] v : xs) = Just v
findConst (AType (ATInt (ITFixed ity))) (ConCase n tag [] v : xs)
| tag == 7 + fromEnum ity = Just v
findConst c (_ : xs) = findConst c xs
getValArgs tm = getValArgs' tm []
getValArgs' (VApp f a) as = getValArgs' f (a:as)
getValArgs' f as = (f, as)
-- tmpToV i vd (VLetHole j) | vd == j = return $ VV i
-- tmpToV i vd (VP nt n v) = liftM (VP nt n) (tmpToV i vd v)
-- tmpToV i vd (VBind n b sc) = do b' <- fmapMB (tmpToV i vd) b
-- let sc' = \x -> do x' <- sc x
-- tmpToV (i + 1) vd x'
-- return (VBind n b' sc')
-- tmpToV i vd (VApp f a) = liftM2 VApp (tmpToV i vd f) (tmpToV i vd a)
-- tmpToV i vd x = return x
| 16,210 | true | true | 188 | 28 | 6,876 | 5,988 | 3,037 | 2,951 | null | null |
mimi1vx/shellcheck
|
ShellCheck/Analytics.hs
|
gpl-3.0
|
prop_checkSetAssignment3 = verify checkSetAssignment "set foo=42"
| 65 |
prop_checkSetAssignment3 = verify checkSetAssignment "set foo=42"
| 65 |
prop_checkSetAssignment3 = verify checkSetAssignment "set foo=42"
| 65 | false | false | 0 | 5 | 5 | 11 | 5 | 6 | null | null |
jgoerzen/dtmconv
|
HaXml-1.12/src/Text/XML/HaXml/Html/Parse.hs
|
gpl-2.0
|
"LABEL" `closes` "LABEL" = True
| 35 |
"LABEL" `closes` "LABEL" = True
| 35 |
"LABEL" `closes` "LABEL" = True
| 35 | false | false | 0 | 5 | 8 | 18 | 8 | 10 | null | null |
robdockins/edison
|
edison-core/src/Data/Edison/Coll/SkewHeap.hs
|
mit
|
fold f e (T x a b) = f x (fold f (fold f e a) b)
| 48 |
fold f e (T x a b) = f x (fold f (fold f e a) b)
| 48 |
fold f e (T x a b) = f x (fold f (fold f e a) b)
| 48 | false | false | 0 | 9 | 16 | 48 | 23 | 25 | null | null |
danr/tfp1
|
Lang/PrettyPolyFOL.hs
|
gpl-3.0
|
ppTerm :: Id a -> Term a -> Doc
ppTerm p = go
where
go tm0 = case tm0 of
Apply f ts as -> p f <> csv (map (ppType p) ts ++ map go as)
Var v -> p v
Lit x -> integer x
| 211 |
ppTerm :: Id a -> Term a -> Doc
ppTerm p = go
where
go tm0 = case tm0 of
Apply f ts as -> p f <> csv (map (ppType p) ts ++ map go as)
Var v -> p v
Lit x -> integer x
| 211 |
ppTerm p = go
where
go tm0 = case tm0 of
Apply f ts as -> p f <> csv (map (ppType p) ts ++ map go as)
Var v -> p v
Lit x -> integer x
| 179 | false | true | 1 | 14 | 92 | 121 | 52 | 69 | null | null |
irreverent-pixel-feats/bitbucket
|
bitbucket-json/src/Irreverent/Bitbucket/Json/Common.hs
|
bsd-3-clause
|
parseRepoSlug :: Value -> Parser RepoSlug
parseRepoSlug v = RepoSlug <$> parseJSON v
| 84 |
parseRepoSlug :: Value -> Parser RepoSlug
parseRepoSlug v = RepoSlug <$> parseJSON v
| 84 |
parseRepoSlug v = RepoSlug <$> parseJSON v
| 42 | false | true | 0 | 6 | 12 | 28 | 13 | 15 | null | null |
vvmann/tyckiting-bot
|
clients/haskell/src/Tyckiting/AI/Joker.hs
|
mit
|
-- | Positions on the whole map, yet without borders
allPositions :: GameConfig -> JokerState
allPositions gameConfig =
neighbours (cfgFieldRadius gameConfig - cfgCannon gameConfig) origo
| 191 |
allPositions :: GameConfig -> JokerState
allPositions gameConfig =
neighbours (cfgFieldRadius gameConfig - cfgCannon gameConfig) origo
| 138 |
allPositions gameConfig =
neighbours (cfgFieldRadius gameConfig - cfgCannon gameConfig) origo
| 97 | true | true | 0 | 8 | 28 | 37 | 18 | 19 | null | null |
mrk21/study_haskell
|
find_max/Main.hs
|
mit
|
main :: IO ()
main = print $ max2 [3,2,1,5,-4]
| 46 |
main :: IO ()
main = print $ max2 [3,2,1,5,-4]
| 46 |
main = print $ max2 [3,2,1,5,-4]
| 32 | false | true | 2 | 7 | 9 | 46 | 23 | 23 | null | null |
nadavshemer/buildsome
|
src/Lib/FilePath.hs
|
gpl-2.0
|
(<.>) :: FilePath -> ByteString -> FilePath
f <.> g = f <> "." <> g
| 67 |
(<.>) :: FilePath -> ByteString -> FilePath
f <.> g = f <> "." <> g
| 67 |
f <.> g = f <> "." <> g
| 23 | false | true | 2 | 9 | 15 | 40 | 19 | 21 | null | null |
urbanslug/ghc
|
compiler/typecheck/TcGenDeriv.hs
|
bsd-3-clause
|
gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds RdrName, BagDerivStuff)
gen_Traversable_binds loc tycon
= (unitBag traverse_bind, emptyBag)
where
data_cons = tyConDataCons tycon
traverse_bind = mkRdrFunBind (L loc traverse_RDR) eqns
eqns = map traverse_eqn data_cons
traverse_eqn con = evalState (match_for_con [f_Pat] con =<< parts) bs_RDRs
where
parts = sequence $ foldDataConArgs ft_trav con
ft_trav :: FFoldType (State [RdrName] (LHsExpr RdrName))
ft_trav = FT { ft_triv = return pure_Expr -- traverse f = pure x
, ft_var = return f_Expr -- traverse f = f x
, ft_tup = \t gs -> do -- traverse f = \x -> case x of (a1,a2,..) ->
gg <- sequence gs -- (,,) <$> g1 a1 <*> g2 a2 <*> ..
mkSimpleLam $ mkSimpleTupleCase match_for_con t gg
, ft_ty_app = \_ g -> nlHsApp traverse_Expr <$> g -- traverse f = travese g
, ft_forall = \_ g -> g
, ft_co_var = panic "contravariant"
, ft_fun = panic "function"
, ft_bad_app = panic "in other argument" }
-- Con a1 a2 ... -> Con <$> g1 a1 <*> g2 a2 <*> ...
match_for_con = mkSimpleConMatch $
\con_name xs -> return $ mkApCon (nlHsVar con_name) xs
-- ((Con <$> x1) <*> x2) <*> ..
mkApCon con [] = nlHsApps pure_RDR [con]
mkApCon con (x:xs) = foldl appAp (nlHsApps fmap_RDR [con,x]) xs
where appAp x y = nlHsApps ap_RDR [x,y]
{-
************************************************************************
* *
Newtype-deriving instances
* *
************************************************************************
We take every method in the original instance and `coerce` it to fit
into the derived instance. We need a type annotation on the argument
to `coerce` to make it obvious what instantiation of the method we're
coercing from.
See #8503 for more discussion.
-}
| 2,255 |
gen_Traversable_binds :: SrcSpan -> TyCon -> (LHsBinds RdrName, BagDerivStuff)
gen_Traversable_binds loc tycon
= (unitBag traverse_bind, emptyBag)
where
data_cons = tyConDataCons tycon
traverse_bind = mkRdrFunBind (L loc traverse_RDR) eqns
eqns = map traverse_eqn data_cons
traverse_eqn con = evalState (match_for_con [f_Pat] con =<< parts) bs_RDRs
where
parts = sequence $ foldDataConArgs ft_trav con
ft_trav :: FFoldType (State [RdrName] (LHsExpr RdrName))
ft_trav = FT { ft_triv = return pure_Expr -- traverse f = pure x
, ft_var = return f_Expr -- traverse f = f x
, ft_tup = \t gs -> do -- traverse f = \x -> case x of (a1,a2,..) ->
gg <- sequence gs -- (,,) <$> g1 a1 <*> g2 a2 <*> ..
mkSimpleLam $ mkSimpleTupleCase match_for_con t gg
, ft_ty_app = \_ g -> nlHsApp traverse_Expr <$> g -- traverse f = travese g
, ft_forall = \_ g -> g
, ft_co_var = panic "contravariant"
, ft_fun = panic "function"
, ft_bad_app = panic "in other argument" }
-- Con a1 a2 ... -> Con <$> g1 a1 <*> g2 a2 <*> ...
match_for_con = mkSimpleConMatch $
\con_name xs -> return $ mkApCon (nlHsVar con_name) xs
-- ((Con <$> x1) <*> x2) <*> ..
mkApCon con [] = nlHsApps pure_RDR [con]
mkApCon con (x:xs) = foldl appAp (nlHsApps fmap_RDR [con,x]) xs
where appAp x y = nlHsApps ap_RDR [x,y]
{-
************************************************************************
* *
Newtype-deriving instances
* *
************************************************************************
We take every method in the original instance and `coerce` it to fit
into the derived instance. We need a type annotation on the argument
to `coerce` to make it obvious what instantiation of the method we're
coercing from.
See #8503 for more discussion.
-}
| 2,255 |
gen_Traversable_binds loc tycon
= (unitBag traverse_bind, emptyBag)
where
data_cons = tyConDataCons tycon
traverse_bind = mkRdrFunBind (L loc traverse_RDR) eqns
eqns = map traverse_eqn data_cons
traverse_eqn con = evalState (match_for_con [f_Pat] con =<< parts) bs_RDRs
where
parts = sequence $ foldDataConArgs ft_trav con
ft_trav :: FFoldType (State [RdrName] (LHsExpr RdrName))
ft_trav = FT { ft_triv = return pure_Expr -- traverse f = pure x
, ft_var = return f_Expr -- traverse f = f x
, ft_tup = \t gs -> do -- traverse f = \x -> case x of (a1,a2,..) ->
gg <- sequence gs -- (,,) <$> g1 a1 <*> g2 a2 <*> ..
mkSimpleLam $ mkSimpleTupleCase match_for_con t gg
, ft_ty_app = \_ g -> nlHsApp traverse_Expr <$> g -- traverse f = travese g
, ft_forall = \_ g -> g
, ft_co_var = panic "contravariant"
, ft_fun = panic "function"
, ft_bad_app = panic "in other argument" }
-- Con a1 a2 ... -> Con <$> g1 a1 <*> g2 a2 <*> ...
match_for_con = mkSimpleConMatch $
\con_name xs -> return $ mkApCon (nlHsVar con_name) xs
-- ((Con <$> x1) <*> x2) <*> ..
mkApCon con [] = nlHsApps pure_RDR [con]
mkApCon con (x:xs) = foldl appAp (nlHsApps fmap_RDR [con,x]) xs
where appAp x y = nlHsApps ap_RDR [x,y]
{-
************************************************************************
* *
Newtype-deriving instances
* *
************************************************************************
We take every method in the original instance and `coerce` it to fit
into the derived instance. We need a type annotation on the argument
to `coerce` to make it obvious what instantiation of the method we're
coercing from.
See #8503 for more discussion.
-}
| 2,176 | false | true | 2 | 11 | 823 | 402 | 208 | 194 | null | null |
khibino/haskell-debian-build.rebuild
|
src/Debian/Package/Data/Packages.hs
|
bsd-3-clause
|
-- | Source package name of 'Source'
sourceName :: Source -> String
sourceName (Source n _) = n
| 95 |
sourceName :: Source -> String
sourceName (Source n _) = n
| 58 |
sourceName (Source n _) = n
| 27 | true | true | 0 | 7 | 17 | 27 | 14 | 13 | null | null |
plaprade/haskoin
|
haskoin-wallet/test/Network/Haskoin/Wallet/Units.hs
|
unlicense
|
testDiceToMnemonic :: Assertion
testDiceToMnemonic = do
assertEqual "Unit 1" (diceToMnemonic "666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666") $ Right "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"
assertEqual "Unit 2" (diceToMnemonic "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") $ Right "coral clown lift boat brown panel lazy feel bronze remember gravity fortune diesel spirit proud grid creek office smoke grid creek office smoke interest"
| 704 |
testDiceToMnemonic :: Assertion
testDiceToMnemonic = do
assertEqual "Unit 1" (diceToMnemonic "666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666") $ Right "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"
assertEqual "Unit 2" (diceToMnemonic "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") $ Right "coral clown lift boat brown panel lazy feel bronze remember gravity fortune diesel spirit proud grid creek office smoke grid creek office smoke interest"
| 704 |
testDiceToMnemonic = do
assertEqual "Unit 1" (diceToMnemonic "666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666") $ Right "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"
assertEqual "Unit 2" (diceToMnemonic "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") $ Right "coral clown lift boat brown panel lazy feel bronze remember gravity fortune diesel spirit proud grid creek office smoke grid creek office smoke interest"
| 672 | false | true | 0 | 10 | 75 | 53 | 24 | 29 | null | null |
HJvT/hdirect
|
src/Parser.hs
|
bsd-3-clause
|
action_346 (172#) = happyShift action_106
| 41 |
action_346 (172#) = happyShift action_106
| 41 |
action_346 (172#) = happyShift action_106
| 41 | false | false | 0 | 6 | 4 | 15 | 7 | 8 | null | null |
wz1000/haskell-lsp
|
lsp/example/Reactor.hs
|
mit
|
handle :: Handlers (LspM Config)
handle = mconcat
[ notificationHandler J.SInitialized $ \_msg -> do
liftIO $ debugM "reactor.handle" "Processing the Initialized notification"
-- We're initialized! Lets send a showMessageRequest now
let params = J.ShowMessageRequestParams
J.MtWarning
"What's your favourite language extension?"
(Just [J.MessageActionItem "Rank2Types", J.MessageActionItem "NPlusKPatterns"])
void $ sendRequest J.SWindowShowMessageRequest params $ \res ->
case res of
Left e -> liftIO $ errorM "reactor.handle" $ "Got an error: " ++ show e
Right _ -> do
sendNotification J.SWindowShowMessage (J.ShowMessageParams J.MtInfo "Excellent choice")
-- We can dynamically register a capability once the user accepts it
sendNotification J.SWindowShowMessage (J.ShowMessageParams J.MtInfo "Turning on code lenses dynamically")
let regOpts = J.CodeLensRegistrationOptions Nothing Nothing (Just False)
void $ registerCapability J.STextDocumentCodeLens regOpts $ \_req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/codeLens request"
let cmd = J.Command "Say hello" "lsp-hello-command" Nothing
rsp = J.List [J.CodeLens (J.mkRange 0 0 0 100) (Just cmd) Nothing]
responder (Right rsp)
, notificationHandler J.STextDocumentDidOpen $ \msg -> do
let doc = msg ^. J.params . J.textDocument . J.uri
fileName = J.uriToFilePath doc
liftIO $ debugM "reactor.handle" $ "Processing DidOpenTextDocument for: " ++ show fileName
sendDiagnostics (J.toNormalizedUri doc) (Just 0)
, notificationHandler J.SWorkspaceDidChangeConfiguration $ \msg -> do
cfg <- getConfig
liftIO $ debugM "configuration changed: " (show (msg,cfg))
sendNotification J.SWindowShowMessage $
J.ShowMessageParams J.MtInfo $ "Wibble factor set to " <> T.pack (show (wibbleFactor cfg))
, notificationHandler J.STextDocumentDidChange $ \msg -> do
let doc = msg ^. J.params
. J.textDocument
. J.uri
. to J.toNormalizedUri
liftIO $ debugM "reactor.handle" $ "Processing DidChangeTextDocument for: " ++ show doc
mdoc <- getVirtualFile doc
case mdoc of
Just (VirtualFile _version str _) -> do
liftIO $ debugM "reactor.handle" $ "Found the virtual file: " ++ show str
Nothing -> do
liftIO $ debugM "reactor.handle" $ "Didn't find anything in the VFS for: " ++ show doc
, notificationHandler J.STextDocumentDidSave $ \msg -> do
let doc = msg ^. J.params . J.textDocument . J.uri
fileName = J.uriToFilePath doc
liftIO $ debugM "reactor.handle" $ "Processing DidSaveTextDocument for: " ++ show fileName
sendDiagnostics (J.toNormalizedUri doc) Nothing
, requestHandler J.STextDocumentRename $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/rename request"
let params = req ^. J.params
J.Position l c = params ^. J.position
newName = params ^. J.newName
vdoc <- getVersionedTextDoc (params ^. J.textDocument)
-- Replace some text at the position with what the user entered
let edit = J.InL $ J.TextEdit (J.mkRange l c l (c + fromIntegral (T.length newName))) newName
tde = J.TextDocumentEdit vdoc (J.List [edit])
-- "documentChanges" field is preferred over "changes"
rsp = J.WorkspaceEdit Nothing (Just (J.List [J.InL tde])) Nothing
responder (Right rsp)
, requestHandler J.STextDocumentHover $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/hover request"
let J.HoverParams _doc pos _workDone = req ^. J.params
J.Position _l _c' = pos
rsp = J.Hover ms (Just range)
ms = J.HoverContents $ J.markedUpContent "lsp-hello" "Your type info here!"
range = J.Range pos pos
responder (Right $ Just rsp)
, requestHandler J.STextDocumentDocumentSymbol $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/documentSymbol request"
let J.DocumentSymbolParams _ _ doc = req ^. J.params
loc = J.Location (doc ^. J.uri) (J.Range (J.Position 0 0) (J.Position 0 0))
sym = J.SymbolInformation "lsp-hello" J.SkFunction Nothing Nothing loc Nothing
rsp = J.InR (J.List [sym])
responder (Right rsp)
, requestHandler J.STextDocumentCodeAction $ \req responder -> do
liftIO $ debugM "reactor.handle" $ "Processing a textDocument/codeAction request"
let params = req ^. J.params
doc = params ^. J.textDocument
(J.List diags) = params ^. J.context . J.diagnostics
-- makeCommand only generates commands for diagnostics whose source is us
makeCommand (J.Diagnostic (J.Range start _) _s _c (Just "lsp-hello") _m _t _l) = [J.Command title cmd cmdparams]
where
title = "Apply LSP hello command:" <> head (T.lines _m)
-- NOTE: the cmd needs to be registered via the InitializeResponse message. See lspOptions above
cmd = "lsp-hello-command"
-- need 'file' and 'start_pos'
args = J.List
[ J.object [("file", J.object [("textDocument",J.toJSON doc)])]
, J.object [("start_pos",J.object [("position", J.toJSON start)])]
]
cmdparams = Just args
makeCommand (J.Diagnostic _r _s _c _source _m _t _l) = []
rsp = J.List $ map J.InL $ concatMap makeCommand diags
responder (Right rsp)
, requestHandler J.SWorkspaceExecuteCommand $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a workspace/executeCommand request"
let params = req ^. J.params
margs = params ^. J.arguments
liftIO $ debugM "reactor.handle" $ "The arguments are: " ++ show margs
responder (Right (J.Object mempty)) -- respond to the request
void $ withProgress "Executing some long running command" Cancellable $ \update ->
forM [(0 :: J.UInt)..10] $ \i -> do
update (ProgressAmount (Just (i * 10)) (Just "Doing stuff"))
liftIO $ threadDelay (1 * 1000000)
]
| 6,479 |
handle :: Handlers (LspM Config)
handle = mconcat
[ notificationHandler J.SInitialized $ \_msg -> do
liftIO $ debugM "reactor.handle" "Processing the Initialized notification"
-- We're initialized! Lets send a showMessageRequest now
let params = J.ShowMessageRequestParams
J.MtWarning
"What's your favourite language extension?"
(Just [J.MessageActionItem "Rank2Types", J.MessageActionItem "NPlusKPatterns"])
void $ sendRequest J.SWindowShowMessageRequest params $ \res ->
case res of
Left e -> liftIO $ errorM "reactor.handle" $ "Got an error: " ++ show e
Right _ -> do
sendNotification J.SWindowShowMessage (J.ShowMessageParams J.MtInfo "Excellent choice")
-- We can dynamically register a capability once the user accepts it
sendNotification J.SWindowShowMessage (J.ShowMessageParams J.MtInfo "Turning on code lenses dynamically")
let regOpts = J.CodeLensRegistrationOptions Nothing Nothing (Just False)
void $ registerCapability J.STextDocumentCodeLens regOpts $ \_req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/codeLens request"
let cmd = J.Command "Say hello" "lsp-hello-command" Nothing
rsp = J.List [J.CodeLens (J.mkRange 0 0 0 100) (Just cmd) Nothing]
responder (Right rsp)
, notificationHandler J.STextDocumentDidOpen $ \msg -> do
let doc = msg ^. J.params . J.textDocument . J.uri
fileName = J.uriToFilePath doc
liftIO $ debugM "reactor.handle" $ "Processing DidOpenTextDocument for: " ++ show fileName
sendDiagnostics (J.toNormalizedUri doc) (Just 0)
, notificationHandler J.SWorkspaceDidChangeConfiguration $ \msg -> do
cfg <- getConfig
liftIO $ debugM "configuration changed: " (show (msg,cfg))
sendNotification J.SWindowShowMessage $
J.ShowMessageParams J.MtInfo $ "Wibble factor set to " <> T.pack (show (wibbleFactor cfg))
, notificationHandler J.STextDocumentDidChange $ \msg -> do
let doc = msg ^. J.params
. J.textDocument
. J.uri
. to J.toNormalizedUri
liftIO $ debugM "reactor.handle" $ "Processing DidChangeTextDocument for: " ++ show doc
mdoc <- getVirtualFile doc
case mdoc of
Just (VirtualFile _version str _) -> do
liftIO $ debugM "reactor.handle" $ "Found the virtual file: " ++ show str
Nothing -> do
liftIO $ debugM "reactor.handle" $ "Didn't find anything in the VFS for: " ++ show doc
, notificationHandler J.STextDocumentDidSave $ \msg -> do
let doc = msg ^. J.params . J.textDocument . J.uri
fileName = J.uriToFilePath doc
liftIO $ debugM "reactor.handle" $ "Processing DidSaveTextDocument for: " ++ show fileName
sendDiagnostics (J.toNormalizedUri doc) Nothing
, requestHandler J.STextDocumentRename $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/rename request"
let params = req ^. J.params
J.Position l c = params ^. J.position
newName = params ^. J.newName
vdoc <- getVersionedTextDoc (params ^. J.textDocument)
-- Replace some text at the position with what the user entered
let edit = J.InL $ J.TextEdit (J.mkRange l c l (c + fromIntegral (T.length newName))) newName
tde = J.TextDocumentEdit vdoc (J.List [edit])
-- "documentChanges" field is preferred over "changes"
rsp = J.WorkspaceEdit Nothing (Just (J.List [J.InL tde])) Nothing
responder (Right rsp)
, requestHandler J.STextDocumentHover $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/hover request"
let J.HoverParams _doc pos _workDone = req ^. J.params
J.Position _l _c' = pos
rsp = J.Hover ms (Just range)
ms = J.HoverContents $ J.markedUpContent "lsp-hello" "Your type info here!"
range = J.Range pos pos
responder (Right $ Just rsp)
, requestHandler J.STextDocumentDocumentSymbol $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/documentSymbol request"
let J.DocumentSymbolParams _ _ doc = req ^. J.params
loc = J.Location (doc ^. J.uri) (J.Range (J.Position 0 0) (J.Position 0 0))
sym = J.SymbolInformation "lsp-hello" J.SkFunction Nothing Nothing loc Nothing
rsp = J.InR (J.List [sym])
responder (Right rsp)
, requestHandler J.STextDocumentCodeAction $ \req responder -> do
liftIO $ debugM "reactor.handle" $ "Processing a textDocument/codeAction request"
let params = req ^. J.params
doc = params ^. J.textDocument
(J.List diags) = params ^. J.context . J.diagnostics
-- makeCommand only generates commands for diagnostics whose source is us
makeCommand (J.Diagnostic (J.Range start _) _s _c (Just "lsp-hello") _m _t _l) = [J.Command title cmd cmdparams]
where
title = "Apply LSP hello command:" <> head (T.lines _m)
-- NOTE: the cmd needs to be registered via the InitializeResponse message. See lspOptions above
cmd = "lsp-hello-command"
-- need 'file' and 'start_pos'
args = J.List
[ J.object [("file", J.object [("textDocument",J.toJSON doc)])]
, J.object [("start_pos",J.object [("position", J.toJSON start)])]
]
cmdparams = Just args
makeCommand (J.Diagnostic _r _s _c _source _m _t _l) = []
rsp = J.List $ map J.InL $ concatMap makeCommand diags
responder (Right rsp)
, requestHandler J.SWorkspaceExecuteCommand $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a workspace/executeCommand request"
let params = req ^. J.params
margs = params ^. J.arguments
liftIO $ debugM "reactor.handle" $ "The arguments are: " ++ show margs
responder (Right (J.Object mempty)) -- respond to the request
void $ withProgress "Executing some long running command" Cancellable $ \update ->
forM [(0 :: J.UInt)..10] $ \i -> do
update (ProgressAmount (Just (i * 10)) (Just "Doing stuff"))
liftIO $ threadDelay (1 * 1000000)
]
| 6,479 |
handle = mconcat
[ notificationHandler J.SInitialized $ \_msg -> do
liftIO $ debugM "reactor.handle" "Processing the Initialized notification"
-- We're initialized! Lets send a showMessageRequest now
let params = J.ShowMessageRequestParams
J.MtWarning
"What's your favourite language extension?"
(Just [J.MessageActionItem "Rank2Types", J.MessageActionItem "NPlusKPatterns"])
void $ sendRequest J.SWindowShowMessageRequest params $ \res ->
case res of
Left e -> liftIO $ errorM "reactor.handle" $ "Got an error: " ++ show e
Right _ -> do
sendNotification J.SWindowShowMessage (J.ShowMessageParams J.MtInfo "Excellent choice")
-- We can dynamically register a capability once the user accepts it
sendNotification J.SWindowShowMessage (J.ShowMessageParams J.MtInfo "Turning on code lenses dynamically")
let regOpts = J.CodeLensRegistrationOptions Nothing Nothing (Just False)
void $ registerCapability J.STextDocumentCodeLens regOpts $ \_req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/codeLens request"
let cmd = J.Command "Say hello" "lsp-hello-command" Nothing
rsp = J.List [J.CodeLens (J.mkRange 0 0 0 100) (Just cmd) Nothing]
responder (Right rsp)
, notificationHandler J.STextDocumentDidOpen $ \msg -> do
let doc = msg ^. J.params . J.textDocument . J.uri
fileName = J.uriToFilePath doc
liftIO $ debugM "reactor.handle" $ "Processing DidOpenTextDocument for: " ++ show fileName
sendDiagnostics (J.toNormalizedUri doc) (Just 0)
, notificationHandler J.SWorkspaceDidChangeConfiguration $ \msg -> do
cfg <- getConfig
liftIO $ debugM "configuration changed: " (show (msg,cfg))
sendNotification J.SWindowShowMessage $
J.ShowMessageParams J.MtInfo $ "Wibble factor set to " <> T.pack (show (wibbleFactor cfg))
, notificationHandler J.STextDocumentDidChange $ \msg -> do
let doc = msg ^. J.params
. J.textDocument
. J.uri
. to J.toNormalizedUri
liftIO $ debugM "reactor.handle" $ "Processing DidChangeTextDocument for: " ++ show doc
mdoc <- getVirtualFile doc
case mdoc of
Just (VirtualFile _version str _) -> do
liftIO $ debugM "reactor.handle" $ "Found the virtual file: " ++ show str
Nothing -> do
liftIO $ debugM "reactor.handle" $ "Didn't find anything in the VFS for: " ++ show doc
, notificationHandler J.STextDocumentDidSave $ \msg -> do
let doc = msg ^. J.params . J.textDocument . J.uri
fileName = J.uriToFilePath doc
liftIO $ debugM "reactor.handle" $ "Processing DidSaveTextDocument for: " ++ show fileName
sendDiagnostics (J.toNormalizedUri doc) Nothing
, requestHandler J.STextDocumentRename $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/rename request"
let params = req ^. J.params
J.Position l c = params ^. J.position
newName = params ^. J.newName
vdoc <- getVersionedTextDoc (params ^. J.textDocument)
-- Replace some text at the position with what the user entered
let edit = J.InL $ J.TextEdit (J.mkRange l c l (c + fromIntegral (T.length newName))) newName
tde = J.TextDocumentEdit vdoc (J.List [edit])
-- "documentChanges" field is preferred over "changes"
rsp = J.WorkspaceEdit Nothing (Just (J.List [J.InL tde])) Nothing
responder (Right rsp)
, requestHandler J.STextDocumentHover $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/hover request"
let J.HoverParams _doc pos _workDone = req ^. J.params
J.Position _l _c' = pos
rsp = J.Hover ms (Just range)
ms = J.HoverContents $ J.markedUpContent "lsp-hello" "Your type info here!"
range = J.Range pos pos
responder (Right $ Just rsp)
, requestHandler J.STextDocumentDocumentSymbol $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a textDocument/documentSymbol request"
let J.DocumentSymbolParams _ _ doc = req ^. J.params
loc = J.Location (doc ^. J.uri) (J.Range (J.Position 0 0) (J.Position 0 0))
sym = J.SymbolInformation "lsp-hello" J.SkFunction Nothing Nothing loc Nothing
rsp = J.InR (J.List [sym])
responder (Right rsp)
, requestHandler J.STextDocumentCodeAction $ \req responder -> do
liftIO $ debugM "reactor.handle" $ "Processing a textDocument/codeAction request"
let params = req ^. J.params
doc = params ^. J.textDocument
(J.List diags) = params ^. J.context . J.diagnostics
-- makeCommand only generates commands for diagnostics whose source is us
makeCommand (J.Diagnostic (J.Range start _) _s _c (Just "lsp-hello") _m _t _l) = [J.Command title cmd cmdparams]
where
title = "Apply LSP hello command:" <> head (T.lines _m)
-- NOTE: the cmd needs to be registered via the InitializeResponse message. See lspOptions above
cmd = "lsp-hello-command"
-- need 'file' and 'start_pos'
args = J.List
[ J.object [("file", J.object [("textDocument",J.toJSON doc)])]
, J.object [("start_pos",J.object [("position", J.toJSON start)])]
]
cmdparams = Just args
makeCommand (J.Diagnostic _r _s _c _source _m _t _l) = []
rsp = J.List $ map J.InL $ concatMap makeCommand diags
responder (Right rsp)
, requestHandler J.SWorkspaceExecuteCommand $ \req responder -> do
liftIO $ debugM "reactor.handle" "Processing a workspace/executeCommand request"
let params = req ^. J.params
margs = params ^. J.arguments
liftIO $ debugM "reactor.handle" $ "The arguments are: " ++ show margs
responder (Right (J.Object mempty)) -- respond to the request
void $ withProgress "Executing some long running command" Cancellable $ \update ->
forM [(0 :: J.UInt)..10] $ \i -> do
update (ProgressAmount (Just (i * 10)) (Just "Doing stuff"))
liftIO $ threadDelay (1 * 1000000)
]
| 6,446 | false | true | 0 | 29 | 1,772 | 1,814 | 877 | 937 | null | null |
xldenis/bookclub
|
src/Query.hs
|
bsd-3-clause
|
query :: (MonadReader Connection m, MonadIO m, FromRow r1, ToRow q) => Query -> q -> m [r1]
query b c = ask >>= \conn -> liftIO $ P.query conn b c
| 146 |
query :: (MonadReader Connection m, MonadIO m, FromRow r1, ToRow q) => Query -> q -> m [r1]
query b c = ask >>= \conn -> liftIO $ P.query conn b c
| 146 |
query b c = ask >>= \conn -> liftIO $ P.query conn b c
| 54 | false | true | 2 | 10 | 31 | 87 | 43 | 44 | null | null |
spechub/Hets
|
OWL2/StaticAnalysis.hs
|
gpl-2.0
|
checkClassExpression :: Sign -> AS.ClassExpression -> Result AS.ClassExpression
checkClassExpression s desc =
let errMsg i = failMsg i desc
objErr i = errMsg $ AS.mkEntity AS.ObjectProperty i
datErr i = errMsg $ AS.mkEntity AS.DataProperty i
in case desc of
AS.Expression u -> if AS.isThing u
then return $ AS.Expression $ AS.setReservedPrefix u
else checkEntity s (AS.mkEntity AS.Class u) >> return desc
AS.ObjectJunction ty ds -> fmap (AS.ObjectJunction ty)
$ mapM (checkClassExpression s) ds
AS.ObjectComplementOf d -> fmap AS.ObjectComplementOf $ checkClassExpression s d
AS.ObjectOneOf _ -> return desc
AS.ObjectValuesFrom q opExpr d -> if isDeclObjProp s opExpr
then fmap (AS.ObjectValuesFrom q opExpr) $ checkClassExpression s d
else let iri = AS.objPropToIRI opExpr
in if isDeclDataProp s iri then
fmap (AS.DataValuesFrom q [iri])
$ classExpressionToDataRange s d
else objErr iri
AS.ObjectHasSelf opExpr -> if isDeclObjProp s opExpr then return desc
else objErr $ AS.objPropToIRI opExpr
AS.ObjectHasValue opExpr _ -> if isDeclObjProp s opExpr then return desc
else objErr $ AS.objPropToIRI opExpr
AS.ObjectCardinality (AS.Cardinality a b opExpr md) -> do
let iri = AS.objPropToIRI opExpr
mbrOP = Set.member iri $ objectProperties s
case md of
Nothing
| mbrOP -> return desc
| isDeclDataProp s iri ->
return $ AS.DataCardinality $ AS.Cardinality a b iri Nothing
| otherwise -> objErr iri
Just d ->
if mbrOP then fmap (AS.ObjectCardinality . AS.Cardinality a b opExpr
. Just) $ checkClassExpression s d
else do
dr <- classExpressionToDataRange s d
if isDeclDataProp s iri then
return $ AS.DataCardinality
$ AS.Cardinality a b iri $ Just dr
else datErr iri
AS.DataValuesFrom _ dExp r -> checkDataRange s r
>> if isDeclDataProp s (head dExp) then return desc else datErr (head dExp)
AS.DataHasValue dExp l -> do
checkLiteral s l
if isDeclDataProp s dExp then return desc
else datErr dExp
AS.DataCardinality (AS.Cardinality _ _ dExp mr) -> if isDeclDataProp s dExp
then case mr of
Nothing -> return desc
Just d -> checkDataRange s d >> return desc
else datErr dExp
| 2,636 |
checkClassExpression :: Sign -> AS.ClassExpression -> Result AS.ClassExpression
checkClassExpression s desc =
let errMsg i = failMsg i desc
objErr i = errMsg $ AS.mkEntity AS.ObjectProperty i
datErr i = errMsg $ AS.mkEntity AS.DataProperty i
in case desc of
AS.Expression u -> if AS.isThing u
then return $ AS.Expression $ AS.setReservedPrefix u
else checkEntity s (AS.mkEntity AS.Class u) >> return desc
AS.ObjectJunction ty ds -> fmap (AS.ObjectJunction ty)
$ mapM (checkClassExpression s) ds
AS.ObjectComplementOf d -> fmap AS.ObjectComplementOf $ checkClassExpression s d
AS.ObjectOneOf _ -> return desc
AS.ObjectValuesFrom q opExpr d -> if isDeclObjProp s opExpr
then fmap (AS.ObjectValuesFrom q opExpr) $ checkClassExpression s d
else let iri = AS.objPropToIRI opExpr
in if isDeclDataProp s iri then
fmap (AS.DataValuesFrom q [iri])
$ classExpressionToDataRange s d
else objErr iri
AS.ObjectHasSelf opExpr -> if isDeclObjProp s opExpr then return desc
else objErr $ AS.objPropToIRI opExpr
AS.ObjectHasValue opExpr _ -> if isDeclObjProp s opExpr then return desc
else objErr $ AS.objPropToIRI opExpr
AS.ObjectCardinality (AS.Cardinality a b opExpr md) -> do
let iri = AS.objPropToIRI opExpr
mbrOP = Set.member iri $ objectProperties s
case md of
Nothing
| mbrOP -> return desc
| isDeclDataProp s iri ->
return $ AS.DataCardinality $ AS.Cardinality a b iri Nothing
| otherwise -> objErr iri
Just d ->
if mbrOP then fmap (AS.ObjectCardinality . AS.Cardinality a b opExpr
. Just) $ checkClassExpression s d
else do
dr <- classExpressionToDataRange s d
if isDeclDataProp s iri then
return $ AS.DataCardinality
$ AS.Cardinality a b iri $ Just dr
else datErr iri
AS.DataValuesFrom _ dExp r -> checkDataRange s r
>> if isDeclDataProp s (head dExp) then return desc else datErr (head dExp)
AS.DataHasValue dExp l -> do
checkLiteral s l
if isDeclDataProp s dExp then return desc
else datErr dExp
AS.DataCardinality (AS.Cardinality _ _ dExp mr) -> if isDeclDataProp s dExp
then case mr of
Nothing -> return desc
Just d -> checkDataRange s d >> return desc
else datErr dExp
| 2,636 |
checkClassExpression s desc =
let errMsg i = failMsg i desc
objErr i = errMsg $ AS.mkEntity AS.ObjectProperty i
datErr i = errMsg $ AS.mkEntity AS.DataProperty i
in case desc of
AS.Expression u -> if AS.isThing u
then return $ AS.Expression $ AS.setReservedPrefix u
else checkEntity s (AS.mkEntity AS.Class u) >> return desc
AS.ObjectJunction ty ds -> fmap (AS.ObjectJunction ty)
$ mapM (checkClassExpression s) ds
AS.ObjectComplementOf d -> fmap AS.ObjectComplementOf $ checkClassExpression s d
AS.ObjectOneOf _ -> return desc
AS.ObjectValuesFrom q opExpr d -> if isDeclObjProp s opExpr
then fmap (AS.ObjectValuesFrom q opExpr) $ checkClassExpression s d
else let iri = AS.objPropToIRI opExpr
in if isDeclDataProp s iri then
fmap (AS.DataValuesFrom q [iri])
$ classExpressionToDataRange s d
else objErr iri
AS.ObjectHasSelf opExpr -> if isDeclObjProp s opExpr then return desc
else objErr $ AS.objPropToIRI opExpr
AS.ObjectHasValue opExpr _ -> if isDeclObjProp s opExpr then return desc
else objErr $ AS.objPropToIRI opExpr
AS.ObjectCardinality (AS.Cardinality a b opExpr md) -> do
let iri = AS.objPropToIRI opExpr
mbrOP = Set.member iri $ objectProperties s
case md of
Nothing
| mbrOP -> return desc
| isDeclDataProp s iri ->
return $ AS.DataCardinality $ AS.Cardinality a b iri Nothing
| otherwise -> objErr iri
Just d ->
if mbrOP then fmap (AS.ObjectCardinality . AS.Cardinality a b opExpr
. Just) $ checkClassExpression s d
else do
dr <- classExpressionToDataRange s d
if isDeclDataProp s iri then
return $ AS.DataCardinality
$ AS.Cardinality a b iri $ Just dr
else datErr iri
AS.DataValuesFrom _ dExp r -> checkDataRange s r
>> if isDeclDataProp s (head dExp) then return desc else datErr (head dExp)
AS.DataHasValue dExp l -> do
checkLiteral s l
if isDeclDataProp s dExp then return desc
else datErr dExp
AS.DataCardinality (AS.Cardinality _ _ dExp mr) -> if isDeclDataProp s dExp
then case mr of
Nothing -> return desc
Just d -> checkDataRange s d >> return desc
else datErr dExp
| 2,556 | false | true | 0 | 22 | 890 | 828 | 384 | 444 | null | null |
GaloisInc/halvm-ghc
|
compiler/main/ErrUtils.hs
|
bsd-3-clause
|
fatalErrorMsg'' :: FatalMessager -> String -> IO ()
fatalErrorMsg'' fm msg = fm msg
| 83 |
fatalErrorMsg'' :: FatalMessager -> String -> IO ()
fatalErrorMsg'' fm msg = fm msg
| 83 |
fatalErrorMsg'' fm msg = fm msg
| 31 | false | true | 0 | 8 | 13 | 32 | 15 | 17 | null | null |
ezyang/ghc
|
compiler/basicTypes/BasicTypes.hs
|
bsd-3-clause
|
isInlinablePragma :: InlinePragma -> Bool
isInlinablePragma prag = case inl_inline prag of
Inlinable -> True
_ -> False
| 181 |
isInlinablePragma :: InlinePragma -> Bool
isInlinablePragma prag = case inl_inline prag of
Inlinable -> True
_ -> False
| 181 |
isInlinablePragma prag = case inl_inline prag of
Inlinable -> True
_ -> False
| 139 | false | true | 0 | 7 | 79 | 37 | 18 | 19 | null | null |
haslab/SecreC
|
src/Language/SecreC/Prover/Expression.hs
|
gpl-3.0
|
proverProcError str t e = do
lift $ do
ppe <- ppExprTy (fmap typed e)
ppt <- pp t
genTcError (locpos $ unTyped $ loc e) True $ text "failed to convert" <+> text str <+> text "expression" <+> ppe <+> text "to prover expression: unknown declaration type" <+> ppt
| 288 |
proverProcError str t e = do
lift $ do
ppe <- ppExprTy (fmap typed e)
ppt <- pp t
genTcError (locpos $ unTyped $ loc e) True $ text "failed to convert" <+> text str <+> text "expression" <+> ppe <+> text "to prover expression: unknown declaration type" <+> ppt
| 288 |
proverProcError str t e = do
lift $ do
ppe <- ppExprTy (fmap typed e)
ppt <- pp t
genTcError (locpos $ unTyped $ loc e) True $ text "failed to convert" <+> text str <+> text "expression" <+> ppe <+> text "to prover expression: unknown declaration type" <+> ppt
| 288 | false | false | 0 | 19 | 77 | 106 | 47 | 59 | null | null |
li-zhirui/JSAnalyzer
|
JSParser.hs
|
mit
|
-- | parse a comma symbol
comma :: Parser String
comma = symbol ","
| 80 |
comma :: Parser String
comma = symbol ","
| 54 |
comma = symbol ","
| 25 | true | true | 0 | 6 | 26 | 24 | 10 | 14 | null | null |
FPtje/GLuaParser
|
src/GLua/Parser.hs
|
lgpl-2.1
|
-- | Parse operators of the same precedence in a chain
samePrioL :: [(Token, BinOp)] -> AParser MExpr -> AParser MExpr
samePrioL ops pr = pChainl (choice (map f ops)) pr
where
choice = foldr (<<|>) pFail
f :: (Token, BinOp) -> AParser (MExpr -> MExpr -> MExpr)
f (t, at) = (\p e1 e2 -> MExpr p (BinOpExpr at e1 e2)) <$> pPos <* pMTok t
| 349 |
samePrioL :: [(Token, BinOp)] -> AParser MExpr -> AParser MExpr
samePrioL ops pr = pChainl (choice (map f ops)) pr
where
choice = foldr (<<|>) pFail
f :: (Token, BinOp) -> AParser (MExpr -> MExpr -> MExpr)
f (t, at) = (\p e1 e2 -> MExpr p (BinOpExpr at e1 e2)) <$> pPos <* pMTok t
| 294 |
samePrioL ops pr = pChainl (choice (map f ops)) pr
where
choice = foldr (<<|>) pFail
f :: (Token, BinOp) -> AParser (MExpr -> MExpr -> MExpr)
f (t, at) = (\p e1 e2 -> MExpr p (BinOpExpr at e1 e2)) <$> pPos <* pMTok t
| 230 | true | true | 0 | 11 | 80 | 159 | 82 | 77 | null | null |
enolan/Idris-dev
|
src/Idris/Error.hs
|
bsd-3-clause
|
warnDisamb ist (PCoerced tm) = warnDisamb ist tm
| 48 |
warnDisamb ist (PCoerced tm) = warnDisamb ist tm
| 48 |
warnDisamb ist (PCoerced tm) = warnDisamb ist tm
| 48 | false | false | 0 | 7 | 7 | 22 | 10 | 12 | null | null |
csabahruska/GFXDemo
|
ShaderParser.hs
|
bsd-3-clause
|
kw :: ByteString -> Parser ()
kw s = ((\w -> if B.map toLower w == s then return () else fail "") =<< word) <?> B.unpack s
| 122 |
kw :: ByteString -> Parser ()
kw s = ((\w -> if B.map toLower w == s then return () else fail "") =<< word) <?> B.unpack s
| 122 |
kw s = ((\w -> if B.map toLower w == s then return () else fail "") =<< word) <?> B.unpack s
| 92 | false | true | 0 | 13 | 27 | 78 | 38 | 40 | null | null |
seereason/cabal
|
cabal-install/Distribution/Client/Setup.hs
|
bsd-3-clause
|
freezeCommand :: CommandUI FreezeFlags
freezeCommand = CommandUI {
commandName = "freeze",
commandSynopsis = "Freeze dependencies.",
commandDescription = Just $ \_ -> wrapText $
"Calculates a valid set of dependencies and their exact versions. "
++ "If successful, saves the result to the file `cabal.config`.\n"
++ "\n"
++ "The package versions specified in `cabal.config` will be used for "
++ "any future installs.\n"
++ "\n"
++ "An existing `cabal.config` is ignored and overwritten.\n",
commandNotes = Nothing,
commandUsage = usageAlternatives "freeze" [""
,"PACKAGES"
],
commandDefaultFlags = defaultFreezeFlags,
commandOptions = \ showOrParseArgs -> [
optionVerbosity freezeVerbosity (\v flags -> flags { freezeVerbosity = v })
, option [] ["dry-run"]
"Do not freeze anything, only print what would be frozen"
freezeDryRun (\v flags -> flags { freezeDryRun = v })
trueArg
, option [] ["tests"]
"freezing of the dependencies of any tests suites in the package description file."
freezeTests (\v flags -> flags { freezeTests = v })
(boolOpt [] [])
, option [] ["benchmarks"]
"freezing of the dependencies of any benchmarks suites in the package description file."
freezeBenchmarks (\v flags -> flags { freezeBenchmarks = v })
(boolOpt [] [])
] ++
optionSolver freezeSolver (\v flags -> flags { freezeSolver = v }) :
optionSolverFlags showOrParseArgs
freezeMaxBackjumps (\v flags -> flags { freezeMaxBackjumps = v })
freezeReorderGoals (\v flags -> flags { freezeReorderGoals = v })
freezeIndependentGoals (\v flags -> flags { freezeIndependentGoals = v })
freezeShadowPkgs (\v flags -> flags { freezeShadowPkgs = v })
freezeStrongFlags (\v flags -> flags { freezeStrongFlags = v })
}
| 2,245 |
freezeCommand :: CommandUI FreezeFlags
freezeCommand = CommandUI {
commandName = "freeze",
commandSynopsis = "Freeze dependencies.",
commandDescription = Just $ \_ -> wrapText $
"Calculates a valid set of dependencies and their exact versions. "
++ "If successful, saves the result to the file `cabal.config`.\n"
++ "\n"
++ "The package versions specified in `cabal.config` will be used for "
++ "any future installs.\n"
++ "\n"
++ "An existing `cabal.config` is ignored and overwritten.\n",
commandNotes = Nothing,
commandUsage = usageAlternatives "freeze" [""
,"PACKAGES"
],
commandDefaultFlags = defaultFreezeFlags,
commandOptions = \ showOrParseArgs -> [
optionVerbosity freezeVerbosity (\v flags -> flags { freezeVerbosity = v })
, option [] ["dry-run"]
"Do not freeze anything, only print what would be frozen"
freezeDryRun (\v flags -> flags { freezeDryRun = v })
trueArg
, option [] ["tests"]
"freezing of the dependencies of any tests suites in the package description file."
freezeTests (\v flags -> flags { freezeTests = v })
(boolOpt [] [])
, option [] ["benchmarks"]
"freezing of the dependencies of any benchmarks suites in the package description file."
freezeBenchmarks (\v flags -> flags { freezeBenchmarks = v })
(boolOpt [] [])
] ++
optionSolver freezeSolver (\v flags -> flags { freezeSolver = v }) :
optionSolverFlags showOrParseArgs
freezeMaxBackjumps (\v flags -> flags { freezeMaxBackjumps = v })
freezeReorderGoals (\v flags -> flags { freezeReorderGoals = v })
freezeIndependentGoals (\v flags -> flags { freezeIndependentGoals = v })
freezeShadowPkgs (\v flags -> flags { freezeShadowPkgs = v })
freezeStrongFlags (\v flags -> flags { freezeStrongFlags = v })
}
| 2,245 |
freezeCommand = CommandUI {
commandName = "freeze",
commandSynopsis = "Freeze dependencies.",
commandDescription = Just $ \_ -> wrapText $
"Calculates a valid set of dependencies and their exact versions. "
++ "If successful, saves the result to the file `cabal.config`.\n"
++ "\n"
++ "The package versions specified in `cabal.config` will be used for "
++ "any future installs.\n"
++ "\n"
++ "An existing `cabal.config` is ignored and overwritten.\n",
commandNotes = Nothing,
commandUsage = usageAlternatives "freeze" [""
,"PACKAGES"
],
commandDefaultFlags = defaultFreezeFlags,
commandOptions = \ showOrParseArgs -> [
optionVerbosity freezeVerbosity (\v flags -> flags { freezeVerbosity = v })
, option [] ["dry-run"]
"Do not freeze anything, only print what would be frozen"
freezeDryRun (\v flags -> flags { freezeDryRun = v })
trueArg
, option [] ["tests"]
"freezing of the dependencies of any tests suites in the package description file."
freezeTests (\v flags -> flags { freezeTests = v })
(boolOpt [] [])
, option [] ["benchmarks"]
"freezing of the dependencies of any benchmarks suites in the package description file."
freezeBenchmarks (\v flags -> flags { freezeBenchmarks = v })
(boolOpt [] [])
] ++
optionSolver freezeSolver (\v flags -> flags { freezeSolver = v }) :
optionSolverFlags showOrParseArgs
freezeMaxBackjumps (\v flags -> flags { freezeMaxBackjumps = v })
freezeReorderGoals (\v flags -> flags { freezeReorderGoals = v })
freezeIndependentGoals (\v flags -> flags { freezeIndependentGoals = v })
freezeShadowPkgs (\v flags -> flags { freezeShadowPkgs = v })
freezeStrongFlags (\v flags -> flags { freezeStrongFlags = v })
}
| 2,206 | false | true | 0 | 16 | 810 | 431 | 242 | 189 | null | null |
green-haskell/ghc
|
libraries/base/Data/OldList.hs
|
bsd-3-clause
|
-- | The 'isSuffixOf' function takes two lists and returns 'True' iff
-- the first list is a suffix of the second. The second list must be
-- finite.
isSuffixOf :: (Eq a) => [a] -> [a] -> Bool
ns `isSuffixOf` hs = maybe False id $ do
delta <- dropLengthMaybe ns hs
return $ ns == dropLength delta hs
-- Since dropLengthMaybe ns hs succeeded, we know that (if hs is finite)
-- length ns + length delta = length hs
-- so dropping the length of delta from hs will yield a suffix exactly
-- the length of ns.
-- A version of drop that drops the length of the first argument from the
-- second argument. If xs is longer than ys, xs will not be traversed in its
-- entirety. dropLength is also generally faster than (drop . length)
-- Both this and dropLengthMaybe could be written as folds over their first
-- arguments, but this reduces clarity with no benefit to isSuffixOf.
| 927 |
isSuffixOf :: (Eq a) => [a] -> [a] -> Bool
ns `isSuffixOf` hs = maybe False id $ do
delta <- dropLengthMaybe ns hs
return $ ns == dropLength delta hs
-- Since dropLengthMaybe ns hs succeeded, we know that (if hs is finite)
-- length ns + length delta = length hs
-- so dropping the length of delta from hs will yield a suffix exactly
-- the length of ns.
-- A version of drop that drops the length of the first argument from the
-- second argument. If xs is longer than ys, xs will not be traversed in its
-- entirety. dropLength is also generally faster than (drop . length)
-- Both this and dropLengthMaybe could be written as folds over their first
-- arguments, but this reduces clarity with no benefit to isSuffixOf.
| 777 |
ns `isSuffixOf` hs = maybe False id $ do
delta <- dropLengthMaybe ns hs
return $ ns == dropLength delta hs
-- Since dropLengthMaybe ns hs succeeded, we know that (if hs is finite)
-- length ns + length delta = length hs
-- so dropping the length of delta from hs will yield a suffix exactly
-- the length of ns.
-- A version of drop that drops the length of the first argument from the
-- second argument. If xs is longer than ys, xs will not be traversed in its
-- entirety. dropLength is also generally faster than (drop . length)
-- Both this and dropLengthMaybe could be written as folds over their first
-- arguments, but this reduces clarity with no benefit to isSuffixOf.
| 721 | true | true | 0 | 9 | 222 | 91 | 51 | 40 | null | null |
lowasser/TrieMap
|
Data/TrieMap/Utils.hs
|
bsd-3-clause
|
toVectorN :: Vector v a => (forall b . (a -> b -> b) -> b -> f -> b) -> (f -> Int) -> f -> v a
toVectorN fold size xs = create $ do
!mv <- unsafeNew (size xs)
fold (\ x m i# -> unsafeWrite mv (I# i#) x >> m (i# +# 1#)) (\ _ -> return mv) xs 0#
| 247 |
toVectorN :: Vector v a => (forall b . (a -> b -> b) -> b -> f -> b) -> (f -> Int) -> f -> v a
toVectorN fold size xs = create $ do
!mv <- unsafeNew (size xs)
fold (\ x m i# -> unsafeWrite mv (I# i#) x >> m (i# +# 1#)) (\ _ -> return mv) xs 0#
| 247 |
toVectorN fold size xs = create $ do
!mv <- unsafeNew (size xs)
fold (\ x m i# -> unsafeWrite mv (I# i#) x >> m (i# +# 1#)) (\ _ -> return mv) xs 0#
| 152 | false | true | 0 | 14 | 68 | 167 | 82 | 85 | null | null |
keithodulaigh/Hets
|
CASL/Freeness.hs
|
gpl-2.0
|
free_formula (Relation f1 c f2 r) = Relation f1' c f2' r
where f1' = free_formula f1
f2' = free_formula f2
| 122 |
free_formula (Relation f1 c f2 r) = Relation f1' c f2' r
where f1' = free_formula f1
f2' = free_formula f2
| 122 |
free_formula (Relation f1 c f2 r) = Relation f1' c f2' r
where f1' = free_formula f1
f2' = free_formula f2
| 122 | false | false | 1 | 7 | 36 | 49 | 23 | 26 | null | null |
music-suite/music-pitch
|
src/Music/Pitch/Common/Harmony.hs
|
bsd-3-clause
|
- | Whether the given interval is a perfect (harmonic) consonance.
isPerfectConsonance :: Interval -> Bool
isPerfectConsonance x = case number (simple x) of
1 -> True
4 -> True
5 -> True
_ -> False
-- | Whether the given interval is an imperfect (harmonic) consonance.
| 278 |
isPerfectConsonance :: Interval -> Bool
isPerfectConsonance x = case number (simple x) of
1 -> True
4 -> True
5 -> True
_ -> False
-- | Whether the given interval is an imperfect (harmonic) consonance.
| 210 |
isPerfectConsonance x = case number (simple x) of
1 -> True
4 -> True
5 -> True
_ -> False
-- | Whether the given interval is an imperfect (harmonic) consonance.
| 170 | true | true | 1 | 8 | 56 | 89 | 43 | 46 | null | null |
rleshchinskiy/vector
|
Data/Vector.hs
|
bsd-3-clause
|
maxIndex = G.maxIndex
| 21 |
maxIndex = G.maxIndex
| 21 |
maxIndex = G.maxIndex
| 21 | false | false | 0 | 5 | 2 | 8 | 4 | 4 | null | null |
rumblesan/haskell-experiments
|
src/Examples/Equations/Parser.hs
|
bsd-3-clause
|
table =
[ [Infix (m_reservedOp "^" >> return EExp) AssocLeft]
, [ Infix (m_reservedOp "" >> return EMult) AssocLeft
, Infix (m_reservedOp "*" >> return EMult) AssocLeft
, Infix (m_reservedOp "/" >> return EDiv) AssocLeft
]
, [ Infix (m_reservedOp "+" >> return EAdd) AssocLeft
, Infix (m_reservedOp "-" >> return ESub) AssocLeft
]
]
| 360 |
table =
[ [Infix (m_reservedOp "^" >> return EExp) AssocLeft]
, [ Infix (m_reservedOp "" >> return EMult) AssocLeft
, Infix (m_reservedOp "*" >> return EMult) AssocLeft
, Infix (m_reservedOp "/" >> return EDiv) AssocLeft
]
, [ Infix (m_reservedOp "+" >> return EAdd) AssocLeft
, Infix (m_reservedOp "-" >> return ESub) AssocLeft
]
]
| 360 |
table =
[ [Infix (m_reservedOp "^" >> return EExp) AssocLeft]
, [ Infix (m_reservedOp "" >> return EMult) AssocLeft
, Infix (m_reservedOp "*" >> return EMult) AssocLeft
, Infix (m_reservedOp "/" >> return EDiv) AssocLeft
]
, [ Infix (m_reservedOp "+" >> return EAdd) AssocLeft
, Infix (m_reservedOp "-" >> return ESub) AssocLeft
]
]
| 360 | false | false | 1 | 11 | 82 | 145 | 69 | 76 | null | null |
mydaum/cabal
|
cabal-install/tests/UnitTests/Distribution/Client/Tar.hs
|
bsd-3-clause
|
getFileEntry :: FilePath -> [Char] -> Entry
getFileEntry pth dta =
simpleEntry tp $ NormalFile dta' $ BS.length dta'
where tp = case toTarPath False pth of
Right tp' -> tp'
Left e -> error e
dta' = BS.Char8.pack dta
| 251 |
getFileEntry :: FilePath -> [Char] -> Entry
getFileEntry pth dta =
simpleEntry tp $ NormalFile dta' $ BS.length dta'
where tp = case toTarPath False pth of
Right tp' -> tp'
Left e -> error e
dta' = BS.Char8.pack dta
| 251 |
getFileEntry pth dta =
simpleEntry tp $ NormalFile dta' $ BS.length dta'
where tp = case toTarPath False pth of
Right tp' -> tp'
Left e -> error e
dta' = BS.Char8.pack dta
| 207 | false | true | 1 | 9 | 75 | 96 | 45 | 51 | null | null |
rahulmutt/ghcvm
|
compiler/Eta/TypeCheck/TcEvidence.hs
|
bsd-3-clause
|
ppr_co p (TcNthCo n co) = pprPrefixApp p (ptext (sLit "Nth:") <+> int n) [pprParendTcCo co]
| 97 |
ppr_co p (TcNthCo n co) = pprPrefixApp p (ptext (sLit "Nth:") <+> int n) [pprParendTcCo co]
| 97 |
ppr_co p (TcNthCo n co) = pprPrefixApp p (ptext (sLit "Nth:") <+> int n) [pprParendTcCo co]
| 97 | false | false | 0 | 10 | 21 | 51 | 24 | 27 | null | null |
brendanhay/gogol
|
gogol-classroom/gen/Network/Google/Classroom/Types/Product.hs
|
mpl-2.0
|
-- | The user\'s full name formed by concatenating the first and last name
-- values. Read-only.
nFullName :: Lens' Name (Maybe Text)
nFullName
= lens _nFullName (\ s a -> s{_nFullName = a})
| 192 |
nFullName :: Lens' Name (Maybe Text)
nFullName
= lens _nFullName (\ s a -> s{_nFullName = a})
| 95 |
nFullName
= lens _nFullName (\ s a -> s{_nFullName = a})
| 58 | true | true | 2 | 9 | 35 | 56 | 26 | 30 | null | null |
deontologician/orbRPG
|
Game/OrbRPG/HAdventure/Builder.hs
|
gpl-3.0
|
-- | Create a particular object at a particular location.
revealAt :: Object -- ^ The object to create.
-> Object -- ^ The location at which to create it.
-> Adv ()
revealAt = addObject
| 207 |
revealAt :: Object -- ^ The object to create.
-> Object -- ^ The location at which to create it.
-> Adv ()
revealAt = addObject
| 149 |
revealAt = addObject
| 20 | true | true | 0 | 8 | 57 | 27 | 15 | 12 | null | null |
fmapfmapfmap/amazonka
|
amazonka-glacier/gen/Network/AWS/Glacier/ListTagsForVault.hs
|
mpl-2.0
|
-- | The response status code.
ltfvrsResponseStatus :: Lens' ListTagsForVaultResponse Int
ltfvrsResponseStatus = lens _ltfvrsResponseStatus (\ s a -> s{_ltfvrsResponseStatus = a})
| 179 |
ltfvrsResponseStatus :: Lens' ListTagsForVaultResponse Int
ltfvrsResponseStatus = lens _ltfvrsResponseStatus (\ s a -> s{_ltfvrsResponseStatus = a})
| 148 |
ltfvrsResponseStatus = lens _ltfvrsResponseStatus (\ s a -> s{_ltfvrsResponseStatus = a})
| 89 | true | true | 1 | 9 | 21 | 43 | 22 | 21 | null | null |
hferreiro/replay
|
compiler/nativeGen/X86/Ppr.hs
|
bsd-3-clause
|
pprInstr (CVTTSS2SIQ sz from to) = pprSizeSizeOpReg (sLit "cvttss2si") FF32 sz from to
| 86 |
pprInstr (CVTTSS2SIQ sz from to) = pprSizeSizeOpReg (sLit "cvttss2si") FF32 sz from to
| 86 |
pprInstr (CVTTSS2SIQ sz from to) = pprSizeSizeOpReg (sLit "cvttss2si") FF32 sz from to
| 86 | false | false | 0 | 7 | 12 | 36 | 17 | 19 | null | null |
bjornbm/astro
|
src/Astro/Coords.hs
|
bsd-3-clause
|
apply (CS f) = S . f . c
| 24 |
apply (CS f) = S . f . c
| 24 |
apply (CS f) = S . f . c
| 24 | false | false | 0 | 7 | 8 | 23 | 11 | 12 | null | null |
ryantrinkle/ghcjs
|
src/Gen2/Prim.hs
|
mit
|
genPrim _ _ WriteByteArrayOp_WideChar [] [a,i,e] = PrimInline [j| `a`.i3[`i`] = `e`; |]
| 87 |
genPrim _ _ WriteByteArrayOp_WideChar [] [a,i,e] = PrimInline [j| `a`.i3[`i`] = `e`; |]
| 87 |
genPrim _ _ WriteByteArrayOp_WideChar [] [a,i,e] = PrimInline [j| `a`.i3[`i`] = `e`; |]
| 87 | false | false | 3 | 6 | 12 | 36 | 20 | 16 | null | null |
Peaker/TraceUtils
|
src/Debug/TraceUtils/Dont.hs
|
bsd-3-clause
|
tracePutStrLn :: Monad m => String -> m ()
tracePutStrLn = const $ return ()
| 76 |
tracePutStrLn :: Monad m => String -> m ()
tracePutStrLn = const $ return ()
| 76 |
tracePutStrLn = const $ return ()
| 33 | false | true | 0 | 8 | 14 | 36 | 17 | 19 | null | null |
psibi/yesod
|
yesod-persistent/test/Yesod/PersistSpec.hs
|
mit
|
getHomeR :: Handler TypedContent
getHomeR = do
runDB $ do
runMigration migrateAll
deleteWhere ([] :: [Filter Person])
insert_ $ Person "Charlie"
insert_ $ Person "Alice"
insert_ $ Person "Bob"
respondSourceDB typePlain $ selectSource [] [Asc PersonName] .| awaitForever toBuilder
where
toBuilder (Entity _ (Person name)) = do
yield $ Chunk $ fromText name
yield $ Chunk $ fromText "\n"
yield Flush
| 475 |
getHomeR :: Handler TypedContent
getHomeR = do
runDB $ do
runMigration migrateAll
deleteWhere ([] :: [Filter Person])
insert_ $ Person "Charlie"
insert_ $ Person "Alice"
insert_ $ Person "Bob"
respondSourceDB typePlain $ selectSource [] [Asc PersonName] .| awaitForever toBuilder
where
toBuilder (Entity _ (Person name)) = do
yield $ Chunk $ fromText name
yield $ Chunk $ fromText "\n"
yield Flush
| 475 |
getHomeR = do
runDB $ do
runMigration migrateAll
deleteWhere ([] :: [Filter Person])
insert_ $ Person "Charlie"
insert_ $ Person "Alice"
insert_ $ Person "Bob"
respondSourceDB typePlain $ selectSource [] [Asc PersonName] .| awaitForever toBuilder
where
toBuilder (Entity _ (Person name)) = do
yield $ Chunk $ fromText name
yield $ Chunk $ fromText "\n"
yield Flush
| 442 | false | true | 0 | 13 | 138 | 166 | 73 | 93 | null | null |
arybczak/haskell-dev-utils
|
cabal/CabalFreeze.hs
|
bsd-3-clause
|
main :: IO ()
main = do
config <- parseCabalConfig <$> T.readFile configFile
copyFile configFile oldConfigFile
system "cabal freeze" >>= \case
ExitFailure code -> putStrLn $ "cabal freeze failed with exit code " ++ show code
ExitSuccess -> do
newConfig <- parseCabalConfig <$> T.readFile configFile
let delta = computeDelta config newConfig
excluded = excludedPackages delta
realDelta = delta `M.difference` excluded
T.putStrLn "EXCLUDED:"
T.putStrLn $ showDelta excluded
T.putStrLn "ADDED:"
T.putStrLn $ showDelta $ addedPackages realDelta
T.putStrLn "REMOVED:"
T.putStrLn $ showDelta $ removedPackages realDelta
T.putStrLn "SUPRESSED CHANGES:"
T.putStrLn $ showDelta $ changedPackages realDelta
T.writeFile configFile $ deltaToCabalConfig realDelta
where
configFile = "cabal.config"
oldConfigFile = "cabal.config.old"
| 937 |
main :: IO ()
main = do
config <- parseCabalConfig <$> T.readFile configFile
copyFile configFile oldConfigFile
system "cabal freeze" >>= \case
ExitFailure code -> putStrLn $ "cabal freeze failed with exit code " ++ show code
ExitSuccess -> do
newConfig <- parseCabalConfig <$> T.readFile configFile
let delta = computeDelta config newConfig
excluded = excludedPackages delta
realDelta = delta `M.difference` excluded
T.putStrLn "EXCLUDED:"
T.putStrLn $ showDelta excluded
T.putStrLn "ADDED:"
T.putStrLn $ showDelta $ addedPackages realDelta
T.putStrLn "REMOVED:"
T.putStrLn $ showDelta $ removedPackages realDelta
T.putStrLn "SUPRESSED CHANGES:"
T.putStrLn $ showDelta $ changedPackages realDelta
T.writeFile configFile $ deltaToCabalConfig realDelta
where
configFile = "cabal.config"
oldConfigFile = "cabal.config.old"
| 937 |
main = do
config <- parseCabalConfig <$> T.readFile configFile
copyFile configFile oldConfigFile
system "cabal freeze" >>= \case
ExitFailure code -> putStrLn $ "cabal freeze failed with exit code " ++ show code
ExitSuccess -> do
newConfig <- parseCabalConfig <$> T.readFile configFile
let delta = computeDelta config newConfig
excluded = excludedPackages delta
realDelta = delta `M.difference` excluded
T.putStrLn "EXCLUDED:"
T.putStrLn $ showDelta excluded
T.putStrLn "ADDED:"
T.putStrLn $ showDelta $ addedPackages realDelta
T.putStrLn "REMOVED:"
T.putStrLn $ showDelta $ removedPackages realDelta
T.putStrLn "SUPRESSED CHANGES:"
T.putStrLn $ showDelta $ changedPackages realDelta
T.writeFile configFile $ deltaToCabalConfig realDelta
where
configFile = "cabal.config"
oldConfigFile = "cabal.config.old"
| 923 | false | true | 1 | 16 | 220 | 251 | 111 | 140 | null | null |
GaloisInc/tower
|
tower/src/Ivory/Tower/AST/Graph.hs
|
bsd-3-clause
|
monitorChanHandlers :: Monitor -> Chan -> [Handler]
monitorChanHandlers m c = filter p (monitor_handlers m)
where p h = handler_chan h == c
-- For a given handler, the list of all channels it emits on.
| 204 |
monitorChanHandlers :: Monitor -> Chan -> [Handler]
monitorChanHandlers m c = filter p (monitor_handlers m)
where p h = handler_chan h == c
-- For a given handler, the list of all channels it emits on.
| 204 |
monitorChanHandlers m c = filter p (monitor_handlers m)
where p h = handler_chan h == c
-- For a given handler, the list of all channels it emits on.
| 152 | false | true | 0 | 7 | 38 | 56 | 28 | 28 | null | null |
HalosGhost/hs
|
numbers/roman.hs
|
isc
|
-- | Convert an integral to a Roman Numeral of the specified format.
-- Because Lenient forms do not have single representation of all numbers
-- and because all Subtractive forms are valid Lenient forms,
-- `toRoman Lenient{,N}` will use the Subtractive forms.
toRoman :: Integral a => RomanFormat -> a -> String
toRoman f n = case f of
Additive -> toAdditiveRoman' n
AdditiveN -> toAdditiveRoman n
Subtractive -> toSubtractiveRoman' n
SubtractiveN -> toSubtractiveRoman n
Lenient -> toSubtractiveRoman' n
LenientN -> toSubtractiveRoman n
-- | Convert a Roman Numeral of the specified format to an integral.
| 647 |
toRoman :: Integral a => RomanFormat -> a -> String
toRoman f n = case f of
Additive -> toAdditiveRoman' n
AdditiveN -> toAdditiveRoman n
Subtractive -> toSubtractiveRoman' n
SubtractiveN -> toSubtractiveRoman n
Lenient -> toSubtractiveRoman' n
LenientN -> toSubtractiveRoman n
-- | Convert a Roman Numeral of the specified format to an integral.
| 385 |
toRoman f n = case f of
Additive -> toAdditiveRoman' n
AdditiveN -> toAdditiveRoman n
Subtractive -> toSubtractiveRoman' n
SubtractiveN -> toSubtractiveRoman n
Lenient -> toSubtractiveRoman' n
LenientN -> toSubtractiveRoman n
-- | Convert a Roman Numeral of the specified format to an integral.
| 333 | true | true | 0 | 9 | 135 | 99 | 47 | 52 | null | null |
dysinger/amazonka
|
amazonka-codedeploy/gen/Network/AWS/CodeDeploy/Types.hs
|
mpl-2.0
|
-- | The number of instances that have failed in the deployment.
doFailed :: Lens' DeploymentOverview (Maybe Integer)
doFailed = lens _doFailed (\s a -> s { _doFailed = a })
| 173 |
doFailed :: Lens' DeploymentOverview (Maybe Integer)
doFailed = lens _doFailed (\s a -> s { _doFailed = a })
| 108 |
doFailed = lens _doFailed (\s a -> s { _doFailed = a })
| 55 | true | true | 1 | 9 | 30 | 52 | 25 | 27 | null | null |
bgamari/pandoc
|
src/Text/Pandoc/Writers/FB2.hs
|
gpl-2.0
|
blockToXml (Header _ _ _) = -- should never happen, see renderSections
error "unexpected header in section text"
| 138 |
blockToXml (Header _ _ _) = -- should never happen, see renderSections
error "unexpected header in section text"
| 138 |
blockToXml (Header _ _ _) = -- should never happen, see renderSections
error "unexpected header in section text"
| 138 | false | false | 0 | 7 | 43 | 23 | 11 | 12 | null | null |
lukexi/stack
|
src/Stack/Setup.hs
|
bsd-3-clause
|
withUnpackedTarball7z :: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasConfig env, HasHttpManager env, MonadBaseControl IO m)
=> String -- ^ Name of tool, used in error messages
-> SetupInfo
-> Path Abs File -- ^ Path to archive file
-> ArchiveType
-> Path Rel Dir -- ^ Name of directory expected to be in archive.
-> Path Abs Dir -- ^ Destination directory.
-> m ()
withUnpackedTarball7z name si archiveFile archiveType srcDir destDir = do
suffix <-
case archiveType of
TarXz -> return ".xz"
TarBz2 -> return ".bz2"
TarGz -> return ".gz"
_ -> error $ name ++ " must be a tarball file"
tarFile <-
case T.stripSuffix suffix $ T.pack $ toFilePath archiveFile of
Nothing -> error $ "Invalid " ++ name ++ " filename: " ++ show archiveFile
Just x -> parseAbsFile $ T.unpack x
run7z <- setup7z si
let tmpName = (toFilePathNoTrailingSep $ dirname destDir) ++ "-tmp"
createTree (parent destDir)
withCanonicalizedTempDirectory (toFilePath $ parent destDir) tmpName $ \tmpDir -> do
let absSrcDir = tmpDir </> srcDir
removeTreeIfExists destDir
run7z (parent archiveFile) archiveFile
run7z tmpDir tarFile
removeFile tarFile `catchIO` \e ->
$logWarn (T.concat
[ "Exception when removing "
, T.pack $ toFilePath tarFile
, ": "
, T.pack $ show e
])
renameDir absSrcDir destDir
-- | Download 7z as necessary, and get a function for unpacking things.
--
-- Returned function takes an unpack directory and archive.
| 1,819 |
withUnpackedTarball7z :: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasConfig env, HasHttpManager env, MonadBaseControl IO m)
=> String -- ^ Name of tool, used in error messages
-> SetupInfo
-> Path Abs File -- ^ Path to archive file
-> ArchiveType
-> Path Rel Dir -- ^ Name of directory expected to be in archive.
-> Path Abs Dir -- ^ Destination directory.
-> m ()
withUnpackedTarball7z name si archiveFile archiveType srcDir destDir = do
suffix <-
case archiveType of
TarXz -> return ".xz"
TarBz2 -> return ".bz2"
TarGz -> return ".gz"
_ -> error $ name ++ " must be a tarball file"
tarFile <-
case T.stripSuffix suffix $ T.pack $ toFilePath archiveFile of
Nothing -> error $ "Invalid " ++ name ++ " filename: " ++ show archiveFile
Just x -> parseAbsFile $ T.unpack x
run7z <- setup7z si
let tmpName = (toFilePathNoTrailingSep $ dirname destDir) ++ "-tmp"
createTree (parent destDir)
withCanonicalizedTempDirectory (toFilePath $ parent destDir) tmpName $ \tmpDir -> do
let absSrcDir = tmpDir </> srcDir
removeTreeIfExists destDir
run7z (parent archiveFile) archiveFile
run7z tmpDir tarFile
removeFile tarFile `catchIO` \e ->
$logWarn (T.concat
[ "Exception when removing "
, T.pack $ toFilePath tarFile
, ": "
, T.pack $ show e
])
renameDir absSrcDir destDir
-- | Download 7z as necessary, and get a function for unpacking things.
--
-- Returned function takes an unpack directory and archive.
| 1,819 |
withUnpackedTarball7z name si archiveFile archiveType srcDir destDir = do
suffix <-
case archiveType of
TarXz -> return ".xz"
TarBz2 -> return ".bz2"
TarGz -> return ".gz"
_ -> error $ name ++ " must be a tarball file"
tarFile <-
case T.stripSuffix suffix $ T.pack $ toFilePath archiveFile of
Nothing -> error $ "Invalid " ++ name ++ " filename: " ++ show archiveFile
Just x -> parseAbsFile $ T.unpack x
run7z <- setup7z si
let tmpName = (toFilePathNoTrailingSep $ dirname destDir) ++ "-tmp"
createTree (parent destDir)
withCanonicalizedTempDirectory (toFilePath $ parent destDir) tmpName $ \tmpDir -> do
let absSrcDir = tmpDir </> srcDir
removeTreeIfExists destDir
run7z (parent archiveFile) archiveFile
run7z tmpDir tarFile
removeFile tarFile `catchIO` \e ->
$logWarn (T.concat
[ "Exception when removing "
, T.pack $ toFilePath tarFile
, ": "
, T.pack $ show e
])
renameDir absSrcDir destDir
-- | Download 7z as necessary, and get a function for unpacking things.
--
-- Returned function takes an unpack directory and archive.
| 1,282 | false | true | 0 | 18 | 638 | 428 | 204 | 224 | null | null |
AlexeyRaga/eta
|
compiler/ETA/Interactive/ByteCodeAsm.hs
|
bsd-3-clause
|
return_ubx F = bci_RETURN_F
| 29 |
return_ubx F = bci_RETURN_F
| 29 |
return_ubx F = bci_RETURN_F
| 29 | false | false | 0 | 5 | 5 | 9 | 4 | 5 | null | null |
ke00n/alabno
|
backend/complexity_analyser/testFiles/MP/student/MP.hs
|
mit
|
expandext input keys
= concat ( map (++"----- \n") [(expand input str1) | str1 <- v])
where
(sep3, v) = split "#" keys
| 126 |
expandext input keys
= concat ( map (++"----- \n") [(expand input str1) | str1 <- v])
where
(sep3, v) = split "#" keys
| 126 |
expandext input keys
= concat ( map (++"----- \n") [(expand input str1) | str1 <- v])
where
(sep3, v) = split "#" keys
| 126 | false | false | 1 | 9 | 30 | 69 | 33 | 36 | null | null |
nickbart1980/pandoc
|
src/Text/Pandoc/Writers/Man.hs
|
gpl-2.0
|
orderedListItemToMan :: WriterOptions -- ^ options
-> String -- ^ order marker for list item
-> Int -- ^ number of spaces to indent
-> [Block] -- ^ list item (list of blocks)
-> State WriterState Doc
orderedListItemToMan _ _ _ [] = return empty
| 356 |
orderedListItemToMan :: WriterOptions -- ^ options
-> String -- ^ order marker for list item
-> Int -- ^ number of spaces to indent
-> [Block] -- ^ list item (list of blocks)
-> State WriterState Doc
orderedListItemToMan _ _ _ [] = return empty
| 356 |
orderedListItemToMan _ _ _ [] = return empty
| 44 | false | true | 0 | 9 | 156 | 53 | 28 | 25 | null | null |
harendra-kumar/stack
|
src/Options/Applicative/Builder/Extra.hs
|
bsd-3-clause
|
-- | Enable/disable flags for a @('Maybe' 'Bool')@.
maybeBoolFlags :: String -- ^ Flag name
-> String -- ^ Help suffix
-> Mod FlagFields (Maybe Bool)
-> Parser (Maybe Bool)
maybeBoolFlags = enableDisableFlags Nothing (Just True) (Just False)
| 330 |
maybeBoolFlags :: String -- ^ Flag name
-> String -- ^ Help suffix
-> Mod FlagFields (Maybe Bool)
-> Parser (Maybe Bool)
maybeBoolFlags = enableDisableFlags Nothing (Just True) (Just False)
| 278 |
maybeBoolFlags = enableDisableFlags Nothing (Just True) (Just False)
| 68 | true | true | 0 | 10 | 126 | 65 | 33 | 32 | null | null |
sherwoodwang/wxHaskell
|
wxcore/src/haskell/Graphics/UI/WXCore/WxcTypes.hs
|
lgpl-2.1
|
withPointResult :: (Ptr CInt -> Ptr CInt -> IO ()) -> IO (Point2 Int)
withPointResult f
= alloca $ \px ->
alloca $ \py ->
do f px py
x <- peek px
y <- peek py
return (fromCPoint x y)
| 213 |
withPointResult :: (Ptr CInt -> Ptr CInt -> IO ()) -> IO (Point2 Int)
withPointResult f
= alloca $ \px ->
alloca $ \py ->
do f px py
x <- peek px
y <- peek py
return (fromCPoint x y)
| 213 |
withPointResult f
= alloca $ \px ->
alloca $ \py ->
do f px py
x <- peek px
y <- peek py
return (fromCPoint x y)
| 143 | false | true | 0 | 13 | 71 | 109 | 50 | 59 | null | null |
mit-plv/riscv-semantics
|
src/Spec/ExecuteF.hs
|
bsd-3-clause
|
execute (Fmin_s rd rs1 rs2) = do
x <- getFPRegister rs1
y <- getFPRegister rs2
let Result z flags = f32LtQuiet (fromIntegral x :: Word32) (fromIntegral y :: Word32)
updateFFlags flags
-- Special cases and other sheNaNigans. Current behavior (v2.3-draft) differs
-- from v2.2 of spec.
let result | x == negativeZero && y == positiveZero = x
| isNaN x && isNaN y = canonicalNaN
| isNaN y = x
| isNaN x = y
| z = x
| otherwise = y
setFPRegister rd result
| 532 |
execute (Fmin_s rd rs1 rs2) = do
x <- getFPRegister rs1
y <- getFPRegister rs2
let Result z flags = f32LtQuiet (fromIntegral x :: Word32) (fromIntegral y :: Word32)
updateFFlags flags
-- Special cases and other sheNaNigans. Current behavior (v2.3-draft) differs
-- from v2.2 of spec.
let result | x == negativeZero && y == positiveZero = x
| isNaN x && isNaN y = canonicalNaN
| isNaN y = x
| isNaN x = y
| z = x
| otherwise = y
setFPRegister rd result
| 532 |
execute (Fmin_s rd rs1 rs2) = do
x <- getFPRegister rs1
y <- getFPRegister rs2
let Result z flags = f32LtQuiet (fromIntegral x :: Word32) (fromIntegral y :: Word32)
updateFFlags flags
-- Special cases and other sheNaNigans. Current behavior (v2.3-draft) differs
-- from v2.2 of spec.
let result | x == negativeZero && y == positiveZero = x
| isNaN x && isNaN y = canonicalNaN
| isNaN y = x
| isNaN x = y
| z = x
| otherwise = y
setFPRegister rd result
| 532 | false | false | 0 | 15 | 167 | 182 | 80 | 102 | null | null |
brendanhay/gogol
|
gogol-shopping-content/gen/Network/Google/Resource/Content/FreeListingsprogram/Requestreview.hs
|
mpl-2.0
|
-- | Upload protocol for media (e.g. \"raw\", \"multipart\").
flrUploadProtocol :: Lens' FreeListingsprogramRequestreview (Maybe Text)
flrUploadProtocol
= lens _flrUploadProtocol
(\ s a -> s{_flrUploadProtocol = a})
| 223 |
flrUploadProtocol :: Lens' FreeListingsprogramRequestreview (Maybe Text)
flrUploadProtocol
= lens _flrUploadProtocol
(\ s a -> s{_flrUploadProtocol = a})
| 161 |
flrUploadProtocol
= lens _flrUploadProtocol
(\ s a -> s{_flrUploadProtocol = a})
| 88 | true | true | 0 | 8 | 33 | 49 | 25 | 24 | null | null |
shayan-najd/HsParser
|
U/Pretty.hs
|
gpl-3.0
|
sep1 _ NoDoc _ _ = NoDoc
| 39 |
sep1 _ NoDoc _ _ = NoDoc
| 39 |
sep1 _ NoDoc _ _ = NoDoc
| 39 | false | false | 0 | 5 | 21 | 15 | 7 | 8 | null | null |
binarin/learnopengl
|
src/Lighting.hs
|
bsd-3-clause
|
mkWhiteCube :: IO WhiteCube
mkWhiteCube = do
vbo <- GL.genBuffer
vao <- GL.genVertexArray
GL.bindVertexArray vao
GL.bindBuffer GL.TargetArray vbo
GL.floatBufferData GL.TargetArray GL.UsageStaticDraw
[ -0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, 0.5, -0.5,
0.5, 0.5, -0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, -0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, 0.5,
-0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
-0.5, -0.5, 0.5,
-0.5, -0.5, -0.5,
-0.5, 0.5, -0.5,
0.5, 0.5, -0.5,
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, 0.5, -0.5
]
GL.vertexAttribPointer 0 3 GL.AttribPointerFloat False 12 0
GL.enableVertexAttribArray 0
prog <- GL.stdProgram
([r|
#version 330 core
layout (location = 0) in vec3 position;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(position, 1.0f);
}
|])
([r|
#version 330 core
out vec4 color;
void main() {
color = vec4(1.0f);
}
|])
locView <- GL.getUniformLocation prog "view"
locModel <- GL.getUniformLocation prog "model"
locProjection <- GL.getUniformLocation prog "projection"
return $ WhiteCube { vao, vbo, prog, locProjection, locModel, locView }
| 1,790 |
mkWhiteCube :: IO WhiteCube
mkWhiteCube = do
vbo <- GL.genBuffer
vao <- GL.genVertexArray
GL.bindVertexArray vao
GL.bindBuffer GL.TargetArray vbo
GL.floatBufferData GL.TargetArray GL.UsageStaticDraw
[ -0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, 0.5, -0.5,
0.5, 0.5, -0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, -0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, 0.5,
-0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
-0.5, -0.5, 0.5,
-0.5, -0.5, -0.5,
-0.5, 0.5, -0.5,
0.5, 0.5, -0.5,
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, 0.5, -0.5
]
GL.vertexAttribPointer 0 3 GL.AttribPointerFloat False 12 0
GL.enableVertexAttribArray 0
prog <- GL.stdProgram
([r|
#version 330 core
layout (location = 0) in vec3 position;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(position, 1.0f);
}
|])
([r|
#version 330 core
out vec4 color;
void main() {
color = vec4(1.0f);
}
|])
locView <- GL.getUniformLocation prog "view"
locModel <- GL.getUniformLocation prog "model"
locProjection <- GL.getUniformLocation prog "projection"
return $ WhiteCube { vao, vbo, prog, locProjection, locModel, locView }
| 1,790 |
mkWhiteCube = do
vbo <- GL.genBuffer
vao <- GL.genVertexArray
GL.bindVertexArray vao
GL.bindBuffer GL.TargetArray vbo
GL.floatBufferData GL.TargetArray GL.UsageStaticDraw
[ -0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, 0.5, -0.5,
0.5, 0.5, -0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, -0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, -0.5,
-0.5, -0.5, 0.5,
-0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
-0.5, -0.5, 0.5,
-0.5, -0.5, -0.5,
-0.5, 0.5, -0.5,
0.5, 0.5, -0.5,
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
-0.5, 0.5, -0.5
]
GL.vertexAttribPointer 0 3 GL.AttribPointerFloat False 12 0
GL.enableVertexAttribArray 0
prog <- GL.stdProgram
([r|
#version 330 core
layout (location = 0) in vec3 position;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(position, 1.0f);
}
|])
([r|
#version 330 core
out vec4 color;
void main() {
color = vec4(1.0f);
}
|])
locView <- GL.getUniformLocation prog "view"
locModel <- GL.getUniformLocation prog "model"
locProjection <- GL.getUniformLocation prog "projection"
return $ WhiteCube { vao, vbo, prog, locProjection, locModel, locView }
| 1,762 | false | true | 0 | 9 | 591 | 631 | 365 | 266 | null | null |
tsiliakis/xmobar
|
src/Plugins/Monitors/Batt.hs
|
bsd-3-clause
|
readBattery sc files =
do a <- grab $ fFull files
b <- grab $ fNow files
d <- grab $ fCurrent files
return $ Battery (3600 * a / sc) -- wattseconds
(3600 * b / sc) -- wattseconds
(d / sc) -- watts
where grab f = handle onError $ withFile f ReadMode (fmap read . hGetLine)
onError = const (return (-1)) :: SomeException -> IO Float
| 417 |
readBattery sc files =
do a <- grab $ fFull files
b <- grab $ fNow files
d <- grab $ fCurrent files
return $ Battery (3600 * a / sc) -- wattseconds
(3600 * b / sc) -- wattseconds
(d / sc) -- watts
where grab f = handle onError $ withFile f ReadMode (fmap read . hGetLine)
onError = const (return (-1)) :: SomeException -> IO Float
| 417 |
readBattery sc files =
do a <- grab $ fFull files
b <- grab $ fNow files
d <- grab $ fCurrent files
return $ Battery (3600 * a / sc) -- wattseconds
(3600 * b / sc) -- wattseconds
(d / sc) -- watts
where grab f = handle onError $ withFile f ReadMode (fmap read . hGetLine)
onError = const (return (-1)) :: SomeException -> IO Float
| 417 | false | false | 1 | 11 | 155 | 170 | 80 | 90 | null | null |
Teaspot-Studio/Urho3D-Haskell
|
src/Graphics/Urho3D/Core/TypeInfo.hs
|
mit
|
typeInfoGetTypeName :: (Parent TypeInfo a, Pointer p a, MonadIO m)
=> p -- ^ Pointer to type info
-> m String
typeInfoGetTypeName p = liftIO $ do
let ptr = parentPointer p
loadConstUrhoString =<< [C.exp| const String* { &$(TypeInfo* ptr)->GetTypeName() } |]
-- | Return base type info.
| 294 |
typeInfoGetTypeName :: (Parent TypeInfo a, Pointer p a, MonadIO m)
=> p -- ^ Pointer to type info
-> m String
typeInfoGetTypeName p = liftIO $ do
let ptr = parentPointer p
loadConstUrhoString =<< [C.exp| const String* { &$(TypeInfo* ptr)->GetTypeName() } |]
-- | Return base type info.
| 294 |
typeInfoGetTypeName p = liftIO $ do
let ptr = parentPointer p
loadConstUrhoString =<< [C.exp| const String* { &$(TypeInfo* ptr)->GetTypeName() } |]
-- | Return base type info.
| 180 | false | true | 0 | 11 | 56 | 82 | 41 | 41 | null | null |
danr/hipspec
|
examples/Russel.hs
|
gpl-3.0
|
prop2 x = russel x =:= False
| 28 |
prop2 x = russel x =:= False
| 28 |
prop2 x = russel x =:= False
| 28 | false | false | 0 | 6 | 6 | 16 | 7 | 9 | null | null |
urbanslug/ghc
|
testsuite/tests/indexed-types/should_run/T2985.hs
|
bsd-3-clause
|
main = print test1
| 18 |
main = print test1
| 18 |
main = print test1
| 18 | false | false | 1 | 5 | 3 | 12 | 4 | 8 | null | null |
chiro/tchhh
|
src/TL.hs
|
mit
|
showTL (SDelete d) = putStrLn $ T.concat ["Delete: ", showT (delUserId d), " " ,showT (delId d)]
| 96 |
showTL (SDelete d) = putStrLn $ T.concat ["Delete: ", showT (delUserId d), " " ,showT (delId d)]
| 96 |
showTL (SDelete d) = putStrLn $ T.concat ["Delete: ", showT (delUserId d), " " ,showT (delId d)]
| 96 | false | false | 0 | 10 | 16 | 54 | 27 | 27 | null | null |
aaronc/Idris-dev
|
src/Idris/Core/TT.hs
|
bsd-3-clause
|
constDocs (B8 w) = "The eight-bit value 0x" ++
showIntAtBase 16 intToDigit w ""
| 150 |
constDocs (B8 w) = "The eight-bit value 0x" ++
showIntAtBase 16 intToDigit w ""
| 150 |
constDocs (B8 w) = "The eight-bit value 0x" ++
showIntAtBase 16 intToDigit w ""
| 150 | false | false | 0 | 6 | 84 | 29 | 13 | 16 | null | null |
frontrowed/stratosphere
|
library-gen/Stratosphere/ResourceProperties/S3BucketCorsRule.hs
|
mit
|
-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors-corsrule.html#cfn-s3-bucket-cors-corsrule-allowedmethods
sbcrAllowedMethods :: Lens' S3BucketCorsRule (ValList Text)
sbcrAllowedMethods = lens _s3BucketCorsRuleAllowedMethods (\s a -> s { _s3BucketCorsRuleAllowedMethods = a })
| 323 |
sbcrAllowedMethods :: Lens' S3BucketCorsRule (ValList Text)
sbcrAllowedMethods = lens _s3BucketCorsRuleAllowedMethods (\s a -> s { _s3BucketCorsRuleAllowedMethods = a })
| 169 |
sbcrAllowedMethods = lens _s3BucketCorsRuleAllowedMethods (\s a -> s { _s3BucketCorsRuleAllowedMethods = a })
| 109 | true | true | 0 | 9 | 21 | 46 | 25 | 21 | null | null |
bitemyapp/ghc
|
libraries/base/GHC/IO/Handle/Internals.hs
|
bsd-3-clause
|
checkReadableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
checkReadableHandle act h_@Handle__{..} =
case haType of
ClosedHandle -> ioe_closedHandle
SemiClosedHandle -> ioe_closedHandle
AppendHandle -> ioe_notReadable
WriteHandle -> ioe_notReadable
ReadWriteHandle -> do
-- a read/write handle and we want to read from it. We must
-- flush all buffered write data first.
bbuf <- readIORef haByteBuffer
when (isWriteBuffer bbuf) $ do
when (not (isEmptyBuffer bbuf)) $ flushByteWriteBuffer h_
cbuf' <- readIORef haCharBuffer
writeIORef haCharBuffer cbuf'{ bufState = ReadBuffer }
bbuf <- readIORef haByteBuffer
writeIORef haByteBuffer bbuf{ bufState = ReadBuffer }
act h_
_other -> act h_
-- ---------------------------------------------------------------------------
-- Wrapper for seek operations.
| 1,005 |
checkReadableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
checkReadableHandle act h_@Handle__{..} =
case haType of
ClosedHandle -> ioe_closedHandle
SemiClosedHandle -> ioe_closedHandle
AppendHandle -> ioe_notReadable
WriteHandle -> ioe_notReadable
ReadWriteHandle -> do
-- a read/write handle and we want to read from it. We must
-- flush all buffered write data first.
bbuf <- readIORef haByteBuffer
when (isWriteBuffer bbuf) $ do
when (not (isEmptyBuffer bbuf)) $ flushByteWriteBuffer h_
cbuf' <- readIORef haCharBuffer
writeIORef haCharBuffer cbuf'{ bufState = ReadBuffer }
bbuf <- readIORef haByteBuffer
writeIORef haByteBuffer bbuf{ bufState = ReadBuffer }
act h_
_other -> act h_
-- ---------------------------------------------------------------------------
-- Wrapper for seek operations.
| 1,005 |
checkReadableHandle act h_@Handle__{..} =
case haType of
ClosedHandle -> ioe_closedHandle
SemiClosedHandle -> ioe_closedHandle
AppendHandle -> ioe_notReadable
WriteHandle -> ioe_notReadable
ReadWriteHandle -> do
-- a read/write handle and we want to read from it. We must
-- flush all buffered write data first.
bbuf <- readIORef haByteBuffer
when (isWriteBuffer bbuf) $ do
when (not (isEmptyBuffer bbuf)) $ flushByteWriteBuffer h_
cbuf' <- readIORef haCharBuffer
writeIORef haCharBuffer cbuf'{ bufState = ReadBuffer }
bbuf <- readIORef haByteBuffer
writeIORef haByteBuffer bbuf{ bufState = ReadBuffer }
act h_
_other -> act h_
-- ---------------------------------------------------------------------------
-- Wrapper for seek operations.
| 943 | false | true | 0 | 18 | 308 | 202 | 96 | 106 | null | null |
bgamari/minir
|
MinIR/OrderedIndex.hs
|
bsd-3-clause
|
firsts :: V.Vector a -> [V.Vector a]
firsts xs | V.length xs < 2 = [xs]
| otherwise = map (\n->V.take n xs) [2..V.length xs]
| 140 |
firsts :: V.Vector a -> [V.Vector a]
firsts xs | V.length xs < 2 = [xs]
| otherwise = map (\n->V.take n xs) [2..V.length xs]
| 140 |
firsts xs | V.length xs < 2 = [xs]
| otherwise = map (\n->V.take n xs) [2..V.length xs]
| 103 | false | true | 0 | 10 | 40 | 88 | 42 | 46 | null | null |
BlairArchibald/bones
|
lib/src/Bones/Skeletons/BranchAndBound/HdpH/GlobalRegistry.hs
|
bsd-3-clause
|
addGlobalSearchSpaceToRegistry :: IORef a -> IO ()
addGlobalSearchSpaceToRegistry = addRefToRegistry searchSpaceKey
| 115 |
addGlobalSearchSpaceToRegistry :: IORef a -> IO ()
addGlobalSearchSpaceToRegistry = addRefToRegistry searchSpaceKey
| 115 |
addGlobalSearchSpaceToRegistry = addRefToRegistry searchSpaceKey
| 64 | false | true | 0 | 8 | 10 | 31 | 13 | 18 | null | null |
olorin/amazonka
|
gen/src/Gen/AST/Data/Syntax.hs
|
mpl-2.0
|
str :: Text -> Exp
str = Exts.Lit . String . Text.unpack
| 56 |
str :: Text -> Exp
str = Exts.Lit . String . Text.unpack
| 56 |
str = Exts.Lit . String . Text.unpack
| 37 | false | true | 0 | 7 | 11 | 34 | 15 | 19 | null | null |
gcampax/ghc
|
compiler/main/HscTypes.hs
|
bsd-3-clause
|
-- | Get annotations from modules "below" this one (in the dependency sense)
hptAnns :: HscEnv -> Maybe [(ModuleName, IsBootInterface)] -> [Annotation]
hptAnns hsc_env (Just deps) = hptSomeThingsBelowUs (md_anns . hm_details) False hsc_env deps
| 244 |
hptAnns :: HscEnv -> Maybe [(ModuleName, IsBootInterface)] -> [Annotation]
hptAnns hsc_env (Just deps) = hptSomeThingsBelowUs (md_anns . hm_details) False hsc_env deps
| 167 |
hptAnns hsc_env (Just deps) = hptSomeThingsBelowUs (md_anns . hm_details) False hsc_env deps
| 92 | true | true | 0 | 9 | 33 | 66 | 34 | 32 | null | null |
yshklarov/hopty
|
Numeric/Optimization/Hopty.hs
|
unlicense
|
patternsearch :: RealFloat a =>
a -- ^ Initial step size
-> ([a] -> a) -- ^ Function to minimize
-> [a] -- ^ Starting point
-> [a] -- ^ Local minimum point
patternsearch stepsize f x
| stepsize < epsilon = x -- Success.
-- FIXME: the following takes too long, is there a better way to detect it?
| or (map isInfinite x) = x -- Failure: diverged to infinity.
| or (map isNaN x) = x
| x == nextx = patternsearch (stepsize/2) f nextx
| otherwise = patternsearch stepsize f nextx
where
nextx = minimumBy (comparing f) $
x : (concatMap adjPoints [0..length x - 1])
adjPoints k = map (\g -> applyToKth k g x)
[(+ stepsize), (subtract stepsize)]
-- | Find the Euclidian norm of a given vector.
| 875 |
patternsearch :: RealFloat a =>
a -- ^ Initial step size
-> ([a] -> a) -- ^ Function to minimize
-> [a] -- ^ Starting point
-> [a]
patternsearch stepsize f x
| stepsize < epsilon = x -- Success.
-- FIXME: the following takes too long, is there a better way to detect it?
| or (map isInfinite x) = x -- Failure: diverged to infinity.
| or (map isNaN x) = x
| x == nextx = patternsearch (stepsize/2) f nextx
| otherwise = patternsearch stepsize f nextx
where
nextx = minimumBy (comparing f) $
x : (concatMap adjPoints [0..length x - 1])
adjPoints k = map (\g -> applyToKth k g x)
[(+ stepsize), (subtract stepsize)]
-- | Find the Euclidian norm of a given vector.
| 842 |
patternsearch stepsize f x
| stepsize < epsilon = x -- Success.
-- FIXME: the following takes too long, is there a better way to detect it?
| or (map isInfinite x) = x -- Failure: diverged to infinity.
| or (map isNaN x) = x
| x == nextx = patternsearch (stepsize/2) f nextx
| otherwise = patternsearch stepsize f nextx
where
nextx = minimumBy (comparing f) $
x : (concatMap adjPoints [0..length x - 1])
adjPoints k = map (\g -> applyToKth k g x)
[(+ stepsize), (subtract stepsize)]
-- | Find the Euclidian norm of a given vector.
| 633 | true | true | 3 | 11 | 322 | 258 | 128 | 130 | null | null |
5HT/n2o.hs
|
sample/server.hs
|
isc
|
sub pubSub channel id = modifyMVar_ pubSub $ return . I.insert (ChannelData channel id)
| 87 |
sub pubSub channel id = modifyMVar_ pubSub $ return . I.insert (ChannelData channel id)
| 87 |
sub pubSub channel id = modifyMVar_ pubSub $ return . I.insert (ChannelData channel id)
| 87 | false | false | 0 | 8 | 13 | 39 | 17 | 22 | null | null |
ozgurakgun/Idris-dev
|
src/Idris/AbsSyntaxTree.hs
|
bsd-3-clause
|
annotationColour ist (AnnName n _ _ _) =
let ctxt = tt_ctxt ist
theme = idris_colourTheme ist
in case () of
_ | isDConName n ctxt -> Just $ dataColour theme
_ | isFnName n ctxt -> Just $ functionColour theme
_ | isTConName n ctxt -> Just $ typeColour theme
_ | isPostulateName n ist -> Just $ postulateColour theme
_ | otherwise -> Nothing -- don't colourise unknown names
| 443 |
annotationColour ist (AnnName n _ _ _) =
let ctxt = tt_ctxt ist
theme = idris_colourTheme ist
in case () of
_ | isDConName n ctxt -> Just $ dataColour theme
_ | isFnName n ctxt -> Just $ functionColour theme
_ | isTConName n ctxt -> Just $ typeColour theme
_ | isPostulateName n ist -> Just $ postulateColour theme
_ | otherwise -> Nothing -- don't colourise unknown names
| 443 |
annotationColour ist (AnnName n _ _ _) =
let ctxt = tt_ctxt ist
theme = idris_colourTheme ist
in case () of
_ | isDConName n ctxt -> Just $ dataColour theme
_ | isFnName n ctxt -> Just $ functionColour theme
_ | isTConName n ctxt -> Just $ typeColour theme
_ | isPostulateName n ist -> Just $ postulateColour theme
_ | otherwise -> Nothing -- don't colourise unknown names
| 443 | false | false | 0 | 13 | 141 | 160 | 70 | 90 | null | null |
dflemstr/ship
|
Ship.hs
|
gpl-3.0
|
shipBoost :: Lens Ship Bool
shipBoost = stateBoost . shipState
| 62 |
shipBoost :: Lens Ship Bool
shipBoost = stateBoost . shipState
| 62 |
shipBoost = stateBoost . shipState
| 34 | false | true | 0 | 5 | 9 | 20 | 10 | 10 | null | null |
gbaz/cabal
|
cabal-install/Main.hs
|
bsd-3-clause
|
initAction :: InitFlags -> [String] -> Action
initAction initFlags extraArgs globalFlags = do
when (extraArgs /= []) $
die $ "'init' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag (initVerbosity initFlags)
(_useSandbox, config) <- loadConfigOrSandboxConfig verbosity
(globalFlags { globalRequireSandbox = Flag False })
let configFlags = savedConfigureFlags config
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, _, conf) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \repoContext ->
initCabal verbosity
(configPackageDB' configFlags)
repoContext
comp
conf
initFlags
| 766 |
initAction :: InitFlags -> [String] -> Action
initAction initFlags extraArgs globalFlags = do
when (extraArgs /= []) $
die $ "'init' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag (initVerbosity initFlags)
(_useSandbox, config) <- loadConfigOrSandboxConfig verbosity
(globalFlags { globalRequireSandbox = Flag False })
let configFlags = savedConfigureFlags config
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, _, conf) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \repoContext ->
initCabal verbosity
(configPackageDB' configFlags)
repoContext
comp
conf
initFlags
| 766 |
initAction initFlags extraArgs globalFlags = do
when (extraArgs /= []) $
die $ "'init' doesn't take any extra arguments: " ++ unwords extraArgs
let verbosity = fromFlag (initVerbosity initFlags)
(_useSandbox, config) <- loadConfigOrSandboxConfig verbosity
(globalFlags { globalRequireSandbox = Flag False })
let configFlags = savedConfigureFlags config
let globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, _, conf) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \repoContext ->
initCabal verbosity
(configPackageDB' configFlags)
repoContext
comp
conf
initFlags
| 720 | false | true | 0 | 13 | 192 | 194 | 95 | 99 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.