on master help sign in
Merge pull request #136 from 3noch/drop-uuid-aeson
a7ce5cfAgentM
project-m36.cabal+11−10
@@ -34,7 +34,7 @@ Library
34 ,directory
34 ,directory
35 ,MonadRandom
35 ,MonadRandom
36 ,random-shuffle
36 ,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/
38 ,uuid >= 1.3.12
38 ,uuid >= 1.3.12
39 ,cassava >= 0.4.5.1 && < 0.6
39 ,cassava >= 0.4.5.1 && < 0.6
40 ,text
40 ,text
@@ -61,7 +61,8 @@ Library
61 ,data-interval
61 ,data-interval
62 ,extended-reals
62 ,extended-reals
63 ,network-transport
63 ,network-transport
64+ -- aeson 1.1 and above includes instances for UUID types
64− ,aeson
65+ ,aeson >= 1.1
65 ,path-pieces
66 ,path-pieces
66 ,conduit
67 ,conduit
67 ,resourcet
68 ,resourcet
@@ -189,7 +190,7 @@ Executable tutd
189 directory,
190 directory,
190 filepath,
191 filepath,
191 temporary,
192 temporary,
192− megaparsec >= 5.2.0 && < 5.3,
193+ megaparsec >= 5.2.0 && < 5.4,
193 haskeline,
194 haskeline,
194 random, MonadRandom,
195 random, MonadRandom,
195 base64-bytestring,
196 base64-bytestring,
@@ -430,7 +431,7 @@ Test-Suite test-scripts
430
431
431Executable project-m36-websocket-server
432Executable project-m36-websocket-server
432 Default-Language: Haskell2010
433 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
434 Main-Is: ProjectM36/Server/WebSocket/websocket-server.hs
435 Main-Is: ProjectM36/Server/WebSocket/websocket-server.hs
435 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
436 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
436 GHC-Options: -Wall
437 GHC-Options: -Wall
@@ -441,7 +442,7 @@ Test-Suite test-websocket-server
441 Default-Language: Haskell2010
442 Default-Language: Haskell2010
442 type: exitcode-stdio-1.0
443 type: exitcode-stdio-1.0
443 main-is: test/Server/WebSocket.hs
444 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
445 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
446 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
446 Default-Extensions: OverloadedStrings
447 Default-Extensions: OverloadedStrings
447 GHC-Options: -Wall
448 GHC-Options: -Wall
@@ -451,7 +452,7 @@ Test-Suite test-isomorphic-schemas
451 Default-Language: Haskell2010
452 Default-Language: Haskell2010
452 type: exitcode-stdio-1.0
453 type: exitcode-stdio-1.0
453 main-is: test/IsomorphicSchema.hs
454 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
455 Default-Extensions: OverloadedStrings
456 Default-Extensions: OverloadedStrings
456 GHC-Options: -Wall
457 GHC-Options: -Wall
457 Hs-Source-Dirs: ./src/bin, .
458 Hs-Source-Dirs: ./src/bin, .
@@ -460,7 +461,7 @@ Test-Suite test-atomable
460 Default-Language: Haskell2010
461 Default-Language: Haskell2010
461 type: exitcode-stdio-1.0
462 type: exitcode-stdio-1.0
462 main-is: test/Relation/Atomable.hs
463 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
464 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
465 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
465 Default-Extensions: OverloadedStrings
466 Default-Extensions: OverloadedStrings
466 GHC-Options: -Wall
467 GHC-Options: -Wall
@@ -470,7 +471,7 @@ Test-Suite test-multiprocess-access
470 Default-Language: Haskell2010
471 Default-Language: Haskell2010
471 type: exitcode-stdio-1.0
472 type: exitcode-stdio-1.0
472 main-is: test/MultiProcessDatabaseAccess.hs
473 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
474 Default-Extensions: OverloadedStrings
475 Default-Extensions: OverloadedStrings
475 GHC-Options: -Wall
476 GHC-Options: -Wall
476 Hs-Source-Dirs: ./src/bin, ., test/
477 Hs-Source-Dirs: ./src/bin, ., test/
@@ -479,7 +480,7 @@ Test-Suite test-transactiongraph-automerge
479 Default-Language: Haskell2010
480 Default-Language: Haskell2010
480 type: exitcode-stdio-1.0
481 type: exitcode-stdio-1.0
481 main-is: test/TransactionGraph/Automerge.hs
482 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
483 Default-Extensions: OverloadedStrings
484 Default-Extensions: OverloadedStrings
484 GHC-Options: -Wall
485 GHC-Options: -Wall
485 Hs-Source-Dirs: ./src/bin, ., test/
486 Hs-Source-Dirs: ./src/bin, ., test/
@@ -488,7 +489,7 @@ Test-Suite test-tupleable
488 Default-Language: Haskell2010
489 Default-Language: Haskell2010
489 type: exitcode-stdio-1.0
490 type: exitcode-stdio-1.0
490 main-is: test/Relation/Tupleable.hs
491 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
492 Default-Extensions: OverloadedStrings
493 Default-Extensions: OverloadedStrings
493 GHC-Options: -Wall
494 GHC-Options: -Wall
494 Hs-Source-Dirs: ./src/bin, ., test/
495 Hs-Source-Dirs: ./src/bin, ., test/
src/bin/ProjectM36/Server/RemoteCallTypes/Json.hs+13−14
@@ -1,17 +1,16 @@
1--create a bunch of orphan instances for use with the websocket server
1--create a bunch of orphan instances for use with the websocket server
2−{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
2+{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
3{-# OPTIONS_GHC -fno-warn-orphans #-}
3{-# OPTIONS_GHC -fno-warn-orphans #-}
4module ProjectM36.Server.RemoteCallTypes.Json where
4module ProjectM36.Server.RemoteCallTypes.Json where
5−import ProjectM36.Server.RemoteCallTypes
5+import ProjectM36.AtomFunctionError
6import ProjectM36.Base
6import ProjectM36.Base
7−import ProjectM36.Error
7+import ProjectM36.DatabaseContextFunctionError
8import ProjectM36.DataTypes.Primitive
8import ProjectM36.DataTypes.Primitive
9+import ProjectM36.Error
9import ProjectM36.IsomorphicSchema
10import ProjectM36.IsomorphicSchema
10−import ProjectM36.DatabaseContextFunctionError
11+import ProjectM36.Server.RemoteCallTypes
11−import ProjectM36.AtomFunctionError
12
12
13import Data.Aeson
13import Data.Aeson
14−import Data.UUID.Aeson ()
15import Data.ByteString.Base64 as B64
14import Data.ByteString.Base64 as B64
16import Data.Text.Encoding
15import Data.Text.Encoding
17import Data.Time.Calendar
16import Data.Time.Calendar
@@ -64,7 +63,7 @@ instance FromJSON SchemaExpr
64instance ToJSON SchemaIsomorph
63instance ToJSON SchemaIsomorph
65instance FromJSON SchemaIsomorph
64instance FromJSON SchemaIsomorph
66
65
67−instance ToJSON Atom where
66+instance ToJSON Atom where
68 toJSON atom@(IntAtom i) = object [ "type" .= atomTypeForAtom atom,
67 toJSON atom@(IntAtom i) = object [ "type" .= atomTypeForAtom atom,
69 "val" .= i ]
68 "val" .= i ]
70 toJSON atom@(DoubleAtom i) = object [ "type" .= atomTypeForAtom atom,
69 toJSON atom@(DoubleAtom i) = object [ "type" .= atomTypeForAtom atom,
@@ -79,9 +78,9 @@ instance ToJSON Atom where
79 "val" .= decodeUtf8 (B64.encode i) ]
78 "val" .= decodeUtf8 (B64.encode i) ]
80 toJSON atom@(BoolAtom i) = object [ "type" .= atomTypeForAtom atom,
79 toJSON atom@(BoolAtom i) = object [ "type" .= atomTypeForAtom atom,
81 "val" .= i ]
80 "val" .= i ]
82−
81+
83 toJSON atom@(IntervalAtom b e i1 i2) = object [ "type" .= atomTypeForAtom atom,
82 toJSON atom@(IntervalAtom b e i1 i2) = object [ "type" .= atomTypeForAtom atom,
84− "val" .= object [
83+ "val" .= object [
85 "begin" .= toJSON b,
84 "begin" .= toJSON b,
86 "end" .= toJSON e,
85 "end" .= toJSON e,
87 "beginopen" .= i1,
86 "beginopen" .= i1,
@@ -95,16 +94,16 @@ instance ToJSON Atom where
95 "type" .= toJSON atomtype,
94 "type" .= toJSON atomtype,
96 "atomlist" .= toJSON atomlist
95 "atomlist" .= toJSON atomlist
97 ]
96 ]
98−
97+
99instance FromJSON Atom where
98instance FromJSON Atom where
100 parseJSON = withObject "atom" $ \o -> do
99 parseJSON = withObject "atom" $ \o -> do
101− atype <- o .: "type"
100+ atype <- o .: "type"
102 case atype of
101 case atype of
103 TypeVariableType _ -> fail "cannot pass TypeVariableType over the wire"
102 TypeVariableType _ -> fail "cannot pass TypeVariableType over the wire"
104 caType@(ConstructedAtomType _ _) -> ConstructedAtom <$> o .: "dataconstructorname" <*> pure caType <*> o .: "atom"
103 caType@(ConstructedAtomType _ _) -> ConstructedAtom <$> o .: "dataconstructorname" <*> pure caType <*> o .: "atom"
105 RelationAtomType _ -> do
104 RelationAtomType _ -> do
106 rel <- o .: "val"
105 rel <- o .: "val"
107− pure $ RelationAtom rel
106+ pure $ RelationAtom rel
108 IntAtomType -> IntAtom <$> o .: "val"
107 IntAtomType -> IntAtom <$> o .: "val"
109 DoubleAtomType -> DoubleAtom <$> o .: "val"
108 DoubleAtomType -> DoubleAtom <$> o .: "val"
110 TextAtomType -> TextAtom <$> o .: "val"
109 TextAtomType -> TextAtom <$> o .: "val"
@@ -118,12 +117,12 @@ instance FromJSON Atom where
118 Left err -> fail ("Failed to parse base64-encoded ByteString: " ++ err)
117 Left err -> fail ("Failed to parse base64-encoded ByteString: " ++ err)
119 Right bs -> pure (ByteStringAtom bs)
118 Right bs -> pure (ByteStringAtom bs)
120 BoolAtomType -> BoolAtom <$> o .: "val"
119 BoolAtomType -> BoolAtom <$> o .: "val"
121− IntervalAtomType _ -> IntervalAtom <$>
120+ IntervalAtomType _ -> IntervalAtom <$>
122 ((o .: "val") >>= (.: "begin")) <*>
121 ((o .: "val") >>= (.: "begin")) <*>
123 ((o .: "val") >>= (.: "end")) <*>
122 ((o .: "val") >>= (.: "end")) <*>
124 ((o .: "val") >>= (.: "beginopen")) <*>
123 ((o .: "val") >>= (.: "beginopen")) <*>
125 ((o .: "val") >>= (.: "endopen"))
124 ((o .: "val") >>= (.: "endopen"))
126−
125+
127
126
128instance ToJSON Notification
127instance ToJSON Notification
129instance FromJSON Notification
128instance FromJSON Notification