persistent-discover-0.1.0.4: Persistent module discover utilities
Safe HaskellNone
LanguageHaskell2010

Database.Persist.Discover.Exe

Description

This module contains types, definitions, and the logic behind finding persistent definitions.

In brief, we do an import of all the models defined in the current directory or any subdirectories. These imports are "instances only" imports. Then we splice in $(discoverEntities) to

The result module is named All, and it's placed in the hierarchy where you define this. So if you have a source file:

-- srcPersistentModelsAll.hs

{-# OPTIONS_GHC -F -pgmF persistent-discover

Then it will translate to:

-- srcPersistentModelsAll.hs

module PersistentModels.All where

import PersistentModels.Foo ()
import PersistentModels.Bar ()
import PersistentModels.Baz ()

allEntityDefs :: [EntityDef]
allEntityDefs = $(discoverEntities)

Since: 0.1.0.0

Synopsis

Documentation

newtype Source Source #

Constructors

Source FilePath 

newtype Destination Source #

Constructors

Destination FilePath 

newtype Render' a Source #

Constructors

Render 

Fields

Instances

Instances details
Monad Render' Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

(>>=) :: Render' a -> (a -> Render' b) -> Render' b #

(>>) :: Render' a -> Render' b -> Render' b #

return :: a -> Render' a #

Functor Render' Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

fmap :: (a -> b) -> Render' a -> Render' b #

(<$) :: a -> Render' b -> Render' a #

Applicative Render' Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

pure :: a -> Render' a #

(<*>) :: Render' (a -> b) -> Render' a -> Render' b #

liftA2 :: (a -> b -> c) -> Render' a -> Render' b -> Render' c #

(*>) :: Render' a -> Render' b -> Render' b #

(<*) :: Render' a -> Render' b -> Render' a #

a ~ () => IsString (Render' a) Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

fromString :: String -> Render' a #

discoverModels :: Source -> Destination -> IO () Source #

Since: 0.1.0.0

getFilesRecursive Source #

Arguments

:: FilePath

The directory to search.

-> IO [FilePath] 

Returns a list of relative paths to all files in the given directory.

data Module Source #

Constructors

Module 

Instances

Instances details
Eq Module Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

(==) :: Module -> Module -> Bool #

(/=) :: Module -> Module -> Bool #

Show Module Source # 
Instance details

Defined in Database.Persist.Discover.Exe

isValidModuleName :: String -> Bool Source #

Returns True if the given string is a valid task module name. See ModuleName (http:/git.iobj34)

isValidModuleChar :: Char -> Bool Source #

Returns True if the given Char is a valid taks module character.

casify :: String -> String Source #

Convert a String in camel case to snake case.

stripSuffix :: Eq a => [a] -> [a] -> Maybe [a] Source #