Skip to content
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

Proposal for new project skeleton #75

Open
wants to merge 5 commits into
base: postgres
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Import.hs

This file was deleted.

151 changes: 78 additions & 73 deletions PROJECTNAME.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,75 +12,80 @@ Flag library-only
Default: False

library
hs-source-dirs: ., app
exposed-modules: Application
Foundation
Import
Import.NoFoundation
Model
Settings
Settings.StaticFiles
Handler.Common
Handler.Home
hs-source-dirs: app
, src

exposed-modules: App.DB.Model
, App.FoundationImport
, App.Handler
, App.NoFoundationImport
, App.Route.Common.Handler
, App.Route.Home.Form
, App.Route.Home.Handler
, Application
, Foundation
, Settings
, Settings.StaticFiles

if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT
ghc-options: -Wall -fwarn-tabs -O0
else
ghc-options: -Wall -fwarn-tabs -O2

extensions: TemplateHaskell
QuasiQuotes
OverloadedStrings
NoImplicitPrelude
CPP
MultiParamTypeClasses
TypeFamilies
GADTs
GeneralizedNewtypeDeriving
FlexibleContexts
EmptyDataDecls
NoMonomorphismRestriction
DeriveDataTypeable
ViewPatterns
TupleSections
RecordWildCards
extensions: CPP
, DeriveDataTypeable
, EmptyDataDecls
, FlexibleContexts
, GADTs
, GeneralizedNewtypeDeriving
, MultiParamTypeClasses
, NoImplicitPrelude
, NoMonomorphismRestriction
, OverloadedStrings
, QuasiQuotes
, RankNTypes
, RecordWildCards
, TemplateHaskell
, TupleSections
, TypeFamilies
, ViewPatterns

build-depends: base >= 4 && < 5
, yesod >= 1.4.1 && < 1.5
, yesod-core >= 1.4.6 && < 1.5
, yesod-auth >= 1.4.0 && < 1.5
, yesod-static >= 1.4.0.3 && < 1.5
, yesod-form >= 1.4.0 && < 1.5
, aeson >= 0.6 && < 0.9
, bytestring >= 0.9 && < 0.11
, classy-prelude >= 0.10.2
, classy-prelude-conduit >= 0.10.2
, classy-prelude-yesod >= 0.10.2
, bytestring >= 0.9 && < 0.11
, text >= 0.11 && < 2.0
, persistent >= 2.0 && < 2.2
, persistent-postgresql >= 2.1.1 && < 2.2
, persistent-template >= 2.0 && < 2.2
, template-haskell
, shakespeare >= 2.0 && < 2.1
, hjsmin >= 0.1 && < 0.2
, monad-control >= 0.3 && < 1.1
, wai-extra >= 3.0 && < 3.1
, yaml >= 0.8 && < 0.9
, http-conduit >= 2.1 && < 2.2
, directory >= 1.1 && < 1.3
, warp >= 3.0 && < 3.1
, data-default
, aeson >= 0.6 && < 0.9
, conduit >= 1.0 && < 2.0
, monad-logger >= 0.3 && < 0.4
, containers
, data-default
, directory >= 1.1 && < 1.3
, fast-logger >= 2.2 && < 2.4
, wai-logger >= 2.2 && < 2.3
, file-embed
, hjsmin >= 0.1 && < 0.2
, http-conduit >= 2.1 && < 2.2
, monad-control >= 0.3 && < 1.1
, monad-logger >= 0.3 && < 0.4
, persistent >= 2.0 && < 2.2
, persistent-postgresql >= 2.1.1 && < 2.2
, persistent-template >= 2.0 && < 2.2
, safe
, shakespeare >= 2.0 && < 2.1
, template-haskell
, text >= 0.11 && < 2.0
, time
, unordered-containers
, containers
, vector
, time
, wai-extra >= 3.0 && < 3.1
, wai-logger >= 2.2 && < 2.3
, warp >= 3.0 && < 3.1
, yaml >= 0.8 && < 0.9
, yesod >= 1.4.1 && < 1.5
, yesod-auth >= 1.4.0 && < 1.5
, yesod-core >= 1.4.6 && < 1.5
, yesod-form >= 1.4.0 && < 1.5
, yesod-static >= 1.4.0.3 && < 1.5

executable PROJECTNAME
if flag(library-only)
Expand All @@ -98,33 +103,33 @@ test-suite test
hs-source-dirs: test
ghc-options: -Wall

extensions: TemplateHaskell
QuasiQuotes
OverloadedStrings
NoImplicitPrelude
CPP
MultiParamTypeClasses
TypeFamilies
GADTs
GeneralizedNewtypeDeriving
FlexibleContexts
EmptyDataDecls
NoMonomorphismRestriction
DeriveDataTypeable
ViewPatterns
TupleSections
extensions: CPP
, DeriveDataTypeable
, EmptyDataDecls
, FlexibleContexts
, GADTs
, GeneralizedNewtypeDeriving
, MultiParamTypeClasses
, NoImplicitPrelude
, NoMonomorphismRestriction
, OverloadedStrings
, QuasiQuotes
, TemplateHaskell
, TupleSections
, TypeFamilies
, ViewPatterns

