on master help sign in
Merge pull request #136 from 3noch/drop-uuid-aeson

Drop uuid aeson

commita7ce5cf3b6dabb8f3450e7e6728da869e62aa475 authorAgentM <agentm@themactionfaction.com> dateTue 12 Sep 2017, 09:15 (9 years ago) parentc7a5965fbfa2ea
2 files changed+24−24
project-m36.cabal+11−10 src/bin/ProjectM36/Server/RemoteCallTypes/Json.hs+13−14
project-m36.cabal+11−10
@@ -34,7 +34,7 @@ Library
3434 ,directory
3535 ,MonadRandom
3636 ,random-shuffle
37− --critical uuid bug in lesser versions https://www.reddit.com/r/haskell/comments/4myot5/psa_make_sure_to_use_uuid_1312/
37+ --critical uuid bug in lesser versions https://www.reddit.com/r/haskell/comments/4myot5/psa_make_sure_to_use_uuid_1312/
3838 ,uuid >= 1.3.12
3939 ,cassava >= 0.4.5.1 && < 0.6
4040 ,text
@@ -61,7 +61,8 @@ Library
6161 ,data-interval
6262 ,extended-reals
6363 ,network-transport
64− ,aeson
64+ -- aeson 1.1 and above includes instances for UUID types
65+ ,aeson >= 1.1
6566 ,path-pieces
6667 ,conduit
6768 ,resourcet
@@ -189,7 +190,7 @@ Executable tutd
189190 directory,
190191 filepath,
191192 temporary,
192− megaparsec >= 5.2.0 && < 5.3,
193+ megaparsec >= 5.2.0 && < 5.4,
193194 haskeline,
194195 random, MonadRandom,
195196 base64-bytestring,
@@ -430,7 +431,7 @@ Test-Suite test-scripts
430431
431432Executable project-m36-websocket-server
432433 Default-Language: Haskell2010
433− Build-Depends: base, aeson, path-pieces, either, conduit, http-api-data, template-haskell, websockets, aeson, uuid-aeson, optparse-applicative, project-m36, containers, bytestring, text, vector, uuid, megaparsec, haskeline, mtl, directory, base64-bytestring, random, MonadRandom, time, network-transport-tcp, semigroups
434+ Build-Depends: base, aeson, path-pieces, either, conduit, http-api-data, template-haskell, websockets, aeson, optparse-applicative, project-m36, containers, bytestring, text, vector, uuid, megaparsec, haskeline, mtl, directory, base64-bytestring, random, MonadRandom, time, network-transport-tcp, semigroups
434435 Main-Is: ProjectM36/Server/WebSocket/websocket-server.hs
435436 Other-Modules: ProjectM36.Client.Json, ProjectM36.Server.RemoteCallTypes.Json, ProjectM36.Server.WebSocket, TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.SchemaOperator
436437 GHC-Options: -Wall
@@ -441,7 +442,7 @@ Test-Suite test-websocket-server
441442 Default-Language: Haskell2010
442443 type: exitcode-stdio-1.0
443444 main-is: test/Server/WebSocket.hs
444− Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, uuid-aeson, project-m36, random, MonadRandom, network-transport-tcp, semigroups
445+ Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36, random, MonadRandom, network-transport-tcp, semigroups
445446 Other-Modules: TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.TransactionGraphOperator, ProjectM36.Client.Json, ProjectM36.Server.RemoteCallTypes.Json, ProjectM36.Server.WebSocket, TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.Types, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.SchemaOperator
446447 Default-Extensions: OverloadedStrings
447448 GHC-Options: -Wall
@@ -451,7 +452,7 @@ Test-Suite test-isomorphic-schemas
451452 Default-Language: Haskell2010
452453 type: exitcode-stdio-1.0
453454 main-is: test/IsomorphicSchema.hs
454− Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, uuid-aeson, project-m36
455+ Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36
455456 Default-Extensions: OverloadedStrings
456457 GHC-Options: -Wall
457458 Hs-Source-Dirs: ./src/bin, .
@@ -460,7 +461,7 @@ Test-Suite test-atomable
460461 Default-Language: Haskell2010
461462 type: exitcode-stdio-1.0
462463 main-is: test/Relation/Atomable.hs
463− Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, uuid-aeson, project-m36, random, MonadRandom, semigroups
464+ Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36, random, MonadRandom, semigroups
464465 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.SchemaOperator, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types
465466 Default-Extensions: OverloadedStrings
466467 GHC-Options: -Wall
@@ -470,7 +471,7 @@ Test-Suite test-multiprocess-access
470471 Default-Language: Haskell2010
471472 type: exitcode-stdio-1.0
472473 main-is: test/MultiProcessDatabaseAccess.hs
473− Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, uuid-aeson, project-m36, random, MonadRandom
474+ Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36, random, MonadRandom
474475 Default-Extensions: OverloadedStrings
475476 GHC-Options: -Wall
476477 Hs-Source-Dirs: ./src/bin, ., test/
@@ -479,7 +480,7 @@ Test-Suite test-transactiongraph-automerge
479480 Default-Language: Haskell2010
480481 type: exitcode-stdio-1.0
481482 main-is: test/TransactionGraph/Automerge.hs
482− Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, uuid-aeson, project-m36, random, MonadRandom, semigroups
483+ Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36, random, MonadRandom, semigroups
483484 Default-Extensions: OverloadedStrings
484485 GHC-Options: -Wall
485486 Hs-Source-Dirs: ./src/bin, ., test/
@@ -488,7 +489,7 @@ Test-Suite test-tupleable
488489 Default-Language: Haskell2010
489490 type: exitcode-stdio-1.0
490491 main-is: test/Relation/Tupleable.hs
491− Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, uuid-aeson, project-m36, random, MonadRandom, semigroups
492+ Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36, random, MonadRandom, semigroups
492493 Default-Extensions: OverloadedStrings
493494 GHC-Options: -Wall
494495 Hs-Source-Dirs: ./src/bin, ., test/
src/bin/ProjectM36/Server/RemoteCallTypes/Json.hs+13−14
@@ -1,17 +1,16 @@
11--create a bunch of orphan instances for use with the websocket server
2−{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
2+{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
33{-# OPTIONS_GHC -fno-warn-orphans #-}
44module ProjectM36.Server.RemoteCallTypes.Json where
5−import ProjectM36.Server.RemoteCallTypes
5+import ProjectM36.AtomFunctionError
66import ProjectM36.Base
7−import ProjectM36.Error
7+import ProjectM36.DatabaseContextFunctionError
88import ProjectM36.DataTypes.Primitive
9+import ProjectM36.Error
910import ProjectM36.IsomorphicSchema
10−import ProjectM36.DatabaseContextFunctionError
11−import ProjectM36.AtomFunctionError
11+import ProjectM36.Server.RemoteCallTypes
1212
1313import Data.Aeson
14−import Data.UUID.Aeson ()
1514import Data.ByteString.Base64 as B64
1615import Data.Text.Encoding
1716import Data.Time.Calendar
@@ -64,7 +63,7 @@ instance FromJSON SchemaExpr
6463instance ToJSON SchemaIsomorph
6564instance FromJSON SchemaIsomorph
6665
67−instance ToJSON Atom where
66+instance ToJSON Atom where
6867 toJSON atom@(IntAtom i) = object [ "type" .= atomTypeForAtom atom,
6968 "val" .= i ]
7069 toJSON atom@(DoubleAtom i) = object [ "type" .= atomTypeForAtom atom,
@@ -79,9 +78,9 @@ instance ToJSON Atom where
7978 "val" .= decodeUtf8 (B64.encode i) ]
8079 toJSON atom@(BoolAtom i) = object [ "type" .= atomTypeForAtom atom,
8180 "val" .= i ]
82−
81+
8382 toJSON atom@(IntervalAtom b e i1 i2) = object [ "type" .= atomTypeForAtom atom,
84− "val" .= object [
83+ "val" .= object [
8584 "begin" .= toJSON b,
8685 "end" .= toJSON e,
8786 "beginopen" .= i1,
@@ -95,16 +94,16 @@ instance ToJSON Atom where
9594 "type" .= toJSON atomtype,
9695 "atomlist" .= toJSON atomlist
9796 ]
98−
97+
9998instance FromJSON Atom where
10099 parseJSON = withObject "atom" $ \o -> do
101− atype <- o .: "type"
100+ atype <- o .: "type"
102101 case atype of
103102 TypeVariableType _ -> fail "cannot pass TypeVariableType over the wire"
104103 caType@(ConstructedAtomType _ _) -> ConstructedAtom <$> o .: "dataconstructorname" <*> pure caType <*> o .: "atom"
105104 RelationAtomType _ -> do
106105 rel <- o .: "val"
107− pure $ RelationAtom rel
106+ pure $ RelationAtom rel
108107 IntAtomType -> IntAtom <$> o .: "val"
109108 DoubleAtomType -> DoubleAtom <$> o .: "val"
110109 TextAtomType -> TextAtom <$> o .: "val"
@@ -118,12 +117,12 @@ instance FromJSON Atom where
118117 Left err -> fail ("Failed to parse base64-encoded ByteString: " ++ err)
119118 Right bs -> pure (ByteStringAtom bs)
120119 BoolAtomType -> BoolAtom <$> o .: "val"
121− IntervalAtomType _ -> IntervalAtom <$>
120+ IntervalAtomType _ -> IntervalAtom <$>
122121 ((o .: "val") >>= (.: "begin")) <*>
123122 ((o .: "val") >>= (.: "end")) <*>
124123 ((o .: "val") >>= (.: "beginopen")) <*>
125124 ((o .: "val") >>= (.: "endopen"))
126−
125+
127126
128127instance ToJSON Notification
129128instance FromJSON Notification