You should use the CommonJS version of path
. If you want to grab path
directly...
git clone https://github.com/pazguille/path
from the working directory so it's loaded into ./path
. I changed the require
statement to point to that location.
module Order where | |
-- DBM is some Monad Transformer stack that allows us to talk to our DB (also a form of DI!) | |
placeOrder :: User -> OrderDetails -> DBM () | |
placeOrder user details = do | |
-- Some users will have discounts for | |
(discount :: Maybe Discount) <- findRelevantDiscount user details | |
-- Create the specific order for this user with any discount |
You should use the CommonJS version of path
. If you want to grab path
directly...
git clone https://github.com/pazguille/path
from the working directory so it's loaded into ./path
. I changed the require
statement to point to that location.
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Data.Validation.Aeson where | |
import Control.Applicative | |
import Control.Lens | |
import Data.Aeson | |
import qualified Data.HashMap.Strict as M | |
import Data.Maybe (fromMaybe) | |
import Data.Semigroup |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
import Control.Applicative | |
import Control.Monad | |
import Control.Monad.IO.Class (liftIO) | |
import Database.PostgreSQL.Simple | |
import Database.PostgreSQL.Simple.FromRow |
import scalaz._ | |
import Scalaz._ | |
class InvoiceValidations { | |
def checkName(name: String): ValidationNel[String, String] = { | |
if (name.length > 100) | |
"name too long".failNel | |
else | |
name.successNel | |
} |
import scalaz._, Scalaz._, shapeless._, ops.hlist.{ RightFolder, Tupler } | |
// Might as well stay generic in `F` for this part. | |
object applicativeFolder extends Poly2 { | |
implicit def caseApplicative[A, B <: HList, F[_]](implicit | |
app: Applicative[F] | |
) = at[F[A], F[B]] { | |
(a, b) => app.ap(a)(app.map(b)(bb => (_: A) :: bb)) | |
} | |
} |