mirror of
https://github.com/sdiehl/wiwinwlh.git
synced 2024-11-09 13:45:09 +03:00
format uniformly
This commit is contained in:
parent
6eaf77fc90
commit
1bd32529e8
@ -26,7 +26,7 @@ data Message = Message
|
||||
|
||||
pprotocol :: Parser Message
|
||||
pprotocol = do
|
||||
act <- paction
|
||||
act <- paction
|
||||
send <- A.takeTill (== '.')
|
||||
body <- A.takeTill (A.isSpace)
|
||||
endOfLine
|
||||
|
@ -10,6 +10,4 @@ conduit = CL.map show
|
||||
sink :: Sink String IO ()
|
||||
sink = CL.mapM_ putStrLn
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
source $$ conduit =$ sink
|
||||
main = source $$ conduit =$ sink
|
||||
|
17
pretty.hs
17
pretty.hs
@ -33,15 +33,15 @@ instance Pretty Expr where
|
||||
ppr _ (Lit (LInt a)) = text (show a)
|
||||
ppr _ (Lit (LBool b)) = text (show b)
|
||||
|
||||
ppr p e@(App _ _) = parensIf (p>0) $ ppr p f <+> args
|
||||
where
|
||||
args = sep $ map (ppr (p+1)) xs
|
||||
(f, xs) = viewApp e
|
||||
ppr p e@(App _ _) =
|
||||
let (f, xs) = viewApp e in
|
||||
let args = sep $ map (ppr (p+1)) xs in
|
||||
parensIf (p>0) $ ppr p f <+> args
|
||||
|
||||
ppr p e@(Lam _ _) = parensIf (p>0) $ char '\\' <> hsep vars <+> text "." <+> body
|
||||
where
|
||||
vars = map (ppr 0) (viewVars e)
|
||||
body = ppr (p+1) (viewBody e)
|
||||
ppr p e@(Lam _ _) =
|
||||
let body = ppr (p+1) (viewBody e) in
|
||||
let vars = map (ppr 0) (viewVars e) in
|
||||
parensIf (p>0) $ char '\\' <> hsep vars <+> text "." <+> body
|
||||
|
||||
viewVars :: Expr -> [Name]
|
||||
viewVars (Lam n a) = n : viewVars a
|
||||
@ -60,6 +60,7 @@ viewApp (App e1 e2) = go e1 [e2]
|
||||
ppexpr :: Expr -> String
|
||||
ppexpr = render . ppr 0
|
||||
|
||||
|
||||
s, k, example :: Expr
|
||||
s = Lam "f" (Lam "g" (Lam "x" (App (Var "f") (App (Var "g") (Var "x")))))
|
||||
k = Lam "x" (Lam "y" (Var "x"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Test.SmallCheck
|
||||
|
||||
assoc :: Int -> Int -> Int -> Bool
|
||||
assoc a b c = a * (b + c) == a * b + a *c
|
||||
distrib :: Int -> Int -> Int -> Bool
|
||||
distrib a b c = a * (b + c) == a * b + a *c
|
||||
|
||||
cauchy :: [Double] -> [Double] -> Bool
|
||||
cauchy xs ys = (abs (dot xs ys))^2 <= (dot xs xs) * (dot ys ys)
|
||||
@ -14,8 +14,8 @@ dot xs ys = sum (zipWith (*) xs ys)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "Testing associativity..."
|
||||
smallCheck 25 assoc
|
||||
putStrLn "Testing distributivity..."
|
||||
smallCheck 25 distrib
|
||||
|
||||
putStrLn "Testing Cauchy-Swartz..."
|
||||
smallCheck 4 cauchy
|
||||
|
@ -5,4 +5,4 @@ example1 :: M.HashMap Int Char
|
||||
example1 = M.fromList $ zip [1..10] ['a'..]
|
||||
|
||||
example2 :: S.HashSet Int
|
||||
example2 = S.fromList $ [1..10]
|
||||
example2 = S.fromList [1..10]
|
||||
|
Loading…
Reference in New Issue
Block a user