Fork me on GitHub
#beginners
<
2017-03-01
>
raspasov00:03:52

@alexmiller thanks Alex 🙂

joshkh16:03:41

i'm writing a library for performing queries against a web service. almost every function needs to clean the query map coming in before it runs (it just gets it into the right format, checks for correct URIs, etc). is there a better way to tackle this other than to run the clean function within every single query function?

joshkh16:03:16

composing every single function with the clean function doesn't feel right either (and i lose parameter info in intellij)

joshkh16:03:17

for example, in this function the path parameter can be a string "Some.dot.notation.path" but i'd also like to convert a vector of values into a string path if that's what i'm given instead. i'd have to do that for every single function in this namespace.

joshkh16:03:05

(... apparently i can't paste into slack)

josh.freckleton18:03:41

is there a core function like haskell's init? (eg (init [1,2,3]) => [1,2]))

rauh18:03:32

@josh.freckleton pop

josh.freckleton18:03:25

that's a sensible name for it 🙂

lgessler23:03:21

@joshkh, just thinking about it conceptually, you have to do some cleaning work for every query, right?

lgessler23:03:47

so your question must be how to write the cleanest code to do it?

lgessler23:03:39

ah of course that's what you're asking--don't know why I was reading you wrong

lgessler23:03:04

looks like this might be close to what you're looking for: https://github.com/weavejester/decorate

lgessler23:03:32

"[Using this library's decoration function] will redefine the [function that is decorated], keeping the metadata intact."

lgessler23:03:03

It says it's specifically for Compojure but even if that's a strict dependency you could probably learn how they pulled that off by reading the source

lgessler23:03:26

oh lol I just looked at it, it's 36 lines. cheers