build-depends: base
, PROJECTNAME
, yesod-test >= 1.4.3 && < 1.5
, yesod-core
, yesod
, classy-prelude
, classy-prelude-yesod
, hspec >= 2.0.0
, monad-logger
, persistent
, persistent-postgresql
, resourcet
, monad-logger
, shakespeare
, transformers
, hspec >= 2.0.0
, classy-prelude
, classy-prelude-yesod
, yesod
, yesod-core
, yesod-test >= 1.4.3 && < 1.5
2 changes: 1 addition & 1 deletion Model.hs → src/App/DB/Model.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Model where
module App.DB.Model where

import ClassyPrelude.Yesod
import Database.Persist.Quasi
Expand Down
6 changes: 6 additions & 0 deletions src/App/FoundationImport.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module App.FoundationImport
( module Import
) where

import Foundation as Import
import App.NoFoundationImport as Import
9 changes: 9 additions & 0 deletions src/App/Handler.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

-- | This module is just for reexports of all handlers in the
-- project.
module App.Handler
( module Import
) where

import App.Route.Common.Handler as Import
import App.Route.Home.Handler as Import
12 changes: 10 additions & 2 deletions Import/NoFoundation.hs → src/App/NoFoundationImport.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
module Import.NoFoundation
module App.NoFoundationImport
( module Import
, Form
) where

import ClassyPrelude.Yesod as Import
import Model as Import

import App.DB.Model as Import
import Settings as Import
import Settings.StaticFiles as Import
import Yesod.Auth as Import
import Yesod.Core.Types as Import (loggerSet)
import Yesod.Default.Config2 as Import


-- | A convenient synonym for creating forms.
type Form app x =
(RenderMessage app FormMessage)
=> Html -> MForm (HandlerT app IO) (FormResult x, WidgetT app IO ())
4 changes: 2 additions & 2 deletions Handler/Common.hs → src/App/Route/Common/Handler.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- | Common handler functions.
module Handler.Common where
module App.Route.Common.Handler where

import App.FoundationImport
import Data.FileEmbed (embedFile)
import Import

-- These handlers embed files in the executable at compile time to avoid a
-- runtime dependency, and for efficiency.
Expand Down
13 changes: 13 additions & 0 deletions src/App/Route/Home/Form.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module App.Route.Home.Form where

import App.NoFoundationImport

import Yesod.Form.Bootstrap3
( BootstrapFormLayout (..), renderBootstrap3
, withSmallInput )


sampleForm :: Form app (FileInfo, Text)
sampleForm = renderBootstrap3 BootstrapBasicForm $ (,)
<$> fileAFormReq "Choose a file"
<*> areq textField (withSmallInput "What's on the file?") Nothing
12 changes: 3 additions & 9 deletions Handler/Home.hs → src/App/Route/Home/Handler.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module Handler.Home where
module App.Route.Home.Handler where

import Import
import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
withSmallInput)
import App.FoundationImport
import App.Route.Home.Form

-- This is a handler function for the GET request method on the HomeR
-- resource pattern. All of your resource patterns are defined in
Expand Down Expand Up @@ -33,8 +32,3 @@ postHomeR = do
aDomId <- newIdent
setTitle "Welcome To Yesod!"
$(widgetFile "homepage")

sampleForm :: Form (FileInfo, Text)
sampleForm = renderBootstrap3 BootstrapBasicForm $ (,)
<$> fileAFormReq "Choose a file"
<*> areq textField (withSmallInput "What's on the file?") Nothing
5 changes: 2 additions & 3 deletions Application.hs → src/Application.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Application
import Control.Monad.Logger (liftLoc, runLoggingT)
import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr,
pgPoolSize, runSqlPool)
import Import
import App.FoundationImport
import Language.Haskell.TH.Syntax (qLocation)
import Network.Wai.Handler.Warp (Settings, defaultSettings,
defaultShouldDisplayException,
Expand All @@ -30,8 +30,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet,

-- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file!
import Handler.Common
import Handler.Home
import App.Handler

-- This line actually creates our YesodDispatch instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
Expand Down
5 changes: 1 addition & 4 deletions Foundation.hs → src/Foundation.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Foundation where

import Import.NoFoundation
import App.NoFoundationImport
import Database.Persist.Sql (ConnectionPool, runSqlPool)
import Text.Hamlet (hamletFile)
import Text.Jasmine (minifym)
Expand Down Expand Up @@ -33,9 +33,6 @@ instance HasHttpManager App where
-- explanation for this split.
mkYesodData "App" $(parseRoutesFile "config/routes")

-- | A convenient synonym for creating forms.
type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)

-- Please see the documentation for the Yesod typeclass. There are a number
-- of settings which can be configured by overriding methods here.
instance Yesod App where
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/TestImport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module TestImport
, module X
) where

import App.DB.Model as X
import Application (makeFoundation)
import ClassyPrelude as X
import Database.Persist as X hiding (get)
import Database.Persist.Sql (SqlPersistM, SqlBackend, runSqlPersistMPool, rawExecute, rawSql, unSingle, connEscapeName)
import Foundation as X
import Model as X
import Test.Hspec as X
import Text.Shakespeare.Text (st)
import Yesod.Default.Config2 (ignoreEnv, loadAppSettings)
Expand Down