-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for view and type blocks
Signed-off-by: Mihovil Ilakovac <[email protected]>
- Loading branch information
Showing
30 changed files
with
795 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,21 @@ | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
|
||
module Wasp.Psl.Ast.Model | ||
( Model (..), | ||
Body (..), | ||
Element (..), | ||
Field (..), | ||
FieldType (..), | ||
FieldTypeModifier (..), | ||
getFields, | ||
) | ||
where | ||
|
||
import Data.Data (Data) | ||
import Wasp.Psl.Ast.Attribute (Attribute) | ||
import Wasp.Psl.Ast.Common (Name) | ||
import Prelude hiding (Enum) | ||
import Wasp.Psl.Ast.Model.Common | ||
( Body (..), | ||
Element (..), | ||
Field, | ||
) | ||
|
||
data Model | ||
= Model | ||
Name | ||
Body | ||
deriving (Show, Eq) | ||
|
||
newtype Body = Body [Element] | ||
deriving (Show, Eq, Data) | ||
|
||
data Element | ||
= ElementField Field | ||
| ElementBlockAttribute Attribute | ||
deriving (Show, Eq, Data) | ||
|
||
-- TODO: To support attributes before the field, | ||
-- we could just have `attrsBefore :: [[Attr]]`, | ||
-- which represents lines, each one with list of attributes. | ||
data Field = Field | ||
{ _name :: String, | ||
_type :: FieldType, | ||
_typeModifiers :: [FieldTypeModifier], | ||
_attrs :: [Attribute] | ||
} | ||
deriving (Show, Eq, Data) | ||
|
||
data FieldType | ||
= String | ||
| Boolean | ||
| Int | ||
| BigInt | ||
| Float | ||
| Decimal | ||
| DateTime | ||
| Json | ||
| Bytes | ||
| Unsupported String | ||
| UserType String | ||
deriving (Show, Eq, Data) | ||
|
||
data FieldTypeModifier | ||
= List | ||
| Optional | ||
deriving (Show, Eq, Data) | ||
|
||
getFields :: Model -> [Field] | ||
getFields (Model _ (Body elements)) = [field | ElementField field <- elements] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
|
||
module Wasp.Psl.Ast.Model.Common | ||
( Body (..), | ||
Element (..), | ||
Field (..), | ||
FieldType (..), | ||
FieldTypeModifier (..), | ||
) | ||
where | ||
|
||
import Data.Data (Data) | ||
import Wasp.Psl.Ast.Attribute (Attribute) | ||
import Prelude hiding (Enum) | ||
|
||
newtype Body = Body [Element] | ||
deriving (Show, Eq, Data) | ||
|
||
data Element | ||
= ElementField Field | ||
| ElementBlockAttribute Attribute | ||
deriving (Show, Eq, Data) | ||
|
||
-- TODO: To support attributes before the field, | ||
-- we could just have `attrsBefore :: [[Attr]]`, | ||
-- which represents lines, each one with list of attributes. | ||
data Field = Field | ||
{ _name :: String, | ||
_type :: FieldType, | ||
_typeModifiers :: [FieldTypeModifier], | ||
_attrs :: [Attribute] | ||
} | ||
deriving (Show, Eq, Data) | ||
|
||
data FieldType | ||
= String | ||
| Boolean | ||
| Int | ||
| BigInt | ||
| Float | ||
| Decimal | ||
| DateTime | ||
| Json | ||
| Bytes | ||
| Unsupported String | ||
| UserType String | ||
deriving (Show, Eq, Data) | ||
|
||
data FieldTypeModifier | ||
= List | ||
| Optional | ||
deriving (Show, Eq, Data) |
Oops, something went wrong.