diff options
author | Julien Dessaux | 2024-03-22 01:13:34 +0100 |
---|---|---|
committer | Julien Dessaux | 2024-03-27 15:21:37 +0100 |
commit | 7e27a0a7eada373780a9757fd89f70d4d911d69a (patch) | |
tree | 8b660bde99d5f9b4ae4f9e9caea4b51f19931dbe /haskell/src/SpaceTraders/APIClient/Systems.hs | |
parent | [node] begin the great typescript rewrite (diff) | |
download | spacetraders-7e27a0a7eada373780a9757fd89f70d4d911d69a.tar.gz spacetraders-7e27a0a7eada373780a9757fd89f70d4d911d69a.tar.bz2 spacetraders-7e27a0a7eada373780a9757fd89f70d4d911d69a.zip |
[haskell] refactoring
Diffstat (limited to '')
-rw-r--r-- | haskell/src/SpaceTraders/APIClient/Systems.hs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/haskell/src/SpaceTraders/APIClient/Systems.hs b/haskell/src/SpaceTraders/APIClient/Systems.hs index eb15b4d..e2690ac 100644 --- a/haskell/src/SpaceTraders/APIClient/Systems.hs +++ b/haskell/src/SpaceTraders/APIClient/Systems.hs @@ -1,24 +1,22 @@ -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} module SpaceTraders.APIClient.Systems ( initSystems ) where -import Control.Exception -import Network.HTTP.Simple +import Control.Exception +import Network.HTTP.Simple -import SpaceTraders -import SpaceTraders.APIClient.Client -import SpaceTraders.APIClient.Pagination -import SpaceTraders.Database.Systems -import SpaceTraders.Model.System(System) +import SpaceTraders +import SpaceTraders.APIClient.Client +import SpaceTraders.APIClient.Pagination +import SpaceTraders.Database.Systems +import SpaceTraders.Model.System (System) initSystems :: SpaceTradersT (APIResponse [System]) initSystems = do s <- getSystems - listSystems' Pagination{limit=20, page=((length s) `div` 20) + 1, total=0} + listSystems' Pagination{limit=20, page=(length s `div` 20) + 1, total=0} where listSystems' :: Pagination -> SpaceTradersT (APIResponse [System]) listSystems' p = do @@ -27,6 +25,6 @@ initSystems = do Left e -> throw e Right (APIMessage r (Just p')) -> do addSystems r - if (limit p' * page p' < total p') then listSystems' (nextPage p') - else Right <$> getSystems + if limit p' * page p' < total p' then listSystems' (nextPage p') + else Right <$> getSystems _ -> undefined |