Copyright | © Thor Michael Støre, 2015 |
---|---|
License | GPL v2 without "any later version" clause |
Maintainer | thormichael át gmail døt com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Relation variable definition, along with IO level support functions.
- data Relvar a = Relvar {}
- relvarType :: Relvar a -> Relation a
- readRel :: forall b. (Ord (HList b), Read (HList (RecordValuesR b)), RecordValues b, HMapAux HList TaggedFn (RecordValuesR b) b) => String -> Relation b
- readRelvar :: (Ord (HList b), Read (HList (RecordValuesR b)), RecordValues b, HMapAux HList TaggedFn (RecordValuesR b) b) => Relvar b -> IO (Relation b)
- hListsToRel :: (Ord (HList b), RecordValues b, HMapAux HList TaggedFn (RecordValuesR b) b) => [HList (RecordValuesR b)] -> Relation b
- writeRelvarBody :: Show r => FilePath -> r -> IO ()
- writeRelvarBody' :: Show r => Relvar rv -> r -> IO ()
- showRelStr :: (Show (HList (RecordValuesR r)), RecordValues r) => Relation r -> String
Relation variable definitions
Relation variable reference. This type has a phantom type variable, which generally calls for the type to be explicity specified:
s = Relvar "SuppliersPartsDB/S.rv" :: Relvar '[SNO, SName, Status, City]
relvarType :: Relvar a -> Relation a Source
Gives the type a relvar results in. Note that the value this results in will always be undefined
.
Relational input
readRel :: forall b. (Ord (HList b), Read (HList (RecordValuesR b)), RecordValues b, HMapAux HList TaggedFn (RecordValuesR b) b) => String -> Relation b Source
Reads a relation value from a string containing HLists of unpacked attribues.
>>>
pt$ ( readRel "H[\"S1\",10],H[\"S2\",50]" :: Relation '[SNO,Status])
┌───────────────┬───────────────────┐ │ sno :: String │ status :: Integer │ ╞═══════════════╪═══════════════════╡ │ S1 │ 10 │ │ S2 │ 50 │ └───────────────┴───────────────────┘
readRelvar :: (Ord (HList b), Read (HList (RecordValuesR b)), RecordValues b, HMapAux HList TaggedFn (RecordValuesR b) b) => Relvar b -> IO (Relation b) Source
Read a relation variable from the file referenced by the first argument
hListsToRel :: (Ord (HList b), RecordValues b, HMapAux HList TaggedFn (RecordValuesR b) b) => [HList (RecordValuesR b)] -> Relation b Source
Converts a list of HLists into a relation value.
Relational output
writeRelvarBody :: Show r => FilePath -> r -> IO () Source
Writes a body of a relvar to a given file
writeRelvarBody' :: Show r => Relvar rv -> r -> IO () Source
Writes a body of a relvar to a given relvar file reference
showRelStr :: (Show (HList (RecordValuesR r)), RecordValues r) => Relation r -> String Source
Prints a relation as a list without the outer brackets.