[question] What to use for persistence in a CLI application?

What to use for persistence in a CLI application?


I'm pretty new to Haskell and I decided to put together a quick GTD application, as a way to use Haskell in a real life scenario and learn from it. I was wondering what would the Haskell community recommend for persisting the action lists, or any other data that the application will require.

I was thinking of something that could be embedded, and light, so that the application could be distributed in a simple way without dependencies (if compiled statically, of course). I've looked at sqlite-simple and opaleye-sqlite.

I wonder what would you recommend (not limited to just those two, nor to sqlite)?


Submitted October 17, 2017 at 04:06PM by mlopes
via reddit http://ift.tt/2gK6Fh1


Switch case with multiple statements?

Switch case with multiple statements?

Hey, anyone know how I could get this code to work:

func GetIps(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(routes) 


func returnByIp(w http.ResponseWriter, r *http.Request) { var response []Route params := mux.Vars(r) for _, item := range routes { switch { case item.Level == params["level"] && item.Ip == params["ip"]: response = append(response, item) case item.Level == params["level"]: response = append(response, item) case item.Ip == params["ip"]: response = append(response,item) case item.Smethod == params["smethod"]: response = append(response, item) default : fmt.Println("Nothing found") } } if len(response) > 0 { json.NewEncoder(w).Encode(response) return } 


Basically it works otherwise but when searching for a specific ip and level it will show all levels regardless as long as the ip is correct and vice versa (if level is correct it will show all ips) And I want the first case to only show results if both are correct.

Submitted October 17, 2017 at 03:37PM by JonTargaryanTheFirst
via reddit http://ift.tt/2xKQSUP

Cleaning up JSON before unmarshaling

Cleaning up JSON before unmarshaling


I'm consuming two separate third-party services. First service uses PascalCase for their keys, and the second uses camelCase. I decided to standardize over snake_case.

The payload of one of these services can have up to hundreds of keys.

How can I unmarshal camelCase or snake_case, but always marshal snake_case?

Submitted October 17, 2017 at 03:08PM by fllr
via reddit http://ift.tt/2ytWSFo