Hoogle Search

Within LTS Haskell 24.28 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. derivePathInfo :: Name -> Q [Dec]

    web-routes-th Web.Routes.TH

    use Template Haskell to create PathInfo instances for a type.

    $(derivePathInfo ''SiteURL)
    
    Uses the standard formatter by default.

  2. derivePathInfo' :: (String -> String) -> Name -> Q [Dec]

    web-routes-th Web.Routes.TH

    use Template Haskell to create PathInfo instances for a type. This variant allows the user to supply a function that transforms the constructor name to a prettier rendering. It is important that the transformation function generates a unique output for each input. For example, simply converting the string to all lower case is not acceptable, because then FooBar and Foobar would be indistinguishable.

    $(derivePathInfo' standard ''SiteURL)
    
    see also: standard

  3. derivePersistField :: String -> Q [Dec]

    classy-prelude-yesod ClassyPrelude.Yesod

    Automatically creates a valid PersistField instance for any datatype that has valid Show and Read instances. Can be very convenient for Enum types.

  4. derivePersistFieldJSON :: String -> Q [Dec]

    classy-prelude-yesod ClassyPrelude.Yesod

    Automatically creates a valid PersistField instance for any datatype that has valid ToJSON and FromJSON instances. For a datatype T it generates instances similar to these:

    instance PersistField T where
    toPersistValue = PersistByteString . L.toStrict . encode
    fromPersistValue = (left T.pack) . eitherDecodeStrict' <=< fromPersistValue
    instance PersistFieldSql T where
    sqlType _ = SqlString
    

  5. deriveCPointed :: Name -> DecsQ

    czipwith Data.CZipWith

    Derives a cPointed instance for a datatype of kind (* -> *) -> *. Requires that for this datatype (we shall call its argument f :: * -> * here)

    • there is exactly one constructor;
    • all fields in the one constructor are either of the form f x for some x or of the form X f for some type X where there is an instance cPointed X.
    For example, the following would be valid usage:
    data A f = A
    { a_str  :: f String
    , a_bool :: f Bool
    }
    
    data B f = B
    { b_int   :: f Int
    , b_float :: f Float
    , b_a     :: A f
    }
    
    derivecPointed ''A
    derivecPointed ''B
    
    This produces the following instances:
    instance cPointed A where
    cPoint f = A f f
    
    instance cPointed B where
    cPoint f = B f f (cPoint f f)
    

  6. deriveCZipWith :: Name -> DecsQ

    czipwith Data.CZipWith

    Derives a CZipWith instance for a datatype of kind (* -> *) -> *. Requires that for this datatype (we shall call its argument f :: * -> * here)

    • there is exactly one constructor;
    • all fields in the one constructor are either of the form f x for some x or of the form X f for some type X where there is an instance CZipWith X.
    For example, the following would be valid usage:
    data A f = A
    { a_str  :: f String
    , a_bool :: f Bool
    }
    
    data B f = B
    { b_int   :: f Int
    , b_float :: f Float
    , b_a     :: A f
    }
    
    deriveCZipWith ''An
    deriveCZipWith ''B
    
    This produces the following instances:
    instance CZipWith A where
    cZipWith f (A x1 x2) (A y1 y2) = A (f x1 y1) (f x2 y2)
    
    instance CZipWith B wheren
    cZipWith f (B x1 x2 x3) (B y1 y2 y3) =
    B (f x1 y1) (f x2 y2) (cZipWith f x3 y3)
    

  7. deriveCZipWithM :: Name -> DecsQ

    czipwith Data.CZipWith

    Derives a CZipWithM instance for a datatype of kind (* -> *) -> *. Requires that for this datatype (we shall call its argument f :: * -> * here)

    • there is exactly one constructor;
    • all fields in the one constructor are either of the form f x for some x or of the form X f for some type X where there is an instance CZipWithM X.
    For example, the following would be valid usage:
    data A f = A
    { a_str  :: f String
    , a_bool :: f Bool
    }
    
    data B f = B
    { b_int   :: f Int
    , b_float :: f Float
    , b_a     :: A f
    }
    
    deriveCZipWithM ''A
    deriveCZipWithM ''B
    
    This produces the following instances:
    instance CZipWithM A where
    cZipWithM f (A x1 x2) (A y1 y2) = A <$> f x1 y1 <*> f x2 y2
    
    instance CZipWith B where
    cZipWithM f (B x1 x2 x3) (B y1 y2 y3) =
    B <$> f x1 y1 <*> f x2 y2 <*> cZipWithM f x3 y3
    

  8. deriveCsvViaSci :: Name -> Q [Dec]

    detour-via-sci Data.Via.Scientific

    Similar to deriveJsonViaSci but for instances of ToField and FromField.

    >>> deriveCsvViaSci ''Lat
    ...
    

  9. deriveDecimalPlaces :: DecimalPlaces -> Name -> Q [Dec]

    detour-via-sci Data.Via.Scientific

    Taking a number of decimal places from the given DecimalPlaces newtype, derives an instance of DefaultDecimalPlaces.

    >>> deriveDecimalPlaces (DecimalPlaces 8) ''Lat
    ...
    

  10. deriveJsonViaSci :: Name -> Q [Dec]

    detour-via-sci Data.Via.Scientific

    Derives an instance of ToJSON wrapping the value with ViaSci before encoding. Similarly the value is decoded as ViaSci and then unwrapped in the derived instance of FromJSON.

    >>> deriveJsonViaSci ''Lat
    ...
    

Page 51 of many | Previous | Next