{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Webc.Generator where
import Control.Applicative (Applicative (..), liftA2)
import Data.Either (Either (..))
import Data.Eq (Eq (..))
-import Data.Function (($))
+import Data.Function (($), (.))
import Data.Functor (Functor (..), (<$>))
import Data.Ord (Ord (..))
import Data.Semigroup (Semigroup (..))
}
deriving (Functor, Show)
+instance Applicative Generator where
+ pure = Generator . pure . pure
+ Generator f <*> Generator x = Generator ((<*>) <$> f <*> x)
+
generate :: Generator a -> [Gen a]
generate = unGenerator
f <*> x = Gen (genSlugs f <> genSlugs x) (genValue f (genValue x))
instance IsoFunctor Generator where
- Iso{..} <%> x = a2b <$> x
+ (<%>) Iso{..} = (a2b <$>)
instance ProductFunctor Generator where
- Generator x <.> Generator y = Generator (liftA2 (,) <$> x <*> y)
+ (<.>) = liftA2 (,)
+ (<.) = (<*)
+ (.>) = (*>)
instance SumFunctor Generator where
x <+> y =
Generator $