MyNixOS website logo
Description

Easily define multiple interrelated data types.

A user-friendly web development tool that can easily define multiple interrelated data types

tedious-web

A user-friendly web development tool that can easily define multiple interrelated data types, automatically generate common type class instances, provide some convenience for web development.

Pros & Cons

Pros:

  • Can easily define multiple interrelated data types.
  • Instances of Show, Eq, Generic, Default (data-default), ToJSON (aeson), FromJSON (aeson), ToSchema (openapi) are created by default.
  • The table definition of the data type in the style of opaleye will be created easily.
  • Database migration statements based on persistent can also be easily generated.
  • Field types support type variables.

Cons:

  • Do not support sum type.
  • Do not support complex requirements.

Example

[tedious|

Person table t_persion deriving Exception -- optional comment of type
  id `ID` Int64 (Maybe (Field SqlInt8), Field SqlInt8) PersonToUpd
  firstName `first name` Text `John` ("first_name", Field SqlText) !UniquePersonName PersonToAdd PersonToUpd?
  lastName `second name` Text `Smith` ("first_name", Field SqlText) !UniquePersonName PersonToAdd PersonToUpd?
  age Int `10` (Field SqlInt4) PersonToAdd -- optional comment of field A
  address `home address` Text? (Maybe (Field SqlText), Field SqlText) PersonToAdd
  profession Text? `teacher` ("profes", Maybe (Field SqlText), Field SqlText) PersonToAdd
  hobby Text? (Maybe (Field SqlText), Field SqlText) PersonToAdd PersonToUpd?
  score `(English, Mathematic)` ((Int, Int))
  other a

|]

will generate:

data Person
  = Person {  _personId :: Int64,
              _personFirstName :: Text,
              _personLastName :: Text,
              _personAge :: Int,
              _personAddress :: (Maybe Text),
              _personProfession :: (Maybe Text),
              _personHobby :: (Maybe Text),
              _personScore :: (Int, Int)
            }

deriving instance Exception Person
deriving stock instance Show Person
deriving stock instance Eq Person
deriving stock instance Generic Person
deriving instance Default Person
instance ToJSON Person where ...
instance FromJSON Person where ...
instance ToSchema Person where ...

data PersonToAdd
  = PersonToAdd { _personToAddFirstName :: Text,
                  _personToAddLastName :: Text,
                  _personToAddAge :: Int,
                  _personToAddAddress :: (Maybe Text),
                  _personToAddProfession :: (Maybe Text),
                  _personToAddHobby :: (Maybe Text)
                }

deriving instance Exception PersonToAdd
deriving stock instance Show PersonToAdd
deriving stock instance Eq PersonToAdd
deriving stock instance Generic PersonToAdd
deriving instance Default PersonToAdd
instance ToJSON PersonToAdd where ...
instance FromJSON PersonToAdd where ...
instance ToSchema PersonToAdd where ...

data PersonToUpd
  = PersonToUpd { _personToUpdId :: Int64,
                  _personToUpdFirstName :: (Maybe Text),
                  _personToUpdLastName :: (Maybe Text),
                  _personToUpdHobby :: (Maybe Text)
                }

deriving instance Exception PersonToUpd
deriving stock instance Show PersonToUpd
deriving stock instance Eq PersonToUpd
deriving stock instance Generic PersonToUpd
deriving instance Default PersonToUpd
instance ToJSON PersonToUpd where ...
instance FromJSON PersonToUpd where ...
instance ToSchema PersonToUpd where ...

personTable :: Table  ( Maybe (Field SqlInt8), 
                        Field SqlText, 
                        Field SqlText, 
                        Field SqlInt4, 
                        Maybe (Field SqlText), 
                        Maybe (Field SqlText), 
                        Mayb(Field SqlText)
                      ) 
                      ( Field SqlInt8,
                        Field SqlText,
                        Field SqlText,
                        Field SqlInt4,
                        Field SqlText,
                        Field SqlText,
                        Field SqlText
                      )
personTable = ...

tediousPersistString :: String
tediousPersistString = ...

You can use tediousPersistString to do migration in another module like this:

share [mkPersist sqlSettings, mkMigrate "migrateAll"] $(quoteExp persistUpperCase tediousPersistString)
Metadata

Version

0.2.1.4

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows