Search Haskell Channel Logs

Friday, February 17, 2017

#haskell channel featuring gtsteel, dmwit, lordcirth_, c_wraith, kadoban, EvanR, and 7 others.

ubsan 2017-02-17 15:45:33
I'm trying to figure out how to case statement
ubsan 2017-02-17 15:46:10
how would I do the equivalence of `match a { b @ ExprTrue => ..., ... }`
ubsan 2017-02-17 15:46:17
(Rust)
glguy 2017-02-17 15:47:21
case a of ExprTrue -> ...; ...
ubsan 2017-02-17 15:47:47
glguy: yeah but I want it to be bound to a variable
ubsan 2017-02-17 15:48:03
that's that `a @` syntax
ubsan 2017-02-17 15:48:08
because I'd like to do something like
glguy 2017-02-17 15:48:21
It's already bound to a
ubsan 2017-02-17 15:48:28
match a { b @ ExprTrue | b @ ExprFalse -> b, ... }
glguy 2017-02-17 15:48:29
otherwise you can use the same @ for an "as-pattern"
lordcirth_ 2017-02-17 15:49:15
So I'm not very good with monads yet. If I have a State wrapping a GameState datatype, is it easy to bind functions, which themselves call functions which operate on the State?
ubsan 2017-02-17 15:49:27
>
ubsan 2017-02-17 15:49:27
main.hs:131:5: error: Parse error in pattern: b @ExprTrue
lambdabot 2017-02-17 15:49:29
: error: not an expression: ''
ubsan 2017-02-17 15:49:32
glguy: ^
ubsan 2017-02-17 15:49:48
with the expression
ubsan 2017-02-17 15:50:03
case (eval a) of b @ ExprTrue | b @ ExprFalse -> ExprFail (ExprSucc b)
glguy 2017-02-17 15:50:05
ubsan: You can paste your code to lpaste.net ; I don't know what you did wrong from that
lordcirth 2017-02-17 15:50:08
ubsan, emptystring is not an expression, this seems reasonable?
lordcirth 2017-02-17 15:50:47
oh nvrm
glguy 2017-02-17 15:50:52
ubsan: You use a ; to separate case alternatives
ubsan 2017-02-17 15:51:24
glguy: so like, b @ ExprTrue; b @ ExprFalse
ubsan 2017-02-17 15:51:24
?
glguy 2017-02-17 15:51:24
ubsan: and there is no syntax for "or-patterns"
glguy 2017-02-17 15:51:24
which is perhaps what you were trying to do with the |
ubsan 2017-02-17 15:51:24
ergh
ubsan 2017-02-17 15:51:24
why
glguy 2017-02-17 15:51:24
because
c_wraith 2017-02-17 15:51:24
lordcirth: Pretend state actions are just like IO actions, and everything composes the same way.
ubsan 2017-02-17 15:51:45
...
lordcirth 2017-02-17 15:51:59
c_wraith, as I said, I am not good with monads yet. I understand how to use -> and so on, but haven't really worked with binding
ubsan 2017-02-17 15:52:10
I do not like haskell case syntax very much :[
c_wraith 2017-02-17 15:52:31
lordcirth: so, what are the types of a few actions you'll be working with?
lordcirth 2017-02-17 15:53:25
c_wraith, well mostly GameState -> (... more args ...) -> (GameState, output) if I'm understanding how to use a State correctly
lordcirth 2017-02-17 15:54:13
functions which take a GameState, and different args depending on function, and return a changed GameState and some value
c_wraith 2017-02-17 15:54:15
lordcirth: State is a wrapper for functions that look vaguely like that, but the whole point of it is that it removes those details
dmwit 2017-02-17 15:54:33
Normally stateful actions have types like `(... more args ...) -> State GameState output`.
dmwit 2017-02-17 15:54:46
These are easy to combine with the bind operation.
lordcirth 2017-02-17 15:55:32
dmwit, so rather than returning a tuple of two, you return a State containing the two, so you can bind?
lordcirth 2017-02-17 15:56:14
and the first item in the State must always be the same (GameState here) and the second can be anything depending on the function?
dmwit 2017-02-17 15:56:49
That sounds right.
c_wraith 2017-02-17 15:56:49
if you mean the first type argument to State, yes
c_wraith 2017-02-17 15:57:03
The type arguments need to align for bind to be well-typed
lordcirth 2017-02-17 15:57:21
So all functions/actions must have a return type of "State GameState a" ?
dmwit 2017-02-17 15:57:31
"must" is such a strong word
lordcirth 2017-02-17 15:57:37
should?
dmwit 2017-02-17 15:57:54
Let's say yes. But that's a first approximation to the truth.
gtsteel 2017-02-17 15:57:58
I'm trying to upload a package I wrote, but I'm getting a build error (FFI related) I can't reproduce. Any idea what's going on? https://hackage.haskell.org/package/maxent-learner-hw-0.1.1
dmwit 2017-02-17 15:59:05
Have you tried unpacking your tarball in a fresh directory and trying to build it?
dmwit 2017-02-17 15:59:26
It's possible the tarball doesn't have all the same files as your dev directory does.
yushyin 2017-02-17 16:00:34
ubsan: I guess haskell does not have it because it would be ambiguous and could also mean 'pattern guards'
dmwit 2017-02-17 16:00:53
That would be my first guess. My second guess would be about a library that's installed on your machine but not Hackage. But the function name it's looking for looks close enough to the function name it has that I suspect you wrote it in one of your C files, making that second guess seem much less likely to me.
ubsan 2017-02-17 16:01:28
yushyin: every time I try to use haskell, I keep hitting up against really dumb problems
yushyin 2017-02-17 16:02:54
that's what happens every time I try to program in any language so far ^^
gtsteel 2017-02-17 16:03:07
builds fine in a clean directory. The function it's complaining about is an inline function defined in the same file where it's called. https://github.com/george-steel/maxent-learner/blob/master/ffisrc/packeddfa.c
ubsan 2017-02-17 16:03:40
mostly syntax
ubsan 2017-02-17 16:03:56
I really dislike small parts haskell's syntax
ubsan 2017-02-17 16:03:58
*of
lordcirth 2017-02-17 16:04:12
'fst' and 'snd' do annoy me a bit
ubsan 2017-02-17 16:04:21
it's not stuff like htat
lordcirth 2017-02-17 16:04:29
no one would die if they used 4 letters
ubsan 2017-02-17 16:04:30
it's like, :: vs :
ubsan 2017-02-17 16:04:38
or -> vs =>
lordcirth 2017-02-17 16:04:38
ubsan, what's : ?
ubsan 2017-02-17 16:05:13
or haskell's specific method of whitespace dependence, which is shockingly bad, compared to other languages like F# or idris
ubsan 2017-02-17 16:05:20
lordcirth: cons
lordcirth 2017-02-17 16:05:26
right I'm dumb
yushyin 2017-02-17 16:05:29
-> vs => is so irrelevant
lordcirth 2017-02-17 16:05:40
further proof I need to get back to working on Haskell
ubsan 2017-02-17 16:05:42
yushyin: death by a thousand cuts
lordcirth 2017-02-17 16:06:04
whitespace dependence is controversial, for good reason
lordcirth 2017-02-17 16:06:08
record syntax needs work
lordcirth 2017-02-17 16:06:18
Other than that, I can't say I have major complaints
ubsan 2017-02-17 16:06:29
lordcirth: it's not whitespace dependence
ubsan 2017-02-17 16:06:33
it's haskell's specific method
lordcirth 2017-02-17 16:06:47
ubsan, what about it?
ubsan 2017-02-17 16:06:53
which is confusing. haskell's shitty errors about whitespace make it worse
`Guest05 2017-02-17 16:07:16
ubsan: what's bad about thin arrows for function type instead of fat arrows?
ubsan 2017-02-17 16:07:25
`Guest05: not that
ubsan 2017-02-17 16:07:30
in case statements, => is better
ubsan 2017-02-17 16:07:36
-> for function types is goo
ubsan 2017-02-17 16:07:37
d
`Guest05 2017-02-17 16:07:40
ok
lordcirth 2017-02-17 16:07:43
meh
`Guest05 2017-02-17 16:07:44
why for case then?
yushyin 2017-02-17 16:07:46
you think it is better for what reason?
ubsan 2017-02-17 16:08:01
yushyin: because I like it better
lordcirth 2017-02-17 16:08:15
It's an arbitrary choice
yushyin 2017-02-17 16:08:15
ok so it is irrelavant
`Guest05 2017-02-17 16:08:15
why do you like it better?
yushyin 2017-02-17 16:08:23
e*
ubsan 2017-02-17 16:08:27
`Guest05: it makes it obvious that they're two different constructs
ubsan 2017-02-17 16:08:39
it's weird that -> for function types and -> for cases is the same operator
`Guest05 2017-02-17 16:08:44
ubsan: heh, there is also => in types
`Guest05 2017-02-17 16:08:55
syntax space for arrows is tight
ubsan 2017-02-17 16:09:01
`Guest05: I guess so.
lordcirth 2017-02-17 16:09:01
but they are in different contexts. I don't recall ever confusing the two
ubsan 2017-02-17 16:09:09
but I'm trained on idris
ubsan 2017-02-17 16:09:13
so I like => better
ubsan 2017-02-17 16:09:17
and also Rust
ubsan 2017-02-17 16:09:35
that's not a big thing at all, I just get annoyed about it
ubsan 2017-02-17 16:09:46
when I make the mistake and have to switch my code
yushyin 2017-02-17 16:10:45
just don't sweat the small stuff?
`Guest05 2017-02-17 16:11:46
ubsan: just remember better that they have different arrows?
ubsan 2017-02-17 16:11:46
https://gist.github.com/ubsan/f8d45340792a394b84809b6626ffdb20
ubsan 2017-02-17 16:12:04
yushyin: the issue with it is just a small annoyance on a pile of bigger annoyances
ubsan 2017-02-17 16:12:35
like, {all this stuff sucks} *and also* {this small thing sucks}
ubsan 2017-02-17 16:13:23
whoever asked about whitespace dependence, that ^ gist
gtsteel 2017-02-17 16:14:06
dmwit: my c file is not using any external libraries
glguy 2017-02-17 16:14:47
ubsan: The definition of dirs must be indented more than dirs is
ubsan 2017-02-17 16:14:57
glguy: no I know
ubsan 2017-02-17 16:14:59
I hate that
glguy 2017-02-17 16:15:11
that's fine
dmwit 2017-02-17 16:20:59
gtsteel: For what it's worth, it builds on my machine, too.
gtsteel 2017-02-17 16:25:13
any idea what version of GCC hackage uses?
lordcirth 2017-02-17 16:27:17
I want to make ~/.stack/config.yaml make all projects GPL by default. Is it the 'copyright' field that I want to change? do I need to copy the GPL text into LICENSE?
kadoban 2017-02-17 16:31:04
lordcirth: You probably actually have to change the template itself. If you always use the same template, it's fairly easy, and you can set your own default template (which can just be a file on your hard drive)
kadoban 2017-02-17 16:31:56
https://github.com/commercialhaskell/stack-templates/blob/master/new-template.hsfiles is what you can start from, you can change the LICENSE file to the GPL text, with appropriate placeholders if they fit into the license text. And then change the license line in the .cabal file too.
lordcirth 2017-02-17 16:32:19
kadoban, oh ok. I don't think I'll bother right now. just did "wget https://www.gnu.org/licenses/gpl-3.0.txt -O LICENSE "
lordcirth 2017-02-17 16:32:34
kadoban, by "the license line" do you mean "copyright" ?
kadoban 2017-02-17 16:32:51
Yeah, that's the easier way. You should also make sure you change the line in .cabal as well, so the metadata matches up.
lordcirth 2017-02-17 16:33:09
oh ok
lordcirth 2017-02-17 16:33:17
cabal + stack seems a bit clumsy
kadoban 2017-02-17 16:33:22
Naw, the copyright line is who has copyright, it's usually like copyright: 2017 John Smith
`Guest05 2017-02-17 16:33:28
i'm using bytestrings which most time are from 64 to 256 bytes but occasionally are 2K and can rarely be as big as 60K. which ByteString flavor should i choose?
kadoban 2017-02-17 16:33:41
And license: specifies the license it's under, so you'd want to put I think GPL3 is a valid value.
EvanR 2017-02-17 16:33:57
`Guest05: define "using"
EvanR 2017-02-17 16:34:26
generating them, accepting them as input, processing them in a pipeline, ...
lordcirth 2017-02-17 16:34:33
kadoban, I was trying to look up if it was "GPL3" or GPLv3, etc
mac10688 2017-02-17 16:34:54
what's the best documented haskell web server framework?
kadoban 2017-02-17 16:34:56
lordcirth: I can't remember where you look them up. If you do 'cabal check' it should tell you if the value is bogus I think.
lordcirth 2017-02-17 16:35:25
kadoban, oh that's handy! Apparently it's "GPL-3"
kadoban 2017-02-17 16:35:55
Really? Hmm, wacky. I guess it makes sense though, kinda.
lordcirth 2017-02-17 16:38:15
kadoban, 'category' doesn't seem to be checked by cabal check.
kadoban 2017-02-17 16:39:26
I think things like that are free-form, I don't know that it has a way to check them.
kadoban 2017-02-17 16:39:54
Could be wrong though.
`Guest05 2017-02-17 16:42:56
EvanR: they are packets, i'm decoding and encoding them