Stylish haskell

This commit is contained in:
Mats Rauhala 2019-10-15 23:12:33 +03:00
parent 10d767157c
commit e347b4753b
3 changed files with 8 additions and 9 deletions

View File

@ -1,2 +1,2 @@
import Distribution.Simple import Distribution.Simple
main = defaultMain main = defaultMain

View File

@ -9,23 +9,22 @@ module API where
import Control.Monad.Reader (MonadReader, asks) import Control.Monad.Reader (MonadReader, asks)
import Control.Monad.Trans (MonadIO) import Control.Monad.Trans (MonadIO)
import Data.List (sortOn, find) import Data.Either (partitionEithers)
import Data.Foldable (traverse_) import Data.Foldable (traverse_)
import Data.List (find, sortOn)
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T
import Lucid.Base (HtmlT, ToHtml (..)) import Lucid.Base (HtmlT, ToHtml (..))
import Lucid.Html5 import Lucid.Html5
import Servant.API import Servant.API
import Servant.API.Generic import Servant.API.Generic
import Servant.HTML.Lucid import Servant.HTML.Lucid
import Servant.Server.Generic import Servant.Server.Generic
import qualified Data.Text as T
import Data.Either (partitionEithers)
import Debug.Trace (traceShow)
import Data.Caesar
import Data.Language
import Solidabis.API (HasClientEnv, HasToken, bullshits, import Solidabis.API (HasClientEnv, HasToken, bullshits,
getBullshits, message) getBullshits, message)
import Data.Language
import Data.Caesar
data Index = data Index =
Index { converted :: [Text] Index { converted :: [Text]
@ -66,4 +65,4 @@ handler =
let caesared = map (\n -> T.map (caesar n) . T.toLower $ sentence) [0..29] let caesared = map (\n -> T.map (caesar n) . T.toLower $ sentence) [0..29]
ranked = sortOn fst $ [(goodness model x, x) | x <- caesared] ranked = sortOn fst $ [(goodness model x, x) | x <- caesared]
found = find (\(rank, _) -> rank > -7.9) (reverse ranked) found = find (\(rank, _) -> rank > -7.9) (reverse ranked)
in ranked `traceShow` maybe (Left sentence) (Right . snd) found in maybe (Left sentence) (Right . snd) found

View File

@ -9,8 +9,8 @@ import Servant
import Servant.Server.Generic import Servant.Server.Generic
import API (handler) import API (handler)
import Data.Language (HasModel)
import Solidabis.API (HasClientEnv, HasToken) import Solidabis.API (HasClientEnv, HasToken)
import Data.Language (HasModel)
newtype Port = Port Int deriving (Show, FromJSON) newtype Port = Port Int deriving (Show, FromJSON)