mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-24 09:34:28 +03:00
Fixed warnings/errors reported by --pedantic build flag.
This commit is contained in:
parent
66e0dc7d50
commit
892a0e70c5
@ -5,10 +5,7 @@ module Generator.FileDraft
|
||||
, createCopyFileDraft
|
||||
) where
|
||||
|
||||
import qualified System.Directory
|
||||
import qualified Data.Text.IO
|
||||
import Data.Aeson as Aeson
|
||||
import Data.Text (Text)
|
||||
|
||||
import Generator.FileDraft.WriteableToFile
|
||||
import Generator.FileDraft.TemplateFileDraft
|
||||
|
@ -10,19 +10,6 @@ import Generator.FileDraft
|
||||
import Wasp
|
||||
|
||||
|
||||
-- NOTE(martin): Here I define general transformation of App into JSON that I can then easily use
|
||||
-- as data for templates, but we will probably want to replace this in the future with the better tailored
|
||||
-- types that are exact fit for what is neeed (for example one type per template).
|
||||
instance Aeson.ToJSON App where
|
||||
toJSON app = Aeson.object
|
||||
[ "name" Aeson..= appName app
|
||||
, "title" Aeson..= appTitle app
|
||||
]
|
||||
instance Aeson.ToJSON Wasp where
|
||||
toJSON wasp = Aeson.object
|
||||
[ "app" Aeson..= getApp wasp
|
||||
]
|
||||
|
||||
defaultCreateTemplateFileDraft :: FilePath -> Wasp -> FileDraft
|
||||
defaultCreateTemplateFileDraft path wasp = createTemplateFileDraft path path (Aeson.toJSON wasp)
|
||||
|
||||
|
@ -2,11 +2,9 @@ module Lib
|
||||
( compile
|
||||
) where
|
||||
|
||||
import System.IO
|
||||
|
||||
import Parser
|
||||
import Generator
|
||||
import Wasp
|
||||
|
||||
|
||||
type CompileError = String
|
||||
|
||||
|
@ -2,18 +2,19 @@ module Parser
|
||||
( parseWasp
|
||||
) where
|
||||
|
||||
import Text.Parsec
|
||||
import Text.Parsec (parse, ParseError)
|
||||
import Text.Parsec.String (Parser)
|
||||
|
||||
import Lexer
|
||||
import Parser.App
|
||||
import qualified Wasp
|
||||
|
||||
|
||||
-- | Top level parser, produces Wasp.
|
||||
waspParser :: Parser Wasp.Wasp
|
||||
waspParser = do
|
||||
-- NOTE(matija): this is the only place we need to use whiteSpace, to skip empty lines
|
||||
-- and comments in the beginning of file. All other used parsers are lexeme parsers
|
||||
-- and comments in the beginning of file. All other used parsers are lexeme parsers
|
||||
-- so they do it themselves.
|
||||
whiteSpace
|
||||
|
||||
@ -25,7 +26,7 @@ waspParser = do
|
||||
-- TODO(matija): after we parsed everything, we should do semantic analysis
|
||||
-- e.g. check there is only 1 title - if not, throw a meaningful error.
|
||||
|
||||
return $ Wasp.fromApp $ Wasp.App
|
||||
return $ Wasp.fromApp $ Wasp.App
|
||||
{ Wasp.appName = parsedAppName
|
||||
, Wasp.appTitle = getAppTitle parsedAppProperties
|
||||
-- TODO(matija): add favicon.
|
||||
|
@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Wasp
|
||||
( Wasp
|
||||
, App (..)
|
||||
@ -6,6 +7,9 @@ module Wasp
|
||||
, setApp
|
||||
) where
|
||||
|
||||
import qualified Data.Aeson as Aeson
|
||||
|
||||
|
||||
data Wasp = Wasp [WaspElement] deriving (Show, Eq)
|
||||
|
||||
data WaspElement
|
||||
@ -33,9 +37,24 @@ getApps :: Wasp -> [App]
|
||||
getApps (Wasp elems) = map getAppFromElem $ filter isAppElem elems
|
||||
where
|
||||
getAppFromElem (WaspElementApp app) = app
|
||||
getAppFromElem _ = error "Not an app"
|
||||
|
||||
setApp :: Wasp -> App -> Wasp
|
||||
setApp (Wasp elems) app = Wasp $ (WaspElementApp app) : (filter (not . isAppElem) elems)
|
||||
|
||||
fromApp :: App -> Wasp
|
||||
fromApp app = Wasp [WaspElementApp app]
|
||||
|
||||
|
||||
-- NOTE(martin): Here I define general transformation of App into JSON that I can then easily use
|
||||
-- as data for templates, but we will probably want to replace this in the future with the better tailored
|
||||
-- types that are exact fit for what is neeed (for example one type per template).
|
||||
instance Aeson.ToJSON App where
|
||||
toJSON app = Aeson.object
|
||||
[ "name" Aeson..= appName app
|
||||
, "title" Aeson..= appTitle app
|
||||
]
|
||||
instance Aeson.ToJSON Wasp where
|
||||
toJSON wasp = Aeson.object
|
||||
[ "app" Aeson..= getApp wasp
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user