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
keithodulaigh/Hets
HasCASL/Builtin.hs
gpl-2.0
eqvId :: Id eqvId = mkInfix equivS
34
eqvId :: Id eqvId = mkInfix equivS
34
eqvId = mkInfix equivS
22
false
true
0
5
6
14
7
7
null
null
green-haskell/ghc
compiler/hsSyn/HsTypes.hs
bsd-3-clause
ppr_mono_ty _ (HsPArrTy ty) = paBrackets (ppr_mono_lty TopPrec ty)
75
ppr_mono_ty _ (HsPArrTy ty) = paBrackets (ppr_mono_lty TopPrec ty)
75
ppr_mono_ty _ (HsPArrTy ty) = paBrackets (ppr_mono_lty TopPrec ty)
75
false
false
0
7
17
28
13
15
null
null
Kirez/hsudoku
src/HSudoku.hs
mit
single :: Technique single g = ng where oneks = findKindredCells g 1 assignments = S.toList . S.fromList $ [ (coord, head ds) | (_, ones) <- oneks , one <- ones, coord <- one , let ds = (\(Left x) -> x) (g ! coord) ] ng = if not . null $ assignments then foldM assign g (S.toList . S.fromList $ assignments) else Nothing
422
single :: Technique single g = ng where oneks = findKindredCells g 1 assignments = S.toList . S.fromList $ [ (coord, head ds) | (_, ones) <- oneks , one <- ones, coord <- one , let ds = (\(Left x) -> x) (g ! coord) ] ng = if not . null $ assignments then foldM assign g (S.toList . S.fromList $ assignments) else Nothing
422
single g = ng where oneks = findKindredCells g 1 assignments = S.toList . S.fromList $ [ (coord, head ds) | (_, ones) <- oneks , one <- ones, coord <- one , let ds = (\(Left x) -> x) (g ! coord) ] ng = if not . null $ assignments then foldM assign g (S.toList . S.fromList $ assignments) else Nothing
402
false
true
0
17
167
162
86
76
null
null
thedobs/LTSmin
doc/code/regroup.hs
bsd-3-clause
cover l (x:g) = if subsumed l x then merge_rows x l : g else if subsumed x l then cover (merge_rows l x) g else x:cover l g
134
cover l (x:g) = if subsumed l x then merge_rows x l : g else if subsumed x l then cover (merge_rows l x) g else x:cover l g
134
cover l (x:g) = if subsumed l x then merge_rows x l : g else if subsumed x l then cover (merge_rows l x) g else x:cover l g
134
false
false
0
9
39
75
37
38
null
null
michaelt/lens-simple
examples/Pong.hs
bsd-3-clause
updatePaddles :: Float -> State Pong () updatePaddles time = do p <- get let paddleMovement = time * paddleSpeed keyPressed key = p^.keys.contains (SpecialKey key) -- Update the player's paddle based on keys when (keyPressed KeyUp) $ paddle1 += paddleMovement when (keyPressed KeyDown) $ paddle1 -= paddleMovement -- Calculate the optimal position let optimal = hitPos (p^.ballPos) (p^.ballSpeed) acc = accuracy p target = optimal * acc + (p^.ballPos._y) * (1 - acc) dist = target - p^.paddle2 -- Move the CPU's paddle towards this optimal position as needed when (abs dist > paddleHeight/3) $ case compare dist 0 of GT -> paddle2 += paddleMovement LT -> paddle2 -= paddleMovement _ -> return () -- Make sure both paddles don't leave the playing area paddle1 %= clamp (paddleHeight/2) paddle2 %= clamp (paddleHeight/2) -- Clamp to the region (-1, 1) but with padding
953
updatePaddles :: Float -> State Pong () updatePaddles time = do p <- get let paddleMovement = time * paddleSpeed keyPressed key = p^.keys.contains (SpecialKey key) -- Update the player's paddle based on keys when (keyPressed KeyUp) $ paddle1 += paddleMovement when (keyPressed KeyDown) $ paddle1 -= paddleMovement -- Calculate the optimal position let optimal = hitPos (p^.ballPos) (p^.ballSpeed) acc = accuracy p target = optimal * acc + (p^.ballPos._y) * (1 - acc) dist = target - p^.paddle2 -- Move the CPU's paddle towards this optimal position as needed when (abs dist > paddleHeight/3) $ case compare dist 0 of GT -> paddle2 += paddleMovement LT -> paddle2 -= paddleMovement _ -> return () -- Make sure both paddles don't leave the playing area paddle1 %= clamp (paddleHeight/2) paddle2 %= clamp (paddleHeight/2) -- Clamp to the region (-1, 1) but with padding
953
updatePaddles time = do p <- get let paddleMovement = time * paddleSpeed keyPressed key = p^.keys.contains (SpecialKey key) -- Update the player's paddle based on keys when (keyPressed KeyUp) $ paddle1 += paddleMovement when (keyPressed KeyDown) $ paddle1 -= paddleMovement -- Calculate the optimal position let optimal = hitPos (p^.ballPos) (p^.ballSpeed) acc = accuracy p target = optimal * acc + (p^.ballPos._y) * (1 - acc) dist = target - p^.paddle2 -- Move the CPU's paddle towards this optimal position as needed when (abs dist > paddleHeight/3) $ case compare dist 0 of GT -> paddle2 += paddleMovement LT -> paddle2 -= paddleMovement _ -> return () -- Make sure both paddles don't leave the playing area paddle1 %= clamp (paddleHeight/2) paddle2 %= clamp (paddleHeight/2) -- Clamp to the region (-1, 1) but with padding
913
false
true
0
14
229
293
144
149
null
null
haroldcarr/learn-haskell-coq-ml-etc
haskell/course/2018-06-snoyman-applied-haskell-at-lambdaconf/all/src/E1.hs
unlicense
parse :: T.Text -> [[T.Text]] parse t = map (map T.strip . T.splitOn ",") (T.lines t)
85
parse :: T.Text -> [[T.Text]] parse t = map (map T.strip . T.splitOn ",") (T.lines t)
85
parse t = map (map T.strip . T.splitOn ",") (T.lines t)
55
false
true
0
9
15
58
29
29
null
null
jbalint/banshee-sympatico
meera/Syntax.hs
mit
apply1 = myFmap addOne (TInt 4)
31
apply1 = myFmap addOne (TInt 4)
31
apply1 = myFmap addOne (TInt 4)
31
false
false
1
7
5
20
8
12
null
null
dsorokin/aivika-experiment-chart
examples/MachRep3/Experiment.hs
bsd-3-clause
t = resultByName "totalUpTime"
30
t = resultByName "totalUpTime"
30
t = resultByName "totalUpTime"
30
false
false
1
5
3
12
4
8
null
null
fredmorcos/attic
projects/pet/archive/pet_haskell_petparser/PetParser.hs
isc
parseShop = parseName "Expecting a shop name"
47
parseShop = parseName "Expecting a shop name"
47
parseShop = parseName "Expecting a shop name"
47
false
false
0
5
8
9
4
5
null
null
csabahruska/GFXDemo
GLBackend.hs
bsd-3-clause
setUniform :: GLProgram -> ByteString -> Uniform -> IO Bool setUniform p n u = do st "BEGIN[setUniform]" r <- setUniform' p n u st "END[setUniform]" return r
173
setUniform :: GLProgram -> ByteString -> Uniform -> IO Bool setUniform p n u = do st "BEGIN[setUniform]" r <- setUniform' p n u st "END[setUniform]" return r
173
setUniform p n u = do st "BEGIN[setUniform]" r <- setUniform' p n u st "END[setUniform]" return r
113
false
true
0
9
43
70
29
41
null
null
tjakway/ghcjvm
compiler/deSugar/DsArrows.hs
bsd-3-clause
dsCmdStmts _ _ _ [] _ = panic "dsCmdStmts []"
45
dsCmdStmts _ _ _ [] _ = panic "dsCmdStmts []"
45
dsCmdStmts _ _ _ [] _ = panic "dsCmdStmts []"
45
false
false
1
5
9
23
9
14
null
null
fmthoma/ghc
compiler/types/TyCon.hs
bsd-3-clause
-- | Extract the bound type variables and type expansion of an eta-contracted -- type synonym 'TyCon'. Panics if the 'TyCon' is not a synonym newTyConEtadRhs :: TyCon -> ([TyVar], Type) newTyConEtadRhs (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) = tvs_rhs
271
newTyConEtadRhs :: TyCon -> ([TyVar], Type) newTyConEtadRhs (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) = tvs_rhs
128
newTyConEtadRhs (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) = tvs_rhs
84
true
true
0
11
43
55
30
25
null
null
graninas/Haskell-Algorithms
Tests/TransitionGraph/transition-graph/app/AdvGame/AdvGameRuntime.hs
gpl-3.0
interpret (Put s next) = error "Not implemented."
53
interpret (Put s next) = error "Not implemented."
53
interpret (Put s next) = error "Not implemented."
53
false
false
0
7
11
20
9
11
null
null
lamdu/lamdu
src/Lamdu/GUI/DefinitionEdit.hs
gpl-3.0
make :: _ => ExprGui.Top Sugar.Definition i o -> M.WidgetId -> GuiM env i o (Responsive o) make def myId = do env <- Lens.view id let nextOutdated = E.keyPresses (env ^. has . Config.pane . Config.nextOutdatedKeys) (E.Doc [env ^. has . Texts.gotoNextOutdated]) (def ^. Sugar.drGotoNextOutdated <&> foldMap (GuiState.updateCursor . WidgetIds.fromEntityId)) case def ^. Sugar.drBody of Sugar.DefinitionBodyExpression bodyExpr -> makeExprDefinition def bodyExpr myId Sugar.DefinitionBodyBuiltin builtin -> makeBuiltinDefinition def builtin myId <&> Responsive.fromWithTextPos <&> M.weakerEvents nextOutdated & local (M.animIdPrefix .~ Widget.toAnimId myId)
853
make :: _ => ExprGui.Top Sugar.Definition i o -> M.WidgetId -> GuiM env i o (Responsive o) make def myId = do env <- Lens.view id let nextOutdated = E.keyPresses (env ^. has . Config.pane . Config.nextOutdatedKeys) (E.Doc [env ^. has . Texts.gotoNextOutdated]) (def ^. Sugar.drGotoNextOutdated <&> foldMap (GuiState.updateCursor . WidgetIds.fromEntityId)) case def ^. Sugar.drBody of Sugar.DefinitionBodyExpression bodyExpr -> makeExprDefinition def bodyExpr myId Sugar.DefinitionBodyBuiltin builtin -> makeBuiltinDefinition def builtin myId <&> Responsive.fromWithTextPos <&> M.weakerEvents nextOutdated & local (M.animIdPrefix .~ Widget.toAnimId myId)
853
make def myId = do env <- Lens.view id let nextOutdated = E.keyPresses (env ^. has . Config.pane . Config.nextOutdatedKeys) (E.Doc [env ^. has . Texts.gotoNextOutdated]) (def ^. Sugar.drGotoNextOutdated <&> foldMap (GuiState.updateCursor . WidgetIds.fromEntityId)) case def ^. Sugar.drBody of Sugar.DefinitionBodyExpression bodyExpr -> makeExprDefinition def bodyExpr myId Sugar.DefinitionBodyBuiltin builtin -> makeBuiltinDefinition def builtin myId <&> Responsive.fromWithTextPos <&> M.weakerEvents nextOutdated & local (M.animIdPrefix .~ Widget.toAnimId myId)
746
false
true
0
17
280
239
114
125
null
null
brendanhay/gogol
gogol-shopping-content/gen/Network/Google/ShoppingContent/Types/Product.hs
mpl-2.0
-- | The ID of the settlement report. srSettlementId :: Lens' SettlementReport (Maybe Text) srSettlementId = lens _srSettlementId (\ s a -> s{_srSettlementId = a})
171
srSettlementId :: Lens' SettlementReport (Maybe Text) srSettlementId = lens _srSettlementId (\ s a -> s{_srSettlementId = a})
133
srSettlementId = lens _srSettlementId (\ s a -> s{_srSettlementId = a})
79
true
true
0
9
32
48
25
23
null
null
phischu/fragnix
tests/packages/scotty/Control.Concurrent.STM.TChan.hs
bsd-3-clause
writeTChan :: TChan a -> a -> STM () writeTChan (TChan _read write) a = do listend <- readTVar write -- listend == TVar pointing to TNil new_listend <- newTVar TNil writeTVar listend (TCons a new_listend) writeTVar write new_listend -- |Read the next value from the 'TChan'.
283
writeTChan :: TChan a -> a -> STM () writeTChan (TChan _read write) a = do listend <- readTVar write -- listend == TVar pointing to TNil new_listend <- newTVar TNil writeTVar listend (TCons a new_listend) writeTVar write new_listend -- |Read the next value from the 'TChan'.
283
writeTChan (TChan _read write) a = do listend <- readTVar write -- listend == TVar pointing to TNil new_listend <- newTVar TNil writeTVar listend (TCons a new_listend) writeTVar write new_listend -- |Read the next value from the 'TChan'.
246
false
true
0
10
55
91
40
51
null
null
Mokosha/HsTetrisAttack
TetrisAttack/Board/Gravity.hs
mit
updateFalling (_, Just ft) = (ft, resolveFalling True)
54
updateFalling (_, Just ft) = (ft, resolveFalling True)
54
updateFalling (_, Just ft) = (ft, resolveFalling True)
54
false
false
0
7
7
27
14
13
null
null
liyanchang/scheme-in-haskell
src/chp5.hs
mit
eval badForm = throwError $ BadSpecialForm "Unrecognized special form" badForm
78
eval badForm = throwError $ BadSpecialForm "Unrecognized special form" badForm
78
eval badForm = throwError $ BadSpecialForm "Unrecognized special form" badForm
78
false
false
1
6
9
21
8
13
null
null
LambdaHack/LambdaHack
engine-src/Game/LambdaHack/Common/Vector.hs
bsd-3-clause
vicinityUnsafe p = [ shift p dxy | dxy <- moves ]
49
vicinityUnsafe p = [ shift p dxy | dxy <- moves ]
49
vicinityUnsafe p = [ shift p dxy | dxy <- moves ]
49
false
false
1
8
11
29
12
17
null
null
carymrobbins/intellij-haskforce
tests/gold/parser/String00007.hs
apache-2.0
s = "\818\773"
14
s = "\818\773"
14
s = "\818\773"
14
false
false
1
5
2
10
3
7
null
null
cuklev/JSBoiler
src/JSBoiler/Eval/Property.hs
gpl-3.0
setPropertyValue :: Text -> IORef Object -> JSType -> JSBoiler () setPropertyValue name ref value = do obj <- liftIO $ readIORef ref let props = properties obj mprop = M.lookup name props setValue prop val = case setter prop of Nothing -> if writeable prop then let obj' = setProperty name (prop { propertyValue = val }) obj in liftIO $ writeIORef ref obj' else jsThrow $ JSString $ "Cannot assign to read only property '" `append` name `append` "'" Just func -> void (callFunction ref func [val]) case mprop of Nothing -> do let props' = M.insert name Property { propertyValue = value , writeable = True , enumerable = True , configurable = True , getter = Nothing , setter = Nothing } props obj' = obj { properties = props' } liftIO $ writeIORef ref obj' Just prop -> setValue prop value -- |Makes object with specified properties
1,179
setPropertyValue :: Text -> IORef Object -> JSType -> JSBoiler () setPropertyValue name ref value = do obj <- liftIO $ readIORef ref let props = properties obj mprop = M.lookup name props setValue prop val = case setter prop of Nothing -> if writeable prop then let obj' = setProperty name (prop { propertyValue = val }) obj in liftIO $ writeIORef ref obj' else jsThrow $ JSString $ "Cannot assign to read only property '" `append` name `append` "'" Just func -> void (callFunction ref func [val]) case mprop of Nothing -> do let props' = M.insert name Property { propertyValue = value , writeable = True , enumerable = True , configurable = True , getter = Nothing , setter = Nothing } props obj' = obj { properties = props' } liftIO $ writeIORef ref obj' Just prop -> setValue prop value -- |Makes object with specified properties
1,179
setPropertyValue name ref value = do obj <- liftIO $ readIORef ref let props = properties obj mprop = M.lookup name props setValue prop val = case setter prop of Nothing -> if writeable prop then let obj' = setProperty name (prop { propertyValue = val }) obj in liftIO $ writeIORef ref obj' else jsThrow $ JSString $ "Cannot assign to read only property '" `append` name `append` "'" Just func -> void (callFunction ref func [val]) case mprop of Nothing -> do let props' = M.insert name Property { propertyValue = value , writeable = True , enumerable = True , configurable = True , getter = Nothing , setter = Nothing } props obj' = obj { properties = props' } liftIO $ writeIORef ref obj' Just prop -> setValue prop value -- |Makes object with specified properties
1,113
false
true
0
21
498
302
154
148
null
null
brendanhay/gogol
gogol-dataproc/gen/Network/Google/Dataproc/Types/Product.hs
mpl-2.0
-- | Output only. The time when this state was entered. jsStateStartTime :: Lens' JobStatus (Maybe UTCTime) jsStateStartTime = lens _jsStateStartTime (\ s a -> s{_jsStateStartTime = a}) . mapping _DateTime
219
jsStateStartTime :: Lens' JobStatus (Maybe UTCTime) jsStateStartTime = lens _jsStateStartTime (\ s a -> s{_jsStateStartTime = a}) . mapping _DateTime
163
jsStateStartTime = lens _jsStateStartTime (\ s a -> s{_jsStateStartTime = a}) . mapping _DateTime
111
true
true
0
10
44
55
28
27
null
null
ksoda/atCoder
a/22.hs
bsd-3-clause
bestBody :: Ord a => (a, a) -> a -> Bool bestBody (s, t) x = s <= x && x <= t
77
bestBody :: Ord a => (a, a) -> a -> Bool bestBody (s, t) x = s <= x && x <= t
77
bestBody (s, t) x = s <= x && x <= t
36
false
true
4
10
22
63
31
32
null
null
stone-guru/tmmha
src/TMM/Selector.hs
gpl-3.0
cget :: Monad m => (Context e -> a) -> SelectT e m a cget f = SelectT $ \sc -> return (f sc, sc)
96
cget :: Monad m => (Context e -> a) -> SelectT e m a cget f = SelectT $ \sc -> return (f sc, sc)
96
cget f = SelectT $ \sc -> return (f sc, sc)
43
false
true
0
9
24
63
31
32
null
null
Zigazou/HaMinitel
src/Minitel/Minitel.hs
gpl-3.0
waitForConnection :: Minitel -> IO (Maybe MString) waitForConnection minitel' = do firstByte <- waitFor 20000000 (getter minitel') followingBytes <- readNCount (getter minitel') 100 return ((:) <$> firstByte <*> Just followingBytes) -- | Opens a full-duplex connection to a Minitel. The default serial is set -- to \/dev\/ttyUSB0.
345
waitForConnection :: Minitel -> IO (Maybe MString) waitForConnection minitel' = do firstByte <- waitFor 20000000 (getter minitel') followingBytes <- readNCount (getter minitel') 100 return ((:) <$> firstByte <*> Just followingBytes) -- | Opens a full-duplex connection to a Minitel. The default serial is set -- to \/dev\/ttyUSB0.
345
waitForConnection minitel' = do firstByte <- waitFor 20000000 (getter minitel') followingBytes <- readNCount (getter minitel') 100 return ((:) <$> firstByte <*> Just followingBytes) -- | Opens a full-duplex connection to a Minitel. The default serial is set -- to \/dev\/ttyUSB0.
294
false
true
0
10
61
87
42
45
null
null
crooney/cinder
examples/Transformer.hs
bsd-3-clause
transformer :: Fay () transformer = do root >>= insert (markup !+ rHWXY 10 15 10 10 ! fill "green" !+ atDRT 4 7 [Scale2d 1 1, Scale2d 2 3, Scale2d 1 1] ! additive "sum" !<+ atDRT 3 8 [Rotate 0 100 100,Rotate 270 100 100,Rotate 0 100 100] ! additive "sum" !< Complete) return ()
321
transformer :: Fay () transformer = do root >>= insert (markup !+ rHWXY 10 15 10 10 ! fill "green" !+ atDRT 4 7 [Scale2d 1 1, Scale2d 2 3, Scale2d 1 1] ! additive "sum" !<+ atDRT 3 8 [Rotate 0 100 100,Rotate 270 100 100,Rotate 0 100 100] ! additive "sum" !< Complete) return ()
321
transformer = do root >>= insert (markup !+ rHWXY 10 15 10 10 ! fill "green" !+ atDRT 4 7 [Scale2d 1 1, Scale2d 2 3, Scale2d 1 1] ! additive "sum" !<+ atDRT 3 8 [Rotate 0 100 100,Rotate 270 100 100,Rotate 0 100 100] ! additive "sum" !< Complete) return ()
299
false
true
0
18
100
157
72
85
null
null
shlevy/ghc
libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
bsd-3-clause
recordPatSyn :: [Name] -> PatSynArgsQ recordPatSyn sels = return $ RecordPatSyn sels
84
recordPatSyn :: [Name] -> PatSynArgsQ recordPatSyn sels = return $ RecordPatSyn sels
84
recordPatSyn sels = return $ RecordPatSyn sels
46
false
true
0
7
11
33
15
18
null
null
gregorycollins/cabal2macpkg
Program/MakePackage.hs
bsd-3-clause
makeMacPkg :: Options -- ^ command-line options -> FilePath -- ^ path to temp directory -> PackageDescription -- ^ a parsed .cabal file -> IO () makeMacPkg opts tmpdir pkgDesc = do -- some portions of package building process require root -- privileges (thanks, Apple!) checkRootPrivileges createDirectories -------------------------------------------------------------------- hasPostFlight <- buildPackageContents setRootPrivileges mkInfoFiles hasPostFlight runPackageMaker where -------------------------------------------------------------------- -- variables -------------------------------------------------------------------- -- package metadata pkgDescription = synopsis pkgDesc pkgTitle = unPackageName . packageName $ pkgDesc pkgVersionString = showVersion . packageVersion $ pkgDesc pkgBaseName = subRegex (mkRegex "[[:space:]]+") pkgTitle "_" -- directories cabalBuildDir = tmpdir </> "dist" contentsDir = stagingDir </> "Contents" scriptsDir = tmpdir </> "Scripts" stagingDir = tmpdir </> "stage" -- config options packageMakerCmd = fromJust $ packageMakerPath opts prefix = fromJust $ installPrefix opts -- output files temporaryPkgConfig = tmpdir </> "temp.pkgconfig" infoPath = tmpdir </> "PackageInfo" postflightScriptFile = scriptsDir </> "postflight" outputPackageDir = fromMaybe "." (packageOutputDir opts) computedPackageFile = (pkgBaseName ++ "-" ++ pkgVersionString ++ ".pkg") outputPackagePath = fromMaybe (outputPackageDir </> computedPackageFile) (packageOutputFile opts) -------------------------------------------------------------------- -- helper I/O actions -------------------------------------------------------------------- -------------------------------------------------------------------- -- creates necessary directories inside the work area createDirectories = (createDirectoryIfMissing True) `mapM_` [stagingDir, scriptsDir, contentsDir] -------------------------------------------------------------------- -- uses cabal to build the package into the work area buildPackageContents = do runSetup "configure" [ "--global", "--prefix="++prefix, "-p" , "--ld-options=-macosx_version_min 10.5" ] runSetup "build" [] runSetup "haddock" ["--hyperlink-source"] runSetup "copy" ["--destdir=" ++ contentsDir] runSetup "register" ["--gen-pkg-config=" ++ temporaryPkgConfig] makePostFlightScriptFile temporaryPkgConfig postflightScriptFile -------------------------------------------------------------------- -- FIXME: make this stuff relocatable makePostFlightScriptFile src dest = do fe <- doesFileExist src if not fe then return False else do contents <- readFile src let output = "#!/bin/sh\n\ \/usr/bin/ghc-pkg --global update - <<EOF\n" ++ contents ++ "\nEOF\n" writeFile dest output return True -------------------------------------------------------------------- -- populate the packageinfo file in the resource directory mkInfoFiles :: Bool -> IO () mkInfoFiles hasPf = do nf <- getNumFiles contentsDir kb <- getFileSizesInKB contentsDir let pf = if hasPf then Just "postflight" else Nothing let pinfo = PackageInfo kb nf ("haskell."++pkgTitle) Nothing pf writePackageInfo infoPath pinfo -------------------------------------------------------------------- -- make sure files are owned by root and have correct permissions setRootPrivileges :: IO () setRootPrivileges = do runCmd "chmod" ["-R", "g+r,g-w,o+r,o-w", tmpdir] runCmd "chown" ["-R", "root:wheel", tmpdir] runCmd "sh" ["-c", "find " ++ tmpdir ++ " -type d -print0 | xargs -0 chmod a+x"] -------------------------------------------------------------------- -- build the package runPackageMaker :: IO () runPackageMaker = do putStrLn $ "building " ++ outputPackagePath hFlush stdout runCmd packageMakerCmd [ "-o" , outputPackagePath , "--root" , contentsDir , "--id" , ("haskell." ++ pkgTitle) , "--scripts" , scriptsDir , "--target" , "10.5" , "--root-volume-only" , "--info" , infoPath ] -------------------------------------------------------------------- -- helper functions -------------------------------------------------------------------- -- | runs Setup.[l]hs with the given subcommand and arguments runSetup :: String -- ^ subcommand of Setup.hs, -- i.e. "configure"/"build"/etc -> [String] -- ^ additional arguments -> IO () runSetup cmd args = runCmd "cabal" $ [cmd] ++ mkOpts args where mkOpts s = s ++ ["--builddir=" ++ cabalBuildDir] unPackageName (PackageName s) = s
5,755
makeMacPkg :: Options -- ^ command-line options -> FilePath -- ^ path to temp directory -> PackageDescription -- ^ a parsed .cabal file -> IO () makeMacPkg opts tmpdir pkgDesc = do -- some portions of package building process require root -- privileges (thanks, Apple!) checkRootPrivileges createDirectories -------------------------------------------------------------------- hasPostFlight <- buildPackageContents setRootPrivileges mkInfoFiles hasPostFlight runPackageMaker where -------------------------------------------------------------------- -- variables -------------------------------------------------------------------- -- package metadata pkgDescription = synopsis pkgDesc pkgTitle = unPackageName . packageName $ pkgDesc pkgVersionString = showVersion . packageVersion $ pkgDesc pkgBaseName = subRegex (mkRegex "[[:space:]]+") pkgTitle "_" -- directories cabalBuildDir = tmpdir </> "dist" contentsDir = stagingDir </> "Contents" scriptsDir = tmpdir </> "Scripts" stagingDir = tmpdir </> "stage" -- config options packageMakerCmd = fromJust $ packageMakerPath opts prefix = fromJust $ installPrefix opts -- output files temporaryPkgConfig = tmpdir </> "temp.pkgconfig" infoPath = tmpdir </> "PackageInfo" postflightScriptFile = scriptsDir </> "postflight" outputPackageDir = fromMaybe "." (packageOutputDir opts) computedPackageFile = (pkgBaseName ++ "-" ++ pkgVersionString ++ ".pkg") outputPackagePath = fromMaybe (outputPackageDir </> computedPackageFile) (packageOutputFile opts) -------------------------------------------------------------------- -- helper I/O actions -------------------------------------------------------------------- -------------------------------------------------------------------- -- creates necessary directories inside the work area createDirectories = (createDirectoryIfMissing True) `mapM_` [stagingDir, scriptsDir, contentsDir] -------------------------------------------------------------------- -- uses cabal to build the package into the work area buildPackageContents = do runSetup "configure" [ "--global", "--prefix="++prefix, "-p" , "--ld-options=-macosx_version_min 10.5" ] runSetup "build" [] runSetup "haddock" ["--hyperlink-source"] runSetup "copy" ["--destdir=" ++ contentsDir] runSetup "register" ["--gen-pkg-config=" ++ temporaryPkgConfig] makePostFlightScriptFile temporaryPkgConfig postflightScriptFile -------------------------------------------------------------------- -- FIXME: make this stuff relocatable makePostFlightScriptFile src dest = do fe <- doesFileExist src if not fe then return False else do contents <- readFile src let output = "#!/bin/sh\n\ \/usr/bin/ghc-pkg --global update - <<EOF\n" ++ contents ++ "\nEOF\n" writeFile dest output return True -------------------------------------------------------------------- -- populate the packageinfo file in the resource directory mkInfoFiles :: Bool -> IO () mkInfoFiles hasPf = do nf <- getNumFiles contentsDir kb <- getFileSizesInKB contentsDir let pf = if hasPf then Just "postflight" else Nothing let pinfo = PackageInfo kb nf ("haskell."++pkgTitle) Nothing pf writePackageInfo infoPath pinfo -------------------------------------------------------------------- -- make sure files are owned by root and have correct permissions setRootPrivileges :: IO () setRootPrivileges = do runCmd "chmod" ["-R", "g+r,g-w,o+r,o-w", tmpdir] runCmd "chown" ["-R", "root:wheel", tmpdir] runCmd "sh" ["-c", "find " ++ tmpdir ++ " -type d -print0 | xargs -0 chmod a+x"] -------------------------------------------------------------------- -- build the package runPackageMaker :: IO () runPackageMaker = do putStrLn $ "building " ++ outputPackagePath hFlush stdout runCmd packageMakerCmd [ "-o" , outputPackagePath , "--root" , contentsDir , "--id" , ("haskell." ++ pkgTitle) , "--scripts" , scriptsDir , "--target" , "10.5" , "--root-volume-only" , "--info" , infoPath ] -------------------------------------------------------------------- -- helper functions -------------------------------------------------------------------- -- | runs Setup.[l]hs with the given subcommand and arguments runSetup :: String -- ^ subcommand of Setup.hs, -- i.e. "configure"/"build"/etc -> [String] -- ^ additional arguments -> IO () runSetup cmd args = runCmd "cabal" $ [cmd] ++ mkOpts args where mkOpts s = s ++ ["--builddir=" ++ cabalBuildDir] unPackageName (PackageName s) = s
5,755
makeMacPkg opts tmpdir pkgDesc = do -- some portions of package building process require root -- privileges (thanks, Apple!) checkRootPrivileges createDirectories -------------------------------------------------------------------- hasPostFlight <- buildPackageContents setRootPrivileges mkInfoFiles hasPostFlight runPackageMaker where -------------------------------------------------------------------- -- variables -------------------------------------------------------------------- -- package metadata pkgDescription = synopsis pkgDesc pkgTitle = unPackageName . packageName $ pkgDesc pkgVersionString = showVersion . packageVersion $ pkgDesc pkgBaseName = subRegex (mkRegex "[[:space:]]+") pkgTitle "_" -- directories cabalBuildDir = tmpdir </> "dist" contentsDir = stagingDir </> "Contents" scriptsDir = tmpdir </> "Scripts" stagingDir = tmpdir </> "stage" -- config options packageMakerCmd = fromJust $ packageMakerPath opts prefix = fromJust $ installPrefix opts -- output files temporaryPkgConfig = tmpdir </> "temp.pkgconfig" infoPath = tmpdir </> "PackageInfo" postflightScriptFile = scriptsDir </> "postflight" outputPackageDir = fromMaybe "." (packageOutputDir opts) computedPackageFile = (pkgBaseName ++ "-" ++ pkgVersionString ++ ".pkg") outputPackagePath = fromMaybe (outputPackageDir </> computedPackageFile) (packageOutputFile opts) -------------------------------------------------------------------- -- helper I/O actions -------------------------------------------------------------------- -------------------------------------------------------------------- -- creates necessary directories inside the work area createDirectories = (createDirectoryIfMissing True) `mapM_` [stagingDir, scriptsDir, contentsDir] -------------------------------------------------------------------- -- uses cabal to build the package into the work area buildPackageContents = do runSetup "configure" [ "--global", "--prefix="++prefix, "-p" , "--ld-options=-macosx_version_min 10.5" ] runSetup "build" [] runSetup "haddock" ["--hyperlink-source"] runSetup "copy" ["--destdir=" ++ contentsDir] runSetup "register" ["--gen-pkg-config=" ++ temporaryPkgConfig] makePostFlightScriptFile temporaryPkgConfig postflightScriptFile -------------------------------------------------------------------- -- FIXME: make this stuff relocatable makePostFlightScriptFile src dest = do fe <- doesFileExist src if not fe then return False else do contents <- readFile src let output = "#!/bin/sh\n\ \/usr/bin/ghc-pkg --global update - <<EOF\n" ++ contents ++ "\nEOF\n" writeFile dest output return True -------------------------------------------------------------------- -- populate the packageinfo file in the resource directory mkInfoFiles :: Bool -> IO () mkInfoFiles hasPf = do nf <- getNumFiles contentsDir kb <- getFileSizesInKB contentsDir let pf = if hasPf then Just "postflight" else Nothing let pinfo = PackageInfo kb nf ("haskell."++pkgTitle) Nothing pf writePackageInfo infoPath pinfo -------------------------------------------------------------------- -- make sure files are owned by root and have correct permissions setRootPrivileges :: IO () setRootPrivileges = do runCmd "chmod" ["-R", "g+r,g-w,o+r,o-w", tmpdir] runCmd "chown" ["-R", "root:wheel", tmpdir] runCmd "sh" ["-c", "find " ++ tmpdir ++ " -type d -print0 | xargs -0 chmod a+x"] -------------------------------------------------------------------- -- build the package runPackageMaker :: IO () runPackageMaker = do putStrLn $ "building " ++ outputPackagePath hFlush stdout runCmd packageMakerCmd [ "-o" , outputPackagePath , "--root" , contentsDir , "--id" , ("haskell." ++ pkgTitle) , "--scripts" , scriptsDir , "--target" , "10.5" , "--root-volume-only" , "--info" , infoPath ] -------------------------------------------------------------------- -- helper functions -------------------------------------------------------------------- -- | runs Setup.[l]hs with the given subcommand and arguments runSetup :: String -- ^ subcommand of Setup.hs, -- i.e. "configure"/"build"/etc -> [String] -- ^ additional arguments -> IO () runSetup cmd args = runCmd "cabal" $ [cmd] ++ mkOpts args where mkOpts s = s ++ ["--builddir=" ++ cabalBuildDir] unPackageName (PackageName s) = s
5,556
false
true
3
15
1,862
831
431
400
null
null
sebastiaanvisser/salvia-sessions
src/Network/Salvia/Handler/Login.hs
bsd-3-clause
authenticate :: Parameters -> UserDatabase -> Maybe User authenticate ps db = do user <- "username" `lookup` ps >>= id pass <- "password" `lookup` ps >>= id case headMay $ filter ((==user) . getL username) (getL users db) of Just u | getL password u == show (md5 (fromString pass)) -> Just u _ -> Nothing -- | Logout the current user by emptying the session payload.
448
authenticate :: Parameters -> UserDatabase -> Maybe User authenticate ps db = do user <- "username" `lookup` ps >>= id pass <- "password" `lookup` ps >>= id case headMay $ filter ((==user) . getL username) (getL users db) of Just u | getL password u == show (md5 (fromString pass)) -> Just u _ -> Nothing -- | Logout the current user by emptying the session payload.
448
authenticate ps db = do user <- "username" `lookup` ps >>= id pass <- "password" `lookup` ps >>= id case headMay $ filter ((==user) . getL username) (getL users db) of Just u | getL password u == show (md5 (fromString pass)) -> Just u _ -> Nothing -- | Logout the current user by emptying the session payload.
391
false
true
0
18
148
148
72
76
null
null
GaloisInc/delicious
Network/Delicious/RSS.hs
bsd-3-clause
recent_url :: {-URL-}String recent_url = deli_base ++ "/rss/recent"
69
recent_url :: {-URL-}String recent_url = deli_base ++ "/rss/recent"
69
recent_url = deli_base ++ "/rss/recent"
40
false
true
0
5
9
16
9
7
null
null
haBuu/tfs-website
Helpers.hs
mit
showDay :: Day -> String showDay date = (show d) ++ "." ++ (show m) ++ "." ++ (show y) where (y,m,d) = toGregorian date
127
showDay :: Day -> String showDay date = (show d) ++ "." ++ (show m) ++ "." ++ (show y) where (y,m,d) = toGregorian date
127
showDay date = (show d) ++ "." ++ (show m) ++ "." ++ (show y) where (y,m,d) = toGregorian date
102
false
true
0
10
32
72
37
35
null
null
haroldcarr/learn-haskell-coq-ml-etc
haskell/book/2014-Alejandro_Serrano_Mena-Beginning_Haskell/old/code/src/C05.hs
unlicense
foo :: a foo = undefined
24
foo :: a foo = undefined
24
foo = undefined
15
false
true
0
6
5
18
7
11
null
null
beni55/hs-tls
core/Tests/PipeChan.hs
bsd-3-clause
runPipe (PipeChan _ _ cToS sToC) = runUniPipe cToS >> runUniPipe sToC
69
runPipe (PipeChan _ _ cToS sToC) = runUniPipe cToS >> runUniPipe sToC
69
runPipe (PipeChan _ _ cToS sToC) = runUniPipe cToS >> runUniPipe sToC
69
false
false
0
7
11
31
14
17
null
null
iu-parfunc/AutoObsidian
interface_brainstorming/06_ExtensibleEffects/newVer/Eff1.hs
bsd-3-clause
-- Application to the `generalized effectful function' GenArr r b w qApp :: b -> GenArr r b w -> Eff r w qApp x q = case tviewl q of TAEmptyL -> Val x k :< t -> case unArr k x of Val y -> qApp y t E u q -> E u (q >< t) -- Compose effectful arrows (and possibly change the effect!)
303
qApp :: b -> GenArr r b w -> Eff r w qApp x q = case tviewl q of TAEmptyL -> Val x k :< t -> case unArr k x of Val y -> qApp y t E u q -> E u (q >< t) -- Compose effectful arrows (and possibly change the effect!)
235
qApp x q = case tviewl q of TAEmptyL -> Val x k :< t -> case unArr k x of Val y -> qApp y t E u q -> E u (q >< t) -- Compose effectful arrows (and possibly change the effect!)
198
true
true
0
13
90
110
52
58
null
null
rrnewton/pcg-random
src/System/Random/PCG/Class.hs
bsd-3-clause
uniformBW8 :: Generator g m => Word8 -> g -> m Word8 uniformBW8 = uniformB
74
uniformBW8 :: Generator g m => Word8 -> g -> m Word8 uniformBW8 = uniformB
74
uniformBW8 = uniformB
21
false
true
0
9
14
37
16
21
null
null
nfjinjing/mps
src/MPS/Math/PermutationGroupExamples.hs
bsd-3-clause
-- t -> t+1 betaL2_23 = fromCycles (map (map (+2)) [[-1],[15,7,14,5,10,20,17,11,22,21,19],[0],[3,6,12,1,2,4,8,16,9,18,13]])
124
betaL2_23 = fromCycles (map (map (+2)) [[-1],[15,7,14,5,10,20,17,11,22,21,19],[0],[3,6,12,1,2,4,8,16,9,18,13]])
111
betaL2_23 = fromCycles (map (map (+2)) [[-1],[15,7,14,5,10,20,17,11,22,21,19],[0],[3,6,12,1,2,4,8,16,9,18,13]])
111
true
false
0
10
11
114
72
42
null
null
beni55/hermit
src/HERMIT/Dictionary/Composite.hs
bsd-2-clause
-- | As bash, but with "let-nonrec-subst" instead of "let-nonrec-subst-safe". smashComponents1 :: ( AddBindings c, ExtendPath c Crumb, HasEmptyContext c, ReadBindings c, ReadPath c Crumb , HasDynFlags m, HasHermitMEnv m, LiftCoreM m, MonadCatch m, MonadIO m, MonadThings m, MonadUnique m ) => [(Rewrite c m LCore, String)] smashComponents1 = [ -- (promoteExprR occurAnalyseExprChangedR, "occur-analyse-expr") -- ?? (promoteExprR betaReduceR, "beta-reduce") -- O(1) , (promoteExprR (caseReduceR True), "case-reduce") -- O(n) , (promoteExprR (caseReduceUnfoldR True), "case-reduce-unfold") -- O(n) , (promoteExprR caseElimSeqR, "case-elim-seq") , (promoteExprR unfoldBasicCombinatorR, "unfold-basic-combinator") -- O(n) , (promoteExprR inlineCaseAlternativeR, "inline-case-alternative") -- O(n) , (promoteExprR etaReduceR, "eta-reduce") -- O(n) -- , (promoteBindR recToNonrecR, "rec-to-nonrec") -- O(n) -- subsumed by occurrence analysis , (promoteExprR letNonRecSubstR, "let-nonrec-subst") -- O(n) , (promoteExprR caseFloatAppR, "case-float-app") -- O(n) , (promoteExprR caseFloatCaseR, "case-float-case") -- O(n) , (promoteExprR caseFloatLetR, "case-float-let") -- O(n) but usually O(1) , (promoteExprR caseFloatCastR, "case-float-cast") -- O(1) -- , (promoteExprR letElimR, "let-elim") -- O(n^2) -- Subsumed by occurrence analysis. , (promoteExprR letFloatAppR, "let-float-app") -- O(n) , (promoteExprR letFloatArgR, "let-float-arg") -- O(n) , (promoteExprR letFloatLamR, "let-float-lam") -- O(n) , (promoteExprR letFloatLetR, "let-float-let") -- O(n) , (promoteExprR letFloatCaseR, "let-float-case") -- O(n) , (promoteExprR letFloatCastR, "let-float-cast") -- O(1) , (promoteProgR letFloatTopR, "let-float-top") -- O(n) , (promoteExprR castElimReflR, "cast-elim-refl") -- O(1) , (promoteExprR castElimSymR, "cast-elim-sym") -- O(1) , (promoteExprR castFloatAppR, "cast-float-app") -- O(1) , (promoteExprR castFloatLamR, "cast-float-lam") -- O(1) , (promoteExprR undefinedExprR, "undefined-expr") -- O(1) -- , (promoteExprR dezombifyR, "dezombify") -- O(1) -- performed at the end ]
2,603
smashComponents1 :: ( AddBindings c, ExtendPath c Crumb, HasEmptyContext c, ReadBindings c, ReadPath c Crumb , HasDynFlags m, HasHermitMEnv m, LiftCoreM m, MonadCatch m, MonadIO m, MonadThings m, MonadUnique m ) => [(Rewrite c m LCore, String)] smashComponents1 = [ -- (promoteExprR occurAnalyseExprChangedR, "occur-analyse-expr") -- ?? (promoteExprR betaReduceR, "beta-reduce") -- O(1) , (promoteExprR (caseReduceR True), "case-reduce") -- O(n) , (promoteExprR (caseReduceUnfoldR True), "case-reduce-unfold") -- O(n) , (promoteExprR caseElimSeqR, "case-elim-seq") , (promoteExprR unfoldBasicCombinatorR, "unfold-basic-combinator") -- O(n) , (promoteExprR inlineCaseAlternativeR, "inline-case-alternative") -- O(n) , (promoteExprR etaReduceR, "eta-reduce") -- O(n) -- , (promoteBindR recToNonrecR, "rec-to-nonrec") -- O(n) -- subsumed by occurrence analysis , (promoteExprR letNonRecSubstR, "let-nonrec-subst") -- O(n) , (promoteExprR caseFloatAppR, "case-float-app") -- O(n) , (promoteExprR caseFloatCaseR, "case-float-case") -- O(n) , (promoteExprR caseFloatLetR, "case-float-let") -- O(n) but usually O(1) , (promoteExprR caseFloatCastR, "case-float-cast") -- O(1) -- , (promoteExprR letElimR, "let-elim") -- O(n^2) -- Subsumed by occurrence analysis. , (promoteExprR letFloatAppR, "let-float-app") -- O(n) , (promoteExprR letFloatArgR, "let-float-arg") -- O(n) , (promoteExprR letFloatLamR, "let-float-lam") -- O(n) , (promoteExprR letFloatLetR, "let-float-let") -- O(n) , (promoteExprR letFloatCaseR, "let-float-case") -- O(n) , (promoteExprR letFloatCastR, "let-float-cast") -- O(1) , (promoteProgR letFloatTopR, "let-float-top") -- O(n) , (promoteExprR castElimReflR, "cast-elim-refl") -- O(1) , (promoteExprR castElimSymR, "cast-elim-sym") -- O(1) , (promoteExprR castFloatAppR, "cast-float-app") -- O(1) , (promoteExprR castFloatLamR, "cast-float-lam") -- O(1) , (promoteExprR undefinedExprR, "undefined-expr") -- O(1) -- , (promoteExprR dezombifyR, "dezombify") -- O(1) -- performed at the end ]
2,525
smashComponents1 = [ -- (promoteExprR occurAnalyseExprChangedR, "occur-analyse-expr") -- ?? (promoteExprR betaReduceR, "beta-reduce") -- O(1) , (promoteExprR (caseReduceR True), "case-reduce") -- O(n) , (promoteExprR (caseReduceUnfoldR True), "case-reduce-unfold") -- O(n) , (promoteExprR caseElimSeqR, "case-elim-seq") , (promoteExprR unfoldBasicCombinatorR, "unfold-basic-combinator") -- O(n) , (promoteExprR inlineCaseAlternativeR, "inline-case-alternative") -- O(n) , (promoteExprR etaReduceR, "eta-reduce") -- O(n) -- , (promoteBindR recToNonrecR, "rec-to-nonrec") -- O(n) -- subsumed by occurrence analysis , (promoteExprR letNonRecSubstR, "let-nonrec-subst") -- O(n) , (promoteExprR caseFloatAppR, "case-float-app") -- O(n) , (promoteExprR caseFloatCaseR, "case-float-case") -- O(n) , (promoteExprR caseFloatLetR, "case-float-let") -- O(n) but usually O(1) , (promoteExprR caseFloatCastR, "case-float-cast") -- O(1) -- , (promoteExprR letElimR, "let-elim") -- O(n^2) -- Subsumed by occurrence analysis. , (promoteExprR letFloatAppR, "let-float-app") -- O(n) , (promoteExprR letFloatArgR, "let-float-arg") -- O(n) , (promoteExprR letFloatLamR, "let-float-lam") -- O(n) , (promoteExprR letFloatLetR, "let-float-let") -- O(n) , (promoteExprR letFloatCaseR, "let-float-case") -- O(n) , (promoteExprR letFloatCastR, "let-float-cast") -- O(1) , (promoteProgR letFloatTopR, "let-float-top") -- O(n) , (promoteExprR castElimReflR, "cast-elim-refl") -- O(1) , (promoteExprR castElimSymR, "cast-elim-sym") -- O(1) , (promoteExprR castFloatAppR, "cast-float-app") -- O(1) , (promoteExprR castFloatLamR, "cast-float-lam") -- O(1) , (promoteExprR undefinedExprR, "undefined-expr") -- O(1) -- , (promoteExprR dezombifyR, "dezombify") -- O(1) -- performed at the end ]
2,243
true
true
3
10
758
443
257
186
null
null
bitemyapp/commercialhaskell.com
src/HL/View/Home/Features.hs
bsd-3-clause
inference :: Html () inference = do h2_ "Type inference" p_ "You don't have to explicitly write out every type in a Haskell program. \ \Types will be inferred by unifying every type bidirectionally. However, you \ \can write out types if you choose, or ask the compiler to write them for you \ \for handy documentation." p_ [class_ "expand"] (a_ "Click to expand") div_ [class_ "expandable"] $ do p_ "This example has a type signature for every binding:" haskellPre "main :: IO ()\n\ \main = do line :: String <- getLine\n\ \ print (parseDigit line)\n\ \ where parseDigit :: String -> Maybe Int\n\ \ parseDigit ((c :: Char) : _) =\n\ \ if isDigit c\n\ \ then Just (ord c - ord '0')\n\ \ else Nothing" p_ "But you can just write:" haskellPre "main = do line <- getLine\n\ \ print (parseDigit line)\n\ \ where parseDigit (c : _) =\n\ \ if isDigit c\n\ \ then Just (ord c - ord '0')\n\ \ else Nothing" p_ "You can also use inference to avoid wasting time explaining \ \what you want:" haskellPre "do ss <- decode \"[\\\"Hello!\\\",\\\"World!\\\"]\"\n\ \ is <- decode \"[1,2,3]\"\n\ \ return (zipWith (\\s i -> s ++ \" \" ++ show (i + 5)) ss is)\n\ \ => Just [\"Hello! 6\",\"World! 7\"]" p_ "Types give a parser specification for free, the following \ \input is not accepted:" haskellPre "do ss <- decode \"[1,2,3]\"\n\ \ is <- decode \"[null,null,null]\"\n\ \ return (zipWith (\\s i -> s ++ \" \" ++ show (i + 5)) ss is)\n\ \ => Nothing"
1,971
inference :: Html () inference = do h2_ "Type inference" p_ "You don't have to explicitly write out every type in a Haskell program. \ \Types will be inferred by unifying every type bidirectionally. However, you \ \can write out types if you choose, or ask the compiler to write them for you \ \for handy documentation." p_ [class_ "expand"] (a_ "Click to expand") div_ [class_ "expandable"] $ do p_ "This example has a type signature for every binding:" haskellPre "main :: IO ()\n\ \main = do line :: String <- getLine\n\ \ print (parseDigit line)\n\ \ where parseDigit :: String -> Maybe Int\n\ \ parseDigit ((c :: Char) : _) =\n\ \ if isDigit c\n\ \ then Just (ord c - ord '0')\n\ \ else Nothing" p_ "But you can just write:" haskellPre "main = do line <- getLine\n\ \ print (parseDigit line)\n\ \ where parseDigit (c : _) =\n\ \ if isDigit c\n\ \ then Just (ord c - ord '0')\n\ \ else Nothing" p_ "You can also use inference to avoid wasting time explaining \ \what you want:" haskellPre "do ss <- decode \"[\\\"Hello!\\\",\\\"World!\\\"]\"\n\ \ is <- decode \"[1,2,3]\"\n\ \ return (zipWith (\\s i -> s ++ \" \" ++ show (i + 5)) ss is)\n\ \ => Just [\"Hello! 6\",\"World! 7\"]" p_ "Types give a parser specification for free, the following \ \input is not accepted:" haskellPre "do ss <- decode \"[1,2,3]\"\n\ \ is <- decode \"[null,null,null]\"\n\ \ return (zipWith (\\s i -> s ++ \" \" ++ show (i + 5)) ss is)\n\ \ => Nothing"
1,971
inference = do h2_ "Type inference" p_ "You don't have to explicitly write out every type in a Haskell program. \ \Types will be inferred by unifying every type bidirectionally. However, you \ \can write out types if you choose, or ask the compiler to write them for you \ \for handy documentation." p_ [class_ "expand"] (a_ "Click to expand") div_ [class_ "expandable"] $ do p_ "This example has a type signature for every binding:" haskellPre "main :: IO ()\n\ \main = do line :: String <- getLine\n\ \ print (parseDigit line)\n\ \ where parseDigit :: String -> Maybe Int\n\ \ parseDigit ((c :: Char) : _) =\n\ \ if isDigit c\n\ \ then Just (ord c - ord '0')\n\ \ else Nothing" p_ "But you can just write:" haskellPre "main = do line <- getLine\n\ \ print (parseDigit line)\n\ \ where parseDigit (c : _) =\n\ \ if isDigit c\n\ \ then Just (ord c - ord '0')\n\ \ else Nothing" p_ "You can also use inference to avoid wasting time explaining \ \what you want:" haskellPre "do ss <- decode \"[\\\"Hello!\\\",\\\"World!\\\"]\"\n\ \ is <- decode \"[1,2,3]\"\n\ \ return (zipWith (\\s i -> s ++ \" \" ++ show (i + 5)) ss is)\n\ \ => Just [\"Hello! 6\",\"World! 7\"]" p_ "Types give a parser specification for free, the following \ \input is not accepted:" haskellPre "do ss <- decode \"[1,2,3]\"\n\ \ is <- decode \"[null,null,null]\"\n\ \ return (zipWith (\\s i -> s ++ \" \" ++ show (i + 5)) ss is)\n\ \ => Nothing"
1,950
false
true
0
10
797
112
44
68
null
null
gnn/Hets
Common/ProverTools.hs
gpl-2.0
checkBinary :: String -> IO (Maybe String) checkBinary name = fmap (\ l -> if null l then Just $ "missing binary in $PATH: " ++ name else Nothing) $ check4FileAux name "PATH"
198
checkBinary :: String -> IO (Maybe String) checkBinary name = fmap (\ l -> if null l then Just $ "missing binary in $PATH: " ++ name else Nothing) $ check4FileAux name "PATH"
198
checkBinary name = fmap (\ l -> if null l then Just $ "missing binary in $PATH: " ++ name else Nothing) $ check4FileAux name "PATH"
155
false
true
2
9
56
67
33
34
null
null
gscalzo/HaskellTheHardWay
gloss-try/gloss-master/gloss-examples/raster/Crystal/Main.hs
mit
th = pi / phi
14
!th = pi / phi
14
!th = pi / phi
14
false
false
3
4
5
14
5
9
null
null
maoe/text-keepalived
src/Text/Keepalived/Parser.hs
bsd-3-clause
pGarpMasterDelay :: Stream s Identity Token => Parsec s u Integer pGarpMasterDelay = do identifier "garp_master_delay" value natural
136
pGarpMasterDelay :: Stream s Identity Token => Parsec s u Integer pGarpMasterDelay = do identifier "garp_master_delay" value natural
136
pGarpMasterDelay = do identifier "garp_master_delay" value natural
70
false
true
0
7
21
41
18
23
null
null
nikita-volkov/stm-containers
library/StmContainers/Bimap.hs
mit
insertRight :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => leftKey -> rightKey -> Bimap leftKey rightKey -> STM () insertRight leftKey rightKey (Bimap leftMap rightMap) = insertLeft leftKey rightKey (Bimap rightMap leftMap)
248
insertRight :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => leftKey -> rightKey -> Bimap leftKey rightKey -> STM () insertRight leftKey rightKey (Bimap leftMap rightMap) = insertLeft leftKey rightKey (Bimap rightMap leftMap)
248
insertRight leftKey rightKey (Bimap leftMap rightMap) = insertLeft leftKey rightKey (Bimap rightMap leftMap)
111
false
true
0
10
36
90
44
46
null
null
2015-Fall-UPT-PLDA/homework
02/your_full_name_here.hs
mit
testLambdaAndApply = assert result (IntVal 42) "testLambdaAndApply" where result = interpret expr -- equivalent to: (\x y -> x * y) 6 7 expr = (Apply (Lambda [Var "x", Var "y"] ((Var "x") :*: (Var "y")) ) [Const (IntVal 6), Const (IntVal 7)] ) ---------------------------------------------------------------------
426
testLambdaAndApply = assert result (IntVal 42) "testLambdaAndApply" where result = interpret expr -- equivalent to: (\x y -> x * y) 6 7 expr = (Apply (Lambda [Var "x", Var "y"] ((Var "x") :*: (Var "y")) ) [Const (IntVal 6), Const (IntVal 7)] ) ---------------------------------------------------------------------
426
testLambdaAndApply = assert result (IntVal 42) "testLambdaAndApply" where result = interpret expr -- equivalent to: (\x y -> x * y) 6 7 expr = (Apply (Lambda [Var "x", Var "y"] ((Var "x") :*: (Var "y")) ) [Const (IntVal 6), Const (IntVal 7)] ) ---------------------------------------------------------------------
426
false
false
1
13
157
109
55
54
null
null
bergmark/haskell-opaleye
opaleye-sqlite/src/Opaleye/SQLite/Sql.hs
bsd-3-clause
-- | Example type specialization: -- -- @ -- showSqlForPostgres :: Query (Column a, Column b) -> String -- @ -- -- Assuming the @makeAdaptorAndInstance@ splice has been run for the -- product type @Foo@: -- -- @ -- showSqlForPostgres :: Query (Foo (Column a) (Column b) (Column c)) -> String -- @ showSqlForPostgres :: forall columns . D.Default U.Unpackspec columns columns => Q.Query columns -> String showSqlForPostgres = showSqlForPostgresExplicit (D.def :: U.Unpackspec columns columns)
513
showSqlForPostgres :: forall columns . D.Default U.Unpackspec columns columns => Q.Query columns -> String showSqlForPostgres = showSqlForPostgresExplicit (D.def :: U.Unpackspec columns columns)
216
showSqlForPostgres = showSqlForPostgresExplicit (D.def :: U.Unpackspec columns columns)
87
true
true
0
9
96
70
41
29
null
null
epost/psc-ide
lib/Purescript/Ide.hs
bsd-3-clause
parseModuleDecl :: Parser ExternDecl parseModuleDecl = do string "module" spaces name <- many1 (noneOf " ") return (ModuleDecl (T.pack name) [])
152
parseModuleDecl :: Parser ExternDecl parseModuleDecl = do string "module" spaces name <- many1 (noneOf " ") return (ModuleDecl (T.pack name) [])
152
parseModuleDecl = do string "module" spaces name <- many1 (noneOf " ") return (ModuleDecl (T.pack name) [])
115
false
true
0
12
28
63
28
35
null
null
dmitmel/goiteens-hw-in-haskell
sorters/Main.hs
apache-2.0
getSorter "merge" = mergeSort
32
getSorter "merge" = mergeSort
32
getSorter "merge" = mergeSort
32
false
false
1
5
6
13
4
9
null
null
rahulmutt/ghcvm
compiler/Eta/HsSyn/HsExpr.hs
bsd-3-clause
hsExprNeedsParens (HsTcBracketOut {}) = False
45
hsExprNeedsParens (HsTcBracketOut {}) = False
45
hsExprNeedsParens (HsTcBracketOut {}) = False
45
false
false
0
7
4
16
8
8
null
null
mariefarrell/Hets
MMT/XMLtoPT.hs
gpl-2.0
parse :: String -> IO [Result Decl] parse fname = do putStr $ "reading file " ++ fname ++ "\n" tree <- readPT fname -- putStr $ "reading XML tree: \n" ++ (show (onlyElems tree)) ++ "\n\n" return (map parseDeclR (onlyElems tree)) -- get attribute value by key (string)
280
parse :: String -> IO [Result Decl] parse fname = do putStr $ "reading file " ++ fname ++ "\n" tree <- readPT fname -- putStr $ "reading XML tree: \n" ++ (show (onlyElems tree)) ++ "\n\n" return (map parseDeclR (onlyElems tree)) -- get attribute value by key (string)
280
parse fname = do putStr $ "reading file " ++ fname ++ "\n" tree <- readPT fname -- putStr $ "reading XML tree: \n" ++ (show (onlyElems tree)) ++ "\n\n" return (map parseDeclR (onlyElems tree)) -- get attribute value by key (string)
244
false
true
0
12
61
78
36
42
null
null
haskellbr/missingh
missingh-all/testsrc/MIMETypestest.hs
mit
test_guessType = let f strict inp exp = TestCase $ exp @=? guessType defaultmtd strict inp in [ f True "" (Nothing, Nothing) ,f True "foo" (Nothing, Nothing) ,f True "foo.txt" (Just "text/plain", Nothing) ,f True "foo.txt.gz" (Just "text/plain", Just "gzip") ,f True "foo.txt.blah" (Nothing, Nothing) ,f True "foo.tar" (Just "application/x-tar", Nothing) ,f True "foo.tar.gz" (Just "application/x-tar", Just "gzip") ,f True "foo.tgz" (Just "application/x-tar", Just "gzip") ,f True "http://foo/test.dir/blah.rtf" (Nothing, Nothing) ,f False "http://foo/test.dir/blah.rtf" (Just "application/rtf", Nothing) ,f True "foo.pict" (Nothing, Nothing) ,f False "foo.pict" (Just "image/pict", Nothing) ]
852
test_guessType = let f strict inp exp = TestCase $ exp @=? guessType defaultmtd strict inp in [ f True "" (Nothing, Nothing) ,f True "foo" (Nothing, Nothing) ,f True "foo.txt" (Just "text/plain", Nothing) ,f True "foo.txt.gz" (Just "text/plain", Just "gzip") ,f True "foo.txt.blah" (Nothing, Nothing) ,f True "foo.tar" (Just "application/x-tar", Nothing) ,f True "foo.tar.gz" (Just "application/x-tar", Just "gzip") ,f True "foo.tgz" (Just "application/x-tar", Just "gzip") ,f True "http://foo/test.dir/blah.rtf" (Nothing, Nothing) ,f False "http://foo/test.dir/blah.rtf" (Just "application/rtf", Nothing) ,f True "foo.pict" (Nothing, Nothing) ,f False "foo.pict" (Just "image/pict", Nothing) ]
852
test_guessType = let f strict inp exp = TestCase $ exp @=? guessType defaultmtd strict inp in [ f True "" (Nothing, Nothing) ,f True "foo" (Nothing, Nothing) ,f True "foo.txt" (Just "text/plain", Nothing) ,f True "foo.txt.gz" (Just "text/plain", Just "gzip") ,f True "foo.txt.blah" (Nothing, Nothing) ,f True "foo.tar" (Just "application/x-tar", Nothing) ,f True "foo.tar.gz" (Just "application/x-tar", Just "gzip") ,f True "foo.tgz" (Just "application/x-tar", Just "gzip") ,f True "http://foo/test.dir/blah.rtf" (Nothing, Nothing) ,f False "http://foo/test.dir/blah.rtf" (Just "application/rtf", Nothing) ,f True "foo.pict" (Nothing, Nothing) ,f False "foo.pict" (Just "image/pict", Nothing) ]
852
false
false
1
11
246
265
136
129
null
null
olorin/github
Github/Private.hs
bsd-3-clause
buildPath :: [String] -> String buildPath paths = '/' : intercalate "/" paths
77
buildPath :: [String] -> String buildPath paths = '/' : intercalate "/" paths
77
buildPath paths = '/' : intercalate "/" paths
45
false
true
0
7
12
35
16
19
null
null
goldfirere/singletons
singletons-th/src/Data/Singletons/TH/Single.hs
bsd-3-clause
singLit :: Lit -> SgM DExp singLit (IntegerL n) = do opts <- getOptions if n >= 0 then return $ DVarE (singledValueName opts fromIntegerName) `DAppE` (DVarE singMethName `DSigE` (singFamily `DAppT` DLitT (NumTyLit n))) else do sLit <- singLit (IntegerL (-n)) return $ DVarE (singledValueName opts negateName) `DAppE` sLit
379
singLit :: Lit -> SgM DExp singLit (IntegerL n) = do opts <- getOptions if n >= 0 then return $ DVarE (singledValueName opts fromIntegerName) `DAppE` (DVarE singMethName `DSigE` (singFamily `DAppT` DLitT (NumTyLit n))) else do sLit <- singLit (IntegerL (-n)) return $ DVarE (singledValueName opts negateName) `DAppE` sLit
379
singLit (IntegerL n) = do opts <- getOptions if n >= 0 then return $ DVarE (singledValueName opts fromIntegerName) `DAppE` (DVarE singMethName `DSigE` (singFamily `DAppT` DLitT (NumTyLit n))) else do sLit <- singLit (IntegerL (-n)) return $ DVarE (singledValueName opts negateName) `DAppE` sLit
352
false
true
0
15
106
145
74
71
null
null
andorp/grin
grin/test/ParserSpec.hs
bsd-3-clause
spec :: Spec spec = do describe "quoted names" $ do it "basic" $ do let before = [prog| "GHC.Tuple.()" = pure (C"GHC.Tuple.()") |] let after = Program [] [ Def "GHC.Tuple.()" [] $ SReturn $ ConstTagNode (Tag C "GHC.Tuple.()") [] ] before `sameAs` after it "special symbols" $ do let before = [prog| "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " = pure () |] let after = Program [] [ Def "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " [] $ SReturn Unit ] before `sameAs` after it "parse . pretty == id" $ do let exp = Program [] [ Def "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " [] $ SReturn Unit ] let Right parsedExp = parseGrin "" (Text.pack $ show $ PP exp) parsedExp `sameAs` exp describe "simple" $ do it "case" $ do let before = [prog| test p = case p of #default -> pure () case p of #default -> pure p |] let after = Program [] [ Def "test"[ "p" ] ( EBind ( ECase ( Var "p" ) [ Alt DefaultPat ( SReturn Unit ) ] ) Unit ( ECase ( Var "p" ) [ Alt DefaultPat ( SReturn ( Var "p" ) ) ] ) ) ] before `sameAs` after it "literal - bind" $ do let before = [prog| grinMain = floatLit1 <- pure 13.1415 nodeLit1 <- pure (CNode 13.1415 +13.1415 -13.1415 42 +42 -42 64u #True #False floatLit1) pure () |] let after = Program [] [ Def "grinMain"[] ( EBind ( SReturn ( Lit ( LFloat 13.1415 ) ) ) ( Var "floatLit1" ) ( EBind ( SReturn ( ConstTagNode ( Tag { tagType = C , tagName = "Node" } ) [ Lit ( LFloat 13.1415 ) , Lit ( LFloat 13.1415 ) , Lit ( LFloat ( -13.1415 ) ) , Lit ( LInt64 42 ) , Lit ( LInt64 42 ) , Lit ( LInt64 ( -42 ) ) , Lit ( LWord64 64 ) , Lit ( LBool True ) , Lit ( LBool False ) , Var "floatLit1" ] ) ) ( Var "nodeLit1" ) ( SReturn Unit ) ) ) ] before `sameAs` after it "literal - case" $ do let before = [prog| grinMain = case -12.12 of 13.1415 -> pure () +14.1415 -> pure () -14.1415 -> pure () 42 -> pure () +43 -> pure () -42 -> pure () 64u -> pure () (CNode a1 a2 a3 a4 a5) -> pure () #default -> pure () #True -> pure () #False -> pure () |] let after = Program [] [ Def "grinMain"[] ( ECase ( Lit ( LFloat ( -12.12 ) ) ) [ Alt ( LitPat ( LFloat 13.1415 ) ) ( SReturn Unit ) , Alt ( LitPat ( LFloat 14.1415 ) ) ( SReturn Unit ) , Alt ( LitPat ( LFloat ( -14.1415 ) ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 42 ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 43 ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 ( -42 ) ) ) ( SReturn Unit ) , Alt ( LitPat ( LWord64 64 ) ) ( SReturn Unit ) , Alt ( NodePat ( Tag { tagType = C , tagName = "Node" } ) [ "a1" , "a2" , "a3" , "a4" , "a5" ] ) ( SReturn Unit ) , Alt DefaultPat ( SReturn Unit ) , Alt ( LitPat ( LBool True ) ) ( SReturn Unit ) , Alt ( LitPat ( LBool False ) ) ( SReturn Unit ) ] ) ] before `sameAs` after xit "bind case on left hand side" $ do let before = [expr| x <- case y of 1 -> pure 2 pure x |] let after = EBind (ECase (Var "y") [ Alt (LitPat (LInt64 1)) $ SReturn $ Lit $ LInt64 2 ]) (Var "x") $ SReturn (Var "x") before `shouldBe` after it "interleaved typeenv" $ do let exp = [text| % grinMain :: T_Int64 grinMain = % a -> T_Int64 a <- pure 5 % n -> {CInt[T_Int64]} n <- pure (CInt a) % 0 -> {CInt[T_Int64]} % p -> {0} p <- store n pure 5 |] let env = parseMarkedTypeEnv' exp env `sameAs` (parseTypeEnv . Text.pack . show . WPP $ env) it "pure undefined ast" $ do let exp = [prog| grinMain = x0 <- pure (#undefined :: T_Int64) x1 <- pure (#undefined :: T_Word64) x4 <- pure (#undefined :: T_Float) x2 <- pure (#undefined :: T_Bool) x3 <- pure (#undefined :: T_Unit) p0 <- pure (#undefined :: #ptr) p1 <- pure (#undefined :: {0}) p2 <- pure (#undefined :: {0,1}) n0 <- pure (#undefined :: {CInt[T_Int64]}) n1 <- pure (#undefined :: {CPair[T_Int64, T_Bool]}) n2 <- pure (#undefined :: {CPair[T_Int64, {0}]}) n3 <- pure (#undefined :: {CPair[T_Int64, {0,1}]}) n4 <- pure (#undefined :: {CPair[T_Int64, #ptr]}) n5 <- pure (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "store undefined" $ do let exp = [prog| grinMain = p0 <- store (#undefined :: {CInt[T_Int64]}) p1 <- store (#undefined :: {CPair[T_Int64, T_Bool]}) p2 <- store (#undefined :: {CPair[T_Int64, {0}]}) p3 <- store (#undefined :: {CPair[T_Int64, {0,1}]}) p4 <- store (#undefined :: {CPair[T_Int64, #ptr]}) p5 <- store (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "update undefined" $ do let exp = [prog| grinMain p = update p (#undefined :: {CInt[T_Int64]}) update p (#undefined :: {CPair[T_Int64, T_Bool]}) update p (#undefined :: {CPair[T_Int64, {0}]}) update p (#undefined :: {CPair[T_Int64, {0,1}]}) update p (#undefined :: {CPair[T_Int64, #ptr]}) update p (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "string literal" $ do let before = [prog| grinMain = v0 <- fun_call $ 1 #"a" 1 v1 <- pure #"" v2 <- pure #"a" v3 <- case #"" of #"" -> pure 1 #"a" -> pure 2 #default -> pure 3 v4 <- pure (CTag1 #"") v5 <- pure (CTag2 #"" #"a") v6 <- pure (CTag3 #"a" #"") v7 <- pure (CTag4 #"a" #"" #"b") v8 <- pure (CTag5 1 #"" 1 #"a") v9 <- pure (CTag6 1 #"" 1 #"a" 4) v10 <- case (CTag7 1 #"" 3) of (CTag7 v11 v12 v13) -> pure 1 v11 <- store (CTag8 #"a" 1 #"") (CTag9 #"a") <- pure (CTag9 #"a") pure () |] let after = Program [] [Def "grinMain" [] (EBind (SApp "fun_call" [Lit (LInt64 1),Lit (LString "a"),Lit (LInt64 1)]) (Var "v0") (EBind (SReturn (Lit (LString ""))) (Var "v1") (EBind (SReturn (Lit (LString "a"))) (Var "v2") (EBind (ECase (Lit (LString "")) [Alt (LitPat (LString "")) (SReturn (Lit (LInt64 1))) ,Alt (LitPat (LString "a")) (SReturn (Lit (LInt64 2))) ,Alt DefaultPat (SReturn (Lit (LInt64 3))) ]) (Var "v3") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag1"}) [Lit (LString "")])) (Var "v4") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag2"}) [Lit (LString ""),Lit (LString "a")])) (Var "v5") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag3"}) [Lit (LString "a"),Lit (LString "")])) (Var "v6") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag4"}) [Lit (LString "a"),Lit (LString ""),Lit (LString "b")])) (Var "v7") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag5"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 1),Lit (LString "a")])) (Var "v8") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag6"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 1),Lit (LString "a"),Lit (LInt64 4)])) (Var "v9") (EBind (ECase (ConstTagNode (Tag {tagType = C, tagName = "Tag7"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 3)]) [Alt (NodePat (Tag {tagType = C, tagName = "Tag7"}) ["v11","v12","v13"]) (SReturn (Lit (LInt64 1)))]) (Var "v10") (EBind (SStore (ConstTagNode (Tag {tagType = C, tagName = "Tag8"}) [Lit (LString "a"),Lit (LInt64 1),Lit (LString "")])) (Var "v11") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LString "a")])) (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LString "a")]) (SReturn Unit)))))))))))))) ] before `shouldBe` after it "char literals" $ do let before = [prog| grinMain = v0 <- fun_call $ 1 #'a' 1 v2 <- pure #'a' v3 <- case #'b' of #'b' -> pure 1 #'c' -> pure 2 #default -> pure 3 v5 <- pure (CTag2 #'a' #'b') v6 <- pure (CTag3 #'a') v8 <- pure (CTag5 1 #'a') v9 <- pure (CTag6 1 #'a' 4) v10 <- case (CTag7 1 #'b' 3) of (CTag7 v11 v12 v13) -> pure 1 v11 <- store (CTag8 #'a' 1 #'c') (CTag9 #'a') <- pure (CTag9 #'a') pure () |] let after = Program [] [Def "grinMain" [] (EBind (SApp "fun_call" [Lit (LInt64 1),Lit (LChar 'a'),Lit (LInt64 1)]) (Var "v0") (EBind (SReturn (Lit (LChar 'a'))) (Var "v2") (EBind (ECase (Lit (LChar 'b')) [Alt (LitPat (LChar 'b')) (SReturn (Lit (LInt64 1))) ,Alt (LitPat (LChar 'c')) (SReturn (Lit (LInt64 2))) ,Alt DefaultPat (SReturn (Lit (LInt64 3))) ]) (Var "v3") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag2"}) [Lit (LChar 'a'),Lit (LChar 'b')])) (Var "v5") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag3"}) [Lit (LChar 'a')])) (Var "v6") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag5"}) [Lit (LInt64 1),Lit (LChar 'a')])) (Var "v8") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag6"}) [Lit (LInt64 1),Lit (LChar 'a'),Lit (LInt64 4)])) (Var "v9") (EBind (ECase (ConstTagNode (Tag {tagType = C, tagName = "Tag7"}) [Lit (LInt64 1),Lit (LChar 'b'),Lit (LInt64 3)]) [Alt (NodePat (Tag {tagType = C, tagName = "Tag7"}) ["v11","v12","v13"]) (SReturn (Lit (LInt64 1))) ]) (Var "v10") (EBind (SStore (ConstTagNode (Tag {tagType = C, tagName = "Tag8"}) [Lit (LChar 'a'),Lit (LInt64 1),Lit (LChar 'c')])) (Var "v11") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LChar 'a')])) (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LChar 'a')]) (SReturn Unit))))))))))) ] before `shouldBe` after describe "external defintions" $ do it "primop" $ do let before = [prog| primop effectful _prim_string_print :: T_String -> T_Unit _prim_read_string :: T_String "newArrayArray#" :: {"Int#"} -> {"State#" %s} -> {"GHC.Prim.Unit#" {"MutableArrayArray#" %s}} primop pure _prim_string_concat :: T_String -> T_String -> T_String ffi pure newArrayArray :: {Int} -> {State %s} -> {GHC.Prim.Unit {MutableArrayArray %s}} grinMain = pure () |] let after = Program [ External { eName = "_prim_string_print" , eRetType = TySimple T_Unit , eArgsType = [ TySimple T_String ] , eEffectful = True , eKind = PrimOp } , External { eName = "_prim_read_string" , eRetType = TySimple T_String , eArgsType = [] , eEffectful = True , eKind = PrimOp } , External { eName = "newArrayArray#" , eRetType = TyCon "GHC.Prim.Unit#" [ TyCon "MutableArrayArray#" [ TyVar "s" ] ] , eArgsType = [ TyCon "Int#" [] , TyCon "State#" [ TyVar "s" ] ] , eEffectful = True , eKind = PrimOp } , External { eName = "_prim_string_concat" , eRetType = TySimple T_String , eArgsType = [ TySimple T_String , TySimple T_String ] , eEffectful = False , eKind = PrimOp } , External { eName = "newArrayArray" , eRetType = TyCon "GHC.Prim.Unit" [ TyCon "MutableArrayArray" [ TyVar "s" ] ] , eArgsType = [ TyCon "Int" [] , TyCon "State" [ TyVar "s" ] ] , eEffectful = False , eKind = FFI } ] [ Def "grinMain" [] ( SReturn Unit ) ] before `sameAs` after it "indentation" $ do let before = [prog| primop pure -- comment _primA :: T_String -> T_String -> T_String {- comment -} _primB :: T_String -> T_String -- comment {- comment -} |] let after = Program [ External { eName = NM { unNM = "_primA" } , eRetType = TySimple T_String , eArgsType = [ TySimple T_String , TySimple T_String ] , eEffectful = False , eKind = PrimOp } , External { eName = NM { unNM = "_primB" } , eRetType = TySimple T_String , eArgsType = [ TySimple T_String ] , eEffectful = False , eKind = PrimOp } ] [] before `sameAs` after describe "generated" $ do it "parse . pretty print == id" $ property $ forAll (PP <$> genProg) $ \p -> let p' = parseGrin "" (Text.pack $ show p) in (fmap PP p') `shouldBe` (Right p)
16,354
spec :: Spec spec = do describe "quoted names" $ do it "basic" $ do let before = [prog| "GHC.Tuple.()" = pure (C"GHC.Tuple.()") |] let after = Program [] [ Def "GHC.Tuple.()" [] $ SReturn $ ConstTagNode (Tag C "GHC.Tuple.()") [] ] before `sameAs` after it "special symbols" $ do let before = [prog| "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " = pure () |] let after = Program [] [ Def "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " [] $ SReturn Unit ] before `sameAs` after it "parse . pretty == id" $ do let exp = Program [] [ Def "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " [] $ SReturn Unit ] let Right parsedExp = parseGrin "" (Text.pack $ show $ PP exp) parsedExp `sameAs` exp describe "simple" $ do it "case" $ do let before = [prog| test p = case p of #default -> pure () case p of #default -> pure p |] let after = Program [] [ Def "test"[ "p" ] ( EBind ( ECase ( Var "p" ) [ Alt DefaultPat ( SReturn Unit ) ] ) Unit ( ECase ( Var "p" ) [ Alt DefaultPat ( SReturn ( Var "p" ) ) ] ) ) ] before `sameAs` after it "literal - bind" $ do let before = [prog| grinMain = floatLit1 <- pure 13.1415 nodeLit1 <- pure (CNode 13.1415 +13.1415 -13.1415 42 +42 -42 64u #True #False floatLit1) pure () |] let after = Program [] [ Def "grinMain"[] ( EBind ( SReturn ( Lit ( LFloat 13.1415 ) ) ) ( Var "floatLit1" ) ( EBind ( SReturn ( ConstTagNode ( Tag { tagType = C , tagName = "Node" } ) [ Lit ( LFloat 13.1415 ) , Lit ( LFloat 13.1415 ) , Lit ( LFloat ( -13.1415 ) ) , Lit ( LInt64 42 ) , Lit ( LInt64 42 ) , Lit ( LInt64 ( -42 ) ) , Lit ( LWord64 64 ) , Lit ( LBool True ) , Lit ( LBool False ) , Var "floatLit1" ] ) ) ( Var "nodeLit1" ) ( SReturn Unit ) ) ) ] before `sameAs` after it "literal - case" $ do let before = [prog| grinMain = case -12.12 of 13.1415 -> pure () +14.1415 -> pure () -14.1415 -> pure () 42 -> pure () +43 -> pure () -42 -> pure () 64u -> pure () (CNode a1 a2 a3 a4 a5) -> pure () #default -> pure () #True -> pure () #False -> pure () |] let after = Program [] [ Def "grinMain"[] ( ECase ( Lit ( LFloat ( -12.12 ) ) ) [ Alt ( LitPat ( LFloat 13.1415 ) ) ( SReturn Unit ) , Alt ( LitPat ( LFloat 14.1415 ) ) ( SReturn Unit ) , Alt ( LitPat ( LFloat ( -14.1415 ) ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 42 ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 43 ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 ( -42 ) ) ) ( SReturn Unit ) , Alt ( LitPat ( LWord64 64 ) ) ( SReturn Unit ) , Alt ( NodePat ( Tag { tagType = C , tagName = "Node" } ) [ "a1" , "a2" , "a3" , "a4" , "a5" ] ) ( SReturn Unit ) , Alt DefaultPat ( SReturn Unit ) , Alt ( LitPat ( LBool True ) ) ( SReturn Unit ) , Alt ( LitPat ( LBool False ) ) ( SReturn Unit ) ] ) ] before `sameAs` after xit "bind case on left hand side" $ do let before = [expr| x <- case y of 1 -> pure 2 pure x |] let after = EBind (ECase (Var "y") [ Alt (LitPat (LInt64 1)) $ SReturn $ Lit $ LInt64 2 ]) (Var "x") $ SReturn (Var "x") before `shouldBe` after it "interleaved typeenv" $ do let exp = [text| % grinMain :: T_Int64 grinMain = % a -> T_Int64 a <- pure 5 % n -> {CInt[T_Int64]} n <- pure (CInt a) % 0 -> {CInt[T_Int64]} % p -> {0} p <- store n pure 5 |] let env = parseMarkedTypeEnv' exp env `sameAs` (parseTypeEnv . Text.pack . show . WPP $ env) it "pure undefined ast" $ do let exp = [prog| grinMain = x0 <- pure (#undefined :: T_Int64) x1 <- pure (#undefined :: T_Word64) x4 <- pure (#undefined :: T_Float) x2 <- pure (#undefined :: T_Bool) x3 <- pure (#undefined :: T_Unit) p0 <- pure (#undefined :: #ptr) p1 <- pure (#undefined :: {0}) p2 <- pure (#undefined :: {0,1}) n0 <- pure (#undefined :: {CInt[T_Int64]}) n1 <- pure (#undefined :: {CPair[T_Int64, T_Bool]}) n2 <- pure (#undefined :: {CPair[T_Int64, {0}]}) n3 <- pure (#undefined :: {CPair[T_Int64, {0,1}]}) n4 <- pure (#undefined :: {CPair[T_Int64, #ptr]}) n5 <- pure (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "store undefined" $ do let exp = [prog| grinMain = p0 <- store (#undefined :: {CInt[T_Int64]}) p1 <- store (#undefined :: {CPair[T_Int64, T_Bool]}) p2 <- store (#undefined :: {CPair[T_Int64, {0}]}) p3 <- store (#undefined :: {CPair[T_Int64, {0,1}]}) p4 <- store (#undefined :: {CPair[T_Int64, #ptr]}) p5 <- store (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "update undefined" $ do let exp = [prog| grinMain p = update p (#undefined :: {CInt[T_Int64]}) update p (#undefined :: {CPair[T_Int64, T_Bool]}) update p (#undefined :: {CPair[T_Int64, {0}]}) update p (#undefined :: {CPair[T_Int64, {0,1}]}) update p (#undefined :: {CPair[T_Int64, #ptr]}) update p (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "string literal" $ do let before = [prog| grinMain = v0 <- fun_call $ 1 #"a" 1 v1 <- pure #"" v2 <- pure #"a" v3 <- case #"" of #"" -> pure 1 #"a" -> pure 2 #default -> pure 3 v4 <- pure (CTag1 #"") v5 <- pure (CTag2 #"" #"a") v6 <- pure (CTag3 #"a" #"") v7 <- pure (CTag4 #"a" #"" #"b") v8 <- pure (CTag5 1 #"" 1 #"a") v9 <- pure (CTag6 1 #"" 1 #"a" 4) v10 <- case (CTag7 1 #"" 3) of (CTag7 v11 v12 v13) -> pure 1 v11 <- store (CTag8 #"a" 1 #"") (CTag9 #"a") <- pure (CTag9 #"a") pure () |] let after = Program [] [Def "grinMain" [] (EBind (SApp "fun_call" [Lit (LInt64 1),Lit (LString "a"),Lit (LInt64 1)]) (Var "v0") (EBind (SReturn (Lit (LString ""))) (Var "v1") (EBind (SReturn (Lit (LString "a"))) (Var "v2") (EBind (ECase (Lit (LString "")) [Alt (LitPat (LString "")) (SReturn (Lit (LInt64 1))) ,Alt (LitPat (LString "a")) (SReturn (Lit (LInt64 2))) ,Alt DefaultPat (SReturn (Lit (LInt64 3))) ]) (Var "v3") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag1"}) [Lit (LString "")])) (Var "v4") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag2"}) [Lit (LString ""),Lit (LString "a")])) (Var "v5") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag3"}) [Lit (LString "a"),Lit (LString "")])) (Var "v6") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag4"}) [Lit (LString "a"),Lit (LString ""),Lit (LString "b")])) (Var "v7") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag5"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 1),Lit (LString "a")])) (Var "v8") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag6"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 1),Lit (LString "a"),Lit (LInt64 4)])) (Var "v9") (EBind (ECase (ConstTagNode (Tag {tagType = C, tagName = "Tag7"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 3)]) [Alt (NodePat (Tag {tagType = C, tagName = "Tag7"}) ["v11","v12","v13"]) (SReturn (Lit (LInt64 1)))]) (Var "v10") (EBind (SStore (ConstTagNode (Tag {tagType = C, tagName = "Tag8"}) [Lit (LString "a"),Lit (LInt64 1),Lit (LString "")])) (Var "v11") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LString "a")])) (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LString "a")]) (SReturn Unit)))))))))))))) ] before `shouldBe` after it "char literals" $ do let before = [prog| grinMain = v0 <- fun_call $ 1 #'a' 1 v2 <- pure #'a' v3 <- case #'b' of #'b' -> pure 1 #'c' -> pure 2 #default -> pure 3 v5 <- pure (CTag2 #'a' #'b') v6 <- pure (CTag3 #'a') v8 <- pure (CTag5 1 #'a') v9 <- pure (CTag6 1 #'a' 4) v10 <- case (CTag7 1 #'b' 3) of (CTag7 v11 v12 v13) -> pure 1 v11 <- store (CTag8 #'a' 1 #'c') (CTag9 #'a') <- pure (CTag9 #'a') pure () |] let after = Program [] [Def "grinMain" [] (EBind (SApp "fun_call" [Lit (LInt64 1),Lit (LChar 'a'),Lit (LInt64 1)]) (Var "v0") (EBind (SReturn (Lit (LChar 'a'))) (Var "v2") (EBind (ECase (Lit (LChar 'b')) [Alt (LitPat (LChar 'b')) (SReturn (Lit (LInt64 1))) ,Alt (LitPat (LChar 'c')) (SReturn (Lit (LInt64 2))) ,Alt DefaultPat (SReturn (Lit (LInt64 3))) ]) (Var "v3") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag2"}) [Lit (LChar 'a'),Lit (LChar 'b')])) (Var "v5") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag3"}) [Lit (LChar 'a')])) (Var "v6") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag5"}) [Lit (LInt64 1),Lit (LChar 'a')])) (Var "v8") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag6"}) [Lit (LInt64 1),Lit (LChar 'a'),Lit (LInt64 4)])) (Var "v9") (EBind (ECase (ConstTagNode (Tag {tagType = C, tagName = "Tag7"}) [Lit (LInt64 1),Lit (LChar 'b'),Lit (LInt64 3)]) [Alt (NodePat (Tag {tagType = C, tagName = "Tag7"}) ["v11","v12","v13"]) (SReturn (Lit (LInt64 1))) ]) (Var "v10") (EBind (SStore (ConstTagNode (Tag {tagType = C, tagName = "Tag8"}) [Lit (LChar 'a'),Lit (LInt64 1),Lit (LChar 'c')])) (Var "v11") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LChar 'a')])) (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LChar 'a')]) (SReturn Unit))))))))))) ] before `shouldBe` after describe "external defintions" $ do it "primop" $ do let before = [prog| primop effectful _prim_string_print :: T_String -> T_Unit _prim_read_string :: T_String "newArrayArray#" :: {"Int#"} -> {"State#" %s} -> {"GHC.Prim.Unit#" {"MutableArrayArray#" %s}} primop pure _prim_string_concat :: T_String -> T_String -> T_String ffi pure newArrayArray :: {Int} -> {State %s} -> {GHC.Prim.Unit {MutableArrayArray %s}} grinMain = pure () |] let after = Program [ External { eName = "_prim_string_print" , eRetType = TySimple T_Unit , eArgsType = [ TySimple T_String ] , eEffectful = True , eKind = PrimOp } , External { eName = "_prim_read_string" , eRetType = TySimple T_String , eArgsType = [] , eEffectful = True , eKind = PrimOp } , External { eName = "newArrayArray#" , eRetType = TyCon "GHC.Prim.Unit#" [ TyCon "MutableArrayArray#" [ TyVar "s" ] ] , eArgsType = [ TyCon "Int#" [] , TyCon "State#" [ TyVar "s" ] ] , eEffectful = True , eKind = PrimOp } , External { eName = "_prim_string_concat" , eRetType = TySimple T_String , eArgsType = [ TySimple T_String , TySimple T_String ] , eEffectful = False , eKind = PrimOp } , External { eName = "newArrayArray" , eRetType = TyCon "GHC.Prim.Unit" [ TyCon "MutableArrayArray" [ TyVar "s" ] ] , eArgsType = [ TyCon "Int" [] , TyCon "State" [ TyVar "s" ] ] , eEffectful = False , eKind = FFI } ] [ Def "grinMain" [] ( SReturn Unit ) ] before `sameAs` after it "indentation" $ do let before = [prog| primop pure -- comment _primA :: T_String -> T_String -> T_String {- comment -} _primB :: T_String -> T_String -- comment {- comment -} |] let after = Program [ External { eName = NM { unNM = "_primA" } , eRetType = TySimple T_String , eArgsType = [ TySimple T_String , TySimple T_String ] , eEffectful = False , eKind = PrimOp } , External { eName = NM { unNM = "_primB" } , eRetType = TySimple T_String , eArgsType = [ TySimple T_String ] , eEffectful = False , eKind = PrimOp } ] [] before `sameAs` after describe "generated" $ do it "parse . pretty print == id" $ property $ forAll (PP <$> genProg) $ \p -> let p' = parseGrin "" (Text.pack $ show p) in (fmap PP p') `shouldBe` (Right p)
16,354
spec = do describe "quoted names" $ do it "basic" $ do let before = [prog| "GHC.Tuple.()" = pure (C"GHC.Tuple.()") |] let after = Program [] [ Def "GHC.Tuple.()" [] $ SReturn $ ConstTagNode (Tag C "GHC.Tuple.()") [] ] before `sameAs` after it "special symbols" $ do let before = [prog| "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " = pure () |] let after = Program [] [ Def "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " [] $ SReturn Unit ] before `sameAs` after it "parse . pretty == id" $ do let exp = Program [] [ Def "extreme name with \" and ~ ! @ # $ % ^ & * ( ) | : > < > ? , . / " [] $ SReturn Unit ] let Right parsedExp = parseGrin "" (Text.pack $ show $ PP exp) parsedExp `sameAs` exp describe "simple" $ do it "case" $ do let before = [prog| test p = case p of #default -> pure () case p of #default -> pure p |] let after = Program [] [ Def "test"[ "p" ] ( EBind ( ECase ( Var "p" ) [ Alt DefaultPat ( SReturn Unit ) ] ) Unit ( ECase ( Var "p" ) [ Alt DefaultPat ( SReturn ( Var "p" ) ) ] ) ) ] before `sameAs` after it "literal - bind" $ do let before = [prog| grinMain = floatLit1 <- pure 13.1415 nodeLit1 <- pure (CNode 13.1415 +13.1415 -13.1415 42 +42 -42 64u #True #False floatLit1) pure () |] let after = Program [] [ Def "grinMain"[] ( EBind ( SReturn ( Lit ( LFloat 13.1415 ) ) ) ( Var "floatLit1" ) ( EBind ( SReturn ( ConstTagNode ( Tag { tagType = C , tagName = "Node" } ) [ Lit ( LFloat 13.1415 ) , Lit ( LFloat 13.1415 ) , Lit ( LFloat ( -13.1415 ) ) , Lit ( LInt64 42 ) , Lit ( LInt64 42 ) , Lit ( LInt64 ( -42 ) ) , Lit ( LWord64 64 ) , Lit ( LBool True ) , Lit ( LBool False ) , Var "floatLit1" ] ) ) ( Var "nodeLit1" ) ( SReturn Unit ) ) ) ] before `sameAs` after it "literal - case" $ do let before = [prog| grinMain = case -12.12 of 13.1415 -> pure () +14.1415 -> pure () -14.1415 -> pure () 42 -> pure () +43 -> pure () -42 -> pure () 64u -> pure () (CNode a1 a2 a3 a4 a5) -> pure () #default -> pure () #True -> pure () #False -> pure () |] let after = Program [] [ Def "grinMain"[] ( ECase ( Lit ( LFloat ( -12.12 ) ) ) [ Alt ( LitPat ( LFloat 13.1415 ) ) ( SReturn Unit ) , Alt ( LitPat ( LFloat 14.1415 ) ) ( SReturn Unit ) , Alt ( LitPat ( LFloat ( -14.1415 ) ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 42 ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 43 ) ) ( SReturn Unit ) , Alt ( LitPat ( LInt64 ( -42 ) ) ) ( SReturn Unit ) , Alt ( LitPat ( LWord64 64 ) ) ( SReturn Unit ) , Alt ( NodePat ( Tag { tagType = C , tagName = "Node" } ) [ "a1" , "a2" , "a3" , "a4" , "a5" ] ) ( SReturn Unit ) , Alt DefaultPat ( SReturn Unit ) , Alt ( LitPat ( LBool True ) ) ( SReturn Unit ) , Alt ( LitPat ( LBool False ) ) ( SReturn Unit ) ] ) ] before `sameAs` after xit "bind case on left hand side" $ do let before = [expr| x <- case y of 1 -> pure 2 pure x |] let after = EBind (ECase (Var "y") [ Alt (LitPat (LInt64 1)) $ SReturn $ Lit $ LInt64 2 ]) (Var "x") $ SReturn (Var "x") before `shouldBe` after it "interleaved typeenv" $ do let exp = [text| % grinMain :: T_Int64 grinMain = % a -> T_Int64 a <- pure 5 % n -> {CInt[T_Int64]} n <- pure (CInt a) % 0 -> {CInt[T_Int64]} % p -> {0} p <- store n pure 5 |] let env = parseMarkedTypeEnv' exp env `sameAs` (parseTypeEnv . Text.pack . show . WPP $ env) it "pure undefined ast" $ do let exp = [prog| grinMain = x0 <- pure (#undefined :: T_Int64) x1 <- pure (#undefined :: T_Word64) x4 <- pure (#undefined :: T_Float) x2 <- pure (#undefined :: T_Bool) x3 <- pure (#undefined :: T_Unit) p0 <- pure (#undefined :: #ptr) p1 <- pure (#undefined :: {0}) p2 <- pure (#undefined :: {0,1}) n0 <- pure (#undefined :: {CInt[T_Int64]}) n1 <- pure (#undefined :: {CPair[T_Int64, T_Bool]}) n2 <- pure (#undefined :: {CPair[T_Int64, {0}]}) n3 <- pure (#undefined :: {CPair[T_Int64, {0,1}]}) n4 <- pure (#undefined :: {CPair[T_Int64, #ptr]}) n5 <- pure (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "store undefined" $ do let exp = [prog| grinMain = p0 <- store (#undefined :: {CInt[T_Int64]}) p1 <- store (#undefined :: {CPair[T_Int64, T_Bool]}) p2 <- store (#undefined :: {CPair[T_Int64, {0}]}) p3 <- store (#undefined :: {CPair[T_Int64, {0,1}]}) p4 <- store (#undefined :: {CPair[T_Int64, #ptr]}) p5 <- store (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "update undefined" $ do let exp = [prog| grinMain p = update p (#undefined :: {CInt[T_Int64]}) update p (#undefined :: {CPair[T_Int64, T_Bool]}) update p (#undefined :: {CPair[T_Int64, {0}]}) update p (#undefined :: {CPair[T_Int64, {0,1}]}) update p (#undefined :: {CPair[T_Int64, #ptr]}) update p (#undefined :: {CTriplet[T_Int64, {0,1}, #ptr]}) pure 0 |] exp `sameAs` (parseProg . Text.pack . show . WPP $ exp) it "string literal" $ do let before = [prog| grinMain = v0 <- fun_call $ 1 #"a" 1 v1 <- pure #"" v2 <- pure #"a" v3 <- case #"" of #"" -> pure 1 #"a" -> pure 2 #default -> pure 3 v4 <- pure (CTag1 #"") v5 <- pure (CTag2 #"" #"a") v6 <- pure (CTag3 #"a" #"") v7 <- pure (CTag4 #"a" #"" #"b") v8 <- pure (CTag5 1 #"" 1 #"a") v9 <- pure (CTag6 1 #"" 1 #"a" 4) v10 <- case (CTag7 1 #"" 3) of (CTag7 v11 v12 v13) -> pure 1 v11 <- store (CTag8 #"a" 1 #"") (CTag9 #"a") <- pure (CTag9 #"a") pure () |] let after = Program [] [Def "grinMain" [] (EBind (SApp "fun_call" [Lit (LInt64 1),Lit (LString "a"),Lit (LInt64 1)]) (Var "v0") (EBind (SReturn (Lit (LString ""))) (Var "v1") (EBind (SReturn (Lit (LString "a"))) (Var "v2") (EBind (ECase (Lit (LString "")) [Alt (LitPat (LString "")) (SReturn (Lit (LInt64 1))) ,Alt (LitPat (LString "a")) (SReturn (Lit (LInt64 2))) ,Alt DefaultPat (SReturn (Lit (LInt64 3))) ]) (Var "v3") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag1"}) [Lit (LString "")])) (Var "v4") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag2"}) [Lit (LString ""),Lit (LString "a")])) (Var "v5") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag3"}) [Lit (LString "a"),Lit (LString "")])) (Var "v6") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag4"}) [Lit (LString "a"),Lit (LString ""),Lit (LString "b")])) (Var "v7") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag5"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 1),Lit (LString "a")])) (Var "v8") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag6"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 1),Lit (LString "a"),Lit (LInt64 4)])) (Var "v9") (EBind (ECase (ConstTagNode (Tag {tagType = C, tagName = "Tag7"}) [Lit (LInt64 1),Lit (LString ""),Lit (LInt64 3)]) [Alt (NodePat (Tag {tagType = C, tagName = "Tag7"}) ["v11","v12","v13"]) (SReturn (Lit (LInt64 1)))]) (Var "v10") (EBind (SStore (ConstTagNode (Tag {tagType = C, tagName = "Tag8"}) [Lit (LString "a"),Lit (LInt64 1),Lit (LString "")])) (Var "v11") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LString "a")])) (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LString "a")]) (SReturn Unit)))))))))))))) ] before `shouldBe` after it "char literals" $ do let before = [prog| grinMain = v0 <- fun_call $ 1 #'a' 1 v2 <- pure #'a' v3 <- case #'b' of #'b' -> pure 1 #'c' -> pure 2 #default -> pure 3 v5 <- pure (CTag2 #'a' #'b') v6 <- pure (CTag3 #'a') v8 <- pure (CTag5 1 #'a') v9 <- pure (CTag6 1 #'a' 4) v10 <- case (CTag7 1 #'b' 3) of (CTag7 v11 v12 v13) -> pure 1 v11 <- store (CTag8 #'a' 1 #'c') (CTag9 #'a') <- pure (CTag9 #'a') pure () |] let after = Program [] [Def "grinMain" [] (EBind (SApp "fun_call" [Lit (LInt64 1),Lit (LChar 'a'),Lit (LInt64 1)]) (Var "v0") (EBind (SReturn (Lit (LChar 'a'))) (Var "v2") (EBind (ECase (Lit (LChar 'b')) [Alt (LitPat (LChar 'b')) (SReturn (Lit (LInt64 1))) ,Alt (LitPat (LChar 'c')) (SReturn (Lit (LInt64 2))) ,Alt DefaultPat (SReturn (Lit (LInt64 3))) ]) (Var "v3") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag2"}) [Lit (LChar 'a'),Lit (LChar 'b')])) (Var "v5") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag3"}) [Lit (LChar 'a')])) (Var "v6") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag5"}) [Lit (LInt64 1),Lit (LChar 'a')])) (Var "v8") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag6"}) [Lit (LInt64 1),Lit (LChar 'a'),Lit (LInt64 4)])) (Var "v9") (EBind (ECase (ConstTagNode (Tag {tagType = C, tagName = "Tag7"}) [Lit (LInt64 1),Lit (LChar 'b'),Lit (LInt64 3)]) [Alt (NodePat (Tag {tagType = C, tagName = "Tag7"}) ["v11","v12","v13"]) (SReturn (Lit (LInt64 1))) ]) (Var "v10") (EBind (SStore (ConstTagNode (Tag {tagType = C, tagName = "Tag8"}) [Lit (LChar 'a'),Lit (LInt64 1),Lit (LChar 'c')])) (Var "v11") (EBind (SReturn (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LChar 'a')])) (ConstTagNode (Tag {tagType = C, tagName = "Tag9"}) [Lit (LChar 'a')]) (SReturn Unit))))))))))) ] before `shouldBe` after describe "external defintions" $ do it "primop" $ do let before = [prog| primop effectful _prim_string_print :: T_String -> T_Unit _prim_read_string :: T_String "newArrayArray#" :: {"Int#"} -> {"State#" %s} -> {"GHC.Prim.Unit#" {"MutableArrayArray#" %s}} primop pure _prim_string_concat :: T_String -> T_String -> T_String ffi pure newArrayArray :: {Int} -> {State %s} -> {GHC.Prim.Unit {MutableArrayArray %s}} grinMain = pure () |] let after = Program [ External { eName = "_prim_string_print" , eRetType = TySimple T_Unit , eArgsType = [ TySimple T_String ] , eEffectful = True , eKind = PrimOp } , External { eName = "_prim_read_string" , eRetType = TySimple T_String , eArgsType = [] , eEffectful = True , eKind = PrimOp } , External { eName = "newArrayArray#" , eRetType = TyCon "GHC.Prim.Unit#" [ TyCon "MutableArrayArray#" [ TyVar "s" ] ] , eArgsType = [ TyCon "Int#" [] , TyCon "State#" [ TyVar "s" ] ] , eEffectful = True , eKind = PrimOp } , External { eName = "_prim_string_concat" , eRetType = TySimple T_String , eArgsType = [ TySimple T_String , TySimple T_String ] , eEffectful = False , eKind = PrimOp } , External { eName = "newArrayArray" , eRetType = TyCon "GHC.Prim.Unit" [ TyCon "MutableArrayArray" [ TyVar "s" ] ] , eArgsType = [ TyCon "Int" [] , TyCon "State" [ TyVar "s" ] ] , eEffectful = False , eKind = FFI } ] [ Def "grinMain" [] ( SReturn Unit ) ] before `sameAs` after it "indentation" $ do let before = [prog| primop pure -- comment _primA :: T_String -> T_String -> T_String {- comment -} _primB :: T_String -> T_String -- comment {- comment -} |] let after = Program [ External { eName = NM { unNM = "_primA" } , eRetType = TySimple T_String , eArgsType = [ TySimple T_String , TySimple T_String ] , eEffectful = False , eKind = PrimOp } , External { eName = NM { unNM = "_primB" } , eRetType = TySimple T_String , eArgsType = [ TySimple T_String ] , eEffectful = False , eKind = PrimOp } ] [] before `sameAs` after describe "generated" $ do it "parse . pretty print == id" $ property $ forAll (PP <$> genProg) $ \p -> let p' = parseGrin "" (Text.pack $ show p) in (fmap PP p') `shouldBe` (Right p)
16,341
false
true
24
47
7,399
3,922
2,100
1,822
null
null
kevinjcliao/bb
src/Main.hs
bsd-3-clause
prettyPrintMessage :: BlueBus -> String prettyPrintMessage (HcToBmc (Haverford d1 t1) (BrynMawr d2 t2)) = "The next blue bus leaves Haverford at: " ++ (show d1) ++ " " ++ (show t1) ++ "\n" ++ " and will arrive at Bryn Mawr at: " ++ (show d2) ++ " " ++ (show t2)
265
prettyPrintMessage :: BlueBus -> String prettyPrintMessage (HcToBmc (Haverford d1 t1) (BrynMawr d2 t2)) = "The next blue bus leaves Haverford at: " ++ (show d1) ++ " " ++ (show t1) ++ "\n" ++ " and will arrive at Bryn Mawr at: " ++ (show d2) ++ " " ++ (show t2)
265
prettyPrintMessage (HcToBmc (Haverford d1 t1) (BrynMawr d2 t2)) = "The next blue bus leaves Haverford at: " ++ (show d1) ++ " " ++ (show t1) ++ "\n" ++ " and will arrive at Bryn Mawr at: " ++ (show d2) ++ " " ++ (show t2)
225
false
true
2
10
55
104
50
54
null
null
siddhanathan/yi
yi-frontend-pango/src/Yi/Frontend/Pango/Layouts.hs
gpl-2.0
-- | Bounds the given requisition to not exceed screen dimensions boundRequisition :: Requisition -> IO Requisition boundRequisition r@(Requisition w h) = do mscr <- screenGetDefault case mscr of Just scr -> Requisition <$> (min w <$> screenGetWidth scr) <*> (min h <$> screenGetHeight scr) Nothing -> return r -- | Position the children appropriately for the given width and height
435
boundRequisition :: Requisition -> IO Requisition boundRequisition r@(Requisition w h) = do mscr <- screenGetDefault case mscr of Just scr -> Requisition <$> (min w <$> screenGetWidth scr) <*> (min h <$> screenGetHeight scr) Nothing -> return r -- | Position the children appropriately for the given width and height
369
boundRequisition r@(Requisition w h) = do mscr <- screenGetDefault case mscr of Just scr -> Requisition <$> (min w <$> screenGetWidth scr) <*> (min h <$> screenGetHeight scr) Nothing -> return r -- | Position the children appropriately for the given width and height
319
true
true
0
14
113
100
48
52
null
null
dimara/ganeti
src/Ganeti/Constants.hs
bsd-2-clause
ispecNicCount :: String ispecNicCount = ConstantUtils.ispecNicCount
67
ispecNicCount :: String ispecNicCount = ConstantUtils.ispecNicCount
67
ispecNicCount = ConstantUtils.ispecNicCount
43
false
true
0
6
5
20
8
12
null
null
gcampax/ghc
compiler/llvmGen/LlvmCodeGen/Base.hs
bsd-3-clause
-- | Translate a Cmm Bit Width to a LlvmType. widthToLlvmInt :: Width -> LlvmType widthToLlvmInt w = LMInt $ widthInBits w
122
widthToLlvmInt :: Width -> LlvmType widthToLlvmInt w = LMInt $ widthInBits w
76
widthToLlvmInt w = LMInt $ widthInBits w
40
true
true
0
6
21
26
13
13
null
null
nevrenato/Hets_Fork
Common/Result.hs
gpl-2.0
-- | check whether no errors are present, coerce into 'Maybe' resultToMaybe :: Result a -> Maybe a resultToMaybe = resultToMonad ""
131
resultToMaybe :: Result a -> Maybe a resultToMaybe = resultToMonad ""
69
resultToMaybe = resultToMonad ""
32
true
true
0
6
21
25
12
13
null
null
fmapfmapfmap/amazonka
amazonka-cognito-sync/gen/Network/AWS/CognitoSync/UnsubscribeFromDataset.hs
mpl-2.0
-- | Creates a value of 'UnsubscribeFromDatasetResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ufdrsResponseStatus' unsubscribeFromDatasetResponse :: Int -- ^ 'ufdrsResponseStatus' -> UnsubscribeFromDatasetResponse unsubscribeFromDatasetResponse pResponseStatus_ = UnsubscribeFromDatasetResponse' { _ufdrsResponseStatus = pResponseStatus_ }
456
unsubscribeFromDatasetResponse :: Int -- ^ 'ufdrsResponseStatus' -> UnsubscribeFromDatasetResponse unsubscribeFromDatasetResponse pResponseStatus_ = UnsubscribeFromDatasetResponse' { _ufdrsResponseStatus = pResponseStatus_ }
244
unsubscribeFromDatasetResponse pResponseStatus_ = UnsubscribeFromDatasetResponse' { _ufdrsResponseStatus = pResponseStatus_ }
137
true
true
0
6
70
32
20
12
null
null
begriffs/postgrest
src/PostgREST/Error.hs
mit
gucHeadersError :: Response gucHeadersError = simpleError HT.status500 [] "response.headers guc must be a JSON array composed of objects with a single key and a string value"
176
gucHeadersError :: Response gucHeadersError = simpleError HT.status500 [] "response.headers guc must be a JSON array composed of objects with a single key and a string value"
176
gucHeadersError = simpleError HT.status500 [] "response.headers guc must be a JSON array composed of objects with a single key and a string value"
148
false
true
0
6
27
23
11
12
null
null
gsdlab/clafer
src/Language/Clafer/ClaferArgs.hs
mit
retrieveModelFromURL :: String -> IO String retrieveModelFromURL url = case url of "" -> getContents -- this is the pre-module system behavior ('f':'i':'l':'e':':':'/':'/':n) -> readFile n ('h':'t':'t':'p':':':'/':'/':_) -> getURL url ('f':'t':'p':':':'/':'/':_) -> getURL url n -> readFile n -- this is the pre-module system behavior
356
retrieveModelFromURL :: String -> IO String retrieveModelFromURL url = case url of "" -> getContents -- this is the pre-module system behavior ('f':'i':'l':'e':':':'/':'/':n) -> readFile n ('h':'t':'t':'p':':':'/':'/':_) -> getURL url ('f':'t':'p':':':'/':'/':_) -> getURL url n -> readFile n -- this is the pre-module system behavior
356
retrieveModelFromURL url = case url of "" -> getContents -- this is the pre-module system behavior ('f':'i':'l':'e':':':'/':'/':n) -> readFile n ('h':'t':'t':'p':':':'/':'/':_) -> getURL url ('f':'t':'p':':':'/':'/':_) -> getURL url n -> readFile n -- this is the pre-module system behavior
312
false
true
0
15
66
158
79
79
null
null
romanb/amazonka
amazonka-storagegateway/gen/Network/AWS/StorageGateway/DescribeVTLDevices.hs
mpl-2.0
-- | 'DescribeVTLDevicesResponse' constructor. -- -- The fields accessible through corresponding lenses are: -- -- * 'dvtldrGatewayARN' @::@ 'Maybe' 'Text' -- -- * 'dvtldrMarker' @::@ 'Maybe' 'Text' -- -- * 'dvtldrVTLDevices' @::@ ['VTLDevice'] -- describeVTLDevicesResponse :: DescribeVTLDevicesResponse describeVTLDevicesResponse = DescribeVTLDevicesResponse { _dvtldrGatewayARN = Nothing , _dvtldrVTLDevices = mempty , _dvtldrMarker = Nothing }
467
describeVTLDevicesResponse :: DescribeVTLDevicesResponse describeVTLDevicesResponse = DescribeVTLDevicesResponse { _dvtldrGatewayARN = Nothing , _dvtldrVTLDevices = mempty , _dvtldrMarker = Nothing }
219
describeVTLDevicesResponse = DescribeVTLDevicesResponse { _dvtldrGatewayARN = Nothing , _dvtldrVTLDevices = mempty , _dvtldrMarker = Nothing }
162
true
true
0
7
72
51
31
20
null
null
sdiehl/ghc
compiler/prelude/PrimOp.hs
bsd-3-clause
-- CoreUnfold.primOpSize already takes into account primOpOutOfLine -- and adds some further costs for the args in that case. primOpCodeSizeForeignCall :: Int primOpCodeSizeForeignCall = 4
191
primOpCodeSizeForeignCall :: Int primOpCodeSizeForeignCall = 4
62
primOpCodeSizeForeignCall = 4
29
true
true
0
4
27
13
8
5
null
null
jaalonso/I1M-Cod-Temas
src/Tema_8.hs
gpl-2.0
-- take.1 take _ [] = []
29
take _ [] = []
19
take _ [] = []
19
true
false
0
6
11
16
8
8
null
null
rpglover64/lens
src/Language/Haskell/TH/Lens.hs
bsd-3-clause
_PrimTyConI :: Prism' Info (Name, Arity, Unlifted) _PrimTyConI = prism remitter reviewer where remitter (x, y, z) = PrimTyConI x y z reviewer (PrimTyConI x y z) = Right (x, y, z) reviewer x = Left x
220
_PrimTyConI :: Prism' Info (Name, Arity, Unlifted) _PrimTyConI = prism remitter reviewer where remitter (x, y, z) = PrimTyConI x y z reviewer (PrimTyConI x y z) = Right (x, y, z) reviewer x = Left x
220
_PrimTyConI = prism remitter reviewer where remitter (x, y, z) = PrimTyConI x y z reviewer (PrimTyConI x y z) = Right (x, y, z) reviewer x = Left x
169
false
true
2
7
58
97
51
46
null
null
parapluu/encore
src/back/CodeGen/CCodeNames.hs
bsd-3-clause
partySequence :: CCode Name partySequence = Nam "party_sequence"
64
partySequence :: CCode Name partySequence = Nam "party_sequence"
64
partySequence = Nam "party_sequence"
36
false
true
1
5
7
20
8
12
null
null
vTurbine/ghc
compiler/main/DynFlags.hs
bsd-3-clause
-- | Unset a 'WarningFlag' wopt_unset :: DynFlags -> WarningFlag -> DynFlags wopt_unset dfs f = dfs{ warningFlags = IntSet.delete (fromEnum f) (warningFlags dfs) }
163
wopt_unset :: DynFlags -> WarningFlag -> DynFlags wopt_unset dfs f = dfs{ warningFlags = IntSet.delete (fromEnum f) (warningFlags dfs) }
136
wopt_unset dfs f = dfs{ warningFlags = IntSet.delete (fromEnum f) (warningFlags dfs) }
86
true
true
0
10
24
57
28
29
null
null
ghcjs/jsaddle-dom
src/JSDOM/Generated/WebSocket.hs
mit
-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebSocket.protocol Mozilla WebSocket.protocol documentation> getProtocolUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => WebSocket -> m result getProtocolUnsafe self = liftDOM (((self ^. js "protocol") >>= fromMaybeJSString) >>= maybe (Prelude.error "Nothing to return") return)
401
getProtocolUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => WebSocket -> m result getProtocolUnsafe self = liftDOM (((self ^. js "protocol") >>= fromMaybeJSString) >>= maybe (Prelude.error "Nothing to return") return)
284
getProtocolUnsafe self = liftDOM (((self ^. js "protocol") >>= fromMaybeJSString) >>= maybe (Prelude.error "Nothing to return") return)
152
true
true
0
12
90
81
41
40
null
null
urbanslug/ghc
compiler/typecheck/TcGenDeriv.hs
bsd-3-clause
ltResult :: OrdOp -> LHsExpr RdrName -- Knowing a<b, what is the result for a `op` b? ltResult OrdCompare = ltTag_Expr
118
ltResult :: OrdOp -> LHsExpr RdrName ltResult OrdCompare = ltTag_Expr
69
ltResult OrdCompare = ltTag_Expr
32
true
true
0
6
20
26
12
14
null
null
gspia/reflex-dom-htmlea
lib/src/Reflex/Dom/HTML5/Elements/Embedded.hs
bsd-3-clause
area' ∷ forall t m a. DomBuilder t m ⇒ Area → m a → m (Element EventResult (DomBuilderSpace m) t, a) area' bm = elAttr' "area" (A.attrMap bm)
142
area' ∷ forall t m a. DomBuilder t m ⇒ Area → m a → m (Element EventResult (DomBuilderSpace m) t, a) area' bm = elAttr' "area" (A.attrMap bm)
142
area' bm = elAttr' "area" (A.attrMap bm)
41
false
true
0
13
29
76
38
38
null
null
m00nlight/99-problems
haskell/p-71.hs
bsd-3-clause
tree4 = Node 'b' [Node 'd' [], Node 'e' []]
43
tree4 = Node 'b' [Node 'd' [], Node 'e' []]
43
tree4 = Node 'b' [Node 'd' [], Node 'e' []]
43
false
false
0
8
9
31
15
16
null
null
atwupack/LearnOpenGL
app/2_Lighting/6_Multiple-lights/Multiple-lights-with-spot.hs
bsd-3-clause
drawLight :: ShaderProgram -> Int -> IO () drawLight shader i = do let model = mkTransformationMat (0.2 *!! identity) (pointLightPositions !! i) setUniform shader "model" model drawArrays Triangles 0 36
214
drawLight :: ShaderProgram -> Int -> IO () drawLight shader i = do let model = mkTransformationMat (0.2 *!! identity) (pointLightPositions !! i) setUniform shader "model" model drawArrays Triangles 0 36
214
drawLight shader i = do let model = mkTransformationMat (0.2 *!! identity) (pointLightPositions !! i) setUniform shader "model" model drawArrays Triangles 0 36
171
false
true
0
12
42
77
36
41
null
null
bitemyapp/bloodhound
src/Database/Bloodhound/Internal/Highlight.hs
bsd-3-clause
commonHighlightPairs (Just (CommonHighlight chScore chForceSource chTag chEncoder chNoMatchSize chHighlightQuery chRequireFieldMatch)) = [ "order" .= chScore , "force_source" .= chForceSource , "encoder" .= chEncoder , "no_match_size" .= chNoMatchSize , "highlight_query" .= chHighlightQuery , "require_fieldMatch" .= chRequireFieldMatch ] ++ highlightTagToPairs chTag
456
commonHighlightPairs (Just (CommonHighlight chScore chForceSource chTag chEncoder chNoMatchSize chHighlightQuery chRequireFieldMatch)) = [ "order" .= chScore , "force_source" .= chForceSource , "encoder" .= chEncoder , "no_match_size" .= chNoMatchSize , "highlight_query" .= chHighlightQuery , "require_fieldMatch" .= chRequireFieldMatch ] ++ highlightTagToPairs chTag
456
commonHighlightPairs (Just (CommonHighlight chScore chForceSource chTag chEncoder chNoMatchSize chHighlightQuery chRequireFieldMatch)) = [ "order" .= chScore , "force_source" .= chForceSource , "encoder" .= chEncoder , "no_match_size" .= chNoMatchSize , "highlight_query" .= chHighlightQuery , "require_fieldMatch" .= chRequireFieldMatch ] ++ highlightTagToPairs chTag
456
false
false
2
9
126
83
43
40
null
null
andygill/kansas-lava
Language/KansasLava/Test.hs
bsd-3-clause
fileReporter :: FilePath -> FilePath -> Result -> IO () fileReporter path nm res = do createDirectoryIfMissing True (path </> nm) writeFile (path </> nm </> "result") $ show res ------------------------------------------------------------------------------------- -- Given a circuit that returns an a, and the expected results, -- do some tests for sanity.
366
fileReporter :: FilePath -> FilePath -> Result -> IO () fileReporter path nm res = do createDirectoryIfMissing True (path </> nm) writeFile (path </> nm </> "result") $ show res ------------------------------------------------------------------------------------- -- Given a circuit that returns an a, and the expected results, -- do some tests for sanity.
366
fileReporter path nm res = do createDirectoryIfMissing True (path </> nm) writeFile (path </> nm </> "result") $ show res ------------------------------------------------------------------------------------- -- Given a circuit that returns an a, and the expected results, -- do some tests for sanity.
310
false
true
0
12
58
82
39
43
null
null
omefire/lens
src/Control/Lens/Lens.hs
bsd-3-clause
-- | Adjust the target of an 'IndexedLens' returning the old value, or -- adjust all of the targets of an 'Control.Lens.Traversal.IndexedTraversal' and return a monoidal summary -- of the old values along with the answer. -- -- @ -- ('<<%@~') :: 'IndexedLens' i s t a b -> (i -> a -> b) -> s -> (a, t) -- ('<<%@~') :: 'Monoid' a => 'Control.Lens.Traversal.IndexedTraversal' i s t a b -> (i -> a -> b) -> s -> (a, t) -- @ (<<%@~) :: Over (Indexed i) ((,) a) s t a b -> (i -> a -> b) -> s -> (a, t) l <<%@~ f = l $ Indexed $ \i a -> second' (f i) (a,a)
567
(<<%@~) :: Over (Indexed i) ((,) a) s t a b -> (i -> a -> b) -> s -> (a, t) l <<%@~ f = l $ Indexed $ \i a -> second' (f i) (a,a)
129
l <<%@~ f = l $ Indexed $ \i a -> second' (f i) (a,a)
53
true
true
0
11
137
117
65
52
null
null
katydid/haslapse
src/Data/Katydid/Relapse/Zip.hs
bsd-3-clause
indexOf :: [Pattern] -> Pattern -> ZipEntry indexOf _ ZAny = ZipZAny
83
indexOf :: [Pattern] -> Pattern -> ZipEntry indexOf _ ZAny = ZipZAny
83
indexOf _ ZAny = ZipZAny
39
false
true
0
6
26
27
14
13
null
null
brendanhay/gogol
gogol-dataflow/gen/Network/Google/Dataflow/Types/Product.hs
mpl-2.0
-- | If set, contains a pubsub label from which to extract record timestamps. -- If left empty, record timestamps will be generated upon arrival. plTimestampLabel :: Lens' PubsubLocation (Maybe Text) plTimestampLabel = lens _plTimestampLabel (\ s a -> s{_plTimestampLabel = a})
285
plTimestampLabel :: Lens' PubsubLocation (Maybe Text) plTimestampLabel = lens _plTimestampLabel (\ s a -> s{_plTimestampLabel = a})
139
plTimestampLabel = lens _plTimestampLabel (\ s a -> s{_plTimestampLabel = a})
85
true
true
0
9
49
49
26
23
null
null
jeffreyrosenbluth/stackage
Stackage/CompleteBuild.hs
mit
finallyUpload :: Settings -> Manager -> IO () finallyUpload settings@Settings{..} man = do putStrLn "Uploading bundle to Stackage Server" mtoken <- lookupEnv "STACKAGE_AUTH_TOKEN" token <- case mtoken of Nothing -> decodeUtf8 <$> readFile "/auth-token" Just token -> return $ pack token now <- epochTime let ghcVer = display $ siGhcVersion $ bpSystemInfo plan (ident, mloc) <- flip uploadBundle man $ setArgs ghcVer def { ubContents = serverBundle now (title ghcVer) slug plan , ubAuthToken = token } putStrLn $ "New ident: " ++ unSnapshotIdent ident forM_ mloc $ \loc -> putStrLn $ "Track progress at: " ++ loc postBuild `catchAny` print putStrLn "Uploading docs to Stackage Server" res1 <- uploadDocs UploadDocs { udServer = def , udAuthToken = token , udDocs = pbDocDir pb , udSnapshot = ident } man putStrLn $ "Doc upload response: " ++ tshow res1 ecreds <- tryIO $ readFile "/hackage-creds" case map encodeUtf8 $ words $ decodeUtf8 $ either (const "") id ecreds of [username, password] -> do putStrLn "Uploading as Hackage distro" res2 <- uploadHackageDistroNamed distroName plan username password man putStrLn $ "Distro upload response: " ++ tshow res2 _ -> putStrLn "No creds found, skipping Hackage distro upload" putStrLn "Uploading doc map" uploadDocMap UploadDocMap { udmServer = def , udmAuthToken = token , udmSnapshot = ident , udmDocDir = pbDocDir pb , udmPlan = plan } man >>= print where pb = getPerformBuild (error "finallyUpload.buildFlags") settings
1,749
finallyUpload :: Settings -> Manager -> IO () finallyUpload settings@Settings{..} man = do putStrLn "Uploading bundle to Stackage Server" mtoken <- lookupEnv "STACKAGE_AUTH_TOKEN" token <- case mtoken of Nothing -> decodeUtf8 <$> readFile "/auth-token" Just token -> return $ pack token now <- epochTime let ghcVer = display $ siGhcVersion $ bpSystemInfo plan (ident, mloc) <- flip uploadBundle man $ setArgs ghcVer def { ubContents = serverBundle now (title ghcVer) slug plan , ubAuthToken = token } putStrLn $ "New ident: " ++ unSnapshotIdent ident forM_ mloc $ \loc -> putStrLn $ "Track progress at: " ++ loc postBuild `catchAny` print putStrLn "Uploading docs to Stackage Server" res1 <- uploadDocs UploadDocs { udServer = def , udAuthToken = token , udDocs = pbDocDir pb , udSnapshot = ident } man putStrLn $ "Doc upload response: " ++ tshow res1 ecreds <- tryIO $ readFile "/hackage-creds" case map encodeUtf8 $ words $ decodeUtf8 $ either (const "") id ecreds of [username, password] -> do putStrLn "Uploading as Hackage distro" res2 <- uploadHackageDistroNamed distroName plan username password man putStrLn $ "Distro upload response: " ++ tshow res2 _ -> putStrLn "No creds found, skipping Hackage distro upload" putStrLn "Uploading doc map" uploadDocMap UploadDocMap { udmServer = def , udmAuthToken = token , udmSnapshot = ident , udmDocDir = pbDocDir pb , udmPlan = plan } man >>= print where pb = getPerformBuild (error "finallyUpload.buildFlags") settings
1,749
finallyUpload settings@Settings{..} man = do putStrLn "Uploading bundle to Stackage Server" mtoken <- lookupEnv "STACKAGE_AUTH_TOKEN" token <- case mtoken of Nothing -> decodeUtf8 <$> readFile "/auth-token" Just token -> return $ pack token now <- epochTime let ghcVer = display $ siGhcVersion $ bpSystemInfo plan (ident, mloc) <- flip uploadBundle man $ setArgs ghcVer def { ubContents = serverBundle now (title ghcVer) slug plan , ubAuthToken = token } putStrLn $ "New ident: " ++ unSnapshotIdent ident forM_ mloc $ \loc -> putStrLn $ "Track progress at: " ++ loc postBuild `catchAny` print putStrLn "Uploading docs to Stackage Server" res1 <- uploadDocs UploadDocs { udServer = def , udAuthToken = token , udDocs = pbDocDir pb , udSnapshot = ident } man putStrLn $ "Doc upload response: " ++ tshow res1 ecreds <- tryIO $ readFile "/hackage-creds" case map encodeUtf8 $ words $ decodeUtf8 $ either (const "") id ecreds of [username, password] -> do putStrLn "Uploading as Hackage distro" res2 <- uploadHackageDistroNamed distroName plan username password man putStrLn $ "Distro upload response: " ++ tshow res2 _ -> putStrLn "No creds found, skipping Hackage distro upload" putStrLn "Uploading doc map" uploadDocMap UploadDocMap { udmServer = def , udmAuthToken = token , udmSnapshot = ident , udmDocDir = pbDocDir pb , udmPlan = plan } man >>= print where pb = getPerformBuild (error "finallyUpload.buildFlags") settings
1,703
false
true
0
14
512
464
224
240
null
null
jstolarek/lattice-structure-hs
src/Signal/Wavelet/List2.hs
bsd-3-clause
dwt angles signal = dwtWorker latticeSeq tail angles extendedSignal where extendedSignal = extendEnd layers signal layers = length angles
161
dwt angles signal = dwtWorker latticeSeq tail angles extendedSignal where extendedSignal = extendEnd layers signal layers = length angles
161
dwt angles signal = dwtWorker latticeSeq tail angles extendedSignal where extendedSignal = extendEnd layers signal layers = length angles
161
false
false
0
7
42
40
19
21
null
null
ozgurakgun/Idris-dev
src/Idris/AbsSyntaxTree.hs
bsd-3-clause
highestFC (PUnquote tm) = highestFC tm
48
highestFC (PUnquote tm) = highestFC tm
48
highestFC (PUnquote tm) = highestFC tm
48
false
false
0
6
15
19
8
11
null
null
ddssff/rdf4h
src/Rdf4hParseMain.hs
bsd-3-clause
strValue (OutputFormat s) = s
30
strValue (OutputFormat s) = s
30
strValue (OutputFormat s) = s
30
false
false
0
6
5
16
7
9
null
null
zachsully/hakaru
haskell/Tests/Models.hs
bsd-3-clause
negate_prob :: Text negate_prob = "unsafeProb(1.0 + negate(2.0))"
65
negate_prob :: Text negate_prob = "unsafeProb(1.0 + negate(2.0))"
65
negate_prob = "unsafeProb(1.0 + negate(2.0))"
45
false
true
0
4
7
11
6
5
null
null
ancientlanguage/haskell-analysis
grammar/src/Grammar/Common/Decompose.hs
mit
decomposeChar '\x1EEB' = "\x0075\x031B\x0300"
45
decomposeChar '\x1EEB' = "\x0075\x031B\x0300"
45
decomposeChar '\x1EEB' = "\x0075\x031B\x0300"
45
false
false
0
5
3
9
4
5
null
null
ezyang/ghc
compiler/main/ErrUtils.hs
bsd-3-clause
pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc] pprErrMsgBagWithLoc bag = [ pprLocErrMsg item | item <- sortMsgBag Nothing bag ]
124
pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc] pprErrMsgBagWithLoc bag = [ pprLocErrMsg item | item <- sortMsgBag Nothing bag ]
124
pprErrMsgBagWithLoc bag = [ pprLocErrMsg item | item <- sortMsgBag Nothing bag ]
80
false
true
0
9
18
47
22
25
null
null
ku-fpg/kansas-amber
System/Hardware/Haskino/Protocol.hs
bsd-3-clause
parseQueryResult (IfThenElseW16Unit _ _ _) (IfThenElseW16LeftReply r) = Just $ exprLeft $ lit r
95
parseQueryResult (IfThenElseW16Unit _ _ _) (IfThenElseW16LeftReply r) = Just $ exprLeft $ lit r
95
parseQueryResult (IfThenElseW16Unit _ _ _) (IfThenElseW16LeftReply r) = Just $ exprLeft $ lit r
95
false
false
0
7
13
38
18
20
null
null
codemac/yi-editor
src/Yi/Monad.hs
gpl-2.0
-- | Combination of the Control.Monad.State 'modify' and 'gets' getsAndModify :: MonadState s m => (s -> (s,a)) -> m a getsAndModify f = do e <- get let (e',result) = f e put e' return result
199
getsAndModify :: MonadState s m => (s -> (s,a)) -> m a getsAndModify f = do e <- get let (e',result) = f e put e' return result
135
getsAndModify f = do e <- get let (e',result) = f e put e' return result
80
true
true
0
10
44
82
39
43
null
null
pparkkin/eta
compiler/ETA/Prelude/PrelNames.hs
bsd-3-clause
floatingClassKey = mkPreludeClassUnique 5
48
floatingClassKey = mkPreludeClassUnique 5
48
floatingClassKey = mkPreludeClassUnique 5
48
false
false
0
5
10
9
4
5
null
null
jesboat/173tourney
server-src/CS173/Actions.hs
bsd-3-clause
dbRep = db "reports"
20
dbRep = db "reports"
20
dbRep = db "reports"
20
false
false
1
5
3
13
4
9
null
null
beni55/cryptol
src/Cryptol/TypeCheck/Solver/Numeric/Simplify.hs
bsd-3-clause
crySimpStep :: Prop -> Maybe Prop crySimpStep prop = case prop of Fin x -> cryIsFin x -- Fin only on variables. x :== y -> Just (cryIsEq x y) x :> y -> Just (cryIsGt x y) x :>= y -> case (x,y) of -- XXX: DUPLICTION (K (Nat 0), _) -> Just (y :== zero) (K (Nat a), Width b) -> Just (K (Nat (2 ^ a)) :>= b) (_, K (Nat 0)) -> Just PTrue (Width e, K (Nat b)) -> Just (e :>= K (Nat (2^(b-1)))) (K Inf, _) -> Just PTrue (_, K Inf) -> Just (x :== inf) _ -> Just (x :== inf :|| one :+ x :> y) x :==: y -> case (x,y) of (K a, K b) -> Just (if a == b then PTrue else PFalse) (K (Nat n), _) | Just p <- cryIsNat True n y -> Just p (_, K (Nat n)) | Just p <- cryIsNat True n x -> Just p _ | x == y -> Just PTrue | otherwise -> case (x,y) of (Var _, _) -> Nothing (_, Var _) -> Just (y :==: x) _ -> Nothing x :>: y -> case (x,y) of (K (Nat n),_) | Just p <- cryNatGt True n y -> Just p (_, K (Nat n)) | Just p <- cryGtNat True n x -> Just p _ | x == y -> Just PFalse | otherwise -> Nothing -- For :&& and :|| we assume that the props have been rearrnaged p :&& q -> cryAnd p q p :|| q -> cryOr p q Not p -> cryNot p PFalse -> Nothing PTrue -> Nothing -- | Rebalance parens, and arrange conjucts so that we can transfer -- information left-to-right.
1,613
crySimpStep :: Prop -> Maybe Prop crySimpStep prop = case prop of Fin x -> cryIsFin x -- Fin only on variables. x :== y -> Just (cryIsEq x y) x :> y -> Just (cryIsGt x y) x :>= y -> case (x,y) of -- XXX: DUPLICTION (K (Nat 0), _) -> Just (y :== zero) (K (Nat a), Width b) -> Just (K (Nat (2 ^ a)) :>= b) (_, K (Nat 0)) -> Just PTrue (Width e, K (Nat b)) -> Just (e :>= K (Nat (2^(b-1)))) (K Inf, _) -> Just PTrue (_, K Inf) -> Just (x :== inf) _ -> Just (x :== inf :|| one :+ x :> y) x :==: y -> case (x,y) of (K a, K b) -> Just (if a == b then PTrue else PFalse) (K (Nat n), _) | Just p <- cryIsNat True n y -> Just p (_, K (Nat n)) | Just p <- cryIsNat True n x -> Just p _ | x == y -> Just PTrue | otherwise -> case (x,y) of (Var _, _) -> Nothing (_, Var _) -> Just (y :==: x) _ -> Nothing x :>: y -> case (x,y) of (K (Nat n),_) | Just p <- cryNatGt True n y -> Just p (_, K (Nat n)) | Just p <- cryGtNat True n x -> Just p _ | x == y -> Just PFalse | otherwise -> Nothing -- For :&& and :|| we assume that the props have been rearrnaged p :&& q -> cryAnd p q p :|| q -> cryOr p q Not p -> cryNot p PFalse -> Nothing PTrue -> Nothing -- | Rebalance parens, and arrange conjucts so that we can transfer -- information left-to-right.
1,613
crySimpStep prop = case prop of Fin x -> cryIsFin x -- Fin only on variables. x :== y -> Just (cryIsEq x y) x :> y -> Just (cryIsGt x y) x :>= y -> case (x,y) of -- XXX: DUPLICTION (K (Nat 0), _) -> Just (y :== zero) (K (Nat a), Width b) -> Just (K (Nat (2 ^ a)) :>= b) (_, K (Nat 0)) -> Just PTrue (Width e, K (Nat b)) -> Just (e :>= K (Nat (2^(b-1)))) (K Inf, _) -> Just PTrue (_, K Inf) -> Just (x :== inf) _ -> Just (x :== inf :|| one :+ x :> y) x :==: y -> case (x,y) of (K a, K b) -> Just (if a == b then PTrue else PFalse) (K (Nat n), _) | Just p <- cryIsNat True n y -> Just p (_, K (Nat n)) | Just p <- cryIsNat True n x -> Just p _ | x == y -> Just PTrue | otherwise -> case (x,y) of (Var _, _) -> Nothing (_, Var _) -> Just (y :==: x) _ -> Nothing x :>: y -> case (x,y) of (K (Nat n),_) | Just p <- cryNatGt True n y -> Just p (_, K (Nat n)) | Just p <- cryGtNat True n x -> Just p _ | x == y -> Just PFalse | otherwise -> Nothing -- For :&& and :|| we assume that the props have been rearrnaged p :&& q -> cryAnd p q p :|| q -> cryOr p q Not p -> cryNot p PFalse -> Nothing PTrue -> Nothing -- | Rebalance parens, and arrange conjucts so that we can transfer -- information left-to-right.
1,579
false
true
20
17
676
700
354
346
null
null
ScrambledEggsOnToast/kdt
app-src/Tests/StaticTest.hs
mit
prop_unbalancedInsertNNEqualToLinear :: Point2d -> Property prop_unbalancedInsertNNEqualToLinear query = forAll (listOf1 arbitrary) $ \xs -> let kdm = batchInsertUnbalanced (empty pointAsList2d) $ testElements xs in nearest kdm query == nearestLinear pointAsList2d (testElements xs) query
299
prop_unbalancedInsertNNEqualToLinear :: Point2d -> Property prop_unbalancedInsertNNEqualToLinear query = forAll (listOf1 arbitrary) $ \xs -> let kdm = batchInsertUnbalanced (empty pointAsList2d) $ testElements xs in nearest kdm query == nearestLinear pointAsList2d (testElements xs) query
299
prop_unbalancedInsertNNEqualToLinear query = forAll (listOf1 arbitrary) $ \xs -> let kdm = batchInsertUnbalanced (empty pointAsList2d) $ testElements xs in nearest kdm query == nearestLinear pointAsList2d (testElements xs) query
239
false
true
0
14
43
85
40
45
null
null
danr/tfp1
Lang/Simple.hs
gpl-3.0
injectExpr :: Expr a -> R.Expr a injectExpr e0 = case e0 of Var x ts -> R.Var x ts App e1 e2 -> R.App (injectExpr e1) (injectExpr e2) Lit l tc -> R.Lit l tc
170
injectExpr :: Expr a -> R.Expr a injectExpr e0 = case e0 of Var x ts -> R.Var x ts App e1 e2 -> R.App (injectExpr e1) (injectExpr e2) Lit l tc -> R.Lit l tc
170
injectExpr e0 = case e0 of Var x ts -> R.Var x ts App e1 e2 -> R.App (injectExpr e1) (injectExpr e2) Lit l tc -> R.Lit l tc
137
false
true
0
10
49
96
44
52
null
null
victoredwardocallaghan/hbts
src/BTS/GSMCommon.hs
gpl-2.0
downlinkFreqKHz :: GSMBand -- ^ GSM band -> Int -- ^ ARFCN -> Int downlinkFreqKHz band arfcn = uplinkFreqKHz band arfcn + uplinkOffsetKHz band
178
downlinkFreqKHz :: GSMBand -- ^ GSM band -> Int -- ^ ARFCN -> Int downlinkFreqKHz band arfcn = uplinkFreqKHz band arfcn + uplinkOffsetKHz band
178
downlinkFreqKHz band arfcn = uplinkFreqKHz band arfcn + uplinkOffsetKHz band
76
false
true
0
6
59
38
19
19
null
null
apriori/daak
lib/DAAK/Algorithms/Gamo.hs
mit
solutionMergeCrossover _ _ gs = fail $ "Invalid crossover attempt with list of len " ++ show (length gs)
104
solutionMergeCrossover _ _ gs = fail $ "Invalid crossover attempt with list of len " ++ show (length gs)
104
solutionMergeCrossover _ _ gs = fail $ "Invalid crossover attempt with list of len " ++ show (length gs)
104
false
false
0
8
18
30
14
16
null
null
GaloisInc/saw-script
saw-core/src/Verifier/SAW/Prim.hs
bsd-3-clause
------------------------------------------------------------ -- Primitive operations -- coerce :: (y x :: sort 0) -> Eq (sort 0) x y -> x -> y; coerce :: () -> () -> () -> a -> a coerce _ _ _ x = x
198
coerce :: () -> () -> () -> a -> a coerce _ _ _ x = x
53
coerce _ _ _ x = x
18
true
true
0
10
40
51
25
26
null
null
imalsogreg/reflex-dom
src/Reflex/Dom/Widget/Input.hs
bsd-3-clause
--TODO: Make attributes possibly dynamic -- | Create an editable checkbox -- Note: if the "type" or "checked" attributes are provided as attributes, they will be ignored checkbox :: MonadWidget t m => Bool -> CheckboxConfig t -> m (Checkbox t) checkbox checked config = do attrs <- mapDyn (\c -> Map.insert "type" "checkbox" $ (if checked then Map.insert "checked" "checked" else Map.delete "checked") c) (_checkboxConfig_attributes config) e <- liftM castToHTMLInputElement $ buildEmptyElement "input" attrs eClick <- wrapDomEvent e elementOnclick $ liftIO $ htmlInputElementGetChecked e performEvent_ $ fmap (\v -> liftIO $ htmlInputElementSetChecked e $! v) $ _checkboxConfig_setValue config dValue <- holdDyn checked $ leftmost [_checkboxConfig_setValue config, eClick] return $ Checkbox dValue eClick
819
checkbox :: MonadWidget t m => Bool -> CheckboxConfig t -> m (Checkbox t) checkbox checked config = do attrs <- mapDyn (\c -> Map.insert "type" "checkbox" $ (if checked then Map.insert "checked" "checked" else Map.delete "checked") c) (_checkboxConfig_attributes config) e <- liftM castToHTMLInputElement $ buildEmptyElement "input" attrs eClick <- wrapDomEvent e elementOnclick $ liftIO $ htmlInputElementGetChecked e performEvent_ $ fmap (\v -> liftIO $ htmlInputElementSetChecked e $! v) $ _checkboxConfig_setValue config dValue <- holdDyn checked $ leftmost [_checkboxConfig_setValue config, eClick] return $ Checkbox dValue eClick
647
checkbox checked config = do attrs <- mapDyn (\c -> Map.insert "type" "checkbox" $ (if checked then Map.insert "checked" "checked" else Map.delete "checked") c) (_checkboxConfig_attributes config) e <- liftM castToHTMLInputElement $ buildEmptyElement "input" attrs eClick <- wrapDomEvent e elementOnclick $ liftIO $ htmlInputElementGetChecked e performEvent_ $ fmap (\v -> liftIO $ htmlInputElementSetChecked e $! v) $ _checkboxConfig_setValue config dValue <- holdDyn checked $ leftmost [_checkboxConfig_setValue config, eClick] return $ Checkbox dValue eClick
573
true
true
0
16
126
227
107
120
null
null
rprospero/PhotoAlign
Main.hs
mit
upgrade :: (Monad m) => Maybe a -> MaybeT m a upgrade = MaybeT . return
71
upgrade :: (Monad m) => Maybe a -> MaybeT m a upgrade = MaybeT . return
71
upgrade = MaybeT . return
25
false
true
0
7
15
36
18
18
null
null
vladfi1/hs-misc
ExpressionHOS.hs
mit
-- call by value eval :: Exp t a -> a eval (Ret a) = a
55
eval :: Exp t a -> a eval (Ret a) = a
37
eval (Ret a) = a
16
true
true
0
9
16
36
16
20
null
null
Fuuzetsu/cabal2nix
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
bsd-3-clause
libNixName x = return (guessNixIdentifier x)
79
libNixName x = return (guessNixIdentifier x)
79
libNixName x = return (guessNixIdentifier x)
79
false
false
0
7
40
18
8
10
null
null
capitanbatata/sandbox
free-monads/src/TestDSL.hs
gpl-3.0
createN :: Int -> EntityType -> Free (TestCommand e) [e] createN n et = mapM (const $ create et) [0..n-1]
105
createN :: Int -> EntityType -> Free (TestCommand e) [e] createN n et = mapM (const $ create et) [0..n-1]
105
createN n et = mapM (const $ create et) [0..n-1]
48
false
true
0
9
19
62
31
31
null
null
sdiehl/ghc
compiler/coreSyn/CoreMap.hs
bsd-3-clause
extendCoreMap :: CoreMap a -> CoreExpr -> a -> CoreMap a extendCoreMap m e v = alterTM e (\_ -> Just v) m
105
extendCoreMap :: CoreMap a -> CoreExpr -> a -> CoreMap a extendCoreMap m e v = alterTM e (\_ -> Just v) m
105
extendCoreMap m e v = alterTM e (\_ -> Just v) m
48
false
true
0
8
22
54
26
28
null
null
Fornost461/drafts-and-stuff
Haskell/projects/colors/Color.hs
cc0-1.0
res5 = signum c2
16
res5 = signum c2
16
res5 = signum c2
16
false
false
0
5
3
9
4
5
null
null