Search Haskell Channel Logs

Sunday, January 29, 2017

#haskell channel featuring systadmin, shiona, MarcelineVQ, reactormonk, Gurkenglas, ph88,

reactormonk 2017-01-29 00:46:31
I've got a bunch of executables here in my .cabal file - any way to dedup build-depends?
ph88 2017-01-29 01:01:08
if i use list in a type i can just use [ ] but what about a non-empty list ?
ph88 2017-01-29 01:01:46
by the way, is the non-empty list a form of dependent type ?
reactormonk 2017-01-29 01:02:33
quick hackage search reveals https://hackage.haskell.org/package/semigroups
reactormonk 2017-01-29 01:02:47
There's probably a few more
reactormonk 2017-01-29 01:03:59
From what I understand, I can't have a type that's one constructor only? aka https://hackage.haskell.org/package/uri-bytestring-0.2.2.1/docs/URI-ByteString.html#t:URIRef but I'd only allow RelativeRef?
cocreature 2017-01-29 01:04:17
ph88: you should use '[element0, element1]. ' is not always required (that's why you can write [] instead of '[]) but modern GHCs warn if you don't use it
skeuomorf 2017-01-29 01:05:42
Is there a haskell cheat sheet? Kinda like https://www.conj.io for Clojure
ph88 2017-01-29 01:06:03
cocreature, eh i don't really understand the syntax you are describing here. So i use a single quote before [ and after ] a dot and a space and a single quote ? but then later you say after ] parenthesis close ?
cocreature 2017-01-29 01:07:33
ph88: [], is kind of special. if you have a data constructor called "Constructor" "'Constructor" is the promoted version at the type level. [] is builtin syntax , in that case you put ' before the first opening bracket, i.e., "'[]", "'[elements]"
reactormonk 2017-01-29 01:08:13
cocreature, isn't that a typelevel list?
cocreature 2017-01-29 01:08:21
sometimes you can get away without putting ' before promoted names but that only gets confusing
cocreature 2017-01-29 01:08:23
reactormonk: yes
cocreature 2017-01-29 01:08:44
maybe I missunderstood ph88
cocreature 2017-01-29 01:09:41
ph88: are you talking about nonempty lists of values or nonempty typelevel lists?
ph88 2017-01-29 01:09:56
i don't know what you mean by promoted version of constructor, i was refering to https://hackage.haskell.org/package/semigroups-0.16/docs/Data-List-NonEmpty.html
cocreature 2017-01-29 01:10:04
ph88: oh sorry
cocreature 2017-01-29 01:10:10
ph88: in that case you just use "NonEmpty"
ph88 2017-01-29 01:10:12
i want to put values, but i still have to put it in my type
ph88 2017-01-29 01:10:29
oh ok, so no nice [] syntax anymore :(
cocreature 2017-01-29 01:10:35
yep
ph88 2017-01-29 01:10:38
is NonEmpty a form of dependent type ?
cocreature 2017-01-29 01:10:43
no
cocreature 2017-01-29 01:10:56
it's just a regular data constructor
ph88 2017-01-29 01:11:03
but it depends on the value no ?
cocreature 2017-01-29 01:11:08
data NonEmpty a = a :| [a]
cocreature 2017-01-29 01:11:35
ph88: the type does not depend on the in the list
cocreature 2017-01-29 01:12:04
*the values
cocreature 2017-01-29 01:12:11
or the number of values in the list
ph88 2017-01-29 01:12:39
i thought it does bcz it has to have at least 1 value of that type ..
Gurkenglas 2017-01-29 01:13:03
Which of these IntelliJ haskell plugins would you recommend? https://gyazo.com/3b7be505552de2bf98c38ecc2600ea60
ph88 2017-01-29 01:13:17
anyway i thought of using this instead of lists in case i want to save things which use combinator "some"
cocreature 2017-01-29 01:13:20
ph88: a dependent type would be one where the type would change depending on the number of elements. NonEmpty just doesn't have a constructor that takes no elements
ph88 2017-01-29 01:13:30
oh ok
cocreature 2017-01-29 01:14:26
ph88: it's not different from "data X = X Int" in that regard: you can only put a single Int in there but it's definitely not a dependent type
ph88 2017-01-29 01:16:17
does anyone know of a tool that visualize all the haskell types of a file, and how one type depends on another type ?
MarcelineVQ 2017-01-29 01:22:15
no but there probably is one, some sort of UML library perhaps
shiona 2017-01-29 01:32:54
Is there a way to insert a cookie into wreq session?
cocreature 2017-01-29 01:34:20
shiona: it looks like there is a "cookies" lens
shiona 2017-01-29 01:34:36
cocreature: Where? I can see such a thing only for the options
cocreature 2017-01-29 01:34:47
shiona: oh right sorry
shiona 2017-01-29 01:35:01
no problem, I was cautiosly optimistic
shiona 2017-01-29 01:35:46
I have no idea who designed this web UI, but it uses javascript to create the session id on the login page
shiona 2017-01-29 01:36:17
so now I need to emulate it somehow, since the server itself will just not give me the seid
cocreature 2017-01-29 01:36:53
shiona: put wreq session should manage cookies automatically, why do you want to put one manually into a session?
shiona 2017-01-29 01:37:37
I have a http server that requires a seid-cookie to be sent on login request.
cocreature 2017-01-29 01:37:49
where does your browser get the seid-cookie from?
shiona 2017-01-29 01:38:05
using a browser, this seid-cookie is created in javascript on the landing page
cocreature 2017-01-29 01:39:18
ah ok, now I understood the problem
cocreature 2017-01-29 01:39:32
shiona: looks like you are just going to have to put the cookies in "Options" for each request
shiona 2017-01-29 01:39:49
:/
shiona 2017-01-29 01:39:54
ok. Thanks
cocreature 2017-01-29 01:40:06
or use a different library depending on how much code you have written that depends on wreq
shiona 2017-01-29 01:40:23
I could go with some other library
shiona 2017-01-29 01:40:38
I haven't been able to get far, as I can't really log in
systadmin 2017-01-29 01:40:43
Does Haskell use operators like: !=, ==. <==, >==, etc?
shiona 2017-01-29 01:41:11
systadmin: I assume you are looking for /=, ==, <=, >= in order
systadmin 2017-01-29 01:41:23
yeah
systadmin 2017-01-29 01:41:50
Also what does Haskell have in place of if, elif, else statements
cocreature 2017-01-29 01:42:02
systadmin: we do have "if" and "else" :)
systadmin 2017-01-29 01:42:18
I'm coming from Python so I'm looking for the Haskell counterparts of Python expressions/statements/etc
systadmin 2017-01-29 01:42:27
cocreature: so no elif?:(
cocreature 2017-01-29 01:42:50
systadmin: there is a MultiWayIf extension that is pretty much that
cocreature 2017-01-29 01:42:59
or you can use guards
MarcelineVQ 2017-01-29 01:43:00
guards tend to subsume elif
systadmin 2017-01-29 01:43:21
Are if and else statements used the same way
systadmin 2017-01-29 01:43:26
Like
shiona 2017-01-29 01:43:36
It's a bit counterproductive to try to force haskell to work in your python mindset
systadmin 2017-01-29 01:43:37
if: followed by another block of code, or column
MarcelineVQ 2017-01-29 01:43:39
else is a neccesary part of if, if pred then one else two
cocreature 2017-01-29 01:44:17
yeah trying to find counterparts for python expressions is not a particularly good idea
ph88 2017-01-29 01:44:22
is there a version of Text that requires that there is at least one character ? Kind of like NonEmpty Char
cocreature 2017-01-29 01:44:26
there is not really a one-to-one correspondence
cocreature 2017-01-29 01:44:43
ph88: afaik no
systadmin 2017-01-29 01:44:47
So I shouldn't really try to learn the counterparts
ph88 2017-01-29 01:44:51
oki
systadmin 2017-01-29 01:44:55
I should learn Haskell normally like I should do?