Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by type signature #61

Open
hackeryarn opened this issue Feb 18, 2016 · 19 comments
Open

Search by type signature #61

hackeryarn opened this issue Feb 18, 2016 · 19 comments

Comments

@hackeryarn
Copy link

Would it be possible to incorporate type signature search in the current search bar. Something resembling Hoogle like functionality.

I would really like to be able to search for (a → b) → f a → f b and get map.

@davidchambers
Copy link
Member

This would be very nice indeed!

@buzzdecafe
Copy link
Member

agree 100% that would be nice.

@CrossEye
Copy link
Member

I agree. This would be very nice. I don't have a clue as to how to implement it, but I want it. I was talking about this just the other day.

If it were just text search, I think it would be easy enough, but it should be smart enough not to distinguish between (a -> b) -> [a] -> [b] and (c -> d) -> [c] -> [d], yet still recognize that while this is related, it's more specific: (x -> x) -> [x] -> [x].

Anyone have ideas?

@hackeryarn
Copy link
Author

My only idea on this would be some tricky pattern matching or regexs.

Such as just checking that structure and ignoring the value names.

@davidchase
Copy link
Contributor

couldn't we replace the current search/filtering with a nice js fuzzy search library?

@buzzdecafe
Copy link
Member

do you have one in mind?

@davidchase
Copy link
Contributor

The ones ive played around with:

http://glench.github.io/fuzzyset.js/
http://kiro.me/projects/fuse.html

@CrossEye
Copy link
Member

I'm on the lookout for one for a work project too, although I haven't started actually looking yet. (I'm actually much more interested in solving that problem myself. It would be nice to do something algorithmically interesting for a change.)

@davidchase
Copy link
Contributor

@CrossEye gotcha, maybe we can add something temporary and then switch it to something you've created... whatever works 😄

@CrossEye
Copy link
Member

Ok, off to research the Bitap algorithm. Looks like fun.

@CrossEye
Copy link
Member

No, there's plenty of fun in Ramda; it's the day job that needs some sprucing up. It's also in a company with a long drawn-out approval process for third-party tools (not that we always tell them, but as this would be consumer-facing it might take some doing.) If I built my own there, there's no approval needed.

I'm all for trying to find a good tool for Ramda to use.

The trouble is that I think what we most want is a lot more tagging in order to search. It's not so much the fuzzy search, but the missing metadata. But I could be mistaken.

@arcseldon
Copy link

The trouble is that I think what we most want is a lot more tagging in order to search.

In agreement here - more tags to group searches by would be excellent, and cater to a wider audience. However, fuzzy search on type signatures would definitely be a helpful addition too.

@davidchase
Copy link
Contributor

makes sense, its probably just missing the signature in the filter code, i was just messing around with the libraries i mentioned above feeding them a data structure like which i scrapped from the DOM

...
  {
    "signature": "(a → a) → Number → [a] → [a]",
    "name": "adjust",
    "category": "List"
  },
  {
    "signature": "(a → Boolean) → [a] → Boolean",
    "name": "all",
    "category": "List"
  },
  {
    "signature": "[(*… → Boolean)] → (*… → Boolean)",
    "name": "allPass",
    "category": "Logic"
  },
  {
    "signature": "[a] → Boolean",
    "name": "allUniq",
    "category": "List"
  },
  {
    "signature": "a → (* → a)",
    "name": "always",
    "category": "Function"
  }
...

worked pretty well...

@CrossEye
Copy link
Member

The problem is that a good fuzzy type search seems much more sophisticated than a fuzzy text search. If we search Hoogle for (a -> b -> c) -> a -> [b] -> c, the results include for instance,

foldl :: (a -> b -> a) -> a -> [b] -> a
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

but do not include

map :: (a -> b) -> [a] -> [b]

I'm not sure if text searches would be able to do that well.

i was just messing around with the libraries i mentioned above feeding them a data structure like which i scrapped from the DOM

...
  {
    "signature": "(a → a) → Number → [a] → [a]",
    "name": "adjust",
    "category": "List"
  },

Funny, I was playing around with something similar thinking about #1652, also scraped from the DOM, although I would hope to do it differently someday. Mine was an object grouped by category, and signature was a list. (See, for instance, init, last, nth.) But it's still much the same idea.

@arcseldon
Copy link

I really like my new Alfred workflow for Ramda docs, which has baked in support for type signatures 😄 Here is an example usage off my desktop:

ramdasearch

I just choose the function I am looking for (in this example by type signature) and it takes me off to the required definition on ramdajs.

Thanks to raine for taking the effort to set this up. Think I even prefer it to the bash support.

@dawehner
Copy link

I've tried to implement some type driven search on http://ramda-search.now.sh
It parses the signature to make some more educated search, but right now it doesn't yet implement the extended logic of #61 (comment)

@CrossEye
Copy link
Member

@dawehner:

This looks like a very promising start. Is the code available somewhere?

@davidchambers
Copy link
Member

This week I will open a pull request for sanctuary-search, which will support type variable substitution as well as less fancy Hoogle features. The module will be used on the Sanctuary website; it may be a good fit for the Ramda website too.

@dawehner
Copy link

@CrossEye
Thank you.I've implemented it here: https://github.com/dawehner/elm-ramda-search/blob/master/src/Main.elm it is in elm, feel free to ask questions if you want to know about it.

@davidchambers
Interesting, I've never heard of sanctuary before, sorry :| I like the existence of Nothing for example! Looking forward to see how you implement the search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants