diff --git a/waspc/src/Wasp/AppSpec/Core/Decl.hs b/waspc/src/Wasp/AppSpec/Core/Decl.hs index 6d82175152..bbe6bddd22 100644 --- a/waspc/src/Wasp/AppSpec/Core/Decl.hs +++ b/waspc/src/Wasp/AppSpec/Core/Decl.hs @@ -1,5 +1,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} module Wasp.AppSpec.Core.Decl ( Decl, @@ -9,9 +10,20 @@ module Wasp.AppSpec.Core.Decl ) where +import Control.Applicative ((<|>)) import Data.Maybe (mapMaybe) import Data.Typeable (cast) +import Wasp.AppSpec.Action (Action) +import Wasp.AppSpec.Api (Api) +import Wasp.AppSpec.ApiNamespace (ApiNamespace) +import Wasp.AppSpec.App (App) import Wasp.AppSpec.Core.IsDecl (IsDecl) +import Wasp.AppSpec.Crud (Crud) +import Wasp.AppSpec.Entity (Entity) +import Wasp.AppSpec.Job (Job) +import Wasp.AppSpec.Page (Page) +import Wasp.AppSpec.Query (Query) +import Wasp.AppSpec.Route (Route) -- | A container for any (IsDecl a) type, allowing you to have a heterogenous list of -- Wasp declarations as [Decl]. @@ -19,6 +31,20 @@ import Wasp.AppSpec.Core.IsDecl (IsDecl) data Decl where Decl :: (IsDecl a) => String -> a -> Decl +instance Show Decl where + show decl = + show $ + (show <$> fromDecl @Api decl) + <|> (show <$> fromDecl @Route decl) + <|> (show <$> fromDecl @Crud decl) + <|> (show <$> fromDecl @App decl) + <|> (show <$> fromDecl @Action decl) + <|> (show <$> fromDecl @Job decl) + <|> (show <$> fromDecl @Entity decl) + <|> (show <$> fromDecl @Page decl) + <|> (show <$> fromDecl @ApiNamespace decl) + <|> (show <$> fromDecl @Query decl) + -- | Extracts all declarations of a certain type from a @[Decl]@s takeDecls :: (IsDecl a) => [Decl] -> [(String, a)] takeDecls = mapMaybe fromDecl diff --git a/waspc/test/AppSpec/FromJSONTest.hs b/waspc/test/AppSpec/FromJSONTest.hs index b4af9e4125..1d0d2d8e7b 100644 --- a/waspc/test/AppSpec/FromJSONTest.hs +++ b/waspc/test/AppSpec/FromJSONTest.hs @@ -278,8 +278,8 @@ spec_AppSpecFromJSON = do } ) where - extNamedImportJson = [trimming| { "kind": "named", "name" : "foo", "path": "folder/file.js" }|] - extDefaultImportJson = [trimming| { "kind": "default", "name" : "foo", "path": "folder/subfolder/file.js" }|] + extNamedImportJson = [trimming| { "kind": "named", "name" : "foo", "path": "@src/folder/file.js" }|] + extDefaultImportJson = [trimming| { "kind": "default", "name" : "foo", "path": "@src/folder/subfolder/file.js" }|] fooEntityRef = [trimming| { "name": "foo", "declType": "Entity" }|] barEntityRef = [trimming| { "name": "bar", "declType": "Entity" }|]