diff --git a/.gitignore b/.gitignore index 23812ba..c368d45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ .stack-work/ -*~ - -# ---> Nix -result -result-* +*~ \ No newline at end of file diff --git a/tickLeiste/ChangeLog.md b/ChangeLog.md similarity index 100% rename from tickLeiste/ChangeLog.md rename to ChangeLog.md diff --git a/tickLeiste-aeson/LICENSE b/LICENSE similarity index 100% rename from tickLeiste-aeson/LICENSE rename to LICENSE diff --git a/tickLeiste/README.md b/README.md similarity index 100% rename from tickLeiste/README.md rename to README.md diff --git a/tickLeiste-aeson/Setup.hs b/Setup.hs similarity index 100% rename from tickLeiste-aeson/Setup.hs rename to Setup.hs diff --git a/flake-module.nix b/flake-module.nix deleted file mode 100644 index 84d3699..0000000 --- a/flake-module.nix +++ /dev/null @@ -1,12 +0,0 @@ -{inputs, ...}: -{ - imports = []; - systems = ["x86_64-linux"]; - perSystem = {pkgs, ...} : - { - packages = rec { - tickLeiste = pkgs.haskellPackages.callPackage ./tickLeiste/tickLeiste.nix {}; - tickLeiste-aeson = pkgs.haskellPackages.callPackage ./tickLeiste-aeson/tickLeiste-aeson.nix {inherit tickLeiste;}; - }; - }; -} diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 39955d4..0000000 --- a/flake.lock +++ /dev/null @@ -1,63 +0,0 @@ -{ - "nodes": { - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1698579227, - "narHash": "sha256-KVWjFZky+gRuWennKsbo6cWyo7c/z/VgCte5pR9pEKg=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "f76e870d64779109e41370848074ac4eaa1606ec", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1698318101, - "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=", - "owner": "NixOs", - "repo": "nixpkgs", - "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c", - "type": "github" - }, - "original": { - "owner": "NixOs", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-lib": { - "locked": { - "dir": "lib", - "lastModified": 1696019113, - "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", - "type": "github" - }, - "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 81027ac..0000000 --- a/flake.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - description = "A very basic flake"; - - inputs = { - nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable"; - }; - - outputs = inputs@{ flake-parts, ...}: - flake-parts.lib.mkFlake { inherit inputs; } (import ./flake-module.nix); - -} diff --git a/tickLeiste/package.yaml b/package.yaml similarity index 100% rename from tickLeiste/package.yaml rename to package.yaml diff --git a/tickLeiste/src/Data/TickLeiste.hs b/src/Data/TickLeiste.hs similarity index 85% rename from tickLeiste/src/Data/TickLeiste.hs rename to src/Data/TickLeiste.hs index 1d7316a..020b8f4 100644 --- a/tickLeiste/src/Data/TickLeiste.hs +++ b/src/Data/TickLeiste.hs @@ -22,13 +22,13 @@ module Data.TickLeiste where import qualified Data.Map.Strict as M -import Data.Maybe (fromMaybe,maybe) +import Data.Maybe (fromMaybe) import qualified Data.Text as T import qualified Data.UUID as U -- | A Tick is just a number data Tick = Abwarten | Bereithalten | Tick Int - deriving (Show, Eq, Ord, Read) + deriving (Show, Eq, Ord) -- | test if 'Tick' is constructed using 'Abwarten' isAbwarten :: Tick -> Bool @@ -109,26 +109,19 @@ setPlayerTick p t tl@(TickLeiste l pl) = TickLeiste (insertPlayerToLeiste p t l' return $ removePlayerFromLeiste p ot l -- TODO --- | removes a 'Player' from the 'TickLeiste' removePlayer :: Player -> TickLeiste -> TickLeiste -removePlayer p tl@(TickLeiste {leiste = l, player = pm}) = TickLeiste l' pm' - where - pt = getPlayerTick p tl - l' = maybe - l - (flip (removePlayerFromLeiste p) l) - pt - pm' = removePlayerFromPlayerMap p pm +removePlayer = error "removePlayer not yet implemented (Franzi?)" -- | convert the Tick[eiste to a list of 'Tick' and 'Player' list pairs. These list are ordered toList :: TickLeiste -> [(Tick, [Player])] toList (TickLeiste l _) = M.toAscList l --- | convert from list to TickLeiste +-- | convert from list to TickLeiste, if a player is at multiple 'Tick' this returns +-- 'Nothing' -- TODO -fromList :: [(Tick, [Player])] -> TickLeiste -fromList = error "not implemented (Franzi?)" +fromList :: [(Tick, [Player])] -> Maybe TickLeiste +fromList = error "not implemented" -- | convert from 'TickLeiste' to a map from 'Tick' to list of 'Player' toMap :: TickLeiste -> M.Map Tick [Player] @@ -138,7 +131,6 @@ toMap = leiste -- it removes a player from a specific tick, if the player -- wasn't at the tick it is the identity. --- TODO this can be written more beautifully with something like M.update removePlayerFromLeiste :: Player -> Tick -> M.Map Tick [Player] -> M.Map Tick [Player] removePlayerFromLeiste p t l = fromMaybe l $ do list <- l M.!? t @@ -147,9 +139,6 @@ removePlayerFromLeiste p t l = fromMaybe l $ do then return $ M.delete t l else return $ M.insert t list' l -removePlayerFromPlayerMap :: Player -> M.Map Player Tick -> M.Map Player Tick -removePlayerFromPlayerMap = M.delete - insertPlayerToLeiste :: Player -> Tick -> M.Map Tick [Player] -> M.Map Tick [Player] insertPlayerToLeiste p t l = M.insert t (M.findWithDefault [] t l ++ [p]) l diff --git a/stack.yaml b/stack.yaml index 3b03c93..aa72cf0 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,8 +17,8 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-17.5 -# url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml +resolver: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml # User packages to be built. # Various formats can be used as shown in the example below. @@ -30,8 +30,7 @@ resolver: lts-17.5 # - auto-update # - wai packages: -- tickLeiste -- tickLeiste-aeson +- . # Dependency packages to be pulled from upstream that are not in the resolver. # These entries can reference officially published versions as well as # forks / in-progress versions pinned to a git hash. For example: diff --git a/stack.yaml.lock b/stack.yaml.lock index 1bba64b..857b03e 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,10 +3,11 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -snapshots: -- original: lts-17.5 - completed: - sha256: 78e8ebabf11406261abbc95b44f240acf71802630b368888f6d758de7fc3a2f7 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/5.yaml - size: 565266 packages: [] +snapshots: +- completed: + size: 532383 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml + sha256: 469d781ab6d2a4eceed6b31b6e4ec842dcd3cd1d11577972e86902603dce24df + original: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml diff --git a/tickLeiste-aeson/test/Spec.hs b/test/Spec.hs similarity index 100% rename from tickLeiste-aeson/test/Spec.hs rename to test/Spec.hs diff --git a/tickLeiste-aeson/.gitignore b/tickLeiste-aeson/.gitignore deleted file mode 100644 index c368d45..0000000 --- a/tickLeiste-aeson/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.stack-work/ -*~ \ No newline at end of file diff --git a/tickLeiste-aeson/ChangeLog.md b/tickLeiste-aeson/ChangeLog.md deleted file mode 100644 index dce1625..0000000 --- a/tickLeiste-aeson/ChangeLog.md +++ /dev/null @@ -1,3 +0,0 @@ -# Changelog for tickLeiste-aeson - -## Unreleased changes diff --git a/tickLeiste-aeson/README.md b/tickLeiste-aeson/README.md deleted file mode 100644 index a49f84b..0000000 --- a/tickLeiste-aeson/README.md +++ /dev/null @@ -1 +0,0 @@ -# tickLeiste-aeson diff --git a/tickLeiste-aeson/default.nix b/tickLeiste-aeson/default.nix deleted file mode 100644 index 7a00703..0000000 --- a/tickLeiste-aeson/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{pkgs ? import {}, ...}: -pkgs.haskellPackages.callPackage ./tickLeiste-aeson.nix {} diff --git a/tickLeiste-aeson/package.yaml b/tickLeiste-aeson/package.yaml deleted file mode 100644 index 51b54b6..0000000 --- a/tickLeiste-aeson/package.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: tickLeiste-aeson -version: 0.1.0.0 -github: "githubuser/tickLeiste-aeson" -license: BSD3 -author: "Author name here" -maintainer: "example@example.com" -copyright: "2020 Author name here" - -extra-source-files: -- README.md -- ChangeLog.md - -# Metadata used when publishing your package -# synopsis: Short description of your package -# category: Web - -# To avoid duplicated efforts in documentation and dealing with the -# complications of embedding Haddock markup inside cabal files, it is -# common to point users to the README.md file. -description: Please see the README on GitHub at - -dependencies: -- base >= 4.7 && < 5 -- tickLeiste -- uuid -- aeson -- text - -library: - source-dirs: src - -tests: - tickLeiste-aeson-test: - main: Spec.hs - source-dirs: test - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - tickLeiste-aeson diff --git a/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs b/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs deleted file mode 100644 index 10541ba..0000000 --- a/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs +++ /dev/null @@ -1,37 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} - -module Data.Aeson.TickLeiste - ( JSONRequest (..), - JSONEvent (..), - ) -where - -import Data.Aeson -import Data.Aeson.TH -import qualified Data.Text as T -import Data.TickLeiste -import qualified Data.UUID as U - -$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "tickType", contentsFieldName = "tickValue"}} ''Tick) - -data JSONRequest - = SetPlayerTickR {sptRplayerUUID :: U.UUID, sptRtick :: Tick} - | AddPlayerTickR {aptRplayerName :: T.Text, aptRtick :: Tick} - | InitializeTickLeisteR {itlRtickLeiste :: [(Tick, [T.Text])]} - | TickLeisteR - | ChangeNameR {cnaRplayerUUID :: U.UUID, cnaRplayerName :: T.Text} - | RemovePlayerR {rmpRplayerUUID :: U.UUID} - deriving (Show, Eq, Read) - -$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "requestType"}, fieldLabelModifier = drop 4} ''JSONRequest) - -data JSONEvent - = SetPlayerTickE {sptEplayerUUID :: U.UUID, sptEtick :: Tick} - | AddPlayerTickE {aptEplayerUUID :: U.UUID, aptEplayerName :: T.Text, aptEtick :: Tick} - | InitializeTickLeisteE {itlEtickLeiste :: [(Tick, [(U.UUID, T.Text)])]} - | ChangeNameE {cnaEplayerUUID :: U.UUID, cnaEplayerName :: T.Text} - | RemovePlayerE {rmpEplayerUUID :: U.UUID} - deriving (Show, Eq, Read) - -$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "eventType"}, fieldLabelModifier = drop 4} ''JSONEvent) diff --git a/tickLeiste-aeson/tickLeiste-aeson.cabal b/tickLeiste-aeson/tickLeiste-aeson.cabal deleted file mode 100644 index 22bb718..0000000 --- a/tickLeiste-aeson/tickLeiste-aeson.cabal +++ /dev/null @@ -1,56 +0,0 @@ -cabal-version: 1.12 - --- This file has been generated from package.yaml by hpack version 0.34.2. --- --- see: https://github.com/sol/hpack - -name: tickLeiste-aeson -version: 0.1.0.0 -description: Please see the README on GitHub at -homepage: https://github.com/githubuser/tickLeiste-aeson#readme -bug-reports: https://github.com/githubuser/tickLeiste-aeson/issues -author: Author name here -maintainer: example@example.com -copyright: 2020 Author name here -license: BSD3 -license-file: LICENSE -build-type: Simple -extra-source-files: - README.md - ChangeLog.md - -source-repository head - type: git - location: https://github.com/githubuser/tickLeiste-aeson - -library - exposed-modules: - Data.Aeson.TickLeiste - other-modules: - Paths_tickLeiste_aeson - hs-source-dirs: - src - build-depends: - aeson - , base >=4.7 && <5 - , text - , tickLeiste - , uuid - default-language: Haskell2010 - -test-suite tickLeiste-aeson-test - type: exitcode-stdio-1.0 - main-is: Spec.hs - other-modules: - Paths_tickLeiste_aeson - hs-source-dirs: - test - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson - , base >=4.7 && <5 - , text - , tickLeiste - , tickLeiste-aeson - , uuid - default-language: Haskell2010 diff --git a/tickLeiste-aeson/tickLeiste-aeson.nix b/tickLeiste-aeson/tickLeiste-aeson.nix deleted file mode 100644 index 3c95b1a..0000000 --- a/tickLeiste-aeson/tickLeiste-aeson.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ mkDerivation, aeson, base, hpack, lib, text, tickLeiste, uuid }: -mkDerivation { - pname = "tickLeiste-aeson"; - version = "0.1.0.0"; - src = ./.; - libraryHaskellDepends = [ aeson base text tickLeiste uuid ]; - libraryToolDepends = [ hpack ]; - testHaskellDepends = [ aeson base text tickLeiste uuid ]; - prePatch = "hpack"; - homepage = "https://github.com/githubuser/tickLeiste-aeson#readme"; - license = lib.licenses.bsd3; -} diff --git a/tickLeiste/tickLeiste.cabal b/tickLeiste.cabal similarity index 100% rename from tickLeiste/tickLeiste.cabal rename to tickLeiste.cabal diff --git a/tickLeiste/LICENSE b/tickLeiste/LICENSE deleted file mode 100644 index e637cde..0000000 --- a/tickLeiste/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright Author name here (c) 2020 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Author name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tickLeiste/Setup.hs b/tickLeiste/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/tickLeiste/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tickLeiste/default.nix b/tickLeiste/default.nix deleted file mode 100644 index e95ebd2..0000000 --- a/tickLeiste/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{pkgs ? import , ...}: -pkgs.haskellPackages.callPackage ./tickLeiste.nix {} diff --git a/tickLeiste/stack.yaml.lock b/tickLeiste/stack.yaml.lock deleted file mode 100644 index 857b03e..0000000 --- a/tickLeiste/stack.yaml.lock +++ /dev/null @@ -1,13 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: [] -snapshots: -- completed: - size: 532383 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml - sha256: 469d781ab6d2a4eceed6b31b6e4ec842dcd3cd1d11577972e86902603dce24df - original: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml diff --git a/tickLeiste/test/Spec.hs b/tickLeiste/test/Spec.hs deleted file mode 100644 index cd4753f..0000000 --- a/tickLeiste/test/Spec.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = putStrLn "Test suite not yet implemented" diff --git a/tickLeiste/tickLeiste.nix b/tickLeiste/tickLeiste.nix deleted file mode 100644 index 9ad8c2c..0000000 --- a/tickLeiste/tickLeiste.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ mkDerivation, base, containers, hpack, lib, text, uuid }: -mkDerivation { - pname = "tickLeiste"; - version = "0.1.0.0"; - src = ./.; - libraryHaskellDepends = [ base containers text uuid ]; - libraryToolDepends = [ hpack ]; - testHaskellDepends = [ base containers text uuid ]; - prePatch = "hpack"; - homepage = "https://github.com/githubuser/tickLeiste#readme"; - license = lib.licenses.bsd3; -}