persistent-discover-0.1.0.7: Persistent module discover utilities
Safe HaskellSafe-Inferred
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
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 #

Functor Render' Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

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

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

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 #

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
Show Module Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Eq Module Source # 
Instance details

Defined in Database.Persist.Discover.Exe

Methods

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

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

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 #