Created
April 6, 2017 16:31
-
-
Save yanok/19b025175aee139e4a51414e17078fce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module DataStore | |
| import Data.Vect | |
| infixr 5 .+. | |
| public export | |
| data Schema = SString | SInt | (.+.) Schema Schema | |
| %name Schema sch, sch1 | |
| public export | |
| SchemaType : Schema -> Type | |
| SchemaType SString = String | |
| SchemaType SInt = Int | |
| SchemaType (sch .+. sch1) = (SchemaType sch, SchemaType sch1) | |
| export | |
| record DataStore (schema : Schema) where | |
| constructor MkData | |
| size : Nat | |
| items : Vect size (SchemaType schema) | |
| export | |
| empty : DataStore schema | |
| empty = MkData _ [] | |
| export | |
| addToStore : (value : SchemaType schema) -> | |
| (store : DataStore schema) -> | |
| DataStore schema | |
| addToStore value (MkData _ items) = MkData _ (value :: items) | |
| public export | |
| data StoreView : DataStore schema -> Type where | |
| SNil : StoreView empty | |
| SAdd : (rec : StoreView store) -> StoreView (addToStore value store) | |
| storeViewHelp : (items : Vect size (SchemaType schema)) -> | |
| StoreView (MkData size items) | |
| storeViewHelp [] = SNil | |
| storeViewHelp (x :: xs) = SNil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment