danse / meta

A repo about other repos
0 stars 0 forks source link

gates #25

Open danse opened 7 years ago

danse commented 7 years ago

This is an old idea. It might be added in Medusa or anywhere else it's easy to add

danse commented 7 years ago
medusa-gate 'offline' 1 2 3
medusa-gate-add 'study' offline/1

I would just want to have the entry hidden from the main view and duplicated in the two gates, but any modification of the entry in one of the gates should apply to all its locations

type Tags = Map String [Int]
type Entries = [Entry]

tags = singleton 'untagged' []
entries = []

This can be wrapped in a data type: Tagged Tag Entry

danse commented 7 years ago

Asking in #haskell i was suggested IxSet

danse commented 7 years ago

IxSet seems overkill for me, i just need Tagged a b, with lookup :: a -> [b]

danse commented 7 years ago
Tagged a b
select :: a -> Tagged a b
instance IsList Tagged
danse commented 7 years ago

This data structure would be useful for me to build a tool to manage links or resources

danse commented 7 years ago

I started with something like:

module Tagged where

-- | Data structure for overlapping labels (tags)
-- >>> Untagged "value"
-- [("untagged", ["value"])]
-- >>> let t = Untagged "value"
-- >>> tag (select "untagged" t) "new tag"
-- TaggedSelection: "untagged", "new tag" -> "value"

import Data.Map as M

data Tagged b = Tagged {
  index :: M.Map Int b,
  tags :: M.Map String [Int]
  }

data TaggedSelection b = TaggedSelection {
  tagged :: Tagged b,
  selection :: [Int]
  }

untagged = "untagged"

empty = Tagged { index = M.empty, tags = M.singleton untagged []}

But there are some problems: i am not satisfied with the Show/Read implementation and with how to represent a selection

danse commented 7 years ago

To simplify the design i would use a similar Show/Read interface as in Map, based on an instance of isList, but with a different semantic. In my case, duplicate keys are allowed and duplicate values represent the same entity. This is very inefficient but i hope that it will unlock me

danse commented 7 years ago

Collected a new starting notes in a folder ready to become a repo