Change the format to a list

This commit is contained in:
Mats Rauhala 2021-01-01 07:55:10 +02:00
parent 98f732dbd2
commit e741d7fd59
3 changed files with 8 additions and 10 deletions

View File

@ -52,6 +52,8 @@ library
, exceptions , exceptions
, bytestring , bytestring
, filepath , filepath
, vector
, hashids
hs-source-dirs: src hs-source-dirs: src
executable buuka executable buuka

View File

@ -1,7 +1,7 @@
{ mkDerivation, aeson, base, bytestring, conduit, conduit-extra { mkDerivation, aeson, base, bytestring, conduit, conduit-extra
, containers, exceptions, filepath, hedgehog, hedgehog-corpus, mtl , containers, exceptions, filepath, hashids, hedgehog
, optparse-applicative, stdenv, tasty, tasty-hedgehog, text , hedgehog-corpus, mtl, optparse-applicative, stdenv, tasty
, transformers, unliftio, yaml , tasty-hedgehog, text, transformers, unliftio, vector, yaml
}: }:
mkDerivation { mkDerivation {
pname = "buuka"; pname = "buuka";
@ -11,7 +11,7 @@ mkDerivation {
isExecutable = true; isExecutable = true;
libraryHaskellDepends = [ libraryHaskellDepends = [
aeson base bytestring conduit conduit-extra containers exceptions aeson base bytestring conduit conduit-extra containers exceptions
filepath mtl transformers unliftio yaml filepath hashids mtl transformers unliftio vector yaml
]; ];
executableHaskellDepends = [ base optparse-applicative unliftio ]; executableHaskellDepends = [ base optparse-applicative unliftio ];
testHaskellDepends = [ testHaskellDepends = [

View File

@ -11,10 +11,6 @@ module Data.Buuka
) )
where where
import Data.Map
(Map)
import qualified Data.Map.Strict as M
import Database.Migrations import Database.Migrations
import Data.Aeson import Data.Aeson
@ -38,12 +34,12 @@ data BuukaEntry
instance SafeJSON BuukaEntry where instance SafeJSON BuukaEntry where
type Version BuukaEntry = 0 type Version BuukaEntry = 0
newtype Buuka = Buuka ( Map URL BuukaEntry ) newtype Buuka = Buuka [BuukaEntry]
deriving stock (Show, Eq) deriving stock (Show, Eq)
deriving newtype (Semigroup, Monoid, FromJSON, ToJSON) deriving newtype (Semigroup, Monoid, FromJSON, ToJSON)
insert :: BuukaEntry -> Buuka -> Buuka insert :: BuukaEntry -> Buuka -> Buuka
insert e (Buuka b) = Buuka (M.insert (url e) e b) insert e (Buuka b) = Buuka (e : b)
instance SafeJSON Buuka where instance SafeJSON Buuka where
type Version Buuka = 0 type Version Buuka = 0