Hoogle Search
Within LTS Haskell 24.35 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
enumFromThenTo :: Enum a => a -> a -> a -> [a]hledger-web Hledger.Web.Import Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0)
f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y
andworker s c v m | c v m = v : worker s c (s v) m | otherwise = []
Examples
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
enumFromTo :: Enum a => a -> a -> [a]hledger-web Hledger.Web.Import Used in Haskell's translation of [n..m] with [n..m] = enumFromTo n m, a possible implementation being
enumFromTo n m | n <= m = n : enumFromTo (succ n) m | otherwise = []
Examples
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumDeltaInteger :: forall (m :: Type -> Type) . Monad m => Integer -> Integer -> Stream m Integerleveldb-haskell Data.Stream.Monadic Like fromList ([n,n+d..] :: [Integer]) but avoids allocating a list
enumFromToChar :: forall (m :: Type -> Type) . Monad m => Char -> Char -> Stream m Charleveldb-haskell Data.Stream.Monadic Like fromList ([n..m] :: [Char]) but avoids allocating a list
enumFromToInt :: forall (m :: Type -> Type) . Monad m => Int -> Int -> Stream m Intleveldb-haskell Data.Stream.Monadic Like fromList ([n..m] :: [Int]) but avoids allocating a list
enumDirective :: DirectiveConstraint a => TypeName -> a -> DirectiveUsagesmorpheus-graphql-server Data.Morpheus.Server.Types No documentation available.
enumDirective' :: DirectiveConstraint a => Name -> a -> DirectiveUsagesmorpheus-graphql-server Data.Morpheus.Server.Types No documentation available.
enumFromField :: EnumMapper sqlEnum haskellSum -> FromField sqlEnum haskellSumopaleye Opaleye.Experimental.Enum No documentation available.
-
opaleye Opaleye.Experimental.Enum Create a mapping between a Postgres ENUM type and a Haskell type. Also works for DOMAIN types. For example, if you have the following ENUM
CREATE TYPE public.mpaa_rating AS ENUM ( 'G', 'PG', 'PG-13', 'R', 'NC-17' );
then you can define data types to represent the enum on the SQL side and Haskell side respectivelydata SqlRating data Rating = G | PG | PG13 | R | NC17 deriving Show
and functions to map between themtoSqlRatingString :: Rating -> String toSqlRatingString r = case r of G -> "G" PG -> "PG" PG13 -> "PG-13" R -> "R" NC17 -> "NC-17" fromSqlRatingString :: String -> Maybe Rating fromSqlRatingString s = case s of "G" -> Just G "PG" -> Just PG "PG-13" -> Just PG13 "R" -> Just R "NC-17" -> Just NC17 _ -> Nothing
Then you can use the mappings as followsimport qualified Opaleye as O import qualified Data.Profunctor.Product.Default as D sqlRatingMapper :: EnumMapper SqlRating Rating sqlRatingMapper = enumMapper "mpaa_rating" fromSqlRatingString toSqlRatingString instance O.DefaultFromField SqlRating Rating where defaultFromField = enumFromField sqlRatingMapper instance rating ~ Rating => D.Default (Inferrable O.FromField) SqlRating rating where def = inferrableDef instance D.Default O.ToFields Rating (O.Field SqlRating) where def = enumToFields sqlRatingMapper instance IsSqlType SqlRating where showSqlType = enumShowSqlType sqlRatingMapper
-
opaleye Opaleye.Experimental.Enum No documentation available.