Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated about a month ago

total matches: 222

ocaml-export-0.13.0
2 matches
src/OCaml/BuckleScript/Types.hs

-- | Capture the Haskell type at the left side declaration `data Maybe a`, `data Person`, etc..
--   Transform the constructor, depending on its values, if necessary.
instance (KnownSymbol typ, KnownSymbol package, KnownSymbol modul, GenericValueConstructor f) => GenericOCamlDatatype (M1 D ('MetaData typ modul package 'False) f) where
  genericToOCamlDatatype datatype =
    OCamlDatatype
      (HaskellTypeMetaData
       (T.pack $ symbolVal (Proxy :: Proxy typ))
       (T.pack $ symbolVal (Proxy :: Proxy modul))

            
src/OCaml/BuckleScript/Types.hs
              then transformToSumOfRecord (T.pack (datatypeName datatype)) ocamlConstructor
              else ocamlConstructor

instance (KnownSymbol typ, KnownSymbol package, KnownSymbol modul, GenericValueConstructor f) => GenericOCamlDatatype (M1 D ('MetaData typ modul package 'True) f) where
  genericToOCamlDatatype datatype =
    OCamlDatatype
      (HaskellTypeMetaData
       (T.pack $ symbolVal (Proxy :: Proxy typ))
       (T.pack $ symbolVal (Proxy :: Proxy modul))

            
queryparser-0.1.0.1
2 matches
src/Database/Sql/Type/Names.hs

import GHC.Exts (Constraint)
import GHC.Generics
import GHC.TypeLits (KnownSymbol, Symbol, symbolVal)
import Data.Proxy

import Control.Applicative (Alternative (..))
import Control.Monad (void)


            
src/Database/Sql/Type/Names.hs
-- | Identifiers picked first from (and shrunk to) symbols in type list.  Used for testing.
data Identifier (ids :: [Symbol]) = Identifier Text deriving Eq

class KnownSymbols (xs :: [Symbol]) where
    symbolVals :: proxy xs -> [String]

instance KnownSymbols '[] where
    symbolVals _ = []

instance (KnownSymbol x, KnownSymbols xs) => KnownSymbols (x ': xs) where
    symbolVals _ = symbolVal (Proxy :: Proxy x) : symbolVals (Proxy :: Proxy xs)

instance KnownSymbols ids => Arbitrary (Identifier ids) where
    arbitrary = do
        arb <- Identifier <$> arbitraryIdentifier
        growingElements $ ids ++ [arb]
      where
        ids = Identifier . pack <$> symbolVals (Proxy :: Proxy ids)

            
react-flux-servant-0.1.1
4 matches
src/React/Flux/Addons/Servant.hs
        , rHeaders = rHeaders r ++ [("Content-Type", "application/json")]
        })

instance (KnownSymbol sym, HasAjaxRequest sub) => HasAjaxRequest (sym :> sub) where
    type MkRequest (sym :> sub) = MkRequest sub
    toRequest _ r = toRequest (Proxy :: Proxy sub) (r { segments = segments r ++ [seg]})
        where
            seg = jsPack $ symbolVal (Proxy :: Proxy sym)


            
src/React/Flux/Addons/Servant.hs
        where
            v' = jsPack $ T.unpack $ toUrlPiece v

instance (KnownSymbol sym, ToHttpApiData a, HasAjaxRequest sub) => HasAjaxRequest (Header sym a :> sub) where
    type MkRequest (Header sym a :> sub) = Maybe a -> MkRequest sub
    toRequest _ r Nothing  = toRequest (Proxy :: Proxy sub) r
    toRequest _ r (Just a) = toRequest (Proxy :: Proxy sub) (r { rHeaders = rHeaders r ++ [(sym',a')]})
        where
            sym' = jsPack $ symbolVal (Proxy :: Proxy sym)

            
src/React/Flux/Addons/Servant.hs
            sym' = jsPack $ symbolVal (Proxy :: Proxy sym)
            a' = jsPack $ T.unpack $ toUrlPiece a

instance (KnownSymbol sym, HasAjaxRequest sub) => HasAjaxRequest (QueryFlag sym :> sub) where
    type MkRequest (QueryFlag sym :> sub) = Bool -> MkRequest sub
    toRequest _ r False = toRequest (Proxy :: Proxy sub) r
    toRequest _ r True = toRequest (Proxy :: Proxy sub) r { rQuery = rQuery r ++ [(sym', "true")]}
        where
            sym' = jsPack $ symbolVal (Proxy :: Proxy sym)

            
src/React/Flux/Addons/Servant.hs
        where
            sym' = jsPack $ symbolVal (Proxy :: Proxy sym)

instance (KnownSymbol sym, ToHttpApiData a, HasAjaxRequest sub) => HasAjaxRequest (QueryParam sym a :> sub) where
    type MkRequest (QueryParam sym a :> sub) = Maybe a -> MkRequest sub
    toRequest _ r Nothing = toRequest (Proxy :: Proxy sub) r
    toRequest _ r (Just a) = toRequest (Proxy :: Proxy sub) r { rQuery = rQuery r ++ [(sym', a')]}
        where
            sym' = jsPack $ symbolVal (Proxy :: Proxy sym)

            
rollbar-hs-0.3.1.0
4 matches
src/Rollbar/Item/Hardcoded.hs
import Data.Text        (pack)

import GHC.Generics (Generic)
import GHC.TypeLits (KnownSymbol, Symbol, symbolVal)

-- | This is basically 'Data.Proxy' with the variable restricted to 'Symbol'.
--  It's mostly useful so a value can be insert into a JSON blob easily.
data Hardcoded (symbol :: Symbol)
    = Hardcoded

            
src/Rollbar/Item/Hardcoded.hs
    = Hardcoded
    deriving (Eq, Generic, Show)

instance KnownSymbol symbol => ToJSON (Hardcoded symbol) where
    toJSON = toJSON . symbolVal
    toEncoding = toEncoding . symbolVal

instance KnownSymbol symbol => FromJSON (Hardcoded symbol) where
    parseJSON (String str)
        | str == pack (symbolVal (Hardcoded :: Hardcoded symbol)) = pure Hardcoded
    parseJSON v = typeMismatch "Hardcoded symbol" v

            
src/Rollbar/Item/MissingHeaders.hs
import Data.Maybe           (catMaybes)
import Data.Proxy           (Proxy(Proxy))

import GHC.TypeLits (KnownSymbol, Symbol, symbolVal)

import Network.HTTP.Types (Header, RequestHeaders)

import qualified Data.ByteString       as BS
import qualified Data.ByteString.Char8 as BSC8

            
src/Rollbar/Item/MissingHeaders.hs
instance RemoveHeaders '[] where
    removeHeaders (MissingHeaders rhs) = rhs

instance (KnownSymbol header, RemoveHeaders headers)
    => RemoveHeaders (header ': headers) where
    removeHeaders (MissingHeaders rhs) =
        removeHeaders (MissingHeaders $ filter go rhs :: MissingHeaders headers)
        where
        go (rh, _) =

            
safe-money-aeson-0.1.1
7 matches
src/Money/Aeson.hs
import qualified Data.Aeson as Ae
import Data.Ratio ((%), numerator, denominator)
import qualified Data.Text as T
import GHC.TypeLits (KnownSymbol)
import qualified Money
import qualified Money.Internal as MoneyI

--------------------------------------------------------------------------------
-- | Compatible with 'Money.SomeDense'

            
src/Money/Aeson.hs
--
-- Note: The JSON serialization changed in version 0.4 (the leading @"Dense"@
-- string was dropped from the rendered 'Ae.Array').
instance KnownSymbol currency => Ae.ToJSON (Money.Dense currency) where
  toJSON = Ae.toJSON . Money.toSomeDense

-- | Compatible with 'Money.SomeDense'
--
-- Note: The JSON serialization changed in @safe-money@ version 0.4. However,

            
src/Money/Aeson.hs
--
-- Note: The JSON serialization changed in @safe-money@ version 0.4. However,
-- this instance is still able to cope with the previous format.
instance KnownSymbol currency => Ae.FromJSON (Money.Dense currency) where
  parseJSON = maybe empty pure <=< fmap Money.fromSomeDense . Ae.parseJSON

-- | Compatible with 'Money.Dense'
--
-- Note: The JSON serialization changed in @safe-money@ version 0.4 (the leading

            
src/Money/Aeson.hs
-- Note: The JSON serialization changed in @safe-money@ version 0.4 (the leading
-- @"Discrete"@ string was dropped from the rendered 'Ae.Array').
instance
  ( KnownSymbol currency, Money.GoodScale scale
  ) => Ae.ToJSON (Money.Discrete' currency scale) where
  toJSON = Ae.toJSON . Money.toSomeDiscrete

-- | Compatible with 'Money.SomeDiscrete'
--

            
src/Money/Aeson.hs
-- Note: The JSON serialization changed in @safe-money@ version 0.4. However,
-- this instance is still able to cope with the previous format.
instance
  ( KnownSymbol currency, Money.GoodScale scale
  ) => Ae.FromJSON (Money.Discrete' currency scale) where
  parseJSON = maybe empty pure <=< fmap Money.fromSomeDiscrete . Ae.parseJSON

-- | Compatible with 'Money.Discrete''
--

            
src/Money/Aeson.hs
-- Note: The JSON serialization changed in version 0.4 (the leading
-- @"ExchangeRate"@ string was dropped from the rendered 'Ae.Array').
instance
  ( KnownSymbol src, KnownSymbol dst
  ) => Ae.ToJSON (Money.ExchangeRate src dst) where
  toJSON = Ae.toJSON . Money.toSomeExchangeRate

-- | Compatible with 'Money.SomeExchangeRate'
--

            
src/Money/Aeson.hs
-- Note: The JSON serialization changed in version 0.4. However, this instance
-- is still able to cope with the previous format.
instance
  ( KnownSymbol src, KnownSymbol dst
  ) => Ae.FromJSON (Money.ExchangeRate src dst) where
  parseJSON =
    maybe empty pure <=< fmap Money.fromSomeExchangeRate . Ae.parseJSON

-- | Compatible with 'Money.ExchangeRate'

            
schematic-0.5.0.0
8 matches
src/Data/Schematic/Schema.hs
    STLe n -> withKnownNat n (DTLe . fromIntegral $ natVal n)
    STGt n -> withKnownNat n (DTGt . fromIntegral $ natVal n)
    STGe n -> withKnownNat n (DTGe . fromIntegral $ natVal n)
    STRegex s -> withKnownSymbol s (DTRegex $ T.pack $ symbolVal s)
    STEnum s -> let
      d :: Sing (s :: [Symbol]) -> [Text]
      d SNil               = []
      d (SCons ss@SSym fs) = T.pack (symbolVal ss) : d fs
      in DTEnum $ d s

            
src/Data/Schematic/Schema.hs
instance (KnownNat n) => SingI ('TGe n) where sing = STGe sing
instance (KnownNat n) => SingI ('TLt n) where sing = STLt sing
instance (KnownNat n) => SingI ('TLe n) where sing = STLe sing
instance (KnownSymbol s, SingI s) => SingI ('TRegex s) where sing = STRegex sing
instance (SingI ss) => SingI ('TEnum ss) where sing = STEnum sing

instance Eq (Sing ('TEq n)) where _ == _ = True
instance Eq (Sing ('TLt n)) where _ == _ = True
instance Eq (Sing ('TLe n)) where _ == _ = True

            
src/Data/Schematic/Schema.hs

data FieldRepr :: (Symbol, Schema) -> Type where
  FieldRepr
    :: (SingI schema, KnownSymbol name)
    => JsonRepr schema
    -> FieldRepr '(name, schema)

-- | Forgetful Functor Ufr
toJsonRepr :: FieldRepr '(fn, sch) -> JsonRepr sch

            
src/Data/Schematic/Schema.hs

knownFieldName
  :: forall proxy (fieldName :: Symbol) schema
  .  KnownSymbol fieldName
  => proxy '(fieldName, schema)
  -> Text
knownFieldName _ = T.pack $ symbolVal (Proxy @fieldName)

knownFieldSchema

            
src/Data/Schematic/Schema.hs
  FieldRepr a == FieldRepr b = a == b

instance
  ( KnownSymbol name
  , SingI schema
  , Serial m (JsonRepr schema) )
  => Serial m (FieldRepr '(name, schema)) where
  series = FieldRepr <$> series


            
src/Data/Schematic/Schema.hs
      let
        demoteFields :: SList s -> H.HashMap Text J.Value -> Parser (Rec FieldRepr s)
        demoteFields SNil _ = pure RNil
        demoteFields (SCons (STuple2 (n :: Sing fn) s) tl) h = withKnownSymbol n $ do
          let fieldName = T.pack $ symbolVal (Proxy @fn)
          fieldRepr <- case s of
            SSchemaText so -> case H.lookup fieldName h of
              Just v  -> withSingI so $ FieldRepr <$> parseJSON v
              Nothing -> fail $ "No text field: " P.++ show fieldName

            
src/Data/Schematic/Schema.hs
  toJSON (ReprArray v)    = J.Array $ toJSON <$> v
  toJSON (ReprObject r)   = J.Object . H.fromList . fold $ r
    where
      extract :: forall name s . (KnownSymbol name)
        => FieldRepr '(name, s)
        -> (Text, Value)
      extract (FieldRepr s) = (T.pack $ symbolVal $ Proxy @name, toJSON s)
      fold :: Rec FieldRepr fs -> [(Text, J.Value)]
      fold = \case

            
src/Data/Schematic/Validation.hs
    unless predicate warn
  STRegex r -> do
    let
      regex     = withKnownSymbol r $ fromSing r
      predicate = matchTest (makeRegex (T.unpack regex) :: Regex) (T.unpack t)
      errMsg    = path <> " must match " <> regex
      warn      = vWarning $ mmSingleton path (pure errMsg)
    unless predicate warn
  STEnum ss -> do

            
servant-docs-0.11.3
3 matches
src/Servant/Docs/Internal.hs
instance AllHeaderSamples '[] where
    allHeaderToSample _  = []

instance (ToHttpApiData l, AllHeaderSamples ls, ToSample l, KnownSymbol h)
    => AllHeaderSamples (Header h l ': ls) where
    allHeaderToSample _ = mkHeader (toSample (Proxy :: Proxy l)) :
                          allHeaderToSample (Proxy :: Proxy ls)
      where headerName = CI.mk . cs $ symbolVal (Proxy :: Proxy h)
            mkHeader (Just x) = (headerName, cs $ toHeader x)

            
src/Servant/Docs/Internal.hs

-- | @"books" :> 'Capture' "isbn" Text@ will appear as
-- @/books/:isbn@ in the docs.
instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs api)
      => HasDocs (Capture' mods sym a :> api) where

  docsFor Proxy (endpoint, action) =
    docsFor subApiP (endpoint', action')


            
src/Servant/Docs/Internal.hs

-- | @"books" :> 'CaptureAll' "isbn" Text@ will appear as
-- @/books/:isbn@ in the docs.
instance (KnownSymbol sym, ToCapture (CaptureAll sym a), HasDocs sublayout)
      => HasDocs (CaptureAll sym a :> sublayout) where

  docsFor Proxy (endpoint, action) =
    docsFor sublayoutP (endpoint', action')