-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App spec json #2284
base: main
Are you sure you want to change the base?
App spec json #2284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sodic there is a lot of small, boring changes, so I commented here on all the changes that are actually interesting, so you don't have to wonder if you missed any among the boredoom of the rest.
takeDecls, | ||
makeDecl, | ||
fromDecl, | ||
) | ||
where | ||
|
||
import Data.Maybe (mapMaybe) | ||
import Data.Typeable (Typeable, cast) | ||
|
||
class (Typeable a) => IsDecl a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took IsDecl from here to its own file to avoid circular dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the main logic (well, generated by TH, which is in JSON/TH.hs file). TH logic has to be in another file (in JSON/TH.hs), GHC demanded it, has to do with order in which stuff is compiled.
In this file are the main TODOs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw cool trick I learned: add {-# OPTIONS_GHC -ddump-splices #-}
at the top, run cabal build
, and you will, in compiler output in stdout, the contents of this file as generated by TH.
|
||
import Data.Typeable (Proxy (Proxy), Typeable, typeRep) | ||
|
||
class (Typeable a) => IsDecl a where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, I just moved this from Decl.hs to here, in this standalone file, to avoid circ deps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ones?
@@ -25,3 +27,16 @@ deriving instance (IsDecl a, Data a) => Data (Ref a) | |||
|
|||
refName :: Ref a -> String | |||
refName (Ref name) = name | |||
|
|||
instance (IsDecl a) => FromJSON (Ref a) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we expect JSON to contain not just the declaration identifier name, but also its declaration type. We could drop that if we want, but then all identifiers need to be unique and I actually wasn't sure if that is so now. Also I thought it can't hurt.
@@ -30,6 +31,9 @@ data Entity = Entity | |||
|
|||
instance IsDecl Entity | |||
|
|||
instance FromJSON Entity where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't allow defining entities via Wasp file any more, but we left some of the old machinery in for now since it was easier then purging it, so I just put this error
here, I think this should be quite fine for now.
deriving (Show, Eq, Data) | ||
deriving (Show, Eq, Data, Generic) | ||
|
||
instance FromJSON ExtImport where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I manually implemented JSON parsing in order to explain how to parse the StrongPath in question.
8b1b8a5
to
3a32723
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving some comments for myself.
waspc/src/Wasp/AppSpec/Core/Decl.hs
Outdated
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE BlockArguments #-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these here? Probably not.
{-# LANGUAGE TypeApplications #-} -- Needed by generateFromJsonInstanceForDecl (TH) | ||
{-# OPTIONS_GHC -Wno-orphans #-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check why we need this.
|
||
import Data.Typeable (Proxy (Proxy), Typeable, typeRep) | ||
|
||
class (Typeable a) => IsDecl a where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ones?
@sodic please take this one and finish it! I think I got it quite far: check TODOs in the code, and see how usable is it for you.