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
haskell/haddock
haddock-api/src/Haddock/Interface/Rename.hs
bsd-2-clause
renameForD (ForeignExport _ lname ltype x) = do lname' <- renameL lname ltype' <- renameLSigType ltype return (ForeignExport noExtField lname' ltype' x)
158
renameForD (ForeignExport _ lname ltype x) = do lname' <- renameL lname ltype' <- renameLSigType ltype return (ForeignExport noExtField lname' ltype' x)
158
renameForD (ForeignExport _ lname ltype x) = do lname' <- renameL lname ltype' <- renameLSigType ltype return (ForeignExport noExtField lname' ltype' x)
158
false
false
0
9
27
59
26
33
null
null
thomie/cabal
cabal-install/Distribution/Client/Sandbox.hs
bsd-3-clause
-- | Try to read the most recently configured compiler from the -- 'localBuildInfoFile', falling back on 'configCompilerAuxEx' if it -- cannot be read. getPersistOrConfigCompiler :: ConfigFlags -> IO (Compiler, Platform, ProgramConfiguration) getPersistOrConfigCompiler configFlags = do distPref <- findDistPrefOrDefault (configDistPref configFlags) mlbi <- maybeGetPersistBuildConfig distPref case mlbi of Nothing -> do configCompilerAux' configFlags Just lbi -> return ( LocalBuildInfo.compiler lbi , LocalBuildInfo.hostPlatform lbi , LocalBuildInfo.withPrograms lbi )
681
getPersistOrConfigCompiler :: ConfigFlags -> IO (Compiler, Platform, ProgramConfiguration) getPersistOrConfigCompiler configFlags = do distPref <- findDistPrefOrDefault (configDistPref configFlags) mlbi <- maybeGetPersistBuildConfig distPref case mlbi of Nothing -> do configCompilerAux' configFlags Just lbi -> return ( LocalBuildInfo.compiler lbi , LocalBuildInfo.hostPlatform lbi , LocalBuildInfo.withPrograms lbi )
529
getPersistOrConfigCompiler configFlags = do distPref <- findDistPrefOrDefault (configDistPref configFlags) mlbi <- maybeGetPersistBuildConfig distPref case mlbi of Nothing -> do configCompilerAux' configFlags Just lbi -> return ( LocalBuildInfo.compiler lbi , LocalBuildInfo.hostPlatform lbi , LocalBuildInfo.withPrograms lbi )
411
true
true
0
13
177
114
55
59
null
null
vTurbine/ghc
compiler/basicTypes/NameEnv.hs
bsd-3-clause
alterDNameEnv :: (Maybe a -> Maybe a) -> DNameEnv a -> Name -> DNameEnv a alterDNameEnv = alterUDFM
99
alterDNameEnv :: (Maybe a -> Maybe a) -> DNameEnv a -> Name -> DNameEnv a alterDNameEnv = alterUDFM
99
alterDNameEnv = alterUDFM
25
false
true
0
9
17
48
21
27
null
null
d-rive/rivers
Data/Rivers/Streams.hs
bsd-3-clause
-- | The 'splitAt' function takes an integer @n@ and a stream @xs@ -- and returns a pair consisting of the prefix of @xs@ of length -- @n@ and the remaining stream immediately following this prefix. -- -- /Beware/: passing a negative integer as the first argument will -- cause an error. ssplitAt n xs | n == 0 = ([],xs) | n > 0 = let (prefix,rest) = ssplitAt (n-1) (stail xs) in (shead xs : prefix, rest) | otherwise = error "S.splitAt negative argument."
485
ssplitAt n xs | n == 0 = ([],xs) | n > 0 = let (prefix,rest) = ssplitAt (n-1) (stail xs) in (shead xs : prefix, rest) | otherwise = error "S.splitAt negative argument."
197
ssplitAt n xs | n == 0 = ([],xs) | n > 0 = let (prefix,rest) = ssplitAt (n-1) (stail xs) in (shead xs : prefix, rest) | otherwise = error "S.splitAt negative argument."
197
true
false
2
11
114
107
56
51
null
null
anchor/servant-purescript
examples/todo/ToDo.hs
bsd-3-clause
tmp :: FilePath tmp = appPath </> "temp"
40
tmp :: FilePath tmp = appPath </> "temp"
40
tmp = appPath </> "temp"
24
false
true
0
6
7
22
9
13
null
null
ckaestne/CIDE
other/CaseStudies/fgl/CIDEfgl/Data/Graph/Inductive/Query/ArtPoint.hs
gpl-3.0
lowTree (B (v, n, bcks) trs) = Brc (v, n, lowv) ts where { lowv = min (minbckEdge n bcks) lowChild; lowChild = minimum (map getLow ts); ts = map lowTree trs}
185
lowTree (B (v, n, bcks) trs) = Brc (v, n, lowv) ts where { lowv = min (minbckEdge n bcks) lowChild; lowChild = minimum (map getLow ts); ts = map lowTree trs}
185
lowTree (B (v, n, bcks) trs) = Brc (v, n, lowv) ts where { lowv = min (minbckEdge n bcks) lowChild; lowChild = minimum (map getLow ts); ts = map lowTree trs}
185
false
false
0
9
59
90
49
41
null
null
fffej/HS-Poker
LookupPatternMatch.hs
bsd-3-clause
getValueFromProduct 20452727 = 215
34
getValueFromProduct 20452727 = 215
34
getValueFromProduct 20452727 = 215
34
false
false
0
5
3
9
4
5
null
null
zaxtax/hakaru
haskell/Language/Hakaru/Expect.hs
bsd-3-clause
pushIntegrate :: (ABT Term abt) => abt '[] 'HReal -> abt '[] 'HReal -> Expect abt (Variable 'HReal) pushIntegrate lo hi = do x <- freshVar Text.empty SReal unsafePush (SStuff1 (Location x) (\c -> syn (Integrate :$ lo :* hi :* bind x c :* End)) []) return x {- -- BUG: we assume the arguments are emissible! emitIntegrate lo hi = emit Text.empty SReal (\c -> syn (Integrate :$ lo :* hi :* c :* End)) -} -- Needs to be more polymorphic
482
pushIntegrate :: (ABT Term abt) => abt '[] 'HReal -> abt '[] 'HReal -> Expect abt (Variable 'HReal) pushIntegrate lo hi = do x <- freshVar Text.empty SReal unsafePush (SStuff1 (Location x) (\c -> syn (Integrate :$ lo :* hi :* bind x c :* End)) []) return x {- -- BUG: we assume the arguments are emissible! emitIntegrate lo hi = emit Text.empty SReal (\c -> syn (Integrate :$ lo :* hi :* c :* End)) -} -- Needs to be more polymorphic
482
pushIntegrate lo hi = do x <- freshVar Text.empty SReal unsafePush (SStuff1 (Location x) (\c -> syn (Integrate :$ lo :* hi :* bind x c :* End)) []) return x {- -- BUG: we assume the arguments are emissible! emitIntegrate lo hi = emit Text.empty SReal (\c -> syn (Integrate :$ lo :* hi :* c :* End)) -} -- Needs to be more polymorphic
366
false
true
0
17
132
151
73
78
null
null
nightscape/platform
node/tests/Unison/Test/ResourcePool.hs
mit
decrement :: IORef Int -> IO Int decrement ref = IORef.atomicModifyIORef' ref (\n -> (n-1, n))
94
decrement :: IORef Int -> IO Int decrement ref = IORef.atomicModifyIORef' ref (\n -> (n-1, n))
94
decrement ref = IORef.atomicModifyIORef' ref (\n -> (n-1, n))
61
false
true
0
9
15
49
25
24
null
null
joelwilliamson/validator
Maker.hs
agpl-3.0
(/@@) :: Maker a → Label → Maker [a] f /@@ k = filterSubForest ((/= Label k) . rootLabel) $ mapSubForest f
106
(/@@) :: Maker a → Label → Maker [a] f /@@ k = filterSubForest ((/= Label k) . rootLabel) $ mapSubForest f
106
f /@@ k = filterSubForest ((/= Label k) . rootLabel) $ mapSubForest f
69
false
true
0
10
21
63
31
32
null
null
christiaanb/ghc
compiler/prelude/PrelNames.hs
bsd-3-clause
unpackCString_RDR = nameRdrName unpackCStringName
55
unpackCString_RDR = nameRdrName unpackCStringName
55
unpackCString_RDR = nameRdrName unpackCStringName
55
false
false
0
5
9
9
4
5
null
null
raventid/coursera_learning
haskell/will_kurt/15_rot.hs
mit
rotEncoder :: String -> String rotEncoder text = map rotChar text where alphaSize = 1 + fromEnum (maxBound :: Char)
117
rotEncoder :: String -> String rotEncoder text = map rotChar text where alphaSize = 1 + fromEnum (maxBound :: Char)
117
rotEncoder text = map rotChar text where alphaSize = 1 + fromEnum (maxBound :: Char)
86
false
true
0
7
21
44
22
22
null
null
haskell-game/fungen
examples/worms/worms.hs
bsd-3-clause
findLastTail (t1:t2:ts) = do (Tail na) <- getObjectAttribute t1 (Tail nb) <- getObjectAttribute t2 if (na > nb) then findLastTail (t1:ts) else findLastTail (t2:ts)
289
findLastTail (t1:t2:ts) = do (Tail na) <- getObjectAttribute t1 (Tail nb) <- getObjectAttribute t2 if (na > nb) then findLastTail (t1:ts) else findLastTail (t2:ts)
289
findLastTail (t1:t2:ts) = do (Tail na) <- getObjectAttribute t1 (Tail nb) <- getObjectAttribute t2 if (na > nb) then findLastTail (t1:ts) else findLastTail (t2:ts)
289
false
false
0
10
149
90
44
46
null
null
ocramz/petsc-hs
src/Numerical/PETSc/Internal/InlineC.hs
gpl-3.0
-- PETSC_EXTERN PetscErrorCode DMDAGetInfo(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DMBoundaryType*,DMBoundaryType*,DMBoundaryType*,DMDAStencilType*); -- PETSC_EXTERN PetscErrorCode DMDAGetProcessorSubset(DM,DMDADirection,PetscInt,MPI_Comm*); -- PETSC_EXTERN PetscErrorCode DMDAGetProcessorSubsets(DM,DMDADirection,MPI_Comm*); -- PETSC_EXTERN PetscErrorCode DMDAGetRay(DM,DMDADirection,PetscInt,Vec*,VecScatter*) -- PetscErrorCode DMDASetUniformCoordinates(DM da,PetscReal xmin,PetscReal xmax,PetscReal ymin,PetscReal ymax,PetscReal zmin,PetscReal zmax) -- Collective on DMDA -- Input Parameters -- da - the distributed array object -- xmin,xmax - extremes in the x direction -- ymin,ymax - extremes in the y direction (value ignored for 1 dimensional problems) -- zmin,zmax - extremes in the z direction (value ignored for 1 or 2 dimensional problems) dmdaSetUniformCoordinates' :: DM -> PetscReal_ -> PetscReal_ -> PetscReal_ -> PetscReal_ -> PetscReal_ -> PetscReal_ -> IO CInt dmdaSetUniformCoordinates' da xmin xmax ymin ymax zmin zmax = [C.exp|int{DMDASetUniformCoordinates($(DM da),$(PetscReal xmin),$(PetscReal xmax),$(PetscReal ymin),$(PetscReal ymax),$(PetscReal zmin),$(PetscReal zmax))}|]
1,511
dmdaSetUniformCoordinates' :: DM -> PetscReal_ -> PetscReal_ -> PetscReal_ -> PetscReal_ -> PetscReal_ -> PetscReal_ -> IO CInt dmdaSetUniformCoordinates' da xmin xmax ymin ymax zmin zmax = [C.exp|int{DMDASetUniformCoordinates($(DM da),$(PetscReal xmin),$(PetscReal xmax),$(PetscReal ymin),$(PetscReal ymax),$(PetscReal zmin),$(PetscReal zmax))}|]
601
dmdaSetUniformCoordinates' da xmin xmax ymin ymax zmin zmax = [C.exp|int{DMDASetUniformCoordinates($(DM da),$(PetscReal xmin),$(PetscReal xmax),$(PetscReal ymin),$(PetscReal ymax),$(PetscReal zmin),$(PetscReal zmax))}|]
221
true
true
0
12
371
74
44
30
null
null
bacchanalia/KitchenSink
KitchenSink/Qualified.hs
gpl-3.0
-- |'Seq.zip' seq_zip = Seq.zip
31
seq_zip = Seq.zip
17
seq_zip = Seq.zip
17
true
false
0
5
4
9
5
4
null
null
imeckler/proof
Parse/Tex.hs
mit
-- TODO: Simple proof proof = fmap (Steps . snd) . env "proof" $ many step
74
proof = fmap (Steps . snd) . env "proof" $ many step
52
proof = fmap (Steps . snd) . env "proof" $ many step
52
true
false
0
9
15
31
15
16
null
null
ghc-android/ghc
compiler/prelude/PrelNames.hs
bsd-3-clause
fromRationalClassOpKey = mkPreludeMiscIdUnique 162
57
fromRationalClassOpKey = mkPreludeMiscIdUnique 162
57
fromRationalClassOpKey = mkPreludeMiscIdUnique 162
57
false
false
0
5
10
9
4
5
null
null
prl-tokyo/bigul-configuration-adaptation
Transformations/src/BiFlux/XPath/HXT/XPathParser.hs
mit
relLocPath :: XPathParser [XStep] relLocPath = do s1 <- step s2 <- many (step') return ([s1] ++ (concat s2)) <?> "relLocPath"
153
relLocPath :: XPathParser [XStep] relLocPath = do s1 <- step s2 <- many (step') return ([s1] ++ (concat s2)) <?> "relLocPath"
153
relLocPath = do s1 <- step s2 <- many (step') return ([s1] ++ (concat s2)) <?> "relLocPath"
119
false
true
2
11
48
70
32
38
null
null
deweyvm/kayvee
src/Database/Kayvee/Common.hs
mit
valuePut :: String -> String -> Put valuePut s v = do let ss = toPointer $ (genericLength s) uLogAll ("Putting value: " ++ show ss) $ putWord64be ss let ps = pack s uLogAll ("Putting value: " ++ show ps) $ putByteString ps let sv = toPointer $ (genericLength v) uLogAll ("Putting value: " ++ show sv) $ putWord64be sv let pv = pack v uLogAll ("Putting value: " ++ show pv) $ putByteString pv
423
valuePut :: String -> String -> Put valuePut s v = do let ss = toPointer $ (genericLength s) uLogAll ("Putting value: " ++ show ss) $ putWord64be ss let ps = pack s uLogAll ("Putting value: " ++ show ps) $ putByteString ps let sv = toPointer $ (genericLength v) uLogAll ("Putting value: " ++ show sv) $ putWord64be sv let pv = pack v uLogAll ("Putting value: " ++ show pv) $ putByteString pv
423
valuePut s v = do let ss = toPointer $ (genericLength s) uLogAll ("Putting value: " ++ show ss) $ putWord64be ss let ps = pack s uLogAll ("Putting value: " ++ show ps) $ putByteString ps let sv = toPointer $ (genericLength v) uLogAll ("Putting value: " ++ show sv) $ putWord64be sv let pv = pack v uLogAll ("Putting value: " ++ show pv) $ putByteString pv
387
false
true
0
12
107
178
80
98
null
null
coolhacks/scripts-hacks
examples/shellcheck-master/ShellCheck/Analytics.hs
mit
getVariableFlow shell parents t = let (_, stack) = runState (doStackAnalysis startScope endScope t) [] in reverse stack where startScope t = let scopeType = leadType shell parents t in do when (scopeType /= NoneScope) $ modify (StackScope scopeType:) when (assignFirst t) $ setWritten t endScope t = let scopeType = leadType shell parents t in do setRead t unless (assignFirst t) $ setWritten t when (scopeType /= NoneScope) $ modify (StackScopeEnd:) assignFirst (T_ForIn {}) = True assignFirst (T_SelectIn {}) = True assignFirst _ = False setRead t = let read = getReferencedVariables t in mapM_ (\v -> modify (Reference v:)) read setWritten t = let written = getModifiedVariables t in mapM_ (\v -> modify (Assignment v:)) written
900
getVariableFlow shell parents t = let (_, stack) = runState (doStackAnalysis startScope endScope t) [] in reverse stack where startScope t = let scopeType = leadType shell parents t in do when (scopeType /= NoneScope) $ modify (StackScope scopeType:) when (assignFirst t) $ setWritten t endScope t = let scopeType = leadType shell parents t in do setRead t unless (assignFirst t) $ setWritten t when (scopeType /= NoneScope) $ modify (StackScopeEnd:) assignFirst (T_ForIn {}) = True assignFirst (T_SelectIn {}) = True assignFirst _ = False setRead t = let read = getReferencedVariables t in mapM_ (\v -> modify (Reference v:)) read setWritten t = let written = getModifiedVariables t in mapM_ (\v -> modify (Assignment v:)) written
900
getVariableFlow shell parents t = let (_, stack) = runState (doStackAnalysis startScope endScope t) [] in reverse stack where startScope t = let scopeType = leadType shell parents t in do when (scopeType /= NoneScope) $ modify (StackScope scopeType:) when (assignFirst t) $ setWritten t endScope t = let scopeType = leadType shell parents t in do setRead t unless (assignFirst t) $ setWritten t when (scopeType /= NoneScope) $ modify (StackScopeEnd:) assignFirst (T_ForIn {}) = True assignFirst (T_SelectIn {}) = True assignFirst _ = False setRead t = let read = getReferencedVariables t in mapM_ (\v -> modify (Reference v:)) read setWritten t = let written = getModifiedVariables t in mapM_ (\v -> modify (Assignment v:)) written
900
false
false
4
12
286
347
156
191
null
null
karamaan/karamaan-plankton
Karamaan/Plankton/Date.hs
bsd-3-clause
todayLocal :: IO Day todayLocal = (return . zonedTimeToDay) =<< getZonedTime
76
todayLocal :: IO Day todayLocal = (return . zonedTimeToDay) =<< getZonedTime
76
todayLocal = (return . zonedTimeToDay) =<< getZonedTime
55
false
true
0
7
10
25
13
12
null
null
ezyang/ghc
compiler/typecheck/TcGenDeriv.hs
bsd-3-clause
eqResult OrdGE = true_Expr
31
eqResult OrdGE = true_Expr
31
eqResult OrdGE = true_Expr
31
false
false
0
5
8
9
4
5
null
null
wavewave/HROOT
HROOT-generate/lib/HROOT/Data/Hist/Class.hs
gpl-3.0
tH2F :: Class tH2F = histclass "TH2F" [tH2, tArrayF] (Protected ["fill1"]) [ Constructor [cstring "name",cstring "title",int "nbinsx",double "xlow",double "xup" ,int "nbinsy", double "ylow", double "yup"] Nothing ]
258
tH2F :: Class tH2F = histclass "TH2F" [tH2, tArrayF] (Protected ["fill1"]) [ Constructor [cstring "name",cstring "title",int "nbinsx",double "xlow",double "xup" ,int "nbinsy", double "ylow", double "yup"] Nothing ]
258
tH2F = histclass "TH2F" [tH2, tArrayF] (Protected ["fill1"]) [ Constructor [cstring "name",cstring "title",int "nbinsx",double "xlow",double "xup" ,int "nbinsy", double "ylow", double "yup"] Nothing ]
244
false
true
0
9
70
91
47
44
null
null
kavigupta/Infsabot
Infsabot/Board/Logic.hs
gpl-3.0
startingBoard :: Parameters -> (Team -> RobotProgram) -> Board startingBoard p programOf = setRobot (0, unNatural (paramBoardSize p) - 1) (bot B) $ setRobot (unNatural (paramBoardSize p) - 1, 0) (bot A) Board { boardContents = startingSpots, boardRobots = M.fromList [], boardSize = unNatural $ paramBoardSize p, boardTime = 0 } where startingSpots :: (RAL (RAL GameSpot)) startingSpots = ys <$> fromList [0..unNatural (paramBoardSize p)] where ys x = initialColor <$> fromList [0..unNatural (paramBoardSize p)] where initialColor :: Int -> GameSpot initialColor y = if isPrime (x * x + y * y) then GameSpot SpotMaterial Nothing else GameSpot SpotEmpty Nothing bot team = Just $ defaultRobot p team (programOf team) -- Sets the robot at the given spot to the given value, or deletes it. -- 1. places the robot at the gamespot at the given coordinates -- 2. Adds the robot to the list of robots
1,122
startingBoard :: Parameters -> (Team -> RobotProgram) -> Board startingBoard p programOf = setRobot (0, unNatural (paramBoardSize p) - 1) (bot B) $ setRobot (unNatural (paramBoardSize p) - 1, 0) (bot A) Board { boardContents = startingSpots, boardRobots = M.fromList [], boardSize = unNatural $ paramBoardSize p, boardTime = 0 } where startingSpots :: (RAL (RAL GameSpot)) startingSpots = ys <$> fromList [0..unNatural (paramBoardSize p)] where ys x = initialColor <$> fromList [0..unNatural (paramBoardSize p)] where initialColor :: Int -> GameSpot initialColor y = if isPrime (x * x + y * y) then GameSpot SpotMaterial Nothing else GameSpot SpotEmpty Nothing bot team = Just $ defaultRobot p team (programOf team) -- Sets the robot at the given spot to the given value, or deletes it. -- 1. places the robot at the gamespot at the given coordinates -- 2. Adds the robot to the list of robots
1,122
startingBoard p programOf = setRobot (0, unNatural (paramBoardSize p) - 1) (bot B) $ setRobot (unNatural (paramBoardSize p) - 1, 0) (bot A) Board { boardContents = startingSpots, boardRobots = M.fromList [], boardSize = unNatural $ paramBoardSize p, boardTime = 0 } where startingSpots :: (RAL (RAL GameSpot)) startingSpots = ys <$> fromList [0..unNatural (paramBoardSize p)] where ys x = initialColor <$> fromList [0..unNatural (paramBoardSize p)] where initialColor :: Int -> GameSpot initialColor y = if isPrime (x * x + y * y) then GameSpot SpotMaterial Nothing else GameSpot SpotEmpty Nothing bot team = Just $ defaultRobot p team (programOf team) -- Sets the robot at the given spot to the given value, or deletes it. -- 1. places the robot at the gamespot at the given coordinates -- 2. Adds the robot to the list of robots
1,059
false
true
0
16
376
296
153
143
null
null
GaloisInc/saw-script
rme/src/Data/RME/Base.hs
bsd-3-clause
depth R1 = 0
12
depth R1 = 0
12
depth R1 = 0
12
false
false
1
5
3
13
4
9
null
null
nomeata/ghc
compiler/cmm/OldCmmUtils.hs
bsd-3-clause
cheapEqExpr (CmmRegOff r n) (CmmRegOff r' n') = r==r' && n==n'
62
cheapEqExpr (CmmRegOff r n) (CmmRegOff r' n') = r==r' && n==n'
62
cheapEqExpr (CmmRegOff r n) (CmmRegOff r' n') = r==r' && n==n'
62
false
false
0
7
10
39
19
20
null
null
mbakke/ganeti
src/Ganeti/WConfd/ConfigModifications.hs
bsd-2-clause
updateDisk :: Disk -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON)) updateDisk disk = do ct <- liftIO getClockTime let dL = csConfigDataL . configDisksL r <- modifyConfigAndReturnWithLock (\_ -> updateConfigIfNecessary ct disk (^. dL) (\cs -> do dC <- toError $ replaceIn ct disk (cs ^. dL) return ((serialOf disk + 1, ct), (dL .~ dC) cs))) . T.releaseDRBDMinors . UTF8.fromString $ uuidOf disk return . MaybeForJSON $ fmap (_2 %~ TimeAsDoubleJSON) r -- * The list of functions exported to RPC.
528
updateDisk :: Disk -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON)) updateDisk disk = do ct <- liftIO getClockTime let dL = csConfigDataL . configDisksL r <- modifyConfigAndReturnWithLock (\_ -> updateConfigIfNecessary ct disk (^. dL) (\cs -> do dC <- toError $ replaceIn ct disk (cs ^. dL) return ((serialOf disk + 1, ct), (dL .~ dC) cs))) . T.releaseDRBDMinors . UTF8.fromString $ uuidOf disk return . MaybeForJSON $ fmap (_2 %~ TimeAsDoubleJSON) r -- * The list of functions exported to RPC.
528
updateDisk disk = do ct <- liftIO getClockTime let dL = csConfigDataL . configDisksL r <- modifyConfigAndReturnWithLock (\_ -> updateConfigIfNecessary ct disk (^. dL) (\cs -> do dC <- toError $ replaceIn ct disk (cs ^. dL) return ((serialOf disk + 1, ct), (dL .~ dC) cs))) . T.releaseDRBDMinors . UTF8.fromString $ uuidOf disk return . MaybeForJSON $ fmap (_2 %~ TimeAsDoubleJSON) r -- * The list of functions exported to RPC.
455
false
true
0
23
108
198
99
99
null
null
tphyahoo/haskoin
haskoin-core/Network/Haskoin/Crypto/Mnemonic.hs
unlicense
getIndices :: [ByteString] -> Either String [Int] getIndices ws | null n = return $ catMaybes i | otherwise = Left $ "getIndices: words not found: " ++ cs w where i = map (`M.lookup` wl') ws n = elemIndices Nothing i w = C.unwords $ map (ws!!) n
267
getIndices :: [ByteString] -> Either String [Int] getIndices ws | null n = return $ catMaybes i | otherwise = Left $ "getIndices: words not found: " ++ cs w where i = map (`M.lookup` wl') ws n = elemIndices Nothing i w = C.unwords $ map (ws!!) n
267
getIndices ws | null n = return $ catMaybes i | otherwise = Left $ "getIndices: words not found: " ++ cs w where i = map (`M.lookup` wl') ws n = elemIndices Nothing i w = C.unwords $ map (ws!!) n
217
false
true
9
8
70
138
60
78
null
null
ndmitchell/hogle-dead
src/Input/Type.hs
bsd-3-clause
isIModule IModule{} = True
26
isIModule IModule{} = True
26
isIModule IModule{} = True
26
false
false
0
6
3
13
6
7
null
null
themoritz/cabal
cabal-install/tests/IntegrationTests2.hs
bsd-3-clause
testSetupScriptStyles :: ProjectConfig -> (String -> IO ()) -> Assertion testSetupScriptStyles config reportSubCase = do reportSubCase (show SetupCustomExplicitDeps) plan0@(_,_,sharedConfig) <- planProject testdir1 config let isOSX (Platform _ OSX) = True isOSX _ = False -- Skip the Custom tests when the shipped Cabal library is buggy unless (isOSX (pkgConfigPlatform sharedConfig) && compilerVersion (pkgConfigCompiler sharedConfig) < mkVersion [7,10]) $ do (plan1, res1) <- executePlan plan0 (pkg1, _) <- expectPackageInstalled plan1 res1 pkgidA elabSetupScriptStyle pkg1 @?= SetupCustomExplicitDeps hasDefaultSetupDeps pkg1 @?= Just False marker1 <- readFile (basedir </> testdir1 </> "marker") marker1 @?= "ok" removeFile (basedir </> testdir1 </> "marker") reportSubCase (show SetupCustomImplicitDeps) (plan2, res2) <- executePlan =<< planProject testdir2 config (pkg2, _) <- expectPackageInstalled plan2 res2 pkgidA elabSetupScriptStyle pkg2 @?= SetupCustomImplicitDeps hasDefaultSetupDeps pkg2 @?= Just True marker2 <- readFile (basedir </> testdir2 </> "marker") marker2 @?= "ok" removeFile (basedir </> testdir2 </> "marker") reportSubCase (show SetupNonCustomInternalLib) (plan3, res3) <- executePlan =<< planProject testdir3 config (pkg3, _) <- expectPackageInstalled plan3 res3 pkgidA elabSetupScriptStyle pkg3 @?= SetupNonCustomInternalLib {- --TODO: the SetupNonCustomExternalLib case is hard to test since it -- requires a version of Cabal that's later than the one we're testing -- e.g. needs a .cabal file that specifies cabal-version: >= 2.0 -- and a corresponding Cabal package that we can use to try and build a -- default Setup.hs. reportSubCase (show SetupNonCustomExternalLib) (plan4, res4) <- executePlan =<< planProject testdir4 config (pkg4, _) <- expectPackageInstalled plan4 res4 pkgidA pkgSetupScriptStyle pkg4 @?= SetupNonCustomExternalLib -} where testdir1 = "build/setup-custom1" testdir2 = "build/setup-custom2" testdir3 = "build/setup-simple" pkgidA = PackageIdentifier "a" (mkVersion [0,1]) -- The solver fills in default setup deps explicitly, but marks them as such hasDefaultSetupDeps = fmap defaultSetupDepends . setupBuildInfo . elabPkgDescription -- | Test the behaviour with and without @--keep-going@ --
2,458
testSetupScriptStyles :: ProjectConfig -> (String -> IO ()) -> Assertion testSetupScriptStyles config reportSubCase = do reportSubCase (show SetupCustomExplicitDeps) plan0@(_,_,sharedConfig) <- planProject testdir1 config let isOSX (Platform _ OSX) = True isOSX _ = False -- Skip the Custom tests when the shipped Cabal library is buggy unless (isOSX (pkgConfigPlatform sharedConfig) && compilerVersion (pkgConfigCompiler sharedConfig) < mkVersion [7,10]) $ do (plan1, res1) <- executePlan plan0 (pkg1, _) <- expectPackageInstalled plan1 res1 pkgidA elabSetupScriptStyle pkg1 @?= SetupCustomExplicitDeps hasDefaultSetupDeps pkg1 @?= Just False marker1 <- readFile (basedir </> testdir1 </> "marker") marker1 @?= "ok" removeFile (basedir </> testdir1 </> "marker") reportSubCase (show SetupCustomImplicitDeps) (plan2, res2) <- executePlan =<< planProject testdir2 config (pkg2, _) <- expectPackageInstalled plan2 res2 pkgidA elabSetupScriptStyle pkg2 @?= SetupCustomImplicitDeps hasDefaultSetupDeps pkg2 @?= Just True marker2 <- readFile (basedir </> testdir2 </> "marker") marker2 @?= "ok" removeFile (basedir </> testdir2 </> "marker") reportSubCase (show SetupNonCustomInternalLib) (plan3, res3) <- executePlan =<< planProject testdir3 config (pkg3, _) <- expectPackageInstalled plan3 res3 pkgidA elabSetupScriptStyle pkg3 @?= SetupNonCustomInternalLib {- --TODO: the SetupNonCustomExternalLib case is hard to test since it -- requires a version of Cabal that's later than the one we're testing -- e.g. needs a .cabal file that specifies cabal-version: >= 2.0 -- and a corresponding Cabal package that we can use to try and build a -- default Setup.hs. reportSubCase (show SetupNonCustomExternalLib) (plan4, res4) <- executePlan =<< planProject testdir4 config (pkg4, _) <- expectPackageInstalled plan4 res4 pkgidA pkgSetupScriptStyle pkg4 @?= SetupNonCustomExternalLib -} where testdir1 = "build/setup-custom1" testdir2 = "build/setup-custom2" testdir3 = "build/setup-simple" pkgidA = PackageIdentifier "a" (mkVersion [0,1]) -- The solver fills in default setup deps explicitly, but marks them as such hasDefaultSetupDeps = fmap defaultSetupDepends . setupBuildInfo . elabPkgDescription -- | Test the behaviour with and without @--keep-going@ --
2,458
testSetupScriptStyles config reportSubCase = do reportSubCase (show SetupCustomExplicitDeps) plan0@(_,_,sharedConfig) <- planProject testdir1 config let isOSX (Platform _ OSX) = True isOSX _ = False -- Skip the Custom tests when the shipped Cabal library is buggy unless (isOSX (pkgConfigPlatform sharedConfig) && compilerVersion (pkgConfigCompiler sharedConfig) < mkVersion [7,10]) $ do (plan1, res1) <- executePlan plan0 (pkg1, _) <- expectPackageInstalled plan1 res1 pkgidA elabSetupScriptStyle pkg1 @?= SetupCustomExplicitDeps hasDefaultSetupDeps pkg1 @?= Just False marker1 <- readFile (basedir </> testdir1 </> "marker") marker1 @?= "ok" removeFile (basedir </> testdir1 </> "marker") reportSubCase (show SetupCustomImplicitDeps) (plan2, res2) <- executePlan =<< planProject testdir2 config (pkg2, _) <- expectPackageInstalled plan2 res2 pkgidA elabSetupScriptStyle pkg2 @?= SetupCustomImplicitDeps hasDefaultSetupDeps pkg2 @?= Just True marker2 <- readFile (basedir </> testdir2 </> "marker") marker2 @?= "ok" removeFile (basedir </> testdir2 </> "marker") reportSubCase (show SetupNonCustomInternalLib) (plan3, res3) <- executePlan =<< planProject testdir3 config (pkg3, _) <- expectPackageInstalled plan3 res3 pkgidA elabSetupScriptStyle pkg3 @?= SetupNonCustomInternalLib {- --TODO: the SetupNonCustomExternalLib case is hard to test since it -- requires a version of Cabal that's later than the one we're testing -- e.g. needs a .cabal file that specifies cabal-version: >= 2.0 -- and a corresponding Cabal package that we can use to try and build a -- default Setup.hs. reportSubCase (show SetupNonCustomExternalLib) (plan4, res4) <- executePlan =<< planProject testdir4 config (pkg4, _) <- expectPackageInstalled plan4 res4 pkgidA pkgSetupScriptStyle pkg4 @?= SetupNonCustomExternalLib -} where testdir1 = "build/setup-custom1" testdir2 = "build/setup-custom2" testdir3 = "build/setup-simple" pkgidA = PackageIdentifier "a" (mkVersion [0,1]) -- The solver fills in default setup deps explicitly, but marks them as such hasDefaultSetupDeps = fmap defaultSetupDepends . setupBuildInfo . elabPkgDescription -- | Test the behaviour with and without @--keep-going@ --
2,385
false
true
0
14
496
499
241
258
null
null
alasconnect/auth0
src/Auth0/Management/Users.hs
apache-2.0
usersApi :: Proxy UsersApi usersApi = Proxy
43
usersApi :: Proxy UsersApi usersApi = Proxy
43
usersApi = Proxy
16
false
true
1
5
6
18
7
11
null
null
IreneKnapp/ozweb
Haskell/Schema.hs
mit
evaluate context expression@(ConstantExpression { }) _ = do let dynamicResult = constantExpressionValue expression case fromDynamic dynamicResult of Nothing -> throwError $ "Expression of unexpected type." Just result -> return result
246
evaluate context expression@(ConstantExpression { }) _ = do let dynamicResult = constantExpressionValue expression case fromDynamic dynamicResult of Nothing -> throwError $ "Expression of unexpected type." Just result -> return result
246
evaluate context expression@(ConstantExpression { }) _ = do let dynamicResult = constantExpressionValue expression case fromDynamic dynamicResult of Nothing -> throwError $ "Expression of unexpected type." Just result -> return result
246
false
false
2
11
41
72
31
41
null
null
gbataille/pandoc
src/Text/Pandoc/Writers/MediaWiki.hs
gpl-2.0
listAttribsToString :: ListAttributes -> String listAttribsToString (startnum, numstyle, _) = let numstyle' = camelCaseToHyphenated $ show numstyle in (if startnum /= 1 then " start=\"" ++ show startnum ++ "\"" else "") ++ (if numstyle /= DefaultStyle then " style=\"list-style-type: " ++ numstyle' ++ ";\"" else "")
367
listAttribsToString :: ListAttributes -> String listAttribsToString (startnum, numstyle, _) = let numstyle' = camelCaseToHyphenated $ show numstyle in (if startnum /= 1 then " start=\"" ++ show startnum ++ "\"" else "") ++ (if numstyle /= DefaultStyle then " style=\"list-style-type: " ++ numstyle' ++ ";\"" else "")
367
listAttribsToString (startnum, numstyle, _) = let numstyle' = camelCaseToHyphenated $ show numstyle in (if startnum /= 1 then " start=\"" ++ show startnum ++ "\"" else "") ++ (if numstyle /= DefaultStyle then " style=\"list-style-type: " ++ numstyle' ++ ";\"" else "")
319
false
true
0
12
97
98
52
46
null
null
kallisti-dev/discordian-calendar
src/Data/Time/Calendar/Discordian.hs
bsd-3-clause
stTibsDay :: Integer -> Maybe Day stTibsDay dYear | isLeapYear gYear = Just (fromGregorian gYear 2 29) | otherwise = Nothing where gYear = dYear - 1166 -- |Show the name of a Discordian season. Input values are clipped to valid ranges.
250
stTibsDay :: Integer -> Maybe Day stTibsDay dYear | isLeapYear gYear = Just (fromGregorian gYear 2 29) | otherwise = Nothing where gYear = dYear - 1166 -- |Show the name of a Discordian season. Input values are clipped to valid ranges.
250
stTibsDay dYear | isLeapYear gYear = Just (fromGregorian gYear 2 29) | otherwise = Nothing where gYear = dYear - 1166 -- |Show the name of a Discordian season. Input values are clipped to valid ranges.
216
false
true
1
8
56
75
32
43
null
null
sleepomeno/TForth
src/TF/Util.hs
apache-2.0
for = flip map
14
for = flip map
14
for = flip map
14
false
false
1
5
3
12
4
8
null
null
xmonad/xmonad-contrib
XMonad/Layout/SortedLayout.hs
bsd-3-clause
-- $usage -- You can use this module with the following in your -- @~\/.xmonad\/xmonad.hs@: -- -- > import XMonad.Layout.SortedLayout -- -- Then edit your @layoutHook@ to sort another layout (in this case, 'XMonad.Layout.Grid.Grid'): -- -- > myLayout = sorted [ClassName "Firefox", ClassName "URxvt"] Grid -- > main = xmonad def { layoutHook = myLayout } -- -- For more detailed instructions on editing the layoutHook see: -- -- "XMonad.Doc.Extending#Editing_the_layout_hook" -- | Modify a layout using a list of properties to sort its windows. sorted :: [Property] -> l a -> ModifiedLayout SortedLayout l a sorted props = ModifiedLayout . SortedLayout $ props ++ [Const True]
692
sorted :: [Property] -> l a -> ModifiedLayout SortedLayout l a sorted props = ModifiedLayout . SortedLayout $ props ++ [Const True]
145
sorted props = ModifiedLayout . SortedLayout $ props ++ [Const True]
68
true
true
0
8
121
73
42
31
null
null
snapframework/snap-core
test/Snap/Core/Tests.hs
bsd-3-clause
testEvalSnap :: Test testEvalSnap = testCase "core/evalSnap-exception" $ do rq <- mkZomgRq expectExceptionH (evalSnap f logerr tout rq >> return ()) where f = do logError "zzz" v <- withResponse (return . rspStatus) liftIO $ assertEqual "evalSnap rsp status" 200 v finishWith emptyResponse ------------------------------------------------------------------------------
416
testEvalSnap :: Test testEvalSnap = testCase "core/evalSnap-exception" $ do rq <- mkZomgRq expectExceptionH (evalSnap f logerr tout rq >> return ()) where f = do logError "zzz" v <- withResponse (return . rspStatus) liftIO $ assertEqual "evalSnap rsp status" 200 v finishWith emptyResponse ------------------------------------------------------------------------------
416
testEvalSnap = testCase "core/evalSnap-exception" $ do rq <- mkZomgRq expectExceptionH (evalSnap f logerr tout rq >> return ()) where f = do logError "zzz" v <- withResponse (return . rspStatus) liftIO $ assertEqual "evalSnap rsp status" 200 v finishWith emptyResponse ------------------------------------------------------------------------------
395
false
true
0
12
91
104
47
57
null
null
sirius94/lambdai
src/Reducer/Renderer.hs
gpl-3.0
alignLeft :: Int -> String -> String alignLeft n s = s ++ replicate (n - (length s)) ' '
88
alignLeft :: Int -> String -> String alignLeft n s = s ++ replicate (n - (length s)) ' '
88
alignLeft n s = s ++ replicate (n - (length s)) ' '
51
false
true
0
10
19
46
23
23
null
null
fcostantini/QuickFuzz
src/Lua.hs
gpl-3.0
popId :: Name -> VState Name () popId i = do st <- get put $ st {vars = delete i (vars st)}
104
popId :: Name -> VState Name () popId i = do st <- get put $ st {vars = delete i (vars st)}
104
popId i = do st <- get put $ st {vars = delete i (vars st)}
72
false
true
0
13
35
63
29
34
null
null
WSCU/JSEuterpea
Euterpea Examples/Random.hs
gpl-3.0
rand1 = (marimba sixteenths) * (flute eighths)
46
rand1 = (marimba sixteenths) * (flute eighths)
46
rand1 = (marimba sixteenths) * (flute eighths)
46
false
false
0
7
6
22
11
11
null
null
fmapfmapfmap/amazonka
amazonka-kms/gen/Network/AWS/KMS/Encrypt.hs
mpl-2.0
-- | The response status code. ersResponseStatus :: Lens' EncryptResponse Int ersResponseStatus = lens _ersResponseStatus (\ s a -> s{_ersResponseStatus = a})
158
ersResponseStatus :: Lens' EncryptResponse Int ersResponseStatus = lens _ersResponseStatus (\ s a -> s{_ersResponseStatus = a})
127
ersResponseStatus = lens _ersResponseStatus (\ s a -> s{_ersResponseStatus = a})
80
true
true
1
9
21
44
22
22
null
null
avieth/postgresql-simple
src/Database/PostgreSQL/Simple/FromField.hs
bsd-3-clause
typeInfoByOid :: PQ.Oid -> Conversion TypeInfo typeInfoByOid oid = Conversion $ \conn -> do Ok <$> (getTypeInfo conn oid) -- | Returns the name of the column. This is often determined by a table -- definition, but it can be set using an @as@ clause.
276
typeInfoByOid :: PQ.Oid -> Conversion TypeInfo typeInfoByOid oid = Conversion $ \conn -> do Ok <$> (getTypeInfo conn oid) -- | Returns the name of the column. This is often determined by a table -- definition, but it can be set using an @as@ clause.
276
typeInfoByOid oid = Conversion $ \conn -> do Ok <$> (getTypeInfo conn oid) -- | Returns the name of the column. This is often determined by a table -- definition, but it can be set using an @as@ clause.
229
false
true
0
11
71
49
25
24
null
null
alexander-at-github/eta
compiler/ETA/CodeGen/ArgRep.hs
bsd-3-clause
slowCallPattern (F: _) = ("ap_f", 1, [jfloat])
61
slowCallPattern (F: _) = ("ap_f", 1, [jfloat])
61
slowCallPattern (F: _) = ("ap_f", 1, [jfloat])
61
false
false
0
7
21
28
16
12
null
null
edom/sound
src/Sound/InfList.hs
bsd-3-clause
-- * Continuation-based transformation {- $ The functions in this section follow this pattern: @ lcfff n ... x0 x1 ... c ~ 'take' n (fff x0 x1 ...) '++' c ('drop' n x0) ('drop' n x1) ... @ The first argument, which can be a number or a predicate, determines the length of the prefix that is being manipulated. The last argument is the continuation. -} -- ** Mapping {- | @ lcmap n f x c ~ 'take' n ('map' f x) '++' c ('drop' n x) @ -} lcmap :: Int -> (a -> b) -> L a -> (L a -> L b) -> L b lcmap n_ f_ x_ c_ = loop n_ x_ where loop n (MkL h t) | n > 0 = MkL (f_ h) (loop (n - 1) t) loop _ x = c_ x {- | @ lcid n x c = 'lcmap' n 'id' x c lcid n x c ~ 'take' n x '++' c ('drop' n x) @ -}
718
lcmap :: Int -> (a -> b) -> L a -> (L a -> L b) -> L b lcmap n_ f_ x_ c_ = loop n_ x_ where loop n (MkL h t) | n > 0 = MkL (f_ h) (loop (n - 1) t) loop _ x = c_ x {- | @ lcid n x c = 'lcmap' n 'id' x c lcid n x c ~ 'take' n x '++' c ('drop' n x) @ -}
275
lcmap n_ f_ x_ c_ = loop n_ x_ where loop n (MkL h t) | n > 0 = MkL (f_ h) (loop (n - 1) t) loop _ x = c_ x {- | @ lcid n x c = 'lcmap' n 'id' x c lcid n x c ~ 'take' n x '++' c ('drop' n x) @ -}
220
true
true
1
12
204
150
71
79
null
null
ribag/ganeti-experiments
src/Ganeti/Query/Node.hs
gpl-2.0
-- | The node fields map. fieldsMap :: FieldMap Node Runtime fieldsMap = fieldListToFieldMap nodeFields
103
fieldsMap :: FieldMap Node Runtime fieldsMap = fieldListToFieldMap nodeFields
77
fieldsMap = fieldListToFieldMap nodeFields
42
true
true
0
5
14
20
10
10
null
null
tittoassini/flat
test/Core.hs
bsd-3-clause
sz32 = getSize E32_13
21
sz32 = getSize E32_13
21
sz32 = getSize E32_13
21
false
false
1
5
3
13
4
9
null
null
jasonrbriggs/proton
haskell/testsuite/TestXml.hs
apache-2.0
xmlTests = [TestLabel "Basic Parse Test" basicParseTest, TestLabel "Contains Attribute Test1" containsAttributeTest1, TestLabel "Copy Elements Test" copyElementsTest, TestLabel "Copy Element Test" copyElementTest, TestLabel "Find Attribute Test1" findAttributeTest1, TestLabel "Find Attribute Test2" findAttributeTest2]
429
xmlTests = [TestLabel "Basic Parse Test" basicParseTest, TestLabel "Contains Attribute Test1" containsAttributeTest1, TestLabel "Copy Elements Test" copyElementsTest, TestLabel "Copy Element Test" copyElementTest, TestLabel "Find Attribute Test1" findAttributeTest1, TestLabel "Find Attribute Test2" findAttributeTest2]
429
xmlTests = [TestLabel "Basic Parse Test" basicParseTest, TestLabel "Contains Attribute Test1" containsAttributeTest1, TestLabel "Copy Elements Test" copyElementsTest, TestLabel "Copy Element Test" copyElementTest, TestLabel "Find Attribute Test1" findAttributeTest1, TestLabel "Find Attribute Test2" findAttributeTest2]
429
false
false
0
6
141
54
27
27
null
null
yuvallanger/threepenny-gui
samples/Paths.hs
bsd-3-clause
getStaticDir :: IO FilePath getStaticDir = (</> "wwwroot") `liftM` Paths_threepenny_gui.getDataDir
98
getStaticDir :: IO FilePath getStaticDir = (</> "wwwroot") `liftM` Paths_threepenny_gui.getDataDir
98
getStaticDir = (</> "wwwroot") `liftM` Paths_threepenny_gui.getDataDir
70
false
true
0
6
9
26
15
11
null
null
worksap-ate/aws-sdk
Cloud/AWS/RDS/OptionGroup.hs
bsd-3-clause
optionGroupOptionSink :: (MonadThrow m, Applicative m) => XmlElement -> m OptionGroupOption optionGroupOptionSink xml = OptionGroupOption <$> xml .< "MajorEngineVersion" <*> xml .< "Persistent" <*> xml .< "PortRequired" <*> elements' "OptionsDependedOn" "OptionName" content xml <*> xml .< "Description" <*> xml .< "DefaultPort" <*> xml .< "Name" <*> elements "OptionGroupOptionSetting" optionGroupOptionSettingSink xml <*> xml .< "EngineName" <*> xml .< "MinimumRequiredMinorEngineVersion"
538
optionGroupOptionSink :: (MonadThrow m, Applicative m) => XmlElement -> m OptionGroupOption optionGroupOptionSink xml = OptionGroupOption <$> xml .< "MajorEngineVersion" <*> xml .< "Persistent" <*> xml .< "PortRequired" <*> elements' "OptionsDependedOn" "OptionName" content xml <*> xml .< "Description" <*> xml .< "DefaultPort" <*> xml .< "Name" <*> elements "OptionGroupOptionSetting" optionGroupOptionSettingSink xml <*> xml .< "EngineName" <*> xml .< "MinimumRequiredMinorEngineVersion"
538
optionGroupOptionSink xml = OptionGroupOption <$> xml .< "MajorEngineVersion" <*> xml .< "Persistent" <*> xml .< "PortRequired" <*> elements' "OptionsDependedOn" "OptionName" content xml <*> xml .< "Description" <*> xml .< "DefaultPort" <*> xml .< "Name" <*> elements "OptionGroupOptionSetting" optionGroupOptionSettingSink xml <*> xml .< "EngineName" <*> xml .< "MinimumRequiredMinorEngineVersion"
438
false
true
45
8
105
175
88
87
null
null
mishun/tangles
src/Math/Topology/KnotTh/Algebra/Homology.hs
lgpl-3.0
smithNormalForm :: (Integral a, Eq g) => V.Vector g -> V.Vector g -> Matrix.Matrix a -> (V.Vector (g, a), V.Vector g) smithNormalForm colGrading rowGrading matrix = ST.runST $ do let rows = Matrix.nrows matrix cols = Matrix.ncols matrix idx i j = i * cols + j when (V.length colGrading /= cols) $ error "bad colGrading length" when (V.length rowGrading /= rows) $ error "bad rowGrading length" rg <- V.thaw rowGrading cg <- V.thaw colGrading v <- V.thaw $ Matrix.getMatrixAsVector matrix let get row col = do x <- MV.read v (idx row col) when (x /= 0) $ do g <- MV.read rg row g' <- MV.read cg col when (g /= g') $ error "non-zero element between different gradings" return x negateRow row = forM_ [0 .. cols - 1] $ \ !k -> MV.modify v negate (idx row k) transformRows !a00 !a01 !a10 !a11 !row0 !row1 = do do g0 <- MV.read rg row0 g1 <- MV.read rg row1 when (g0 /= g1) $ error "different row gradings" forM_ [0 .. cols - 1] $ \ !k -> do x0 <- MV.read v (idx row0 k) x1 <- MV.read v (idx row1 k) MV.write v (idx row0 k) $! a00 * x0 + a01 * x1 MV.write v (idx row1 k) $! a10 * x0 + a11 * x1 transformCols !a00 !a01 !a10 !a11 !col0 !col1 = do do g0 <- MV.read cg col0 g1 <- MV.read cg col1 when (g0 /= g1) $ error "different col gradings" forM_ [0 .. rows - 1] $ \ !k -> do x0 <- MV.read v (idx k col0) x1 <- MV.read v (idx k col1) MV.write v (idx k col0) $! a00 * x0 + a01 * x1 MV.write v (idx k col1) $! a10 * x0 + a11 * x1 swapRows rowA rowB = when (rowA /= rowB) $ do MV.swap rg rowA rowB forM_ [0 .. cols - 1] $ \ k -> MV.swap v (idx rowA k) (idx rowB k) swapCols colA colB = when (colA /= colB) $ do MV.swap cg colA colB forM_ [0 .. rows - 1] $ \ k -> MV.swap v (idx k colA) (idx k colB) findPivot !t !row !col | col >= cols = return False | row >= rows = findPivot t t (col + 1) | otherwise = do pivot <- get row col if pivot == 0 then findPivot t (row + 1) col else do swapRows t row swapCols t col when (pivot < 0) $ negateRow t return True eliminate !t = do ok <- findPivot t t t if ok then do get t t >>= clearCorner t eliminate $ t + 1 else liftM2 (,) (V.generateM t $ \ i -> liftM2 (,) (MV.read rg i) (get i i)) (V.generateM (cols - t) $ \ i -> MV.read cg (t + i)) clearCorner !t !pivot = do pivot' <- clearRow t (t + 1) pivot >>= clearCol t (t + 1) when (pivot' /= pivot) $ clearCorner t pivot' clearRow !t !i !pivot = if i >= rows then return pivot else do x <- get i t case divMod x pivot of (quotient, 0) -> do when (quotient /= 0) $ transformRows 1 0 (-quotient) 1 t i clearRow t (i + 1) pivot _ -> do let (g, sigma, tau) = extendedGCD pivot x transformRows sigma tau (-x `div` g) (pivot `div` g) t i clearRow t (i + 1) g clearCol !t !i !pivot = if i >= cols then return pivot else do x <- get t i case divMod x pivot of (quotient, 0) -> do when (quotient /= 0) $ transformCols 1 0 (-quotient) 1 t i clearCol t (i + 1) pivot _ -> do let (g, sigma, tau) = extendedGCD pivot x transformCols sigma tau (-x `div` g) (pivot `div` g) t i clearCol t (i + 1) g eliminate 0
4,641
smithNormalForm :: (Integral a, Eq g) => V.Vector g -> V.Vector g -> Matrix.Matrix a -> (V.Vector (g, a), V.Vector g) smithNormalForm colGrading rowGrading matrix = ST.runST $ do let rows = Matrix.nrows matrix cols = Matrix.ncols matrix idx i j = i * cols + j when (V.length colGrading /= cols) $ error "bad colGrading length" when (V.length rowGrading /= rows) $ error "bad rowGrading length" rg <- V.thaw rowGrading cg <- V.thaw colGrading v <- V.thaw $ Matrix.getMatrixAsVector matrix let get row col = do x <- MV.read v (idx row col) when (x /= 0) $ do g <- MV.read rg row g' <- MV.read cg col when (g /= g') $ error "non-zero element between different gradings" return x negateRow row = forM_ [0 .. cols - 1] $ \ !k -> MV.modify v negate (idx row k) transformRows !a00 !a01 !a10 !a11 !row0 !row1 = do do g0 <- MV.read rg row0 g1 <- MV.read rg row1 when (g0 /= g1) $ error "different row gradings" forM_ [0 .. cols - 1] $ \ !k -> do x0 <- MV.read v (idx row0 k) x1 <- MV.read v (idx row1 k) MV.write v (idx row0 k) $! a00 * x0 + a01 * x1 MV.write v (idx row1 k) $! a10 * x0 + a11 * x1 transformCols !a00 !a01 !a10 !a11 !col0 !col1 = do do g0 <- MV.read cg col0 g1 <- MV.read cg col1 when (g0 /= g1) $ error "different col gradings" forM_ [0 .. rows - 1] $ \ !k -> do x0 <- MV.read v (idx k col0) x1 <- MV.read v (idx k col1) MV.write v (idx k col0) $! a00 * x0 + a01 * x1 MV.write v (idx k col1) $! a10 * x0 + a11 * x1 swapRows rowA rowB = when (rowA /= rowB) $ do MV.swap rg rowA rowB forM_ [0 .. cols - 1] $ \ k -> MV.swap v (idx rowA k) (idx rowB k) swapCols colA colB = when (colA /= colB) $ do MV.swap cg colA colB forM_ [0 .. rows - 1] $ \ k -> MV.swap v (idx k colA) (idx k colB) findPivot !t !row !col | col >= cols = return False | row >= rows = findPivot t t (col + 1) | otherwise = do pivot <- get row col if pivot == 0 then findPivot t (row + 1) col else do swapRows t row swapCols t col when (pivot < 0) $ negateRow t return True eliminate !t = do ok <- findPivot t t t if ok then do get t t >>= clearCorner t eliminate $ t + 1 else liftM2 (,) (V.generateM t $ \ i -> liftM2 (,) (MV.read rg i) (get i i)) (V.generateM (cols - t) $ \ i -> MV.read cg (t + i)) clearCorner !t !pivot = do pivot' <- clearRow t (t + 1) pivot >>= clearCol t (t + 1) when (pivot' /= pivot) $ clearCorner t pivot' clearRow !t !i !pivot = if i >= rows then return pivot else do x <- get i t case divMod x pivot of (quotient, 0) -> do when (quotient /= 0) $ transformRows 1 0 (-quotient) 1 t i clearRow t (i + 1) pivot _ -> do let (g, sigma, tau) = extendedGCD pivot x transformRows sigma tau (-x `div` g) (pivot `div` g) t i clearRow t (i + 1) g clearCol !t !i !pivot = if i >= cols then return pivot else do x <- get t i case divMod x pivot of (quotient, 0) -> do when (quotient /= 0) $ transformCols 1 0 (-quotient) 1 t i clearCol t (i + 1) pivot _ -> do let (g, sigma, tau) = extendedGCD pivot x transformCols sigma tau (-x `div` g) (pivot `div` g) t i clearCol t (i + 1) g eliminate 0
4,641
smithNormalForm colGrading rowGrading matrix = ST.runST $ do let rows = Matrix.nrows matrix cols = Matrix.ncols matrix idx i j = i * cols + j when (V.length colGrading /= cols) $ error "bad colGrading length" when (V.length rowGrading /= rows) $ error "bad rowGrading length" rg <- V.thaw rowGrading cg <- V.thaw colGrading v <- V.thaw $ Matrix.getMatrixAsVector matrix let get row col = do x <- MV.read v (idx row col) when (x /= 0) $ do g <- MV.read rg row g' <- MV.read cg col when (g /= g') $ error "non-zero element between different gradings" return x negateRow row = forM_ [0 .. cols - 1] $ \ !k -> MV.modify v negate (idx row k) transformRows !a00 !a01 !a10 !a11 !row0 !row1 = do do g0 <- MV.read rg row0 g1 <- MV.read rg row1 when (g0 /= g1) $ error "different row gradings" forM_ [0 .. cols - 1] $ \ !k -> do x0 <- MV.read v (idx row0 k) x1 <- MV.read v (idx row1 k) MV.write v (idx row0 k) $! a00 * x0 + a01 * x1 MV.write v (idx row1 k) $! a10 * x0 + a11 * x1 transformCols !a00 !a01 !a10 !a11 !col0 !col1 = do do g0 <- MV.read cg col0 g1 <- MV.read cg col1 when (g0 /= g1) $ error "different col gradings" forM_ [0 .. rows - 1] $ \ !k -> do x0 <- MV.read v (idx k col0) x1 <- MV.read v (idx k col1) MV.write v (idx k col0) $! a00 * x0 + a01 * x1 MV.write v (idx k col1) $! a10 * x0 + a11 * x1 swapRows rowA rowB = when (rowA /= rowB) $ do MV.swap rg rowA rowB forM_ [0 .. cols - 1] $ \ k -> MV.swap v (idx rowA k) (idx rowB k) swapCols colA colB = when (colA /= colB) $ do MV.swap cg colA colB forM_ [0 .. rows - 1] $ \ k -> MV.swap v (idx k colA) (idx k colB) findPivot !t !row !col | col >= cols = return False | row >= rows = findPivot t t (col + 1) | otherwise = do pivot <- get row col if pivot == 0 then findPivot t (row + 1) col else do swapRows t row swapCols t col when (pivot < 0) $ negateRow t return True eliminate !t = do ok <- findPivot t t t if ok then do get t t >>= clearCorner t eliminate $ t + 1 else liftM2 (,) (V.generateM t $ \ i -> liftM2 (,) (MV.read rg i) (get i i)) (V.generateM (cols - t) $ \ i -> MV.read cg (t + i)) clearCorner !t !pivot = do pivot' <- clearRow t (t + 1) pivot >>= clearCol t (t + 1) when (pivot' /= pivot) $ clearCorner t pivot' clearRow !t !i !pivot = if i >= rows then return pivot else do x <- get i t case divMod x pivot of (quotient, 0) -> do when (quotient /= 0) $ transformRows 1 0 (-quotient) 1 t i clearRow t (i + 1) pivot _ -> do let (g, sigma, tau) = extendedGCD pivot x transformRows sigma tau (-x `div` g) (pivot `div` g) t i clearRow t (i + 1) g clearCol !t !i !pivot = if i >= cols then return pivot else do x <- get t i case divMod x pivot of (quotient, 0) -> do when (quotient /= 0) $ transformCols 1 0 (-quotient) 1 t i clearCol t (i + 1) pivot _ -> do let (g, sigma, tau) = extendedGCD pivot x transformCols sigma tau (-x `div` g) (pivot `div` g) t i clearCol t (i + 1) g eliminate 0
4,523
false
true
3
28
2,318
1,771
832
939
null
null
ekmett/wxHaskell
wxcore/src/haskell/Graphics/UI/WXCore/Types.hs
lgpl-2.1
-- | Return the height. (see also 'sizeH'). sizeHeight :: (Num a) => Size2D a -> a sizeHeight (Size w h) = h
110
sizeHeight :: (Num a) => Size2D a -> a sizeHeight (Size w h) = h
66
sizeHeight (Size w h) = h
27
true
true
0
7
24
39
20
19
null
null
fffej/HS-Poker
LookupPatternMatch.hs
bsd-3-clause
getValueFromProduct 1103414 = 3635
34
getValueFromProduct 1103414 = 3635
34
getValueFromProduct 1103414 = 3635
34
false
false
0
5
3
9
4
5
null
null
onponomarev/ganeti
test/hs/Test/Ganeti/OpCodes.hs
bsd-2-clause
-- | Generates list of disk indices. genDiskIndices :: Gen [DiskIndex] genDiskIndices = do cnt <- choose (0, C.maxDisks) genUniquesList cnt arbitrary -- | Generates a list of node names.
191
genDiskIndices :: Gen [DiskIndex] genDiskIndices = do cnt <- choose (0, C.maxDisks) genUniquesList cnt arbitrary -- | Generates a list of node names.
154
genDiskIndices = do cnt <- choose (0, C.maxDisks) genUniquesList cnt arbitrary -- | Generates a list of node names.
120
true
true
0
10
34
45
23
22
null
null
andorp/hs-bluesnap
test/Bluesnap/Test/Parser.hs
gpl-3.0
testParamDecryptionRspParser = testXMLParser Response.elementParam_decryption
77
testParamDecryptionRspParser = testXMLParser Response.elementParam_decryption
77
testParamDecryptionRspParser = testXMLParser Response.elementParam_decryption
77
false
false
0
6
3
11
5
6
null
null
GaloisInc/haskell-tor
src/Tor/DataFormat/TorCell.hs
bsd-3-clause
putDestroyReason ORConnectionClosed = putWord8 8
56
putDestroyReason ORConnectionClosed = putWord8 8
56
putDestroyReason ORConnectionClosed = putWord8 8
56
false
false
0
5
12
13
5
8
null
null
garetxe/cabal
cabal-install/tests/UnitTests/Distribution/Client/Sandbox/Timestamp.hs
bsd-3-clause
timestampRecord_v2 :: String timestampRecord_v2 = "2\n" ++ "[(\"i386-linux-ghc-8.0.0.20160204\",[(\"/foo/bar/Baz\",1455350946)])" ++ ",(\"i386-linux-ghc-7.10.3\",[(\"/foo/bar/Baz\",1455484719)])]"
202
timestampRecord_v2 :: String timestampRecord_v2 = "2\n" ++ "[(\"i386-linux-ghc-8.0.0.20160204\",[(\"/foo/bar/Baz\",1455350946)])" ++ ",(\"i386-linux-ghc-7.10.3\",[(\"/foo/bar/Baz\",1455484719)])]"
202
timestampRecord_v2 = "2\n" ++ "[(\"i386-linux-ghc-8.0.0.20160204\",[(\"/foo/bar/Baz\",1455350946)])" ++ ",(\"i386-linux-ghc-7.10.3\",[(\"/foo/bar/Baz\",1455484719)])]"
173
false
true
0
6
15
19
10
9
null
null
jameshsmith/HRL
Server/Abyss/Spell.hs
mit
fizzleEffect :: Effect fizzleEffect = Effect Nothing (Ana (\s -> lift (message s) >> mzero) "*Fizzle*")
103
fizzleEffect :: Effect fizzleEffect = Effect Nothing (Ana (\s -> lift (message s) >> mzero) "*Fizzle*")
103
fizzleEffect = Effect Nothing (Ana (\s -> lift (message s) >> mzero) "*Fizzle*")
80
false
true
0
13
15
51
24
27
null
null
beloglazov/haskell-course
hw1.hs
apache-2.0
doubleEveryOtherRev (x:y:rest) = x : (y * 2) : doubleEveryOtherRev rest
71
doubleEveryOtherRev (x:y:rest) = x : (y * 2) : doubleEveryOtherRev rest
71
doubleEveryOtherRev (x:y:rest) = x : (y * 2) : doubleEveryOtherRev rest
71
false
false
0
8
10
38
19
19
null
null
ocean0yohsuke/Scheme
src/Scheme/Evaluator/Eval.hs
bsd-3-clause
eagerApply (CLOS (CELL params seq msp) mlenv) args = localMSP msp $ do lenv <- newLEnv mlenv params <- bind lenv params args case params of NIL -> localMLEnv (Just lenv) $ seqM eval seq _ -> (*:) $ RETURN $ CLOS (CELL params seq msp) (Just lenv)
271
eagerApply (CLOS (CELL params seq msp) mlenv) args = localMSP msp $ do lenv <- newLEnv mlenv params <- bind lenv params args case params of NIL -> localMLEnv (Just lenv) $ seqM eval seq _ -> (*:) $ RETURN $ CLOS (CELL params seq msp) (Just lenv)
271
eagerApply (CLOS (CELL params seq msp) mlenv) args = localMSP msp $ do lenv <- newLEnv mlenv params <- bind lenv params args case params of NIL -> localMLEnv (Just lenv) $ seqM eval seq _ -> (*:) $ RETURN $ CLOS (CELL params seq msp) (Just lenv)
271
false
false
0
14
73
128
60
68
null
null
NCrashed/servant-auth-token
servant-auth-token-leveldb/src/Servant/Server/Auth/Token/LevelDB/Schema.hs
bsd-3-clause
storeModel :: MonadResource m => LevelDBEnv -> Model -> m () storeModel db = store db modelId
93
storeModel :: MonadResource m => LevelDBEnv -> Model -> m () storeModel db = store db modelId
93
storeModel db = store db modelId
32
false
true
0
9
16
39
18
21
null
null
emmanueldenloye/manifoldRNC
src/Utils.hs
bsd-3-clause
errorMsg1 :: String errorMsg1 = "You did not enter two positive integers.\n"
76
errorMsg1 :: String errorMsg1 = "You did not enter two positive integers.\n"
76
errorMsg1 = "You did not enter two positive integers.\n"
56
false
true
0
4
11
11
6
5
null
null
Persi/shellcheck
ShellCheck/Parser.hs
gpl-3.0
prop_readDollarBraced3 = isOk readDollarBraced "${foo%%$(echo cow\\})}"
71
prop_readDollarBraced3 = isOk readDollarBraced "${foo%%$(echo cow\\})}"
71
prop_readDollarBraced3 = isOk readDollarBraced "${foo%%$(echo cow\\})}"
71
false
false
0
5
5
11
5
6
null
null
cirquit/hjc
src/TypeCheck/TypeCheck.hs
mit
checkReturnType rtype = do let id = showJC rtype exists <- classExists id when (not exists) $ appendError typeNotDefinedError where typeNotDefinedError = do let id = showJC rtype return $ printf "Undefined type \"%s\" in the return type" id
274
checkReturnType rtype = do let id = showJC rtype exists <- classExists id when (not exists) $ appendError typeNotDefinedError where typeNotDefinedError = do let id = showJC rtype return $ printf "Undefined type \"%s\" in the return type" id
274
checkReturnType rtype = do let id = showJC rtype exists <- classExists id when (not exists) $ appendError typeNotDefinedError where typeNotDefinedError = do let id = showJC rtype return $ printf "Undefined type \"%s\" in the return type" id
274
false
false
0
10
72
82
35
47
null
null
TomMD/ghc
compiler/prelude/PrelNames.hs
bsd-3-clause
geIntegerPrimIdKey = mkPreludeMiscIdUnique 77
56
geIntegerPrimIdKey = mkPreludeMiscIdUnique 77
56
geIntegerPrimIdKey = mkPreludeMiscIdUnique 77
56
false
false
0
5
14
9
4
5
null
null
TOSPIO/yi
src/library/Yi/Rectangle.hs
gpl-2.0
killRectangle :: EditorM () killRectangle = do cutted <- withCurrentBuffer $ do (reg, l, r) <- getRectangle text <- readRegionB reg let (cutted, rest) = unzip $ fmap cut $ R.lines' text cut :: R.YiString -> (R.YiString, R.YiString) cut line = let [left,mid,right] = multiSplit [l,r] line in (mid, left <> right) replaceRegionB reg (R.unlines rest) return cutted setRegE (R.unlines cutted)
464
killRectangle :: EditorM () killRectangle = do cutted <- withCurrentBuffer $ do (reg, l, r) <- getRectangle text <- readRegionB reg let (cutted, rest) = unzip $ fmap cut $ R.lines' text cut :: R.YiString -> (R.YiString, R.YiString) cut line = let [left,mid,right] = multiSplit [l,r] line in (mid, left <> right) replaceRegionB reg (R.unlines rest) return cutted setRegE (R.unlines cutted)
464
killRectangle = do cutted <- withCurrentBuffer $ do (reg, l, r) <- getRectangle text <- readRegionB reg let (cutted, rest) = unzip $ fmap cut $ R.lines' text cut :: R.YiString -> (R.YiString, R.YiString) cut line = let [left,mid,right] = multiSplit [l,r] line in (mid, left <> right) replaceRegionB reg (R.unlines rest) return cutted setRegE (R.unlines cutted)
436
false
true
0
19
136
192
95
97
null
null
jwiegley/ghc-release
utils/haddock/test/Haddock/ParserSpec.hs
gpl-3.0
spec :: Spec spec = before initStaticOpts $ do describe "parseString" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc RdrName -> Expectation shouldParseTo input ast = parseString input `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseString) xs `shouldSatisfy` (> 0) context "when parsing text" $ do it "can handle unicode" $ do "灼眼のシャナ" `shouldParseTo` "灼眼のシャナ" it "accepts numeric character references" $ do "foo b&#97;r b&#97;z &#955;" `shouldParseTo` "foo bar baz λ" it "accepts hexadecimal character references" $ do "&#x65;" `shouldParseTo` "e" it "allows to backslash-escape characters" $ do property $ \x -> ['\\', x] `shouldParseTo` DocString [x] context "when parsing strings contaning numeric character references" $ do it "will implicitly convert digits to characters" $ do "&#65;&#65;&#65;&#65;" `shouldParseTo` "AAAA" "&#28796;&#30524;&#12398;&#12471;&#12515;&#12490;" `shouldParseTo` "灼眼のシャナ" it "will implicitly convert hex encoded characters" $ do "&#x65;&#x65;&#x65;&#x65;" `shouldParseTo` "eeee" context "when parsing identifiers" $ do it "parses identifiers enclosed within single ticks" $ do "'foo'" `shouldParseTo` DocIdentifier "foo" it "parses identifiers enclosed within backticks" $ do "`foo`" `shouldParseTo` DocIdentifier "foo" it "parses a word with an one of the delimiters in it as DocString" $ do "don't" `shouldParseTo` "don't" it "doesn't pass pairs of delimiters with spaces between them" $ do "hel'lo w'orld" `shouldParseTo` "hel'lo w'orld" it "don't use apostrophe's in the wrong place's" $ do " don't use apostrophe's in the wrong place's" `shouldParseTo` "don't use apostrophe's in the wrong place's" context "when parsing URLs" $ do let hyperlink :: String -> Maybe String -> Doc RdrName hyperlink url = DocHyperlink . Hyperlink url it "parses a URL" $ do "<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing it "accepts an optional label" $ do "<http://example.com/ some link>" `shouldParseTo` hyperlink "http://example.com/" "some link" it "does not accept newlines in label" $ do "<foo bar\nbaz>" `shouldParseTo` "<foo bar\nbaz>" -- new behaviour test, this will be now consistent with other markup it "allows us to escape > inside the URL" $ do "<http://examp\\>le.com>" `shouldParseTo` hyperlink "http://examp>le.com" Nothing "<http://exa\\>mp\\>le.com>" `shouldParseTo` hyperlink "http://exa>mp>le.com" Nothing -- Likewise in label "<http://example.com f\\>oo>" `shouldParseTo` hyperlink "http://example.com" "f>oo" it "parses inline URLs" $ do "foo <http://example.com/> bar" `shouldParseTo` "foo " <> hyperlink "http://example.com/" Nothing <> " bar" it "doesn't allow for multi-line link tags" $ do "<ba\nz aar>" `shouldParseTo` "<ba\nz aar>" context "when autolinking URLs" $ do it "autolinks HTTP URLs" $ do "http://example.com/" `shouldParseTo` hyperlink "http://example.com/" Nothing it "autolinks HTTPS URLs" $ do "https://www.example.com/" `shouldParseTo` hyperlink "https://www.example.com/" Nothing it "autolinks FTP URLs" $ do "ftp://example.com/" `shouldParseTo` hyperlink "ftp://example.com/" Nothing it "does not include a trailing comma" $ do "http://example.com/, Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> ", Some other sentence." it "does not include a trailing dot" $ do "http://example.com/. Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> ". Some other sentence." it "does not include a trailing exclamation mark" $ do "http://example.com/! Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> "! Some other sentence." it "does not include a trailing question mark" $ do "http://example.com/? Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> "? Some other sentence." context "when parsing pictures" $ do let picture :: String -> Maybe String -> Doc RdrName picture uri = DocPic . Picture uri it "parses a simple picture" $ do "<<baz>>" `shouldParseTo` picture "baz" Nothing it "parses a picture with a title" $ do "<<b a z>>" `shouldParseTo` picture "b" (Just "a z") it "parses a picture with unicode" $ do "<<灼眼のシャナ>>" `shouldParseTo` picture "灼眼のシャナ" Nothing it "allows for escaping of the closing tags" $ do "<<ba\\>>z>>" `shouldParseTo` picture "ba>>z" Nothing it "doesn't allow for multi-line picture tags" $ do "<<ba\nz aar>>" `shouldParseTo` "<<ba\nz aar>>" context "when parsing anchors" $ do it "parses a single word anchor" $ do "#foo#" `shouldParseTo` DocAName "foo" it "parses a multi word anchor" $ do "#foo bar#" `shouldParseTo` DocAName "foo bar" it "parses a unicode anchor" $ do "#灼眼のシャナ#" `shouldParseTo` DocAName "灼眼のシャナ" it "does not accept newlines in anchors" $ do "#foo\nbar#" `shouldParseTo` "#foo\nbar#" it "accepts anchors mid-paragraph" $ do "Hello #someAnchor# world!" `shouldParseTo` "Hello " <> DocAName "someAnchor" <> " world!" it "does not accept empty anchors" $ do "##" `shouldParseTo` "##" context "when parsing emphasised text" $ do it "emphasises a word on its own" $ do "/foo/" `shouldParseTo` DocEmphasis "foo" it "emphasises inline correctly" $ do "foo /bar/ baz" `shouldParseTo` "foo " <> DocEmphasis "bar" <> " baz" it "emphasises unicode" $ do "/灼眼のシャナ/" `shouldParseTo` DocEmphasis "灼眼のシャナ" it "does not emphasise multi-line strings" $ do " /foo\nbar/" `shouldParseTo` "/foo\nbar/" it "does not emphasise the empty string" $ do "//" `shouldParseTo` "//" it "parses escaped slashes literally" $ do "/foo\\/bar/" `shouldParseTo` DocEmphasis "foo/bar" it "recognizes other markup constructs within emphasised text" $ do "/foo @bar@ baz/" `shouldParseTo` DocEmphasis ("foo " <> DocMonospaced "bar" <> " baz") it "allows other markup inside of emphasis" $ do "/__inner bold__/" `shouldParseTo` DocEmphasis (DocBold "inner bold") it "doesn't mangle inner markup unicode" $ do "/__灼眼のシャナ &#65;__/" `shouldParseTo` DocEmphasis (DocBold "灼眼のシャナ A") it "properly converts HTML escape sequences" $ do "/&#65;&#65;&#65;&#65;/" `shouldParseTo` DocEmphasis "AAAA" it "allows to escape the emphasis delimiter inside of emphasis" $ do "/empha\\/sis/" `shouldParseTo` DocEmphasis "empha/sis" context "when parsing monospaced text" $ do it "parses simple monospaced text" $ do "@foo@" `shouldParseTo` DocMonospaced "foo" it "parses inline monospaced text" $ do "foo @bar@ baz" `shouldParseTo` "foo " <> DocMonospaced "bar" <> " baz" it "allows to escape @" $ do "@foo \\@ bar@" `shouldParseTo` DocMonospaced "foo @ bar" it "accepts unicode" $ do "@foo 灼眼のシャナ bar@" `shouldParseTo` DocMonospaced "foo 灼眼のシャナ bar" it "accepts other markup in monospaced text" $ do "@/foo/@" `shouldParseTo` DocMonospaced (DocEmphasis "foo") it "requires the closing @" $ do "@foo /bar/ baz" `shouldParseTo` "@foo " <> DocEmphasis "bar" <> " baz" context "when parsing bold strings" $ do it "allows for a bold string on its own" $ do "__bold string__" `shouldParseTo` DocBold "bold string" it "bolds inline correctly" $ do "hello __everyone__ there" `shouldParseTo` "hello " <> DocBold "everyone" <> " there" it "bolds unicode" $ do "__灼眼のシャナ__" `shouldParseTo` DocBold "灼眼のシャナ" it "does not do __multi-line\\n bold__" $ do " __multi-line\n bold__" `shouldParseTo` "__multi-line\n bold__" it "allows other markup inside of bold" $ do "__/inner emphasis/__" `shouldParseTo` (DocBold $ DocEmphasis "inner emphasis") it "doesn't mangle inner markup unicode" $ do "__/灼眼のシャナ &#65;/__" `shouldParseTo` (DocBold $ DocEmphasis "灼眼のシャナ A") it "properly converts HTML escape sequences" $ do "__&#65;&#65;&#65;&#65;__" `shouldParseTo` DocBold "AAAA" it "allows to escape the bold delimiter inside of bold" $ do "__bo\\__ld__" `shouldParseTo` DocBold "bo__ld" it "doesn't allow for empty bold" $ do "____" `shouldParseTo` "____" context "when parsing module strings" $ do it "should parse a module on its own" $ do "\"Module\"" `shouldParseTo` DocModule "Module" it "should parse a module inline" $ do "This is a \"Module\"." `shouldParseTo` "This is a " <> DocModule "Module" <> "." it "can accept a simple module name" $ do "\"Hello\"" `shouldParseTo` DocModule "Hello" it "can accept a module name with dots" $ do "\"Hello.World\"" `shouldParseTo` DocModule "Hello.World" it "can accept a module name with unicode" $ do "\"Hello.Worldλ\"" `shouldParseTo` DocModule "Hello.Worldλ" it "parses a module name with a trailing dot as regular quoted string" $ do "\"Hello.\"" `shouldParseTo` "\"Hello.\"" it "parses a module name with a space as regular quoted string" $ do "\"Hello World\"" `shouldParseTo` "\"Hello World\"" it "parses a module name with invalid characters as regular quoted string" $ do "\"Hello&[{}(=*)+]!\"" `shouldParseTo` "\"Hello&[{}(=*)+]!\"" it "accepts a module name with unicode" $ do "\"Foo.Barλ\"" `shouldParseTo` DocModule "Foo.Barλ" it "treats empty module name as regular double quotes" $ do "\"\"" `shouldParseTo` "\"\"" it "accepts anchor reference syntax as DocModule" $ do "\"Foo#bar\"" `shouldParseTo` DocModule "Foo#bar" it "accepts old anchor reference syntax as DocModule" $ do "\"Foo\\#bar\"" `shouldParseTo` DocModule "Foo\\#bar" describe "parseParas" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc RdrName -> Expectation shouldParseTo input ast = parseParas input `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseParas) xs `shouldSatisfy` (> 0) context "when parsing text paragraphs" $ do let filterSpecial = filter (`notElem` (".(=#-[*`\v\f\n\t\r\\\"'_/@<> " :: String)) it "parses an empty paragraph" $ do "" `shouldParseTo` DocEmpty it "parses a simple text paragraph" $ do "foo bar baz" `shouldParseTo` DocParagraph "foo bar baz" it "accepts markup in text paragraphs" $ do "foo /bar/ baz" `shouldParseTo` DocParagraph ("foo " <> DocEmphasis "bar" <> " baz") it "preserve all regular characters" $ do property $ \xs -> let input = filterSpecial xs in (not . null) input ==> input `shouldParseTo` DocParagraph (DocString input) it "separates paragraphs by empty lines" $ do unlines [ "foo" , " \t " , "bar" ] `shouldParseTo` DocParagraph "foo" <> DocParagraph "bar" context "when a pragraph only contains monospaced text" $ do it "turns it into a code block" $ do "@foo@" `shouldParseTo` DocCodeBlock "foo" context "when parsing birdtracks" $ do it "parses them as a code block" $ do unlines [ ">foo" , ">bar" , ">baz" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz" it "ignores leading whitespace" $ do unlines [ " >foo" , " \t >bar" , " >baz" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz" it "strips one leading space from each line of the block" $ do unlines [ "> foo" , "> bar" , "> baz" ] `shouldParseTo` DocCodeBlock "foo\n bar\nbaz" it "ignores empty lines when stripping spaces" $ do unlines [ "> foo" , ">" , "> bar" ] `shouldParseTo` DocCodeBlock "foo\n\nbar" context "when any non-empty line does not start with a space" $ do it "does not strip any spaces" $ do unlines [ ">foo" , "> bar" ] `shouldParseTo` DocCodeBlock "foo\n bar" it "ignores nested markup" $ do unlines [ ">/foo/" ] `shouldParseTo` DocCodeBlock "/foo/" it "treats them as regular text inside text paragraphs" $ do unlines [ "foo" , ">bar" ] `shouldParseTo` DocParagraph "foo\n>bar" context "when parsing code blocks" $ do it "accepts a simple code block" $ do unlines [ "@" , "foo" , "bar" , "baz" , "@" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz\n" it "ignores trailing whitespace after the opening @" $ do unlines [ "@ " , "foo" , "@" ] `shouldParseTo` DocCodeBlock "foo\n" it "rejects code blocks that are not closed" $ do unlines [ "@" , "foo" ] `shouldParseTo` DocParagraph "@\nfoo" it "accepts nested markup" $ do unlines [ "@" , "/foo/" , "@" ] `shouldParseTo` DocCodeBlock (DocEmphasis "foo" <> "\n") it "allows to escape the @" $ do unlines [ "@" , "foo" , "\\@" , "bar" , "@" ] `shouldParseTo` DocCodeBlock "foo\n@\nbar\n" it "accepts horizontal space before the @" $ do unlines [ " @" , "foo" , "" , "bar" , "@" ] `shouldParseTo` DocCodeBlock "foo\n\nbar\n" it "strips a leading space from a @ block if present" $ do unlines [ " @" , " hello" , " world" , " @" ] `shouldParseTo` DocCodeBlock "hello\nworld\n" unlines [ " @" , " hello" , "" , " world" , " @" ] `shouldParseTo` DocCodeBlock "hello\n\nworld\n" it "only drops whitespace if there's some before closing @" $ do unlines [ "@" , " Formatting" , " matters." , "@" ] `shouldParseTo` DocCodeBlock " Formatting\n matters.\n" it "accepts unicode" $ do "@foo 灼眼のシャナ bar@" `shouldParseTo` DocCodeBlock "foo 灼眼のシャナ bar" it "requires the closing @" $ do "@foo /bar/ baz" `shouldParseTo` DocParagraph ("@foo " <> DocEmphasis "bar" <> " baz") context "when parsing examples" $ do it "parses a simple example" $ do ">>> foo" `shouldParseTo` DocExamples [Example "foo" []] it "parses an example with result" $ do unlines [ ">>> foo" , "bar" , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]] it "parses consecutive examples" $ do unlines [ ">>> fib 5" , "5" , ">>> fib 10" , "55" ] `shouldParseTo` DocExamples [ Example "fib 5" ["5"] , Example "fib 10" ["55"] ] it ("requires an example to be separated" ++ " from a previous paragraph by an empty line") $ do "foobar\n\n>>> fib 10\n55" `shouldParseTo` DocParagraph "foobar" <> DocExamples [Example "fib 10" ["55"]] it "parses bird-tracks inside of paragraphs as plain strings" $ do let xs = "foo\n>>> bar" xs `shouldParseTo` DocParagraph (DocString xs) it "skips empty lines in front of an example" $ do "\n \n\n>>> foo" `shouldParseTo` DocExamples [Example "foo" []] it "terminates example on empty line" $ do unlines [ ">>> foo" , "bar" , " " , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar"]] <> DocParagraph "baz" it "parses a <BLANKLINE> result as an empty result" $ do unlines [ ">>> foo" , "bar" , "<BLANKLINE>" , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "", "baz"]] it "accepts unicode in examples" $ do ">>> 灼眼\nシャナ" `shouldParseTo` DocExamples [Example "灼眼" ["シャナ"]] context "when prompt is prefixed by whitespace" $ do it "strips the exact same amount of whitespace from result lines" $ do unlines [ " >>> foo" , " bar" , " baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]] it "preserves additional whitespace" $ do unlines [ " >>> foo" , " bar" ] `shouldParseTo` DocExamples [Example "foo" [" bar"]] it "keeps original if stripping is not possible" $ do unlines [ " >>> foo" , " bar" ] `shouldParseTo` DocExamples [Example "foo" [" bar"]] context "when parsing paragraphs nested in lists" $ do it "can nest the same type of list" $ do "* foo\n\n * bar" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [DocParagraph "bar"]] it "can nest another type of list inside" $ do "* foo\n\n 1. bar" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocOrderedList [DocParagraph "bar"]] it "can nest a code block inside" $ do "* foo\n\n @foo bar baz@" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocCodeBlock "foo bar baz"] "* foo\n\n @\n foo bar baz\n @" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocCodeBlock "foo bar baz\n"] it "can nest more than one level" $ do "* foo\n\n * bar\n\n * baz\n qux" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph $ "bar" <> DocUnorderedList [DocParagraph "baz\nqux"] ] ] it "won't fail on not fully indented paragraph" $ do "* foo\n\n * bar\n\n * qux\nquux" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph "bar" ] , DocParagraph "qux\nquux"] it "can nest definition lists" $ do "[a] foo\n\n [b] bar\n\n [c] baz\n qux" `shouldParseTo` DocDefList [ ("a", "foo" <> DocDefList [ ("b", "bar" <> DocDefList [("c", "baz\nqux")]) ]) ] it "can come back to top level with a different list" $ do "* foo\n\n * bar\n\n1. baz" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph "bar" ] ] <> DocOrderedList [ DocParagraph "baz" ] it "definition lists can come back to top level with a different list" $ do "[foo] foov\n\n [bar] barv\n\n1. baz" `shouldParseTo` DocDefList [ ("foo", "foov" <> DocDefList [ ("bar", "barv") ]) ] <> DocOrderedList [ DocParagraph "baz" ] context "when parsing properties" $ do it "can parse a single property" $ do "prop> 23 == 23" `shouldParseTo` DocProperty "23 == 23" it "can parse multiple subsequent properties" $ do unlines [ "prop> 23 == 23" , "prop> 42 == 42" ] `shouldParseTo` DocProperty "23 == 23" <> DocProperty "42 == 42" it "accepts unicode in properties" $ do "prop> 灼眼のシャナ ≡ 愛" `shouldParseTo` DocProperty "灼眼のシャナ ≡ 愛" it "can deal with whitespace before and after the prop> prompt" $ do " prop> xs == (reverse $ reverse xs) " `shouldParseTo` DocProperty "xs == (reverse $ reverse xs)" context "when parsing unordered lists" $ do it "parses a simple list" $ do unlines [ " * one" , " * two" , " * three" ] `shouldParseTo` DocUnorderedList [ DocParagraph "one" , DocParagraph "two" , DocParagraph "three" ] it "ignores empty lines between list items" $ do unlines [ "* one" , "" , "* two" ] `shouldParseTo` DocUnorderedList [ DocParagraph "one" , DocParagraph "two" ] it "accepts an empty list item" $ do "*" `shouldParseTo` DocUnorderedList [DocParagraph DocEmpty] it "accepts multi-line list items" $ do unlines [ "* point one" , " more one" , "* point two" , "more two" ] `shouldParseTo` DocUnorderedList [ DocParagraph "point one\n more one" , DocParagraph "point two\nmore two" ] it "accepts markup in list items" $ do "* /foo/" `shouldParseTo` DocUnorderedList [DocParagraph (DocEmphasis "foo")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "* bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocUnorderedList [DocParagraph "bar"] <> DocParagraph "baz" context "when parsing ordered lists" $ do it "parses a simple list" $ do unlines [ " 1. one" , " (1) two" , " 3. three" ] `shouldParseTo` DocOrderedList [ DocParagraph "one" , DocParagraph "two" , DocParagraph "three" ] it "ignores empty lines between list items" $ do unlines [ "1. one" , "" , "2. two" ] `shouldParseTo` DocOrderedList [ DocParagraph "one" , DocParagraph "two" ] it "accepts an empty list item" $ do "1." `shouldParseTo` DocOrderedList [DocParagraph DocEmpty] it "accepts multi-line list items" $ do unlines [ "1. point one" , " more one" , "1. point two" , "more two" ] `shouldParseTo` DocOrderedList [ DocParagraph "point one\n more one" , DocParagraph "point two\nmore two" ] it "accepts markup in list items" $ do "1. /foo/" `shouldParseTo` DocOrderedList [DocParagraph (DocEmphasis "foo")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "1. bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocOrderedList [DocParagraph "bar"] <> DocParagraph "baz" context "when parsing definition lists" $ do it "parses a simple list" $ do unlines [ " [foo] one" , " [bar] two" , " [baz] three" ] `shouldParseTo` DocDefList [ ("foo", "one") , ("bar", "two") , ("baz", "three") ] it "ignores empty lines between list items" $ do unlines [ "[foo] one" , "" , "[bar] two" ] `shouldParseTo` DocDefList [ ("foo", "one") , ("bar", "two") ] it "accepts an empty list item" $ do "[foo]" `shouldParseTo` DocDefList [("foo", DocEmpty)] it "accepts multi-line list items" $ do unlines [ "[foo] point one" , " more one" , "[bar] point two" , "more two" ] `shouldParseTo` DocDefList [ ("foo", "point one\n more one") , ("bar", "point two\nmore two") ] it "accepts markup in list items" $ do "[foo] /foo/" `shouldParseTo` DocDefList [("foo", DocEmphasis "foo")] it "accepts markup for the label" $ do "[/foo/] bar" `shouldParseTo` DocDefList [(DocEmphasis "foo", "bar")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "[foo] bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocDefList [("foo", "bar")] <> DocParagraph "baz" context "when parsing consecutive paragraphs" $ do it "will not capture irrelevant consecutive lists" $ do unlines [ " * bullet" , "" , "" , " - different bullet" , "" , "" , " (1) ordered" , " " , " 2. different bullet" , " " , " [cat] kitten" , " " , " [pineapple] fruit" ] `shouldParseTo` DocUnorderedList [ DocParagraph "bullet" , DocParagraph "different bullet"] <> DocOrderedList [ DocParagraph "ordered" , DocParagraph "different bullet" ] <> DocDefList [ ("cat", "kitten") , ("pineapple", "fruit") ] context "when parsing function documentation headers" $ do it "can parse a simple header" $ do "= Header 1\nHello." `shouldParseTo` DocParagraph (DocHeader (Header 1 "Header 1")) <> DocParagraph "Hello." it "allow consecutive headers" $ do "= Header 1\n== Header 2" `shouldParseTo` DocParagraph (DocHeader (Header 1 "Header 1")) <> DocParagraph (DocHeader (Header 2 "Header 2")) it "accepts markup in the header" $ do "= /Header/ __1__\nFoo" `shouldParseTo` DocParagraph (DocHeader (Header 1 (DocEmphasis "Header" <> " " <> DocBold "1"))) <> DocParagraph "Foo"
27,355
spec :: Spec spec = before initStaticOpts $ do describe "parseString" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc RdrName -> Expectation shouldParseTo input ast = parseString input `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseString) xs `shouldSatisfy` (> 0) context "when parsing text" $ do it "can handle unicode" $ do "灼眼のシャナ" `shouldParseTo` "灼眼のシャナ" it "accepts numeric character references" $ do "foo b&#97;r b&#97;z &#955;" `shouldParseTo` "foo bar baz λ" it "accepts hexadecimal character references" $ do "&#x65;" `shouldParseTo` "e" it "allows to backslash-escape characters" $ do property $ \x -> ['\\', x] `shouldParseTo` DocString [x] context "when parsing strings contaning numeric character references" $ do it "will implicitly convert digits to characters" $ do "&#65;&#65;&#65;&#65;" `shouldParseTo` "AAAA" "&#28796;&#30524;&#12398;&#12471;&#12515;&#12490;" `shouldParseTo` "灼眼のシャナ" it "will implicitly convert hex encoded characters" $ do "&#x65;&#x65;&#x65;&#x65;" `shouldParseTo` "eeee" context "when parsing identifiers" $ do it "parses identifiers enclosed within single ticks" $ do "'foo'" `shouldParseTo` DocIdentifier "foo" it "parses identifiers enclosed within backticks" $ do "`foo`" `shouldParseTo` DocIdentifier "foo" it "parses a word with an one of the delimiters in it as DocString" $ do "don't" `shouldParseTo` "don't" it "doesn't pass pairs of delimiters with spaces between them" $ do "hel'lo w'orld" `shouldParseTo` "hel'lo w'orld" it "don't use apostrophe's in the wrong place's" $ do " don't use apostrophe's in the wrong place's" `shouldParseTo` "don't use apostrophe's in the wrong place's" context "when parsing URLs" $ do let hyperlink :: String -> Maybe String -> Doc RdrName hyperlink url = DocHyperlink . Hyperlink url it "parses a URL" $ do "<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing it "accepts an optional label" $ do "<http://example.com/ some link>" `shouldParseTo` hyperlink "http://example.com/" "some link" it "does not accept newlines in label" $ do "<foo bar\nbaz>" `shouldParseTo` "<foo bar\nbaz>" -- new behaviour test, this will be now consistent with other markup it "allows us to escape > inside the URL" $ do "<http://examp\\>le.com>" `shouldParseTo` hyperlink "http://examp>le.com" Nothing "<http://exa\\>mp\\>le.com>" `shouldParseTo` hyperlink "http://exa>mp>le.com" Nothing -- Likewise in label "<http://example.com f\\>oo>" `shouldParseTo` hyperlink "http://example.com" "f>oo" it "parses inline URLs" $ do "foo <http://example.com/> bar" `shouldParseTo` "foo " <> hyperlink "http://example.com/" Nothing <> " bar" it "doesn't allow for multi-line link tags" $ do "<ba\nz aar>" `shouldParseTo` "<ba\nz aar>" context "when autolinking URLs" $ do it "autolinks HTTP URLs" $ do "http://example.com/" `shouldParseTo` hyperlink "http://example.com/" Nothing it "autolinks HTTPS URLs" $ do "https://www.example.com/" `shouldParseTo` hyperlink "https://www.example.com/" Nothing it "autolinks FTP URLs" $ do "ftp://example.com/" `shouldParseTo` hyperlink "ftp://example.com/" Nothing it "does not include a trailing comma" $ do "http://example.com/, Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> ", Some other sentence." it "does not include a trailing dot" $ do "http://example.com/. Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> ". Some other sentence." it "does not include a trailing exclamation mark" $ do "http://example.com/! Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> "! Some other sentence." it "does not include a trailing question mark" $ do "http://example.com/? Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> "? Some other sentence." context "when parsing pictures" $ do let picture :: String -> Maybe String -> Doc RdrName picture uri = DocPic . Picture uri it "parses a simple picture" $ do "<<baz>>" `shouldParseTo` picture "baz" Nothing it "parses a picture with a title" $ do "<<b a z>>" `shouldParseTo` picture "b" (Just "a z") it "parses a picture with unicode" $ do "<<灼眼のシャナ>>" `shouldParseTo` picture "灼眼のシャナ" Nothing it "allows for escaping of the closing tags" $ do "<<ba\\>>z>>" `shouldParseTo` picture "ba>>z" Nothing it "doesn't allow for multi-line picture tags" $ do "<<ba\nz aar>>" `shouldParseTo` "<<ba\nz aar>>" context "when parsing anchors" $ do it "parses a single word anchor" $ do "#foo#" `shouldParseTo` DocAName "foo" it "parses a multi word anchor" $ do "#foo bar#" `shouldParseTo` DocAName "foo bar" it "parses a unicode anchor" $ do "#灼眼のシャナ#" `shouldParseTo` DocAName "灼眼のシャナ" it "does not accept newlines in anchors" $ do "#foo\nbar#" `shouldParseTo` "#foo\nbar#" it "accepts anchors mid-paragraph" $ do "Hello #someAnchor# world!" `shouldParseTo` "Hello " <> DocAName "someAnchor" <> " world!" it "does not accept empty anchors" $ do "##" `shouldParseTo` "##" context "when parsing emphasised text" $ do it "emphasises a word on its own" $ do "/foo/" `shouldParseTo` DocEmphasis "foo" it "emphasises inline correctly" $ do "foo /bar/ baz" `shouldParseTo` "foo " <> DocEmphasis "bar" <> " baz" it "emphasises unicode" $ do "/灼眼のシャナ/" `shouldParseTo` DocEmphasis "灼眼のシャナ" it "does not emphasise multi-line strings" $ do " /foo\nbar/" `shouldParseTo` "/foo\nbar/" it "does not emphasise the empty string" $ do "//" `shouldParseTo` "//" it "parses escaped slashes literally" $ do "/foo\\/bar/" `shouldParseTo` DocEmphasis "foo/bar" it "recognizes other markup constructs within emphasised text" $ do "/foo @bar@ baz/" `shouldParseTo` DocEmphasis ("foo " <> DocMonospaced "bar" <> " baz") it "allows other markup inside of emphasis" $ do "/__inner bold__/" `shouldParseTo` DocEmphasis (DocBold "inner bold") it "doesn't mangle inner markup unicode" $ do "/__灼眼のシャナ &#65;__/" `shouldParseTo` DocEmphasis (DocBold "灼眼のシャナ A") it "properly converts HTML escape sequences" $ do "/&#65;&#65;&#65;&#65;/" `shouldParseTo` DocEmphasis "AAAA" it "allows to escape the emphasis delimiter inside of emphasis" $ do "/empha\\/sis/" `shouldParseTo` DocEmphasis "empha/sis" context "when parsing monospaced text" $ do it "parses simple monospaced text" $ do "@foo@" `shouldParseTo` DocMonospaced "foo" it "parses inline monospaced text" $ do "foo @bar@ baz" `shouldParseTo` "foo " <> DocMonospaced "bar" <> " baz" it "allows to escape @" $ do "@foo \\@ bar@" `shouldParseTo` DocMonospaced "foo @ bar" it "accepts unicode" $ do "@foo 灼眼のシャナ bar@" `shouldParseTo` DocMonospaced "foo 灼眼のシャナ bar" it "accepts other markup in monospaced text" $ do "@/foo/@" `shouldParseTo` DocMonospaced (DocEmphasis "foo") it "requires the closing @" $ do "@foo /bar/ baz" `shouldParseTo` "@foo " <> DocEmphasis "bar" <> " baz" context "when parsing bold strings" $ do it "allows for a bold string on its own" $ do "__bold string__" `shouldParseTo` DocBold "bold string" it "bolds inline correctly" $ do "hello __everyone__ there" `shouldParseTo` "hello " <> DocBold "everyone" <> " there" it "bolds unicode" $ do "__灼眼のシャナ__" `shouldParseTo` DocBold "灼眼のシャナ" it "does not do __multi-line\\n bold__" $ do " __multi-line\n bold__" `shouldParseTo` "__multi-line\n bold__" it "allows other markup inside of bold" $ do "__/inner emphasis/__" `shouldParseTo` (DocBold $ DocEmphasis "inner emphasis") it "doesn't mangle inner markup unicode" $ do "__/灼眼のシャナ &#65;/__" `shouldParseTo` (DocBold $ DocEmphasis "灼眼のシャナ A") it "properly converts HTML escape sequences" $ do "__&#65;&#65;&#65;&#65;__" `shouldParseTo` DocBold "AAAA" it "allows to escape the bold delimiter inside of bold" $ do "__bo\\__ld__" `shouldParseTo` DocBold "bo__ld" it "doesn't allow for empty bold" $ do "____" `shouldParseTo` "____" context "when parsing module strings" $ do it "should parse a module on its own" $ do "\"Module\"" `shouldParseTo` DocModule "Module" it "should parse a module inline" $ do "This is a \"Module\"." `shouldParseTo` "This is a " <> DocModule "Module" <> "." it "can accept a simple module name" $ do "\"Hello\"" `shouldParseTo` DocModule "Hello" it "can accept a module name with dots" $ do "\"Hello.World\"" `shouldParseTo` DocModule "Hello.World" it "can accept a module name with unicode" $ do "\"Hello.Worldλ\"" `shouldParseTo` DocModule "Hello.Worldλ" it "parses a module name with a trailing dot as regular quoted string" $ do "\"Hello.\"" `shouldParseTo` "\"Hello.\"" it "parses a module name with a space as regular quoted string" $ do "\"Hello World\"" `shouldParseTo` "\"Hello World\"" it "parses a module name with invalid characters as regular quoted string" $ do "\"Hello&[{}(=*)+]!\"" `shouldParseTo` "\"Hello&[{}(=*)+]!\"" it "accepts a module name with unicode" $ do "\"Foo.Barλ\"" `shouldParseTo` DocModule "Foo.Barλ" it "treats empty module name as regular double quotes" $ do "\"\"" `shouldParseTo` "\"\"" it "accepts anchor reference syntax as DocModule" $ do "\"Foo#bar\"" `shouldParseTo` DocModule "Foo#bar" it "accepts old anchor reference syntax as DocModule" $ do "\"Foo\\#bar\"" `shouldParseTo` DocModule "Foo\\#bar" describe "parseParas" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc RdrName -> Expectation shouldParseTo input ast = parseParas input `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseParas) xs `shouldSatisfy` (> 0) context "when parsing text paragraphs" $ do let filterSpecial = filter (`notElem` (".(=#-[*`\v\f\n\t\r\\\"'_/@<> " :: String)) it "parses an empty paragraph" $ do "" `shouldParseTo` DocEmpty it "parses a simple text paragraph" $ do "foo bar baz" `shouldParseTo` DocParagraph "foo bar baz" it "accepts markup in text paragraphs" $ do "foo /bar/ baz" `shouldParseTo` DocParagraph ("foo " <> DocEmphasis "bar" <> " baz") it "preserve all regular characters" $ do property $ \xs -> let input = filterSpecial xs in (not . null) input ==> input `shouldParseTo` DocParagraph (DocString input) it "separates paragraphs by empty lines" $ do unlines [ "foo" , " \t " , "bar" ] `shouldParseTo` DocParagraph "foo" <> DocParagraph "bar" context "when a pragraph only contains monospaced text" $ do it "turns it into a code block" $ do "@foo@" `shouldParseTo` DocCodeBlock "foo" context "when parsing birdtracks" $ do it "parses them as a code block" $ do unlines [ ">foo" , ">bar" , ">baz" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz" it "ignores leading whitespace" $ do unlines [ " >foo" , " \t >bar" , " >baz" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz" it "strips one leading space from each line of the block" $ do unlines [ "> foo" , "> bar" , "> baz" ] `shouldParseTo` DocCodeBlock "foo\n bar\nbaz" it "ignores empty lines when stripping spaces" $ do unlines [ "> foo" , ">" , "> bar" ] `shouldParseTo` DocCodeBlock "foo\n\nbar" context "when any non-empty line does not start with a space" $ do it "does not strip any spaces" $ do unlines [ ">foo" , "> bar" ] `shouldParseTo` DocCodeBlock "foo\n bar" it "ignores nested markup" $ do unlines [ ">/foo/" ] `shouldParseTo` DocCodeBlock "/foo/" it "treats them as regular text inside text paragraphs" $ do unlines [ "foo" , ">bar" ] `shouldParseTo` DocParagraph "foo\n>bar" context "when parsing code blocks" $ do it "accepts a simple code block" $ do unlines [ "@" , "foo" , "bar" , "baz" , "@" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz\n" it "ignores trailing whitespace after the opening @" $ do unlines [ "@ " , "foo" , "@" ] `shouldParseTo` DocCodeBlock "foo\n" it "rejects code blocks that are not closed" $ do unlines [ "@" , "foo" ] `shouldParseTo` DocParagraph "@\nfoo" it "accepts nested markup" $ do unlines [ "@" , "/foo/" , "@" ] `shouldParseTo` DocCodeBlock (DocEmphasis "foo" <> "\n") it "allows to escape the @" $ do unlines [ "@" , "foo" , "\\@" , "bar" , "@" ] `shouldParseTo` DocCodeBlock "foo\n@\nbar\n" it "accepts horizontal space before the @" $ do unlines [ " @" , "foo" , "" , "bar" , "@" ] `shouldParseTo` DocCodeBlock "foo\n\nbar\n" it "strips a leading space from a @ block if present" $ do unlines [ " @" , " hello" , " world" , " @" ] `shouldParseTo` DocCodeBlock "hello\nworld\n" unlines [ " @" , " hello" , "" , " world" , " @" ] `shouldParseTo` DocCodeBlock "hello\n\nworld\n" it "only drops whitespace if there's some before closing @" $ do unlines [ "@" , " Formatting" , " matters." , "@" ] `shouldParseTo` DocCodeBlock " Formatting\n matters.\n" it "accepts unicode" $ do "@foo 灼眼のシャナ bar@" `shouldParseTo` DocCodeBlock "foo 灼眼のシャナ bar" it "requires the closing @" $ do "@foo /bar/ baz" `shouldParseTo` DocParagraph ("@foo " <> DocEmphasis "bar" <> " baz") context "when parsing examples" $ do it "parses a simple example" $ do ">>> foo" `shouldParseTo` DocExamples [Example "foo" []] it "parses an example with result" $ do unlines [ ">>> foo" , "bar" , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]] it "parses consecutive examples" $ do unlines [ ">>> fib 5" , "5" , ">>> fib 10" , "55" ] `shouldParseTo` DocExamples [ Example "fib 5" ["5"] , Example "fib 10" ["55"] ] it ("requires an example to be separated" ++ " from a previous paragraph by an empty line") $ do "foobar\n\n>>> fib 10\n55" `shouldParseTo` DocParagraph "foobar" <> DocExamples [Example "fib 10" ["55"]] it "parses bird-tracks inside of paragraphs as plain strings" $ do let xs = "foo\n>>> bar" xs `shouldParseTo` DocParagraph (DocString xs) it "skips empty lines in front of an example" $ do "\n \n\n>>> foo" `shouldParseTo` DocExamples [Example "foo" []] it "terminates example on empty line" $ do unlines [ ">>> foo" , "bar" , " " , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar"]] <> DocParagraph "baz" it "parses a <BLANKLINE> result as an empty result" $ do unlines [ ">>> foo" , "bar" , "<BLANKLINE>" , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "", "baz"]] it "accepts unicode in examples" $ do ">>> 灼眼\nシャナ" `shouldParseTo` DocExamples [Example "灼眼" ["シャナ"]] context "when prompt is prefixed by whitespace" $ do it "strips the exact same amount of whitespace from result lines" $ do unlines [ " >>> foo" , " bar" , " baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]] it "preserves additional whitespace" $ do unlines [ " >>> foo" , " bar" ] `shouldParseTo` DocExamples [Example "foo" [" bar"]] it "keeps original if stripping is not possible" $ do unlines [ " >>> foo" , " bar" ] `shouldParseTo` DocExamples [Example "foo" [" bar"]] context "when parsing paragraphs nested in lists" $ do it "can nest the same type of list" $ do "* foo\n\n * bar" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [DocParagraph "bar"]] it "can nest another type of list inside" $ do "* foo\n\n 1. bar" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocOrderedList [DocParagraph "bar"]] it "can nest a code block inside" $ do "* foo\n\n @foo bar baz@" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocCodeBlock "foo bar baz"] "* foo\n\n @\n foo bar baz\n @" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocCodeBlock "foo bar baz\n"] it "can nest more than one level" $ do "* foo\n\n * bar\n\n * baz\n qux" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph $ "bar" <> DocUnorderedList [DocParagraph "baz\nqux"] ] ] it "won't fail on not fully indented paragraph" $ do "* foo\n\n * bar\n\n * qux\nquux" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph "bar" ] , DocParagraph "qux\nquux"] it "can nest definition lists" $ do "[a] foo\n\n [b] bar\n\n [c] baz\n qux" `shouldParseTo` DocDefList [ ("a", "foo" <> DocDefList [ ("b", "bar" <> DocDefList [("c", "baz\nqux")]) ]) ] it "can come back to top level with a different list" $ do "* foo\n\n * bar\n\n1. baz" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph "bar" ] ] <> DocOrderedList [ DocParagraph "baz" ] it "definition lists can come back to top level with a different list" $ do "[foo] foov\n\n [bar] barv\n\n1. baz" `shouldParseTo` DocDefList [ ("foo", "foov" <> DocDefList [ ("bar", "barv") ]) ] <> DocOrderedList [ DocParagraph "baz" ] context "when parsing properties" $ do it "can parse a single property" $ do "prop> 23 == 23" `shouldParseTo` DocProperty "23 == 23" it "can parse multiple subsequent properties" $ do unlines [ "prop> 23 == 23" , "prop> 42 == 42" ] `shouldParseTo` DocProperty "23 == 23" <> DocProperty "42 == 42" it "accepts unicode in properties" $ do "prop> 灼眼のシャナ ≡ 愛" `shouldParseTo` DocProperty "灼眼のシャナ ≡ 愛" it "can deal with whitespace before and after the prop> prompt" $ do " prop> xs == (reverse $ reverse xs) " `shouldParseTo` DocProperty "xs == (reverse $ reverse xs)" context "when parsing unordered lists" $ do it "parses a simple list" $ do unlines [ " * one" , " * two" , " * three" ] `shouldParseTo` DocUnorderedList [ DocParagraph "one" , DocParagraph "two" , DocParagraph "three" ] it "ignores empty lines between list items" $ do unlines [ "* one" , "" , "* two" ] `shouldParseTo` DocUnorderedList [ DocParagraph "one" , DocParagraph "two" ] it "accepts an empty list item" $ do "*" `shouldParseTo` DocUnorderedList [DocParagraph DocEmpty] it "accepts multi-line list items" $ do unlines [ "* point one" , " more one" , "* point two" , "more two" ] `shouldParseTo` DocUnorderedList [ DocParagraph "point one\n more one" , DocParagraph "point two\nmore two" ] it "accepts markup in list items" $ do "* /foo/" `shouldParseTo` DocUnorderedList [DocParagraph (DocEmphasis "foo")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "* bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocUnorderedList [DocParagraph "bar"] <> DocParagraph "baz" context "when parsing ordered lists" $ do it "parses a simple list" $ do unlines [ " 1. one" , " (1) two" , " 3. three" ] `shouldParseTo` DocOrderedList [ DocParagraph "one" , DocParagraph "two" , DocParagraph "three" ] it "ignores empty lines between list items" $ do unlines [ "1. one" , "" , "2. two" ] `shouldParseTo` DocOrderedList [ DocParagraph "one" , DocParagraph "two" ] it "accepts an empty list item" $ do "1." `shouldParseTo` DocOrderedList [DocParagraph DocEmpty] it "accepts multi-line list items" $ do unlines [ "1. point one" , " more one" , "1. point two" , "more two" ] `shouldParseTo` DocOrderedList [ DocParagraph "point one\n more one" , DocParagraph "point two\nmore two" ] it "accepts markup in list items" $ do "1. /foo/" `shouldParseTo` DocOrderedList [DocParagraph (DocEmphasis "foo")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "1. bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocOrderedList [DocParagraph "bar"] <> DocParagraph "baz" context "when parsing definition lists" $ do it "parses a simple list" $ do unlines [ " [foo] one" , " [bar] two" , " [baz] three" ] `shouldParseTo` DocDefList [ ("foo", "one") , ("bar", "two") , ("baz", "three") ] it "ignores empty lines between list items" $ do unlines [ "[foo] one" , "" , "[bar] two" ] `shouldParseTo` DocDefList [ ("foo", "one") , ("bar", "two") ] it "accepts an empty list item" $ do "[foo]" `shouldParseTo` DocDefList [("foo", DocEmpty)] it "accepts multi-line list items" $ do unlines [ "[foo] point one" , " more one" , "[bar] point two" , "more two" ] `shouldParseTo` DocDefList [ ("foo", "point one\n more one") , ("bar", "point two\nmore two") ] it "accepts markup in list items" $ do "[foo] /foo/" `shouldParseTo` DocDefList [("foo", DocEmphasis "foo")] it "accepts markup for the label" $ do "[/foo/] bar" `shouldParseTo` DocDefList [(DocEmphasis "foo", "bar")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "[foo] bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocDefList [("foo", "bar")] <> DocParagraph "baz" context "when parsing consecutive paragraphs" $ do it "will not capture irrelevant consecutive lists" $ do unlines [ " * bullet" , "" , "" , " - different bullet" , "" , "" , " (1) ordered" , " " , " 2. different bullet" , " " , " [cat] kitten" , " " , " [pineapple] fruit" ] `shouldParseTo` DocUnorderedList [ DocParagraph "bullet" , DocParagraph "different bullet"] <> DocOrderedList [ DocParagraph "ordered" , DocParagraph "different bullet" ] <> DocDefList [ ("cat", "kitten") , ("pineapple", "fruit") ] context "when parsing function documentation headers" $ do it "can parse a simple header" $ do "= Header 1\nHello." `shouldParseTo` DocParagraph (DocHeader (Header 1 "Header 1")) <> DocParagraph "Hello." it "allow consecutive headers" $ do "= Header 1\n== Header 2" `shouldParseTo` DocParagraph (DocHeader (Header 1 "Header 1")) <> DocParagraph (DocHeader (Header 2 "Header 2")) it "accepts markup in the header" $ do "= /Header/ __1__\nFoo" `shouldParseTo` DocParagraph (DocHeader (Header 1 (DocEmphasis "Header" <> " " <> DocBold "1"))) <> DocParagraph "Foo"
27,355
spec = before initStaticOpts $ do describe "parseString" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc RdrName -> Expectation shouldParseTo input ast = parseString input `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseString) xs `shouldSatisfy` (> 0) context "when parsing text" $ do it "can handle unicode" $ do "灼眼のシャナ" `shouldParseTo` "灼眼のシャナ" it "accepts numeric character references" $ do "foo b&#97;r b&#97;z &#955;" `shouldParseTo` "foo bar baz λ" it "accepts hexadecimal character references" $ do "&#x65;" `shouldParseTo` "e" it "allows to backslash-escape characters" $ do property $ \x -> ['\\', x] `shouldParseTo` DocString [x] context "when parsing strings contaning numeric character references" $ do it "will implicitly convert digits to characters" $ do "&#65;&#65;&#65;&#65;" `shouldParseTo` "AAAA" "&#28796;&#30524;&#12398;&#12471;&#12515;&#12490;" `shouldParseTo` "灼眼のシャナ" it "will implicitly convert hex encoded characters" $ do "&#x65;&#x65;&#x65;&#x65;" `shouldParseTo` "eeee" context "when parsing identifiers" $ do it "parses identifiers enclosed within single ticks" $ do "'foo'" `shouldParseTo` DocIdentifier "foo" it "parses identifiers enclosed within backticks" $ do "`foo`" `shouldParseTo` DocIdentifier "foo" it "parses a word with an one of the delimiters in it as DocString" $ do "don't" `shouldParseTo` "don't" it "doesn't pass pairs of delimiters with spaces between them" $ do "hel'lo w'orld" `shouldParseTo` "hel'lo w'orld" it "don't use apostrophe's in the wrong place's" $ do " don't use apostrophe's in the wrong place's" `shouldParseTo` "don't use apostrophe's in the wrong place's" context "when parsing URLs" $ do let hyperlink :: String -> Maybe String -> Doc RdrName hyperlink url = DocHyperlink . Hyperlink url it "parses a URL" $ do "<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing it "accepts an optional label" $ do "<http://example.com/ some link>" `shouldParseTo` hyperlink "http://example.com/" "some link" it "does not accept newlines in label" $ do "<foo bar\nbaz>" `shouldParseTo` "<foo bar\nbaz>" -- new behaviour test, this will be now consistent with other markup it "allows us to escape > inside the URL" $ do "<http://examp\\>le.com>" `shouldParseTo` hyperlink "http://examp>le.com" Nothing "<http://exa\\>mp\\>le.com>" `shouldParseTo` hyperlink "http://exa>mp>le.com" Nothing -- Likewise in label "<http://example.com f\\>oo>" `shouldParseTo` hyperlink "http://example.com" "f>oo" it "parses inline URLs" $ do "foo <http://example.com/> bar" `shouldParseTo` "foo " <> hyperlink "http://example.com/" Nothing <> " bar" it "doesn't allow for multi-line link tags" $ do "<ba\nz aar>" `shouldParseTo` "<ba\nz aar>" context "when autolinking URLs" $ do it "autolinks HTTP URLs" $ do "http://example.com/" `shouldParseTo` hyperlink "http://example.com/" Nothing it "autolinks HTTPS URLs" $ do "https://www.example.com/" `shouldParseTo` hyperlink "https://www.example.com/" Nothing it "autolinks FTP URLs" $ do "ftp://example.com/" `shouldParseTo` hyperlink "ftp://example.com/" Nothing it "does not include a trailing comma" $ do "http://example.com/, Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> ", Some other sentence." it "does not include a trailing dot" $ do "http://example.com/. Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> ". Some other sentence." it "does not include a trailing exclamation mark" $ do "http://example.com/! Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> "! Some other sentence." it "does not include a trailing question mark" $ do "http://example.com/? Some other sentence." `shouldParseTo` hyperlink "http://example.com/" Nothing <> "? Some other sentence." context "when parsing pictures" $ do let picture :: String -> Maybe String -> Doc RdrName picture uri = DocPic . Picture uri it "parses a simple picture" $ do "<<baz>>" `shouldParseTo` picture "baz" Nothing it "parses a picture with a title" $ do "<<b a z>>" `shouldParseTo` picture "b" (Just "a z") it "parses a picture with unicode" $ do "<<灼眼のシャナ>>" `shouldParseTo` picture "灼眼のシャナ" Nothing it "allows for escaping of the closing tags" $ do "<<ba\\>>z>>" `shouldParseTo` picture "ba>>z" Nothing it "doesn't allow for multi-line picture tags" $ do "<<ba\nz aar>>" `shouldParseTo` "<<ba\nz aar>>" context "when parsing anchors" $ do it "parses a single word anchor" $ do "#foo#" `shouldParseTo` DocAName "foo" it "parses a multi word anchor" $ do "#foo bar#" `shouldParseTo` DocAName "foo bar" it "parses a unicode anchor" $ do "#灼眼のシャナ#" `shouldParseTo` DocAName "灼眼のシャナ" it "does not accept newlines in anchors" $ do "#foo\nbar#" `shouldParseTo` "#foo\nbar#" it "accepts anchors mid-paragraph" $ do "Hello #someAnchor# world!" `shouldParseTo` "Hello " <> DocAName "someAnchor" <> " world!" it "does not accept empty anchors" $ do "##" `shouldParseTo` "##" context "when parsing emphasised text" $ do it "emphasises a word on its own" $ do "/foo/" `shouldParseTo` DocEmphasis "foo" it "emphasises inline correctly" $ do "foo /bar/ baz" `shouldParseTo` "foo " <> DocEmphasis "bar" <> " baz" it "emphasises unicode" $ do "/灼眼のシャナ/" `shouldParseTo` DocEmphasis "灼眼のシャナ" it "does not emphasise multi-line strings" $ do " /foo\nbar/" `shouldParseTo` "/foo\nbar/" it "does not emphasise the empty string" $ do "//" `shouldParseTo` "//" it "parses escaped slashes literally" $ do "/foo\\/bar/" `shouldParseTo` DocEmphasis "foo/bar" it "recognizes other markup constructs within emphasised text" $ do "/foo @bar@ baz/" `shouldParseTo` DocEmphasis ("foo " <> DocMonospaced "bar" <> " baz") it "allows other markup inside of emphasis" $ do "/__inner bold__/" `shouldParseTo` DocEmphasis (DocBold "inner bold") it "doesn't mangle inner markup unicode" $ do "/__灼眼のシャナ &#65;__/" `shouldParseTo` DocEmphasis (DocBold "灼眼のシャナ A") it "properly converts HTML escape sequences" $ do "/&#65;&#65;&#65;&#65;/" `shouldParseTo` DocEmphasis "AAAA" it "allows to escape the emphasis delimiter inside of emphasis" $ do "/empha\\/sis/" `shouldParseTo` DocEmphasis "empha/sis" context "when parsing monospaced text" $ do it "parses simple monospaced text" $ do "@foo@" `shouldParseTo` DocMonospaced "foo" it "parses inline monospaced text" $ do "foo @bar@ baz" `shouldParseTo` "foo " <> DocMonospaced "bar" <> " baz" it "allows to escape @" $ do "@foo \\@ bar@" `shouldParseTo` DocMonospaced "foo @ bar" it "accepts unicode" $ do "@foo 灼眼のシャナ bar@" `shouldParseTo` DocMonospaced "foo 灼眼のシャナ bar" it "accepts other markup in monospaced text" $ do "@/foo/@" `shouldParseTo` DocMonospaced (DocEmphasis "foo") it "requires the closing @" $ do "@foo /bar/ baz" `shouldParseTo` "@foo " <> DocEmphasis "bar" <> " baz" context "when parsing bold strings" $ do it "allows for a bold string on its own" $ do "__bold string__" `shouldParseTo` DocBold "bold string" it "bolds inline correctly" $ do "hello __everyone__ there" `shouldParseTo` "hello " <> DocBold "everyone" <> " there" it "bolds unicode" $ do "__灼眼のシャナ__" `shouldParseTo` DocBold "灼眼のシャナ" it "does not do __multi-line\\n bold__" $ do " __multi-line\n bold__" `shouldParseTo` "__multi-line\n bold__" it "allows other markup inside of bold" $ do "__/inner emphasis/__" `shouldParseTo` (DocBold $ DocEmphasis "inner emphasis") it "doesn't mangle inner markup unicode" $ do "__/灼眼のシャナ &#65;/__" `shouldParseTo` (DocBold $ DocEmphasis "灼眼のシャナ A") it "properly converts HTML escape sequences" $ do "__&#65;&#65;&#65;&#65;__" `shouldParseTo` DocBold "AAAA" it "allows to escape the bold delimiter inside of bold" $ do "__bo\\__ld__" `shouldParseTo` DocBold "bo__ld" it "doesn't allow for empty bold" $ do "____" `shouldParseTo` "____" context "when parsing module strings" $ do it "should parse a module on its own" $ do "\"Module\"" `shouldParseTo` DocModule "Module" it "should parse a module inline" $ do "This is a \"Module\"." `shouldParseTo` "This is a " <> DocModule "Module" <> "." it "can accept a simple module name" $ do "\"Hello\"" `shouldParseTo` DocModule "Hello" it "can accept a module name with dots" $ do "\"Hello.World\"" `shouldParseTo` DocModule "Hello.World" it "can accept a module name with unicode" $ do "\"Hello.Worldλ\"" `shouldParseTo` DocModule "Hello.Worldλ" it "parses a module name with a trailing dot as regular quoted string" $ do "\"Hello.\"" `shouldParseTo` "\"Hello.\"" it "parses a module name with a space as regular quoted string" $ do "\"Hello World\"" `shouldParseTo` "\"Hello World\"" it "parses a module name with invalid characters as regular quoted string" $ do "\"Hello&[{}(=*)+]!\"" `shouldParseTo` "\"Hello&[{}(=*)+]!\"" it "accepts a module name with unicode" $ do "\"Foo.Barλ\"" `shouldParseTo` DocModule "Foo.Barλ" it "treats empty module name as regular double quotes" $ do "\"\"" `shouldParseTo` "\"\"" it "accepts anchor reference syntax as DocModule" $ do "\"Foo#bar\"" `shouldParseTo` DocModule "Foo#bar" it "accepts old anchor reference syntax as DocModule" $ do "\"Foo\\#bar\"" `shouldParseTo` DocModule "Foo\\#bar" describe "parseParas" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc RdrName -> Expectation shouldParseTo input ast = parseParas input `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseParas) xs `shouldSatisfy` (> 0) context "when parsing text paragraphs" $ do let filterSpecial = filter (`notElem` (".(=#-[*`\v\f\n\t\r\\\"'_/@<> " :: String)) it "parses an empty paragraph" $ do "" `shouldParseTo` DocEmpty it "parses a simple text paragraph" $ do "foo bar baz" `shouldParseTo` DocParagraph "foo bar baz" it "accepts markup in text paragraphs" $ do "foo /bar/ baz" `shouldParseTo` DocParagraph ("foo " <> DocEmphasis "bar" <> " baz") it "preserve all regular characters" $ do property $ \xs -> let input = filterSpecial xs in (not . null) input ==> input `shouldParseTo` DocParagraph (DocString input) it "separates paragraphs by empty lines" $ do unlines [ "foo" , " \t " , "bar" ] `shouldParseTo` DocParagraph "foo" <> DocParagraph "bar" context "when a pragraph only contains monospaced text" $ do it "turns it into a code block" $ do "@foo@" `shouldParseTo` DocCodeBlock "foo" context "when parsing birdtracks" $ do it "parses them as a code block" $ do unlines [ ">foo" , ">bar" , ">baz" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz" it "ignores leading whitespace" $ do unlines [ " >foo" , " \t >bar" , " >baz" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz" it "strips one leading space from each line of the block" $ do unlines [ "> foo" , "> bar" , "> baz" ] `shouldParseTo` DocCodeBlock "foo\n bar\nbaz" it "ignores empty lines when stripping spaces" $ do unlines [ "> foo" , ">" , "> bar" ] `shouldParseTo` DocCodeBlock "foo\n\nbar" context "when any non-empty line does not start with a space" $ do it "does not strip any spaces" $ do unlines [ ">foo" , "> bar" ] `shouldParseTo` DocCodeBlock "foo\n bar" it "ignores nested markup" $ do unlines [ ">/foo/" ] `shouldParseTo` DocCodeBlock "/foo/" it "treats them as regular text inside text paragraphs" $ do unlines [ "foo" , ">bar" ] `shouldParseTo` DocParagraph "foo\n>bar" context "when parsing code blocks" $ do it "accepts a simple code block" $ do unlines [ "@" , "foo" , "bar" , "baz" , "@" ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz\n" it "ignores trailing whitespace after the opening @" $ do unlines [ "@ " , "foo" , "@" ] `shouldParseTo` DocCodeBlock "foo\n" it "rejects code blocks that are not closed" $ do unlines [ "@" , "foo" ] `shouldParseTo` DocParagraph "@\nfoo" it "accepts nested markup" $ do unlines [ "@" , "/foo/" , "@" ] `shouldParseTo` DocCodeBlock (DocEmphasis "foo" <> "\n") it "allows to escape the @" $ do unlines [ "@" , "foo" , "\\@" , "bar" , "@" ] `shouldParseTo` DocCodeBlock "foo\n@\nbar\n" it "accepts horizontal space before the @" $ do unlines [ " @" , "foo" , "" , "bar" , "@" ] `shouldParseTo` DocCodeBlock "foo\n\nbar\n" it "strips a leading space from a @ block if present" $ do unlines [ " @" , " hello" , " world" , " @" ] `shouldParseTo` DocCodeBlock "hello\nworld\n" unlines [ " @" , " hello" , "" , " world" , " @" ] `shouldParseTo` DocCodeBlock "hello\n\nworld\n" it "only drops whitespace if there's some before closing @" $ do unlines [ "@" , " Formatting" , " matters." , "@" ] `shouldParseTo` DocCodeBlock " Formatting\n matters.\n" it "accepts unicode" $ do "@foo 灼眼のシャナ bar@" `shouldParseTo` DocCodeBlock "foo 灼眼のシャナ bar" it "requires the closing @" $ do "@foo /bar/ baz" `shouldParseTo` DocParagraph ("@foo " <> DocEmphasis "bar" <> " baz") context "when parsing examples" $ do it "parses a simple example" $ do ">>> foo" `shouldParseTo` DocExamples [Example "foo" []] it "parses an example with result" $ do unlines [ ">>> foo" , "bar" , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]] it "parses consecutive examples" $ do unlines [ ">>> fib 5" , "5" , ">>> fib 10" , "55" ] `shouldParseTo` DocExamples [ Example "fib 5" ["5"] , Example "fib 10" ["55"] ] it ("requires an example to be separated" ++ " from a previous paragraph by an empty line") $ do "foobar\n\n>>> fib 10\n55" `shouldParseTo` DocParagraph "foobar" <> DocExamples [Example "fib 10" ["55"]] it "parses bird-tracks inside of paragraphs as plain strings" $ do let xs = "foo\n>>> bar" xs `shouldParseTo` DocParagraph (DocString xs) it "skips empty lines in front of an example" $ do "\n \n\n>>> foo" `shouldParseTo` DocExamples [Example "foo" []] it "terminates example on empty line" $ do unlines [ ">>> foo" , "bar" , " " , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar"]] <> DocParagraph "baz" it "parses a <BLANKLINE> result as an empty result" $ do unlines [ ">>> foo" , "bar" , "<BLANKLINE>" , "baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "", "baz"]] it "accepts unicode in examples" $ do ">>> 灼眼\nシャナ" `shouldParseTo` DocExamples [Example "灼眼" ["シャナ"]] context "when prompt is prefixed by whitespace" $ do it "strips the exact same amount of whitespace from result lines" $ do unlines [ " >>> foo" , " bar" , " baz" ] `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]] it "preserves additional whitespace" $ do unlines [ " >>> foo" , " bar" ] `shouldParseTo` DocExamples [Example "foo" [" bar"]] it "keeps original if stripping is not possible" $ do unlines [ " >>> foo" , " bar" ] `shouldParseTo` DocExamples [Example "foo" [" bar"]] context "when parsing paragraphs nested in lists" $ do it "can nest the same type of list" $ do "* foo\n\n * bar" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [DocParagraph "bar"]] it "can nest another type of list inside" $ do "* foo\n\n 1. bar" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocOrderedList [DocParagraph "bar"]] it "can nest a code block inside" $ do "* foo\n\n @foo bar baz@" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocCodeBlock "foo bar baz"] "* foo\n\n @\n foo bar baz\n @" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocCodeBlock "foo bar baz\n"] it "can nest more than one level" $ do "* foo\n\n * bar\n\n * baz\n qux" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph $ "bar" <> DocUnorderedList [DocParagraph "baz\nqux"] ] ] it "won't fail on not fully indented paragraph" $ do "* foo\n\n * bar\n\n * qux\nquux" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph "bar" ] , DocParagraph "qux\nquux"] it "can nest definition lists" $ do "[a] foo\n\n [b] bar\n\n [c] baz\n qux" `shouldParseTo` DocDefList [ ("a", "foo" <> DocDefList [ ("b", "bar" <> DocDefList [("c", "baz\nqux")]) ]) ] it "can come back to top level with a different list" $ do "* foo\n\n * bar\n\n1. baz" `shouldParseTo` DocUnorderedList [ DocParagraph $ "foo" <> DocUnorderedList [ DocParagraph "bar" ] ] <> DocOrderedList [ DocParagraph "baz" ] it "definition lists can come back to top level with a different list" $ do "[foo] foov\n\n [bar] barv\n\n1. baz" `shouldParseTo` DocDefList [ ("foo", "foov" <> DocDefList [ ("bar", "barv") ]) ] <> DocOrderedList [ DocParagraph "baz" ] context "when parsing properties" $ do it "can parse a single property" $ do "prop> 23 == 23" `shouldParseTo` DocProperty "23 == 23" it "can parse multiple subsequent properties" $ do unlines [ "prop> 23 == 23" , "prop> 42 == 42" ] `shouldParseTo` DocProperty "23 == 23" <> DocProperty "42 == 42" it "accepts unicode in properties" $ do "prop> 灼眼のシャナ ≡ 愛" `shouldParseTo` DocProperty "灼眼のシャナ ≡ 愛" it "can deal with whitespace before and after the prop> prompt" $ do " prop> xs == (reverse $ reverse xs) " `shouldParseTo` DocProperty "xs == (reverse $ reverse xs)" context "when parsing unordered lists" $ do it "parses a simple list" $ do unlines [ " * one" , " * two" , " * three" ] `shouldParseTo` DocUnorderedList [ DocParagraph "one" , DocParagraph "two" , DocParagraph "three" ] it "ignores empty lines between list items" $ do unlines [ "* one" , "" , "* two" ] `shouldParseTo` DocUnorderedList [ DocParagraph "one" , DocParagraph "two" ] it "accepts an empty list item" $ do "*" `shouldParseTo` DocUnorderedList [DocParagraph DocEmpty] it "accepts multi-line list items" $ do unlines [ "* point one" , " more one" , "* point two" , "more two" ] `shouldParseTo` DocUnorderedList [ DocParagraph "point one\n more one" , DocParagraph "point two\nmore two" ] it "accepts markup in list items" $ do "* /foo/" `shouldParseTo` DocUnorderedList [DocParagraph (DocEmphasis "foo")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "* bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocUnorderedList [DocParagraph "bar"] <> DocParagraph "baz" context "when parsing ordered lists" $ do it "parses a simple list" $ do unlines [ " 1. one" , " (1) two" , " 3. three" ] `shouldParseTo` DocOrderedList [ DocParagraph "one" , DocParagraph "two" , DocParagraph "three" ] it "ignores empty lines between list items" $ do unlines [ "1. one" , "" , "2. two" ] `shouldParseTo` DocOrderedList [ DocParagraph "one" , DocParagraph "two" ] it "accepts an empty list item" $ do "1." `shouldParseTo` DocOrderedList [DocParagraph DocEmpty] it "accepts multi-line list items" $ do unlines [ "1. point one" , " more one" , "1. point two" , "more two" ] `shouldParseTo` DocOrderedList [ DocParagraph "point one\n more one" , DocParagraph "point two\nmore two" ] it "accepts markup in list items" $ do "1. /foo/" `shouldParseTo` DocOrderedList [DocParagraph (DocEmphasis "foo")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "1. bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocOrderedList [DocParagraph "bar"] <> DocParagraph "baz" context "when parsing definition lists" $ do it "parses a simple list" $ do unlines [ " [foo] one" , " [bar] two" , " [baz] three" ] `shouldParseTo` DocDefList [ ("foo", "one") , ("bar", "two") , ("baz", "three") ] it "ignores empty lines between list items" $ do unlines [ "[foo] one" , "" , "[bar] two" ] `shouldParseTo` DocDefList [ ("foo", "one") , ("bar", "two") ] it "accepts an empty list item" $ do "[foo]" `shouldParseTo` DocDefList [("foo", DocEmpty)] it "accepts multi-line list items" $ do unlines [ "[foo] point one" , " more one" , "[bar] point two" , "more two" ] `shouldParseTo` DocDefList [ ("foo", "point one\n more one") , ("bar", "point two\nmore two") ] it "accepts markup in list items" $ do "[foo] /foo/" `shouldParseTo` DocDefList [("foo", DocEmphasis "foo")] it "accepts markup for the label" $ do "[/foo/] bar" `shouldParseTo` DocDefList [(DocEmphasis "foo", "bar")] it "requires empty lines between list and other paragraphs" $ do unlines [ "foo" , "" , "[foo] bar" , "" , "baz" ] `shouldParseTo` DocParagraph "foo" <> DocDefList [("foo", "bar")] <> DocParagraph "baz" context "when parsing consecutive paragraphs" $ do it "will not capture irrelevant consecutive lists" $ do unlines [ " * bullet" , "" , "" , " - different bullet" , "" , "" , " (1) ordered" , " " , " 2. different bullet" , " " , " [cat] kitten" , " " , " [pineapple] fruit" ] `shouldParseTo` DocUnorderedList [ DocParagraph "bullet" , DocParagraph "different bullet"] <> DocOrderedList [ DocParagraph "ordered" , DocParagraph "different bullet" ] <> DocDefList [ ("cat", "kitten") , ("pineapple", "fruit") ] context "when parsing function documentation headers" $ do it "can parse a simple header" $ do "= Header 1\nHello." `shouldParseTo` DocParagraph (DocHeader (Header 1 "Header 1")) <> DocParagraph "Hello." it "allow consecutive headers" $ do "= Header 1\n== Header 2" `shouldParseTo` DocParagraph (DocHeader (Header 1 "Header 1")) <> DocParagraph (DocHeader (Header 2 "Header 2")) it "accepts markup in the header" $ do "= /Header/ __1__\nFoo" `shouldParseTo` DocParagraph (DocHeader (Header 1 (DocEmphasis "Header" <> " " <> DocBold "1"))) <> DocParagraph "Foo"
27,342
false
true
0
111
9,624
5,385
2,599
2,786
null
null
vikraman/ghc
compiler/hsSyn/HsUtils.hs
bsd-3-clause
mkNPlusKPat id lit = NPlusKPat id lit (unLoc lit) noSyntaxExpr noSyntaxExpr placeHolderType
91
mkNPlusKPat id lit = NPlusKPat id lit (unLoc lit) noSyntaxExpr noSyntaxExpr placeHolderType
91
mkNPlusKPat id lit = NPlusKPat id lit (unLoc lit) noSyntaxExpr noSyntaxExpr placeHolderType
91
false
false
1
7
11
37
14
23
null
null
TueHaulund/ROOPLC
src/MacroExpander.hs
mit
meMacro (AddressMacro l) = getAddress l
39
meMacro (AddressMacro l) = getAddress l
39
meMacro (AddressMacro l) = getAddress l
39
false
false
0
6
5
19
8
11
null
null
CloudI/CloudI
src/api/haskell/external/bytestring-0.10.10.0/Data/ByteString/Builder/Prim/ASCII.hs
mit
int8HexFixed :: FixedPrim Int8 int8HexFixed = fromIntegral >$< word8HexFixed
76
int8HexFixed :: FixedPrim Int8 int8HexFixed = fromIntegral >$< word8HexFixed
76
int8HexFixed = fromIntegral >$< word8HexFixed
45
false
true
1
6
8
22
9
13
null
null
wtetzner/hatemail
haskell/src/Parse.hs
gpl-3.0
bodyExtMPart = choice [bodyExtLoc bodyFieldPrm, bodyExtLang bodyFieldPrm, bodyExtDsp bodyFieldPrm, prm] where prm = do params <- bodyFieldPrm return $ BodyExt params
257
bodyExtMPart = choice [bodyExtLoc bodyFieldPrm, bodyExtLang bodyFieldPrm, bodyExtDsp bodyFieldPrm, prm] where prm = do params <- bodyFieldPrm return $ BodyExt params
257
bodyExtMPart = choice [bodyExtLoc bodyFieldPrm, bodyExtLang bodyFieldPrm, bodyExtDsp bodyFieldPrm, prm] where prm = do params <- bodyFieldPrm return $ BodyExt params
257
false
false
2
9
112
62
26
36
null
null
wxwxwwxxx/ghc
compiler/cmm/SMRep.hs
bsd-3-clause
hALF_WORD_SIZE_IN_BITS :: DynFlags -> Int hALF_WORD_SIZE_IN_BITS dflags = platformWordSize (targetPlatform dflags) `shiftL` 2
125
hALF_WORD_SIZE_IN_BITS :: DynFlags -> Int hALF_WORD_SIZE_IN_BITS dflags = platformWordSize (targetPlatform dflags) `shiftL` 2
125
hALF_WORD_SIZE_IN_BITS dflags = platformWordSize (targetPlatform dflags) `shiftL` 2
83
false
true
0
8
12
37
18
19
null
null
jsnajder/counts
src/Data/Counts.hs
bsd-3-clause
inc :: (Ord a) => a -> Counts a -> Counts a inc x cs = Counts { counts_ = M.insertWith (+) x 1 (counts_ cs), total = total cs + 1}
136
inc :: (Ord a) => a -> Counts a -> Counts a inc x cs = Counts { counts_ = M.insertWith (+) x 1 (counts_ cs), total = total cs + 1}
136
inc x cs = Counts { counts_ = M.insertWith (+) x 1 (counts_ cs), total = total cs + 1}
92
false
true
0
10
37
84
42
42
null
null
kolmodin/cabal
Cabal/tests/PackageTests/PackageTester.hs
bsd-3-clause
ghcProg :: SuiteConfig -> ConfiguredProgram ghcProg suite = getBootProgram suite ghcProgram
91
ghcProg :: SuiteConfig -> ConfiguredProgram ghcProg suite = getBootProgram suite ghcProgram
91
ghcProg suite = getBootProgram suite ghcProgram
47
false
true
0
5
10
23
11
12
null
null
AaronFriel/eff-experiments
src/Data/Iota/Tagged/OpenUnion51.hs
bsd-3-clause
decomp :: Union (t ': r) v -> Either (Union r v) (t v) decomp (Union0 v) = Right $ unsafeCoerce v
97
decomp :: Union (t ': r) v -> Either (Union r v) (t v) decomp (Union0 v) = Right $ unsafeCoerce v
97
decomp (Union0 v) = Right $ unsafeCoerce v
42
false
true
0
8
21
64
31
33
null
null
osa1/toylisp
src/Parser.hs
bsd-3-clause
symbol :: Parser Char symbol = oneOf "!$%&|*+-/:<=?>@^_~#"
58
symbol :: Parser Char symbol = oneOf "!$%&|*+-/:<=?>@^_~#"
58
symbol = oneOf "!$%&|*+-/:<=?>@^_~#"
36
false
true
0
5
7
17
8
9
null
null
ajnsit/luachunk
src/Scripting/Lua/Chunk/Reader.hs
gpl-3.0
local :: Header -> A.Parser Local local h = do s <- str h case s of Nothing -> error "Unnamed local variable encountered!" Just si -> do startpc <- intP $ sizeOfInt h endpc <- intP $ sizeOfInt h return $ Local si startpc endpc -- List of Upvals
275
local :: Header -> A.Parser Local local h = do s <- str h case s of Nothing -> error "Unnamed local variable encountered!" Just si -> do startpc <- intP $ sizeOfInt h endpc <- intP $ sizeOfInt h return $ Local si startpc endpc -- List of Upvals
275
local h = do s <- str h case s of Nothing -> error "Unnamed local variable encountered!" Just si -> do startpc <- intP $ sizeOfInt h endpc <- intP $ sizeOfInt h return $ Local si startpc endpc -- List of Upvals
241
false
true
0
14
80
101
45
56
null
null
alphalambda/codeworld
funblocks-client/src/Blocks/Types.hs
apache-2.0
typePicture = Picture
21
typePicture = Picture
21
typePicture = Picture
21
false
false
0
4
2
6
3
3
null
null
glhrmfrts/lusk
Lusk/Parser.hs
mit
getOpType "-" = Sub
19
getOpType "-" = Sub
19
getOpType "-" = Sub
19
false
false
1
5
3
13
4
9
null
null
nevrenato/Hets_Fork
Common/Keywords.hs
gpl-2.0
-- | two percent signs (for line comments) percents :: String percents = percentS ++ percentS
93
percents :: String percents = percentS ++ percentS
50
percents = percentS ++ percentS
31
true
true
0
5
15
16
9
7
null
null
krgn/leo
src/Web/Leo.hs
bsd-3-clause
query :: String -- ^ search term to translate -> Language -- ^ language to translate to (e.g. 'En', 'Es' ...) -> Int -- ^ maximum number of results to fetch -> IO [QueryResult] -- ^ returns a list of QueryResult query term l num = do result <- fetch term (l, De) num let categories = processRaw result return $ map toQueryResult categories -- take a query string, some options and fetches a response from the webservice
485
query :: String -- ^ search term to translate -> Language -- ^ language to translate to (e.g. 'En', 'Es' ...) -> Int -- ^ maximum number of results to fetch -> IO [QueryResult] query term l num = do result <- fetch term (l, De) num let categories = processRaw result return $ map toQueryResult categories -- take a query string, some options and fetches a response from the webservice
449
query term l num = do result <- fetch term (l, De) num let categories = processRaw result return $ map toQueryResult categories -- take a query string, some options and fetches a response from the webservice
220
true
true
0
10
143
85
43
42
null
null
hsyl20/ViperVM
haskus-system/src/lib/Haskus/System/Linux/Sound/Pcm.hs
bsd-3-clause
-- | Any mask anyMask :: Mask anyMask = Mask (complement zeroBits)
66
anyMask :: Mask anyMask = Mask (complement zeroBits)
52
anyMask = Mask (complement zeroBits)
36
true
true
0
7
11
21
11
10
null
null
forked-upstream-packages-for-ghcjs/ghc
compiler/llvmGen/Llvm/PpLlvm.hs
bsd-3-clause
ppReturn :: Maybe LlvmVar -> SDoc ppReturn (Just var) = text "ret" <+> ppr var
78
ppReturn :: Maybe LlvmVar -> SDoc ppReturn (Just var) = text "ret" <+> ppr var
78
ppReturn (Just var) = text "ret" <+> ppr var
44
false
true
0
7
14
37
17
20
null
null
silky/csound-expression
src/Csound/Air/Wav.hs
bsd-3-clause
- Stereo -- | Reads stereo signal from the sound-file (wav or mp3 or aiff). readSnd :: String -> (Sig, Sig) readSnd fileName | isMp3 fileName = mp3in (text fileName) | otherwise = diskin2 (text fileName) 1
228
readSnd :: String -> (Sig, Sig) readSnd fileName | isMp3 fileName = mp3in (text fileName) | otherwise = diskin2 (text fileName) 1
150
readSnd fileName | isMp3 fileName = mp3in (text fileName) | otherwise = diskin2 (text fileName) 1
118
true
true
1
8
59
66
32
34
null
null
kajigor/uKanren_transformations
test/auto/Test/VarNormalization.hs
bsd-3-clause
y = V "y"
9
y = V "y"
9
y = V "y"
9
false
false
1
5
3
12
4
8
null
null
siddhanathan/ghc
compiler/hsSyn/HsTypes.hs
bsd-3-clause
ignoreParens ty = ty
36
ignoreParens ty = ty
36
ignoreParens ty = ty
36
false
false
0
5
19
9
4
5
null
null
pbl64k/HackerRank-Contests
2014-10-10-FP/SequenceFullOfColors/sfoc.accepted.hs
bsd-2-clause
tst = do cs <- getLine putStrLn $ show $ slv (0, 0, 0, 0) cs
68
tst = do cs <- getLine putStrLn $ show $ slv (0, 0, 0, 0) cs
68
tst = do cs <- getLine putStrLn $ show $ slv (0, 0, 0, 0) cs
68
false
false
1
10
23
45
21
24
null
null
Southern-Exposure-Seed-Exchange/Order-Manager-Prototypes
spock/src/App.hs
gpl-3.0
omApp :: OM a omApp = do subcomponent "categories" categoryHandlers subcomponent "products" productHandlers
115
omApp :: OM a omApp = do subcomponent "categories" categoryHandlers subcomponent "products" productHandlers
115
omApp = do subcomponent "categories" categoryHandlers subcomponent "products" productHandlers
101
false
true
1
8
20
34
13
21
null
null
bos/statistics
Statistics/Distribution/Transform.hs
bsd-2-clause
-- | Get fixed point of linear transformation linTransFixedPoint :: LinearTransform d -> Double linTransFixedPoint (LinearTransform loc sc _) = loc / (1 - sc)
158
linTransFixedPoint :: LinearTransform d -> Double linTransFixedPoint (LinearTransform loc sc _) = loc / (1 - sc)
112
linTransFixedPoint (LinearTransform loc sc _) = loc / (1 - sc)
62
true
true
0
7
24
43
22
21
null
null
olorin/amazonka
amazonka-iam/gen/Network/AWS/IAM/SimulatePrincipalPolicy.hs
mpl-2.0
-- | Use this only when paginating results to indicate the maximum number of -- items you want in the response. If there are additional items beyond the -- maximum you specify, the 'IsTruncated' response element is 'true'. -- -- This parameter is optional. If you do not include it, it defaults to -- 100. Note that IAM might return fewer results, even when there are more -- results available. If this is the case, the 'IsTruncated' response -- element returns 'true' and 'Marker' contains a value to include in the -- subsequent call that tells the service where to continue from. sppMaxItems :: Lens' SimulatePrincipalPolicy (Maybe Natural) sppMaxItems = lens _sppMaxItems (\ s a -> s{_sppMaxItems = a}) . mapping _Nat
721
sppMaxItems :: Lens' SimulatePrincipalPolicy (Maybe Natural) sppMaxItems = lens _sppMaxItems (\ s a -> s{_sppMaxItems = a}) . mapping _Nat
138
sppMaxItems = lens _sppMaxItems (\ s a -> s{_sppMaxItems = a}) . mapping _Nat
77
true
true
0
10
121
61
36
25
null
null
scslab/iterIO
Examples/httpsEcho.hs
bsd-3-clause
parmsI :: (Monad m) => HttpReq s -> Iter L m Parms parmsI req = foldForm req getPart [] where getPart parts mp = do front <- takeI 50 backLen <- countI return ((mp,front,backLen):parts)
200
parmsI :: (Monad m) => HttpReq s -> Iter L m Parms parmsI req = foldForm req getPart [] where getPart parts mp = do front <- takeI 50 backLen <- countI return ((mp,front,backLen):parts)
200
parmsI req = foldForm req getPart [] where getPart parts mp = do front <- takeI 50 backLen <- countI return ((mp,front,backLen):parts)
149
false
true
0
10
48
98
47
51
null
null
ygale/yesod
yesod-form/Yesod/Form/Bootstrap3.hs
mit
withLargeInput :: FieldSettings site -> FieldSettings site withLargeInput fs = fs { fsAttrs = newAttrs } where newAttrs = addClass "input-lg" (fsAttrs fs) -- | Add the @input-sm@ CSS class to a field. -- -- Since: yesod-form 1.3.8
236
withLargeInput :: FieldSettings site -> FieldSettings site withLargeInput fs = fs { fsAttrs = newAttrs } where newAttrs = addClass "input-lg" (fsAttrs fs) -- | Add the @input-sm@ CSS class to a field. -- -- Since: yesod-form 1.3.8
236
withLargeInput fs = fs { fsAttrs = newAttrs } where newAttrs = addClass "input-lg" (fsAttrs fs) -- | Add the @input-sm@ CSS class to a field. -- -- Since: yesod-form 1.3.8
177
false
true
0
7
43
54
28
26
null
null
GregorySchwartz/tree-fun
src/Math/TreeFun/Tree.hs
gpl-3.0
-- | Return the list of properties in a property map for a tree getProperties :: (Eq b) => PropertyMap a b -> [b] getProperties = nub . F.toList . F.foldl' (S.><) S.empty . M.elems
180
getProperties :: (Eq b) => PropertyMap a b -> [b] getProperties = nub . F.toList . F.foldl' (S.><) S.empty . M.elems
116
getProperties = nub . F.toList . F.foldl' (S.><) S.empty . M.elems
66
true
true
0
8
34
62
33
29
null
null
sdiehl/ghc
compiler/utils/Outputable.hs
bsd-3-clause
cat ds = SDoc $ \sty -> Pretty.cat [runSDoc d sty | d <- ds]
62
cat ds = SDoc $ \sty -> Pretty.cat [runSDoc d sty | d <- ds]
62
cat ds = SDoc $ \sty -> Pretty.cat [runSDoc d sty | d <- ds]
62
false
false
0
10
16
39
19
20
null
null
Mathnerd314/lamdu
bottlelib/Data/Cache.hs
gpl-3.0
lookupHelper :: Key k => (KeyBS -> r) -> (KeyBS -> ValEntry -> r) -> k -> Cache -> r lookupHelper onMiss onHit key cache = maybe (onMiss bsKey) (onHit bsKey) . Map.lookup bsKey $ cache ^. cEntries where bsKey = bsOfKey key
232
lookupHelper :: Key k => (KeyBS -> r) -> (KeyBS -> ValEntry -> r) -> k -> Cache -> r lookupHelper onMiss onHit key cache = maybe (onMiss bsKey) (onHit bsKey) . Map.lookup bsKey $ cache ^. cEntries where bsKey = bsOfKey key
232
lookupHelper onMiss onHit key cache = maybe (onMiss bsKey) (onHit bsKey) . Map.lookup bsKey $ cache ^. cEntries where bsKey = bsOfKey key
147
false
true
3
11
52
117
53
64
null
null
charles-cooper/postgresql-orm
examples.hs
gpl-3.0
bar :: Bar bar = Bar NullKey (Just 44) "hi" Nothing
51
bar :: Bar bar = Bar NullKey (Just 44) "hi" Nothing
51
bar = Bar NullKey (Just 44) "hi" Nothing
40
false
true
0
7
10
32
14
18
null
null
brendanhay/gogol
gogol-servicenetworking/gen/Network/Google/Resource/ServiceNetworking/Services/Roles/Add.hs
mpl-2.0
-- | JSONP sraCallback :: Lens' ServicesRolesAdd (Maybe Text) sraCallback = lens _sraCallback (\ s a -> s{_sraCallback = a})
126
sraCallback :: Lens' ServicesRolesAdd (Maybe Text) sraCallback = lens _sraCallback (\ s a -> s{_sraCallback = a})
115
sraCallback = lens _sraCallback (\ s a -> s{_sraCallback = a})
64
true
true
0
9
21
48
25
23
null
null
aisamanra/config-ini
src/Data/Ini/Config/Bidir.hs
bsd-3-clause
-- | If the field is not found in parsing, simply skip instead of -- raising an error or setting anything. optional :: FieldDescription t -> FieldDescription t optional fd = fd {fdSkipIfMissing = True}
203
optional :: FieldDescription t -> FieldDescription t optional fd = fd {fdSkipIfMissing = True}
94
optional fd = fd {fdSkipIfMissing = True}
41
true
true
0
6
36
34
18
16
null
null
danr/hipspec
src/HipSpec/Utils.hs
gpl-3.0
-- | Pretty show ppShow :: Show a => a -> String ppShow = Pretty.ppShow
71
ppShow :: Show a => a -> String ppShow = Pretty.ppShow
54
ppShow = Pretty.ppShow
22
true
true
0
6
14
25
13
12
null
null
creichert/persistent
persistent-sqlite/Database/Persist/Sqlite.hs
mit
escape :: DBName -> Text escape (DBName s) = T.concat [q, T.concatMap go s, q] where q = T.singleton '"' go '"' = "\"\"" go c = T.singleton c
159
escape :: DBName -> Text escape (DBName s) = T.concat [q, T.concatMap go s, q] where q = T.singleton '"' go '"' = "\"\"" go c = T.singleton c
159
escape (DBName s) = T.concat [q, T.concatMap go s, q] where q = T.singleton '"' go '"' = "\"\"" go c = T.singleton c
134
false
true
3
9
46
94
40
54
null
null
tamarin-prover/tamarin-prover
lib/theory/src/Theory/Model/Formula.hs
gpl-3.0
-- | Change the representation of atoms. mapAtoms :: (Integer -> ProtoAtom syn (VTerm c (BVar v)) -> ProtoAtom syn1 (VTerm c1 (BVar v1))) -> ProtoFormula syn s c v -> ProtoFormula syn1 s c1 v1 mapAtoms f = foldFormulaScope (\i a -> Ato $ f i a) TF Not Conn Qua
278
mapAtoms :: (Integer -> ProtoAtom syn (VTerm c (BVar v)) -> ProtoAtom syn1 (VTerm c1 (BVar v1))) -> ProtoFormula syn s c v -> ProtoFormula syn1 s c1 v1 mapAtoms f = foldFormulaScope (\i a -> Ato $ f i a) TF Not Conn Qua
237
mapAtoms f = foldFormulaScope (\i a -> Ato $ f i a) TF Not Conn Qua
67
true
true
0
13
69
120
59
61
null
null