From 58e9e6c16ce132ac98c56c9821cee3176c6bbc5b Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Sun, 6 Sep 2020 02:13:02 +0200 Subject: [PATCH 01/10] make a good default instead of maybe --- src/Data/TickLeiste.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Data/TickLeiste.hs b/src/Data/TickLeiste.hs index 020b8f4..385c39f 100644 --- a/src/Data/TickLeiste.hs +++ b/src/Data/TickLeiste.hs @@ -116,11 +116,10 @@ removePlayer = error "removePlayer not yet implemented (Franzi?)" toList :: TickLeiste -> [(Tick, [Player])] toList (TickLeiste l _) = M.toAscList l --- | convert from list to TickLeiste, if a player is at multiple 'Tick' this returns --- 'Nothing' +-- | convert from list to TickLeiste -- TODO -fromList :: [(Tick, [Player])] -> Maybe TickLeiste +fromList :: [(Tick, [Player])] -> TickLeiste fromList = error "not implemented" -- | convert from 'TickLeiste' to a map from 'Tick' to list of 'Player' From 41055a852102dcaa8658452c09c1c0afd2f42900 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Mon, 21 Sep 2020 23:13:13 +0200 Subject: [PATCH 02/10] added Aeson instances --- src/Data/Aeson/TickLeiste.hs | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Data/Aeson/TickLeiste.hs diff --git a/src/Data/Aeson/TickLeiste.hs b/src/Data/Aeson/TickLeiste.hs new file mode 100644 index 0000000..ee3cbf3 --- /dev/null +++ b/src/Data/Aeson/TickLeiste.hs @@ -0,0 +1,37 @@ +{-# 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) + +$(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) + +$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "eventType"}, fieldLabelModifier = drop 4} ''JSONEvent) From c41d8aa43e7183d0f3d85bd1d8799d03db58be74 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Tue, 22 Sep 2020 12:11:10 +0200 Subject: [PATCH 03/10] refactored aeson instance in own package, this is now a multi-package project --- stack.yaml | 3 +- tickLeiste-aeson/.gitignore | 2 + tickLeiste-aeson/ChangeLog.md | 3 + LICENSE => tickLeiste-aeson/LICENSE | 0 tickLeiste-aeson/README.md | 1 + Setup.hs => tickLeiste-aeson/Setup.hs | 0 tickLeiste-aeson/app/Main.hs | 6 ++ tickLeiste-aeson/package.yaml | 52 +++++++++++++ .../src}/Data/Aeson/TickLeiste.hs | 0 tickLeiste-aeson/src/Lib.hs | 6 ++ {test => tickLeiste-aeson/test}/Spec.hs | 0 tickLeiste-aeson/tickLeiste-aeson.cabal | 73 +++++++++++++++++++ ChangeLog.md => tickLeiste/ChangeLog.md | 0 tickLeiste/LICENSE | 30 ++++++++ README.md => tickLeiste/README.md | 0 tickLeiste/Setup.hs | 2 + package.yaml => tickLeiste/package.yaml | 0 {src => tickLeiste/src}/Data/TickLeiste.hs | 0 tickLeiste/stack.yaml.lock | 13 ++++ tickLeiste/test/Spec.hs | 2 + .../tickLeiste.cabal | 0 21 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 tickLeiste-aeson/.gitignore create mode 100644 tickLeiste-aeson/ChangeLog.md rename LICENSE => tickLeiste-aeson/LICENSE (100%) create mode 100644 tickLeiste-aeson/README.md rename Setup.hs => tickLeiste-aeson/Setup.hs (100%) create mode 100644 tickLeiste-aeson/app/Main.hs create mode 100644 tickLeiste-aeson/package.yaml rename {src => tickLeiste-aeson/src}/Data/Aeson/TickLeiste.hs (100%) create mode 100644 tickLeiste-aeson/src/Lib.hs rename {test => tickLeiste-aeson/test}/Spec.hs (100%) create mode 100644 tickLeiste-aeson/tickLeiste-aeson.cabal rename ChangeLog.md => tickLeiste/ChangeLog.md (100%) create mode 100644 tickLeiste/LICENSE rename README.md => tickLeiste/README.md (100%) create mode 100644 tickLeiste/Setup.hs rename package.yaml => tickLeiste/package.yaml (100%) rename {src => tickLeiste/src}/Data/TickLeiste.hs (100%) create mode 100644 tickLeiste/stack.yaml.lock create mode 100644 tickLeiste/test/Spec.hs rename tickLeiste.cabal => tickLeiste/tickLeiste.cabal (100%) diff --git a/stack.yaml b/stack.yaml index aa72cf0..41feb9d 100644 --- a/stack.yaml +++ b/stack.yaml @@ -30,7 +30,8 @@ resolver: # - 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/tickLeiste-aeson/.gitignore b/tickLeiste-aeson/.gitignore new file mode 100644 index 0000000..c368d45 --- /dev/null +++ b/tickLeiste-aeson/.gitignore @@ -0,0 +1,2 @@ +.stack-work/ +*~ \ No newline at end of file diff --git a/tickLeiste-aeson/ChangeLog.md b/tickLeiste-aeson/ChangeLog.md new file mode 100644 index 0000000..dce1625 --- /dev/null +++ b/tickLeiste-aeson/ChangeLog.md @@ -0,0 +1,3 @@ +# Changelog for tickLeiste-aeson + +## Unreleased changes diff --git a/LICENSE b/tickLeiste-aeson/LICENSE similarity index 100% rename from LICENSE rename to tickLeiste-aeson/LICENSE diff --git a/tickLeiste-aeson/README.md b/tickLeiste-aeson/README.md new file mode 100644 index 0000000..a49f84b --- /dev/null +++ b/tickLeiste-aeson/README.md @@ -0,0 +1 @@ +# tickLeiste-aeson diff --git a/Setup.hs b/tickLeiste-aeson/Setup.hs similarity index 100% rename from Setup.hs rename to tickLeiste-aeson/Setup.hs diff --git a/tickLeiste-aeson/app/Main.hs b/tickLeiste-aeson/app/Main.hs new file mode 100644 index 0000000..de1c1ab --- /dev/null +++ b/tickLeiste-aeson/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import Lib + +main :: IO () +main = someFunc diff --git a/tickLeiste-aeson/package.yaml b/tickLeiste-aeson/package.yaml new file mode 100644 index 0000000..dc642a4 --- /dev/null +++ b/tickLeiste-aeson/package.yaml @@ -0,0 +1,52 @@ +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 + +executables: + tickLeiste-aeson-exe: + main: Main.hs + source-dirs: app + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - tickLeiste-aeson + +tests: + tickLeiste-aeson-test: + main: Spec.hs + source-dirs: test + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - tickLeiste-aeson diff --git a/src/Data/Aeson/TickLeiste.hs b/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs similarity index 100% rename from src/Data/Aeson/TickLeiste.hs rename to tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs diff --git a/tickLeiste-aeson/src/Lib.hs b/tickLeiste-aeson/src/Lib.hs new file mode 100644 index 0000000..d36ff27 --- /dev/null +++ b/tickLeiste-aeson/src/Lib.hs @@ -0,0 +1,6 @@ +module Lib + ( someFunc + ) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/test/Spec.hs b/tickLeiste-aeson/test/Spec.hs similarity index 100% rename from test/Spec.hs rename to tickLeiste-aeson/test/Spec.hs diff --git a/tickLeiste-aeson/tickLeiste-aeson.cabal b/tickLeiste-aeson/tickLeiste-aeson.cabal new file mode 100644 index 0000000..d670bd1 --- /dev/null +++ b/tickLeiste-aeson/tickLeiste-aeson.cabal @@ -0,0 +1,73 @@ +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 + Lib + other-modules: + Paths_tickLeiste_aeson + hs-source-dirs: + src + build-depends: + aeson + , base >=4.7 && <5 + , text + , tickLeiste + , uuid + default-language: Haskell2010 + +executable tickLeiste-aeson-exe + main-is: Main.hs + other-modules: + Paths_tickLeiste_aeson + hs-source-dirs: + app + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson + , base >=4.7 && <5 + , text + , tickLeiste + , tickLeiste-aeson + , 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/ChangeLog.md b/tickLeiste/ChangeLog.md similarity index 100% rename from ChangeLog.md rename to tickLeiste/ChangeLog.md diff --git a/tickLeiste/LICENSE b/tickLeiste/LICENSE new file mode 100644 index 0000000..e637cde --- /dev/null +++ b/tickLeiste/LICENSE @@ -0,0 +1,30 @@ +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/README.md b/tickLeiste/README.md similarity index 100% rename from README.md rename to tickLeiste/README.md diff --git a/tickLeiste/Setup.hs b/tickLeiste/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/tickLeiste/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/package.yaml b/tickLeiste/package.yaml similarity index 100% rename from package.yaml rename to tickLeiste/package.yaml diff --git a/src/Data/TickLeiste.hs b/tickLeiste/src/Data/TickLeiste.hs similarity index 100% rename from src/Data/TickLeiste.hs rename to tickLeiste/src/Data/TickLeiste.hs diff --git a/tickLeiste/stack.yaml.lock b/tickLeiste/stack.yaml.lock new file mode 100644 index 0000000..857b03e --- /dev/null +++ b/tickLeiste/stack.yaml.lock @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 0000000..cd4753f --- /dev/null +++ b/tickLeiste/test/Spec.hs @@ -0,0 +1,2 @@ +main :: IO () +main = putStrLn "Test suite not yet implemented" diff --git a/tickLeiste.cabal b/tickLeiste/tickLeiste.cabal similarity index 100% rename from tickLeiste.cabal rename to tickLeiste/tickLeiste.cabal From b40c7faef0343a09f256833d822cc7734e3fcb4f Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Tue, 22 Sep 2020 12:16:11 +0200 Subject: [PATCH 04/10] cleaned tickLeiste-aeson Lib.hs and executable --- tickLeiste-aeson/app/Main.hs | 6 ------ tickLeiste-aeson/package.yaml | 11 ----------- tickLeiste-aeson/src/Lib.hs | 6 ------ tickLeiste-aeson/tickLeiste-aeson.cabal | 17 ----------------- 4 files changed, 40 deletions(-) delete mode 100644 tickLeiste-aeson/app/Main.hs delete mode 100644 tickLeiste-aeson/src/Lib.hs diff --git a/tickLeiste-aeson/app/Main.hs b/tickLeiste-aeson/app/Main.hs deleted file mode 100644 index de1c1ab..0000000 --- a/tickLeiste-aeson/app/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Main where - -import Lib - -main :: IO () -main = someFunc diff --git a/tickLeiste-aeson/package.yaml b/tickLeiste-aeson/package.yaml index dc642a4..51b54b6 100644 --- a/tickLeiste-aeson/package.yaml +++ b/tickLeiste-aeson/package.yaml @@ -29,17 +29,6 @@ dependencies: library: source-dirs: src -executables: - tickLeiste-aeson-exe: - main: Main.hs - source-dirs: app - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - tickLeiste-aeson - tests: tickLeiste-aeson-test: main: Spec.hs diff --git a/tickLeiste-aeson/src/Lib.hs b/tickLeiste-aeson/src/Lib.hs deleted file mode 100644 index d36ff27..0000000 --- a/tickLeiste-aeson/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tickLeiste-aeson/tickLeiste-aeson.cabal b/tickLeiste-aeson/tickLeiste-aeson.cabal index d670bd1..22bb718 100644 --- a/tickLeiste-aeson/tickLeiste-aeson.cabal +++ b/tickLeiste-aeson/tickLeiste-aeson.cabal @@ -26,7 +26,6 @@ source-repository head library exposed-modules: Data.Aeson.TickLeiste - Lib other-modules: Paths_tickLeiste_aeson hs-source-dirs: @@ -39,22 +38,6 @@ library , uuid default-language: Haskell2010 -executable tickLeiste-aeson-exe - main-is: Main.hs - other-modules: - Paths_tickLeiste_aeson - hs-source-dirs: - app - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson - , base >=4.7 && <5 - , text - , tickLeiste - , tickLeiste-aeson - , uuid - default-language: Haskell2010 - test-suite tickLeiste-aeson-test type: exitcode-stdio-1.0 main-is: Spec.hs From 4af9f88b839c00ba22f36ba5d003459f7efbe04b Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Tue, 22 Sep 2020 17:05:34 +0200 Subject: [PATCH 05/10] switched to newer resolver --- stack.yaml | 2 +- stack.yaml.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stack.yaml b/stack.yaml index 41feb9d..701474a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -18,7 +18,7 @@ # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml resolver: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/stack.yaml.lock b/stack.yaml.lock index 857b03e..b10e8c4 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -6,8 +6,8 @@ packages: [] snapshots: - completed: - size: 532383 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml - sha256: 469d781ab6d2a4eceed6b31b6e4ec842dcd3cd1d11577972e86902603dce24df + size: 532380 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml + sha256: 3b5f2a699aa5ed3abbc30410062bf743926f0868ce3eeb5655370c6c6cc1a9f4 original: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/10.yaml + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml From da214ba266d8b2924f4e77530734f771bd38abe0 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Tue, 22 Sep 2020 17:33:15 +0200 Subject: [PATCH 06/10] added read instances --- tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs | 4 ++-- tickLeiste/src/Data/TickLeiste.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs b/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs index ee3cbf3..10541ba 100644 --- a/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs +++ b/tickLeiste-aeson/src/Data/Aeson/TickLeiste.hs @@ -22,7 +22,7 @@ data JSONRequest | TickLeisteR | ChangeNameR {cnaRplayerUUID :: U.UUID, cnaRplayerName :: T.Text} | RemovePlayerR {rmpRplayerUUID :: U.UUID} - deriving (Show,Eq) + deriving (Show, Eq, Read) $(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "requestType"}, fieldLabelModifier = drop 4} ''JSONRequest) @@ -32,6 +32,6 @@ data JSONEvent | InitializeTickLeisteE {itlEtickLeiste :: [(Tick, [(U.UUID, T.Text)])]} | ChangeNameE {cnaEplayerUUID :: U.UUID, cnaEplayerName :: T.Text} | RemovePlayerE {rmpEplayerUUID :: U.UUID} - deriving (Show,Eq) + deriving (Show, Eq, Read) $(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "eventType"}, fieldLabelModifier = drop 4} ''JSONEvent) diff --git a/tickLeiste/src/Data/TickLeiste.hs b/tickLeiste/src/Data/TickLeiste.hs index 385c39f..ef5a65d 100644 --- a/tickLeiste/src/Data/TickLeiste.hs +++ b/tickLeiste/src/Data/TickLeiste.hs @@ -28,7 +28,7 @@ import qualified Data.UUID as U -- | A Tick is just a number data Tick = Abwarten | Bereithalten | Tick Int - deriving (Show, Eq, Ord) + deriving (Show, Eq, Ord, Read) -- | test if 'Tick' is constructed using 'Abwarten' isAbwarten :: Tick -> Bool From 10318ade8cef231843ac2b95ce51d0a2986feeb9 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Sun, 14 Mar 2021 18:32:56 +0100 Subject: [PATCH 07/10] changed to lts version 17.5 --- stack.yaml | 4 ++-- stack.yaml.lock | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/stack.yaml b/stack.yaml index 701474a..3b03c93 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: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml +resolver: lts-17.5 +# url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/stack.yaml.lock b/stack.yaml.lock index b10e8c4..1bba64b 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,11 +3,10 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: [] snapshots: -- completed: - size: 532380 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml - sha256: 3b5f2a699aa5ed3abbc30410062bf743926f0868ce3eeb5655370c6c6cc1a9f4 - original: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml +- original: lts-17.5 + completed: + sha256: 78e8ebabf11406261abbc95b44f240acf71802630b368888f6d758de7fc3a2f7 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/5.yaml + size: 565266 +packages: [] From 3a9592f9585b842b09643684e0060199233416e4 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Tue, 30 Mar 2021 14:21:28 +0200 Subject: [PATCH 08/10] added removePlayer --- tickLeiste/src/Data/TickLeiste.hs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tickLeiste/src/Data/TickLeiste.hs b/tickLeiste/src/Data/TickLeiste.hs index ef5a65d..ecfe4ea 100644 --- a/tickLeiste/src/Data/TickLeiste.hs +++ b/tickLeiste/src/Data/TickLeiste.hs @@ -22,7 +22,7 @@ module Data.TickLeiste where import qualified Data.Map.Strict as M -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe,maybe) import qualified Data.Text as T import qualified Data.UUID as U @@ -110,7 +110,14 @@ setPlayerTick p t tl@(TickLeiste l pl) = TickLeiste (insertPlayerToLeiste p t l' -- TODO removePlayer :: Player -> TickLeiste -> TickLeiste -removePlayer = error "removePlayer not yet implemented (Franzi?)" +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 -- | convert the Tick[eiste to a list of 'Tick' and 'Player' list pairs. These list are ordered toList :: TickLeiste -> [(Tick, [Player])] @@ -120,7 +127,7 @@ toList (TickLeiste l _) = M.toAscList l -- TODO fromList :: [(Tick, [Player])] -> TickLeiste -fromList = error "not implemented" +fromList = error "not implemented (Franzi?)" -- | convert from 'TickLeiste' to a map from 'Tick' to list of 'Player' toMap :: TickLeiste -> M.Map Tick [Player] @@ -130,6 +137,7 @@ 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 @@ -138,6 +146,9 @@ 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 From fd9e5545f5486b0e24cd94b7fb26bfaea5154206 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Mon, 3 Jan 2022 21:25:44 +0100 Subject: [PATCH 09/10] added haddock for removePlayer --- tickLeiste/src/Data/TickLeiste.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/tickLeiste/src/Data/TickLeiste.hs b/tickLeiste/src/Data/TickLeiste.hs index ecfe4ea..1d7316a 100644 --- a/tickLeiste/src/Data/TickLeiste.hs +++ b/tickLeiste/src/Data/TickLeiste.hs @@ -109,6 +109,7 @@ 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 From 5c0134bd060c5d83f2b6682fc616c5307b2836da Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Mon, 30 Oct 2023 12:12:46 +0100 Subject: [PATCH 10/10] make it a nix flake --- .gitignore | 6 ++- flake-module.nix | 12 +++++ flake.lock | 63 +++++++++++++++++++++++++++ flake.nix | 11 +++++ tickLeiste-aeson/default.nix | 2 + tickLeiste-aeson/tickLeiste-aeson.nix | 12 +++++ tickLeiste/default.nix | 2 + tickLeiste/tickLeiste.nix | 12 +++++ 8 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 flake-module.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 tickLeiste-aeson/default.nix create mode 100644 tickLeiste-aeson/tickLeiste-aeson.nix create mode 100644 tickLeiste/default.nix create mode 100644 tickLeiste/tickLeiste.nix diff --git a/.gitignore b/.gitignore index c368d45..23812ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ .stack-work/ -*~ \ No newline at end of file +*~ + +# ---> Nix +result +result-* diff --git a/flake-module.nix b/flake-module.nix new file mode 100644 index 0000000..84d3699 --- /dev/null +++ b/flake-module.nix @@ -0,0 +1,12 @@ +{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 new file mode 100644 index 0000000..39955d4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,63 @@ +{ + "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 new file mode 100644 index 0000000..81027ac --- /dev/null +++ b/flake.nix @@ -0,0 +1,11 @@ +{ + 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-aeson/default.nix b/tickLeiste-aeson/default.nix new file mode 100644 index 0000000..7a00703 --- /dev/null +++ b/tickLeiste-aeson/default.nix @@ -0,0 +1,2 @@ +{pkgs ? import {}, ...}: +pkgs.haskellPackages.callPackage ./tickLeiste-aeson.nix {} diff --git a/tickLeiste-aeson/tickLeiste-aeson.nix b/tickLeiste-aeson/tickLeiste-aeson.nix new file mode 100644 index 0000000..3c95b1a --- /dev/null +++ b/tickLeiste-aeson/tickLeiste-aeson.nix @@ -0,0 +1,12 @@ +{ 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/default.nix b/tickLeiste/default.nix new file mode 100644 index 0000000..e95ebd2 --- /dev/null +++ b/tickLeiste/default.nix @@ -0,0 +1,2 @@ +{pkgs ? import , ...}: +pkgs.haskellPackages.callPackage ./tickLeiste.nix {} diff --git a/tickLeiste/tickLeiste.nix b/tickLeiste/tickLeiste.nix new file mode 100644 index 0000000..9ad8c2c --- /dev/null +++ b/tickLeiste/tickLeiste.nix @@ -0,0 +1,12 @@ +{ 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; +}