Commit f8326bc3 authored by Camil Staps's avatar Camil Staps
Browse files

Add resetDB for suggestions

parent 9e53aed0
......@@ -218,6 +218,8 @@ syncDB :: !Int !*CloogleDB -> *CloogleDB
saveDB :: *CloogleDB *File -> *(*CloogleDB, *File)
openDB :: !*File -> *(!Maybe *CloogleDB, !*File)
resetDB :: !*CloogleDB -> *CloogleDB
getIndex :: !Index !*CloogleDB -> *(Entry CloogleEntry AnnotationKey Annotation, *CloogleDB)
getIndices :: ![Index] !*CloogleDB -> *([Entry CloogleEntry AnnotationKey Annotation], *CloogleDB)
......
......@@ -293,6 +293,9 @@ where
# (line,f) = freadline f
= (fromJSON (fromString line), f)
resetDB :: !*CloogleDB -> *CloogleDB
resetDB wrap=:{db} = {wrap & db='DB'.resetDB db}
getIndex :: !Index !*CloogleDB -> *(Entry CloogleEntry AnnotationKey Annotation, *CloogleDB)
getIndex idx wrap=:{db}
# (e,db) = 'DB'.getIndex idx db
......
......@@ -55,6 +55,11 @@ saveDB :: *(DB v ak a) *File -> *(*DB v ak a, *File) | JSONEncode{|*|} v
*/
openDB :: !*File -> *(!Maybe (*DB v ak a), !*File) | JSONDecode{|*|} v
/**
* Reset all entries to included.
*/
resetDB :: !*(DB v ak a) -> *DB v ak a
/**
* Return all entries (whether they have been excluded or not).
*/
......
......@@ -60,6 +60,18 @@ where
(Nothing, f) -> (Nothing, f)
(Just es, f) -> (Just [e:es], f)
resetDB :: !*(DB v ak a) -> *DB v ak a
resetDB (DB db)
# (s,db) = usize db
# db = upd (s-1) db
= DB db
where
upd :: !Int !*{!Entry v ak a} -> *{!Entry v ak a}
upd -1 es = es
upd i es
# (e,es) = es![i]
= upd (i-1) {es & [i]={e & included=True}}
allEntries :: *(DB v ak a) -> *([v], *DB v ak a)
allEntries (DB db)
# (s,db) = usize db
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment