Skip to content

Instantly share code, notes, and snippets.

@yanok
Created April 6, 2017 16:31
Show Gist options
  • Select an option

  • Save yanok/19b025175aee139e4a51414e17078fce to your computer and use it in GitHub Desktop.

Select an option

Save yanok/19b025175aee139e4a51414e17078fce to your computer and use it in GitHub Desktop.
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