Add pre-commit hook that enforces ormolu formatting

This commit is contained in:
David Pätzel 2019-10-22 16:42:16 +02:00
parent c5dca4b33a
commit 9866603dbe
5 changed files with 23 additions and 9 deletions

17
pre-commit Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
tmp=$(mktemp)
find src/ -type f | while read f; do
if ! ormolu --mode check "$f"; then
echo "$f is not properly formatted"
echo 1 > "$tmp"
fi
done
if test "X1" = "X$(cat "$tmp")"; then
exit 1
fi

View File

@ -2,11 +2,11 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
import Protolude hiding (for)
import Pretty
import WS19
import Pipes
import Pretty
import Protolude hiding (for)
import System.IO
import WS19
mkPop = population 100 (I prios [])
@ -16,7 +16,7 @@ main = do
let t = fromMaybe 100 $ headMay args >>= readMaybe
hSetBuffering stdout NoBuffering
pop <- mkPop
pop' <- runEffect $ for (run 2 1 (5/100) pop (steps t)) log
pop' <- runEffect $ for (run 2 1 (5 / 100) pop (steps t)) log
(res, _) <- bests 5 pop'
sequence_ $ format <$> res
where

View File

@ -1,11 +1,8 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Pretty where
import Protolude
class Pretty a where
pretty :: a -> Text

View File

@ -28,7 +28,7 @@ instance Pretty (Maybe Topic) where
pretty (Just t) = t
pretty Nothing = "Kein Thema"
newtype Priorities = P { unP :: [(Student, [(Topic, Int)])] }
newtype Priorities = P {unP :: [(Student, [(Topic, Int)])]}
deriving (Eq, Show)
instance Arbitrary Priorities where

View File

@ -2,9 +2,9 @@
module Main where
import qualified GA
import Protolude
import qualified Seminar
import qualified GA
main :: IO ()
main = do