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

bdcs-api-0.1.3
2 matches
src/BDCS/API/V0.hs
-- UUID-metadata.tar
--
-- The .tar is uncompressed, but is not large.
composeMetadata :: KnownSymbol h => ServerConfig -> String -> Handler (Headers '[Header h String] LBS.ByteString)
composeMetadata serverConf uuid =
    returnResults serverConf uuid (Just "-metadata") ["blueprint.toml", "compose.toml", "frozen.toml"]


-- | /api/v0/compose/results/<uuid>

            
src/BDCS/API/V0.hs
--
-- The mime type is set to 'application/x-tar' and the filename is set to
-- UUID.tar
composeResults :: KnownSymbol h => ServerConfig -> String -> Handler (Headers '[Header h String] LBS.ByteString)
composeResults serverConf uuid = do
    imageLocation <- returnImageLocation serverConf uuid

    case imageLocation of
        Just loc -> returnResults serverConf uuid Nothing ["compose.log", "blueprint.toml", "compose.toml", "frozen.toml", takeFileName loc]

            
composable-associations-aeson-0.1.0.0
3 matches
src/Data/ComposableAssociation/Aeson.hs



instance (ToJSON obj, KnownSymbol key) => ToJSON (Association key obj) where
  toJSON (Association key obj) = object [keyName .= toJSON obj]
    where keyName = T.pack $ symbolVal key

instance (FromJSON obj, KnownSymbol key) => FromJSON (Association key obj) where
  parseJSON = withObject "Association" $ \v' -> Association proxy <$> (v' .:? key .!= Null >>= parseJSON)
      where proxy = Proxy :: Proxy key
            key = T.pack $ symbolVal proxy



            
src/Data/ComposableAssociation/Aeson.hs


-- | Throws a @JsonObjectEncodingException@ if the base value isn't encoded as a JSON object
instance (ToJSON base, ToJSON obj, KnownSymbol key) => ToJSON (base :<> Association key obj) where
  toJSON (base :<> Association key obj) = Object $ HashMap.insert keyName objJson baseJsonMap
    where keyName = T.pack $ symbolVal key
          baseJsonMap = case toJSON base of (Object jsonObjVal) -> jsonObjVal
                                            notAnObject -> throw $ JsonObjectEncodingException notAnObject
          objJson = toJSON obj

            
src/Data/ComposableAssociation/Aeson.hs
                                            notAnObject -> throw $ JsonObjectEncodingException notAnObject
          objJson = toJSON obj

instance (FromJSON base, FromJSON obj, KnownSymbol key) => FromJSON (base :<> Association key obj) where
  parseJSON = withObject "base :<> assoc" $ \v' -> (:<>) <$>
                                            parseJSON (Object $ HashMap.delete key v') <*>
                                            fmap (Association proxy) (v' .:? key .!= Null >>= parseJSON)
    where proxy = Proxy :: Proxy key
          key = T.pack $ symbolVal proxy

            
configifier-0.1.1
8 matches
src/Data/Configifier.hs
import Data.Typeable (Typeable, Proxy(Proxy), typeOf)
import Data.Yaml.Include (decodeFileEither)
import Data.Yaml (ToJSON, FromJSON, Value(Object, Array, Null), object, toJSON, parseJSON, (.=))
import GHC.TypeLits (Symbol, KnownSymbol, symbolVal)
import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Language.Haskell.TH (runQ)
import System.Directory (doesFileExist)
import System.Environment (getEnvironment, getArgs, getProgName)
import System.IO.Unsafe (unsafePerformIO)

            
src/Data/Configifier.hs

-- | @instance ToJSON Label@
instance ( ToJSON (TaggedM cfg)
         , KnownSymbol s
         )
        => ToJSON (TaggedM (Label s cfg)) where
    toJSON (TaggedM Nothing) = Null
    toJSON (TaggedM (Just v)) = case toJSON (TaggedM v :: TaggedM cfg) of
        Null -> Null

            
src/Data/Configifier.hs
        return . TaggedM $ o1 :*> o2

-- | @instance FromJSON Label@ (tolerates unknown fields in json object.)
instance (FromJSON (TaggedM cfg), KnownSymbol s) => FromJSON (TaggedM (Label s cfg)) where
    parseJSON (Object hashmap) =
          case HashMap.lookup key hashmap of
            (Just json) -> TaggedM . Just . fromTaggedM <$> parseJSON' json
            Nothing     -> return $ TaggedM Nothing
        where

            
src/Data/Configifier.hs
-- still ok to have '_' in your config path names.  This parser chops
-- off complete matching names, whether they contain '_' or not, and
-- only then worries about trailing '_'.)
instance (KnownSymbol path, HasParseShellEnv a) => HasParseShellEnv (Label path a) where
    parseShellEnv [] = return $ TaggedM Nothing
    parseShellEnv env@(_:_) =
          case parseShellEnv env' :: Either Error (TaggedM a) of
              Right (TaggedM a) -> Right . TaggedM . Just $ a
              Left ShellEnvNil  -> Right . TaggedM $ Nothing

            
src/Data/Configifier.hs

instance ( cfg ~ Label p cfg'
         , Sel cfg' ps
         , KnownSymbol p
         ) => Sel (Label p cfg') (p ': ps) where
    sel (Tagged (Id a)) Proxy = sel (Tagged a :: Tagged cfg') (Proxy :: Proxy ps)

instance ( cfg ~ Descr cfg' s
         , Sel cfg' ps

            
src/Data/Configifier.hs
        let y' = thw (Proxy :: Proxy b) y in
        x' :*> y'

instance (KnownSymbol s, Freeze t) => Freeze (Label s t) where
    frz Proxy path = f
      where
        path' = symbolVal (Proxy :: Proxy s) : path
        f (Just x) = Id <$> frz (Proxy :: Proxy t) path' x
        f Nothing  = Left $ FreezeIncomplete path'

            
src/Data/Configifier.hs
instance (HasToDoc a, HasToDoc b) => HasToDoc (Record a b) where
    toDoc Proxy = toDoc (Proxy :: Proxy a) `concatDoc` toDoc (Proxy :: Proxy b)

instance (KnownSymbol path, HasToDoc a) => HasToDoc (Label path a) where
    toDoc Proxy = DocDict
        [( symbolVal (Proxy :: Proxy path)
         , Nothing
         , toDoc (Proxy :: Proxy a)
         , DocMandatory

            
src/Data/Configifier.hs
         , DocMandatory
         )]

instance (HasToDoc a, KnownSymbol path, KnownSymbol descr)
        => HasToDoc (Descr (Label path a) descr) where
    toDoc Proxy = DocDict
        [( symbolVal (Proxy :: Proxy path)
         , Just $ symbolVal (Proxy :: Proxy descr)
         , toDoc (Proxy :: Proxy a)

            
currency-convert-0.2.1.0
3 matches
Data/Currency/Convert.hs
    deriving (Eq, Ord)


instance KnownSymbol s => Show (Currency s) where
    show (Currency val) = symbolVal (Proxy :: Proxy s) ++ " " ++ show val

instance Read (Currency a) where
    readsPrec _ s = let (currency : value : rest) = words s in
                    let n :: Proxy s 

            
Data/Currency/Convert.hs
defaultProvider :: RateProvider
defaultProvider = fixerIOProvider <|-|> backupProvider

convert :: forall a b. (KnownSymbol a, KnownSymbol b, ?dict :: [(String, Double)], ?name :: String) 
           => Currency a -> Currency b
convert (Currency a) = let as = symbolVal (Proxy :: Proxy a) 
                           bs = symbolVal (Proxy :: Proxy b) in
                       case lookup as ?dict of
                           Just aRate -> let eurVal = a / aRate in

            
Data/Currency/Convert.hs
{-|
    @'Converter'@ is a newtype wrapper around the type of conversion functions to avoid @ImpredicativeTypes@ in @'getConverter'@
-}
newtype Converter = Converter (forall a b. (KnownSymbol a, KnownSymbol b) => Currency a -> Currency b)


{-|
    @'getConverter'@ takes a rate provider and returns a @'Converter'@ in the @IO@ monad.
    It is used like this:

            
data-basic-0.3.0.0
10 matches
src/Internal/Data/Basic/Types.hs
import Data.String (fromString)

import Control.Lens (Lens')
import GHC.TypeLits (KnownSymbol, Symbol, symbolVal)
import Database.PostgreSQL.Simple.FromField (FromField(..))
import Database.PostgreSQL.Simple.FromRow (FromRow, fromRow)
import Database.PostgreSQL.Simple.ToField (ToField)
import Database.PostgreSQL.Simple.ToRow (ToRow)
import qualified Database.PostgreSQL.Simple.Types as PSQL

            
src/Internal/Data/Basic/Types.hs
    TableFieldTypes a '[] = '[]
    TableFieldTypes a (f ': fs) = TableFieldType a f ': TableFieldTypes a fs

class (KnownSymbol (CapsName t s)) => HasCapsFieldName t (s :: Symbol) where
    capsFieldName :: proxy s -> Text
instance (KnownSymbol (CapsName t s)) => HasCapsFieldName t (s :: Symbol) where
    capsFieldName _ = toS $ symbolVal (Proxy @(CapsName t s))

class (AllSatisfy (TableField table) fields)
    => AllTypesSatisfy (c :: * -> Symbol -> Constraint) (table :: *) (fields :: [Symbol]) where
    mapFields :: (fields `IsSubset` SetFields (MissingFields entKind) table)

            
src/Internal/Data/Basic/Types.hs
    => ToJSON (Entity ('FromDb 'Live) a) where
    toJSON = toJSON . toFreshEntity @'[]

class    (KnownSymbol n, ToJSON a) => JSONableField a (n :: Symbol)
instance (KnownSymbol n, ToJSON a) => JSONableField a (n :: Symbol)

instance
    ( IsSubset (SetFields fs a) (SetFields fs a)
    , AllTypesSatisfy JSONableField a (SetFields fs a) )
    => ToJSON (Entity ('Fresh fs) a) where

            
src/Internal/Data/Basic/Types.hs
    SameTypes toTable (x ': xs) fromTable (y ': ys) =
        (TableFieldType toTable x ~ TableFieldType fromTable y, SameTypes toTable xs fromTable ys)

class ( KnownSymbol (TableName table)
      , AllSatisfy (TableField table) (TableFields table)
      , AllSatisfy KnownSymbol (TableFields table)
      , AllSatisfy (ValidConstraint table) (TableConstraints table)
      , AllTypesSatisfy (TypeSatisfies ToField) table (TableFields table)
      , OnMaybe (() :: Constraint) PrimaryKeyConstraint (TablePrimaryKey table)
      , FromRow table )
    => Table table where

            
src/Internal/Data/Basic/Types.hs
    => ValidConstraint table ('ForeignKey name)

getDbFields :: forall table. Table table => [Text]
getDbFields = mapTypeList (Proxy @KnownSymbol) (toS . symbolVal) (Proxy @(TableFields table))

type family IsDbExp a :: Bool where
    IsDbExp (DbExp k a) = 'True
    IsDbExp a = 'False


            
src/Internal/Data/Basic/Types.hs
    CapsName' name ('Just cName) = cName

class
    ( KnownSymbol name, KnownSymbol (CapsName table name)
    , IsDbExp (TableFieldType table name) ~ 'False )
    => TableField (table :: *) (name :: Symbol) where
    type TableFieldType table name :: *
    type TableFieldCapsName table name :: Maybe Symbol
    type TableFieldCapsName table name = 'Nothing

            
src/Internal/Data/Basic/Types.hs
     => PrimaryKeyConstraint (name :: Symbol)

class ( AllSatisfy (TableField (UniqueTable name)) (UniqueFields name)
      , KnownSymbol name )
   => UniqueConstraint (name :: Symbol) where
    type UniqueTable name :: *
    type UniqueFields name :: [Symbol]

class ( KnownSymbol name

            
src/Internal/Data/Basic/Types.hs
    type UniqueTable name :: *
    type UniqueFields name :: [Symbol]

class ( KnownSymbol name
      , AllSatisfy (TableField (ForeignKeyFrom name)) (ForeignKeyFromFields name)
      , AllSatisfy (TableField (ForeignKeyTo   name)) (ForeignKeyToFields   name)
      , SameTypes (ForeignKeyTo   name) (ForeignKeyToFields   name)
                  (ForeignKeyFrom name) (ForeignKeyFromFields name) )
   => ForeignKeyConstraint (name :: Symbol) where

            
src/Internal/Data/Basic/Types.hs
                                ':<>: ErrorText " is not set" )

type CanUpdate table pk =
    ( KnownSymbol pk
    , Table table
    , SetFields '[] table `IsSubset` SetFields '[] table -- needed for the compile function
    )

type DbResult list = ListToTuple (Entity ('FromDb 'Live)) list

            
src/Internal/Data/Basic/Types.hs
    => Aggregatable a where
    getAggregating a = [getAggregatingBase a]

nameText :: forall name. KnownSymbol name => Text
nameText = toS (symbolVal (Proxy @name))

            
elm-export-persistent-0.2.0
3 matches
src/Elm/Export/Persist/Ent.hs
    _ -> ev


instance (KnownSymbol field, ElmType a) => ElmType (Ent field a) where
  toElmType _ =
    case toElmType (Proxy :: Proxy a) of
      ElmDatatype name (RecordConstructor x (Values v vals)) ->
        ElmDatatype name (RecordConstructor x
                            (Values v (addIdToVals keyname vals)))

            
src/Elm/Export/Persist/Ent.hs
      keyname :: String
      keyname = symbolVal (Proxy :: Proxy field)

instance (KnownSymbol field, ToJSON a, ToJSON (Key a)) => ToJSON (Ent field a) where
  toJSON (Ent (Entity k val)) =
    case toJSON val of
      Object hmap -> Object (Map.insert keyname (toJSON k) hmap)
      x           -> x
    where

            
src/Elm/Export/Persist/Ent.hs

instance ( ToBackendKey SqlBackend a
         , PersistEntity a
         , KnownSymbol field
         , FromJSON a) => FromJSON (Ent field a) where
  parseJSON obj@(Object o) =
    let
      keyname :: String
      keyname = symbolVal (Proxy :: Proxy field)

            
extensible-0.6
1 matches
src/Data/Extensible/Dictionary.hs
  parseRecord rec = hgenerateFor (Proxy :: Proxy (Instance1 Csv.FromField h))
    $ \i -> G.indexM rec (getMemberId i) >>= Csv.parseField

instance Forall (KeyTargetAre KnownSymbol (Instance1 Csv.FromField h)) xs => Csv.FromNamedRecord (xs :& Field h) where
  parseNamedRecord rec = hgenerateFor (Proxy :: Proxy (KeyTargetAre KnownSymbol (Instance1 Csv.FromField h)))
    $ \i -> rec Csv..: BC.pack (symbolVal (proxyKeyOf i)) >>= Csv.parseField

instance WrapForall Csv.ToField h xs => Csv.ToRecord (xs :& h) where
  toRecord = V.fromList
    . hfoldrWithIndexFor (Proxy :: Proxy (Instance1 Csv.ToField h))