Search Haskell Channel Logs

Wednesday, February 1, 2017

#haskell channel featuring eklavya, piyush-kurur, quchen, systadmin, reactormonk, haskelllord69, and 9 others.

phz_ 2017-02-01 00:45:17
plus, I wonder what the reasons to drop the extensions are
merijn 2017-02-01 00:45:22
phz_: I don't know how to translate that to Haskell, so I can't say if you're right
phz_ 2017-02-01 00:45:23
extension*
thatguy 2017-02-01 00:45:49
merijn, no I think I get how instances work, you make instances of classes for your types to define how the class-properties work for that type
phz_ 2017-02-01 00:45:54
merijn: it changes the type of the field / record size depending on the implementation of the Dimensionable trait
merijn 2017-02-01 00:46:02
phz_: The reason was that it doesn't do what people want and what people want is not possible. As a result the only thing it does is make datatypes needlessly constrained for no reason
merijn 2017-02-01 00:46:08
phz_: Can you translate it to haskell?
thatguy 2017-02-01 00:46:22
but if I can bind any kind of data to my newtype T a = T a deriving Num, what does the Num exactly do on a lower level?
merijn 2017-02-01 00:46:29
phz_: I fail how to see that that requires DatatypeContexts
phz_ 2017-02-01 00:46:32
data (Dimensionable a) Texture a = Foo { size :: Dimensionable.Dim a }
phz_ 2017-02-01 00:46:34
something like that.
phz_ 2017-02-01 00:46:38
I missed the =>
thatguy 2017-02-01 00:46:39
I mean does haskell then just look if a is num, and then instanciate to Num and if a is not Num, not instanciate to Num?
merijn 2017-02-01 00:46:51
phz_: How is that not trivially possible with TypeFamilies?
phz_ 2017-02-01 00:47:00
what do you mean?
phz_ 2017-02-01 00:47:10
I think I even have that in Haskell
phz_ 2017-02-01 00:47:15
because luminance is Haskell at first
merijn 2017-02-01 00:47:17
phz_: I don't see how datatype contexts requires that
phz_ 2017-02-01 00:47:17
wait I'll have a look
phz_ 2017-02-01 00:47:27
merijn: how would you write that without it?
merijn 2017-02-01 00:47:31
eh, s/requires/is required for that
Logio 2017-02-01 00:47:47
thatguy: deriving hides some details here
thatguy 2017-02-01 00:47:53
ahhh I think I got it
thatguy 2017-02-01 00:48:05
haskell does something like an instance of Num for T a in case a is Num
phz_ 2017-02-01 00:48:16
https://github.com/phaazon/luminance/blob/master/src/Graphics/Luminance/Core/Texture.hs#L97
thatguy 2017-02-01 00:48:18
so I have an instance Num a => T a right?
cocreature 2017-02-01 00:48:21
yep
phz_ 2017-02-01 00:48:23
ok, in the Haskell version, I use a typeclass for Texture
thatguy 2017-02-01 00:48:24
gosh
cocreature 2017-02-01 00:48:26
or rather Num a => Num (T a)
phz_ 2017-02-01 00:48:27
so I have the associated type.
thatguy 2017-02-01 00:48:31
that was hard
phz_ 2017-02-01 00:48:32
not exactly the same thing
thatguy 2017-02-01 00:48:38
Thanks everyone for helping!
thatguy 2017-02-01 00:49:01
well it was not hard, just somehow I had a hard time getting it
phz_ 2017-02-01 00:49:05
merijn: also, I'm curious about why it's wrong to restrict data
phz_ 2017-02-01 00:49:18
especially if that restriction makes sense at the type level
phz_ 2017-02-01 00:49:34
creating a Texture with a ~ String has no sense at all
phz_ 2017-02-01 00:49:45
preventing people from doing that is not bad IMO
merijn 2017-02-01 00:50:12
phz_: Well, take a look at Set which normally requires an Ord instance, right?
phz_ 2017-02-01 00:50:22
yeah
merijn 2017-02-01 00:50:23
phz_: Why disallow "singleton :: a -> Set a"?
phz_ 2017-02-01 00:50:37
because it has no sense?
merijn 2017-02-01 00:50:48
phz_: containers disagrees, it has that function
merijn 2017-02-01 00:50:55
phz_: And why does it not make sense?
phz_ 2017-02-01 00:50:56
well that's cool for it :D
merijn 2017-02-01 00:51:01
It's perfectly fine to have a singleton set
phz_ 2017-02-01 00:51:01
but it doesn't make any sense
merijn 2017-02-01 00:51:13
phz_: Please clarify what makes no sense about a singleton set
merijn 2017-02-01 00:51:33
phz_: Also, I'm no saying disallowing String is wrong, I'm saying DatatypeContexts is the wrong way to disallow it
phz_ 2017-02-01 00:51:59
merijn: because a Set implies Ord
merijn 2017-02-01 00:52:03
phz_: Why?
merijn 2017-02-01 00:52:10
That's an implementation detail
phz_ 2017-02-01 00:52:10
if you end up using Set without Ord, you might be using the wrong container
phz_ 2017-02-01 00:52:22
is it?
merijn 2017-02-01 00:52:56
phz_: My point is, how does, according to you, changing Set to "data Ord a => Set a =..." help/make thing better?
merijn 2017-02-01 00:53:18
Name one thing that changes, except "singleton" no longer being allowed
phz_ 2017-02-01 00:53:29
in that case, nothing, yeah
thatguy 2017-02-01 00:53:29
one last thing, it would be very nice just to check if I got it if anyone could check if these two short code snippets are "equivalent" at runtime then, since Num a <=> Num (Sum a): http://lpaste.net/351860
phz_ 2017-02-01 00:53:41
you just took an example that suits not having to use such a feature :D
merijn 2017-02-01 00:54:02
phz_: It doesn't help for you Texture example in haskell either, since that's not using DatatypeContexts
phz_ 2017-02-01 00:54:11
because it's a typeclass
phz_ 2017-02-01 00:54:13
not a type
Axman6 2017-02-01 00:54:16
thatguy: you should read Num a => Num (T a) as basically "IF a is a Num, then T a is also a Num". but this matters when you _use_ functions from Num, not everywhere you use T
systadmin 2017-02-01 00:54:21
Is there a way to convert numbers to strings in Haskell>
merijn 2017-02-01 00:54:24
phz_: Right, so can you name one example type where it *does* help?
Axman6 2017-02-01 00:54:28
systadmin: show
merijn 2017-02-01 00:54:30
systadmin: Eh, show? :p
Axman6 2017-02-01 00:54:31
:T show
Axman6 2017-02-01 00:54:34
:t show
systadmin 2017-02-01 00:54:36
:t show
lambdabot 2017-02-01 00:54:37
Show a => a -> String
lambdabot 2017-02-01 00:54:39
Show a => a -> String
phz_ 2017-02-01 00:54:41
merijn: types that express logic
Axman6 2017-02-01 00:54:44
> show 2^128
lambdabot 2017-02-01 00:54:47
error:
lambdabot 2017-02-01 00:54:47
• No instance for (Num String) arising from a use of '^'
lambdabot 2017-02-01 00:54:47
• In the expression: show 2 ^ 128
Axman6 2017-02-01 00:54:51
> show (2^128)
phz_ 2017-02-01 00:54:51
at the type level
lambdabot 2017-02-01 00:54:55
"340282366920938463463374607431768211456"
phz_ 2017-02-01 00:54:56
which is not uncommon
thatguy 2017-02-01 00:55:08
Axman6, yeah I think I got that now, I think I actually even understood what deriving explicitly does
merijn 2017-02-01 00:55:15
phz_: I do plenty of that and I've never needed datatypecontexts, so I'm just asking for a single example :)
phz_ 2017-02-01 00:55:30
what do you use as alternative?
merijn 2017-02-01 00:55:52
Alternative to what? I'm still not even sure what you're claiming it's useful for?
phz_ 2017-02-01 00:56:18
I think I've never used that extension in Haskell, but I see uses of it though
phz_ 2017-02-01 00:56:25
for instance
phz_ 2017-02-01 00:56:31
if you require a type to be inhabited
merijn 2017-02-01 00:56:36
phz_: I have used it and I have since learned the error of my way :)
phz_ 2017-02-01 00:56:37
like for a box type
phz_ 2017-02-01 00:56:42
https://doc.rust-lang.org/std/boxed/struct.Box.html
merijn 2017-02-01 00:56:54
phz_: Except all types are already inhabited by definition in Haskell
phz_ 2017-02-01 00:57:06
merijn: data Void
phz_ 2017-02-01 00:57:07
it's not
cocreature 2017-02-01 00:57:18
phz_: you can just put the Sized constraint on "new"
merijn 2017-02-01 00:57:37
phz_: Void is inhabited by bottom
phz_ 2017-02-01 00:57:41
cocreature: well, no
merijn 2017-02-01 00:57:47
:t undefined :: Void
lambdabot 2017-02-01 00:57:49
Void
phz_ 2017-02-01 00:57:56
having the constraint on the type enables the compiler to perform aggressive optimisations
merijn 2017-02-01 00:57:58
:t let a = a in a :: Void
lambdabot 2017-02-01 00:58:00
Void
merijn 2017-02-01 00:58:18
phz_: Except that it doesn't in the way Haskell is defined
phz_ 2017-02-01 00:58:20
especially when you put that in a Vec, for instance
phz_ 2017-02-01 00:58:40
a Vec, in Rust, would result in no allocation at all
merijn 2017-02-01 00:58:44
phz_: You seem to be arguing for a feature with arguments that come from/apply to Rust, but hold no water in Haskell
phz_ 2017-02-01 00:58:54
merijn: you might be right yeah :)
merijn 2017-02-01 00:58:59
phz_: That argument is silly in Haskell becase all types are boxed by default
haskelllord69 2017-02-01 00:59:00
rustaceans btfo
phz_ 2017-02-01 00:59:10
I'm doing most Rust now, but I still do some Haskell ;)
phz_ 2017-02-01 00:59:23
but replace Sized by another constraint
phz_ 2017-02-01 00:59:58
haskelllord69: btfo? why?
quchen 2017-02-01 01:00:06
haskelllord69: Watch your tone.
haskelllord69 2017-02-01 01:00:11
:(
phz_ 2017-02-01 01:00:37
I've been Haskell for three years, so I'm a bit surprised of such a comment, but ok :D
quchen 2017-02-01 01:00:39
phz_: … continue. We're not a Rust channel, but Rust per se is not offtopic. Lots of us are playing around with it, lots of Rust people play around with Haskell.
phz_ 2017-02-01 01:00:40
+doing
phz_ 2017-02-01 01:00:50
yeah
phz_ 2017-02-01 01:00:52
I do both.
phz_ 2017-02-01 01:01:01
and I have found a job in Haskell \o
phz_ 2017-02-01 01:01:02
anyway
bjz_ 2017-02-01 01:01:06
I'm a Rust person playing with Haskell too :)
quchen 2017-02-01 01:01:09
And we're certainly not a »all languages except ours suck« community, or aiming to be one.
phz_ 2017-02-01 01:01:14
yeah, I know you bjz_ ;)
merijn 2017-02-01 01:01:17
phz_: The point is that Rust takes the C++ template approach to generics, i.e. specialise all functions for every invocation
phz_ 2017-02-01 01:01:19
and I hear about you IRL (nical ;) )
merijn 2017-02-01 01:01:29
phz_: Whereas Haskell takes the "box everything" approach to generics
bjz_ 2017-02-01 01:01:32
?? :O
lambdabot 2017-02-01 01:01:32
:O
phz_ 2017-02-01 01:01:35
merijn: not really
phz_ 2017-02-01 01:01:43
that depends upon which dispatch method you choose.
phz_ 2017-02-01 01:01:55
bjz_: the algebra storm ;)
merijn 2017-02-01 01:02:02
I should probably learn Rust at some point, but I'm lazy
phz_ 2017-02-01 01:02:15
merijn: but in a way, you're right
phz_ 2017-02-01 01:02:16
by default
phz_ 2017-02-01 01:02:19
Rust uses static dispatch.
bjz_ 2017-02-01 01:02:25
phz_: storm?
merijn 2017-02-01 01:02:33
Plus it lacks C++ FFI I'd need to consider using Rust
quchen 2017-02-01 01:02:55
extern C { … }
phz_ 2017-02-01 01:02:59
bjz_: I heard a lot of stuff about the algebra crate you're trying to do (euclide, nalgebra, cgmath and all others)
merijn 2017-02-01 01:03:04
quchen: That's not a C++ FFI and not good enough
merijn 2017-02-01 01:03:09
quchen: I need to call template functions
bjz_ 2017-02-01 01:03:15
bjz_: oh, righto - heh
quchen 2017-02-01 01:03:17
Eww. Okay.
bjz_ 2017-02-01 01:03:24
phz_: I mean
phz_ 2017-02-01 01:03:28
I see a lot of "constrainted types" in Rust
phz_ 2017-02-01 01:03:37
while in Haskell, I've never used that, yep.
merijn 2017-02-01 01:03:38
quchen: If you think *calling* template functions is eww you clearly haven't seen the horrors I've wrought
phz_ 2017-02-01 01:03:47
but I don't see what's wrong in constrainted types
phz_ 2017-02-01 01:03:54
it might be a bit boring to copy the constraints everywhere
phz_ 2017-02-01 01:03:58
but it's needed everywhere
phz_ 2017-02-01 01:03:59
so…
quchen 2017-02-01 01:04:06
merijn: I've seen some things myself as well, don't worry.
quchen 2017-02-01 01:04:19
Scars so deep Haskell could infect them ;-)
bjz_ 2017-02-01 01:04:24
what do you mean by constrained? you mean on the structs?
Axman6 2017-02-01 01:04:41
merijn: foo -> foo_inf_vector_string C func, I'm sure that can;t be too hard :P
phz_ 2017-02-01 01:04:45
bjz_: struct Foo = … where T: …
merijn 2017-02-01 01:05:14
phz_: The point is that you need the constraint in functions on your types anyway so they don't save typing and they don't affect how your data is represented in memory, so really the only thing they can do in haskell is "disallow application of constructors to some types", but if your functions are already constrained that's already disallowed indirectly
merijn 2017-02-01 01:05:34
Axman6: Sure, and now manually write that out for your 200 or so template variations :)
phz_ 2017-02-01 01:05:38
merijn: well
merijn 2017-02-01 01:05:41
Axman6: Less pain to just write in C++14 :p
phz_ 2017-02-01 01:05:45
that's not all :P
phz_ 2017-02-01 01:05:47
imagine a Proxy a
phz_ 2017-02-01 01:05:53
if a ~ Texture b
thatguy 2017-02-01 01:05:55
does anyone of you make money with programming haskell and if yes, if I may ask, in which area?
Axman6 2017-02-01 01:05:56
yeah, exactly, simple!
phz_ 2017-02-01 01:06:04
Proxy (Texture String) would have still no sense
phz_ 2017-02-01 01:06:11
but you don't really call any ctor of Texture here
merijn 2017-02-01 01:06:14
phz_: Sure it would
phz_ 2017-02-01 01:06:27
well, constrainted types would make it not!
Axman6 2017-02-01 01:06:28
thatguy: yes, for a federal research organisation in Australia
merijn 2017-02-01 01:06:29
phz_: Just enable ConstraintKinds :p
thatguy 2017-02-01 01:06:49
Axman6, so is it about working with a lot of data?
eklavya 2017-02-01 01:06:56
please help with wai logging, http://lpaste.net/351863 requestbody is always empty
merijn 2017-02-01 01:07:00
thatguy: I get paid and I write Haskell, although that's mostly because no one is telling me what language to use :p
phz_ 2017-02-01 01:07:01
bjz_: what's your opinion about Rust vs. Haskell btw?
Axman6 2017-02-01 01:07:11
thatguy: there are many of people in here whose dayjob is writing Haskell. we're the stealthy in our success
merijn 2017-02-01 01:07:16
phz_: I think they have very different goals/fields of use
phz_ 2017-02-01 01:07:29
merijn: I think I'd stick to Haskell if it didn't have a GC
Axman6 2017-02-01 01:07:30
eklavya: I assume you're senidng a POST request or something that actually has a request body?
eklavya 2017-02-01 01:07:39
Axman6: yes :D
phz_ 2017-02-01 01:07:43
but as I'm doing realtime applications / rendering stuff…
eklavya 2017-02-01 01:07:51
the content length is also printed
merijn 2017-02-01 01:07:56
phz_: Right, for realtime I'd use Rust :)
thatguy 2017-02-01 01:07:57
merijn, thats probably the best thing which can happen :D
bjz_ 2017-02-01 01:07:58
phz_: I like how I can more clearly understand the runtime/physical properties of Rust code
phz_ 2017-02-01 01:08:02
plus Haskell suffers from the "lens" problem to me
eklavya 2017-02-01 01:08:03
and it's 179/183/etc
phz_ 2017-02-01 01:08:03
:(
merijn 2017-02-01 01:08:11
phz_: What lens problem?
phz_ 2017-02-01 01:08:15
bjz_: I kinda feel the same
Axman6 2017-02-01 01:08:17
eklavya: what is the type of requestBody?
phz_ 2017-02-01 01:08:18
merijn: yep.
phz_ 2017-02-01 01:08:25
just try to bring linear to your project
eklavya 2017-02-01 01:08:31
IO ByteString
phz_ 2017-02-01 01:08:36
it depends on lens for wrong reasons to me
eklavya 2017-02-01 01:08:41
Request -> IO ByteString
phz_ 2017-02-01 01:08:43
aaaaaaaaaand… it brings 40+ dependencies
phz_ 2017-02-01 01:08:46
that's ridiculous
bjz_ 2017-02-01 01:08:50
phz_: I miss not having some sort of effects tracking in Rust though, and it can be quite clunky composition wise
merijn 2017-02-01 01:09:00
phz_: tbh, I stopped giving a shit about dependency count :p
phz_ 2017-02-01 01:09:01
bjz_: you mean purity?
suppi 2017-02-01 01:09:02
phz_: it wouldn't have been haskell without gc :)
phz_ 2017-02-01 01:09:08
merijn: you shouldn't
phz_ 2017-02-01 01:09:13
because even though you have optical fiber
phz_ 2017-02-01 01:09:20
others don't always have it :D
bjz_ 2017-02-01 01:09:21
phz_: you don't need to be pure to track effects
phz_ 2017-02-01 01:09:39
suppi: well, sure :)
bjz_ 2017-02-01 01:10:05
phz_: like - having effects as part of the type signature. But even haskell frustrates me in that regard :P
phz_ 2017-02-01 01:10:06
bjz_: how would you track it without purity?
merijn 2017-02-01 01:10:17
thatguy: There's plenty of Haskell positions, they're just not always as obvious as obnoxious "rockstar ninja ruby programmer" positions
phz_ 2017-02-01 01:10:19
oh, you mean monadic code?
quchen 2017-02-01 01:10:33
merijn: Pity!
phz_ 2017-02-01 01:10:45
merijn: to me, lens is the big problem of Haskell
phz_ 2017-02-01 01:10:48
Haskell records just suck.
phz_ 2017-02-01 01:11:09
and lens brings a solution that solves it, and solves every other problem in the world and the universe
phz_ 2017-02-01 01:11:17
problems*
phz_ 2017-02-01 01:11:44
you ask for a knife to cut your meat, you're givin a very sophisticated jet that gois at mach 17
phz_ 2017-02-01 01:11:48
but there's a knife in the cockpit!
phz_ 2017-02-01 01:11:49
:D
phz_ 2017-02-01 01:11:56
given*
phz_ 2017-02-01 01:11:59
goes*
phz_ 2017-02-01 01:12:04
dammit am I already drunk
merijn 2017-02-01 01:12:25
I don't think Haskell records are ideal, but tbh I dunno what a better solution would look like
merijn 2017-02-01 01:12:41
The next Haskell should just have lenses built-in :)
phz_ 2017-02-01 01:12:49
and I (re) discovered that a lot of haskellers are wrong at wanting one-liners.
quchen 2017-02-01 01:12:50
merijn: Rho types?
phz_ 2017-02-01 01:12:56
Rust doesn't have custom operators
phz_ 2017-02-01 01:13:04
at first I found it was drawback
phz_ 2017-02-01 01:13:09
nowadays, I'm glad it doesn't.
phz_ 2017-02-01 01:13:10
:D
merijn 2017-02-01 01:13:20
quchen: I've never heard of Rho types? Are you, perhaps, referring to rowtype polymorphism?
quchen 2017-02-01 01:13:39
merijn: Edwin tries building Idris {jokingly,specifically} so that lenses are unnecessary. We'll see what Edward does with that once he gives it a shot (which will take some time because how he dislikes strict-by-default).
phz_ 2017-02-01 01:13:48
merijn: yeah, better solution would be native support of some kind of lensing
Axman6 2017-02-01 01:14:03
phz_: the findamentals of lens are very simple, but incredibly generic, so lens also provides tools for common things people want to do
phz_ 2017-02-01 01:14:09
strict by default is cool
bjz_ 2017-02-01 01:14:12
quchen: idris' record syntax/system is weird... :/
phz_ 2017-02-01 01:14:19
Axman6: and that's wrong to me
phz_ 2017-02-01 01:14:24
having lens in linear is wrong to me
phz_ 2017-02-01 01:14:31
having it depending on aeson is worse
phz_ 2017-02-01 01:14:32
etc.
phz_ 2017-02-01 01:14:50
I want "free" features, not bloated ones! ;)
quchen 2017-02-01 01:14:52
merijn: Eh, yes. Someone used ρ for them once and now I constantly mix up the names.
quchen 2017-02-01 01:14:57
I think it was Jasper.
quchen 2017-02-01 01:15:05
I'm pretty sure it was Jasper. Curses!
Axman6 2017-02-01 01:15:05
you don't pay for those features except in a one off compile time cost
suppi 2017-02-01 01:15:09
i like purescript's records system :)
phz_ 2017-02-01 01:15:13
bjz_: I don't know it actually, I should have a look
Axman6 2017-02-01 01:15:18
they don't slow your program but by their mere existance
phz_ 2017-02-01 01:15:23
Axman6: of course you pay for them!
phz_ 2017-02-01 01:15:27
you have 40+ deps!
quchen 2017-02-01 01:15:32
Π types, Σ types, rho…w types. :-)
Axman6 2017-02-01 01:15:51
Ed could easily have split lens into many (many!) different libraries, but that becomes more painful fast
phz_ 2017-02-01 01:15:53
it's more code to compile
phz_ 2017-02-01 01:15:57
it's more licenses to bring in
phz_ 2017-02-01 01:15:57
etc.
Axman6 2017-02-01 01:16:24
it's like one license, BSD3 for pretty much all deps ;)
phz_ 2017-02-01 01:16:30
haha :)
cocreature 2017-02-01 01:16:32
quchen: here's a unicode ρ for your collection
Axman6 2017-02-01 01:16:35
and like I said, that's a one off cost for the compile time
Axman6 2017-02-01 01:17:16
I agree that lens is massive, and that can be an issue, but it provides me far too much I wouldn't want to give up to avoid those minor costs
merijn 2017-02-01 01:17:19
quchen: ρ is the common variable for rowtype variables, yes, hence why I guessed the confusion ;)
phz_ 2017-02-01 01:17:42
Axman6: that's just the first issue ; the other one is how utterly ugly and complex it makes your code
phz_ 2017-02-01 01:17:48
the snail operator, come on!
phz_ 2017-02-01 01:17:49
:D
phz_ 2017-02-01 01:18:21
I don't remember who said that… someone one or two years ago
Axman6 2017-02-01 01:18:23
ugliness is an opinion, and I don't agree it's ugly
phz_ 2017-02-01 01:18:31
"it's not Haskell anymore, it's Haskell-lens!"
eklavya 2017-02-01 01:18:33
Axman6: do you see anything wrong in what I am doing?
phz_ 2017-02-01 01:18:34
and that's true
merijn 2017-02-01 01:18:41
cocreature: Somehow (I forgot how...) configuring my OSX alternative input (the thing that normally does pinjin to unicode Chinese characters) to support LaTeX input for unicode was the best thing I ever did ;)
cocreature 2017-02-01 01:19:12
merijn: I use a weird keyboard layout that has most of the greek letters on it
merijn 2017-02-01 01:19:40
cocreature: Yes, but that doesn't work for ∀∃∈ etc :p
cocreature 2017-02-01 01:19:47
merijn: it does :)
merijn 2017-02-01 01:19:57
Those aren't greek letters! :O
cocreature 2017-02-01 01:20:11
I didn't say I _only_ have greek letters on my keyboard layout :)
Axman6 2017-02-01 01:20:27
eklavya: it's quite likely that your call to strictRequestBody is "draining" the data. that and see what happens. remember that Wai is stream based, it's not dealing with a massive strict bytestring of the bosy of your request, it's pulling it off the wire as it's needed
eklavya 2017-02-01 01:21:35
Axman6: even if that was happening, wouldn't "b" be non empty?
phz_ 2017-02-01 01:21:37
cocreature: what layout?
phz_ 2017-02-01 01:21:40
I'm using bépo
eklavya 2017-02-01 01:21:43
also I added strict one later
phz_ 2017-02-01 01:21:44
I can type them all as well!
phz_ 2017-02-01 01:21:45
δ !
cocreature 2017-02-01 01:21:53
phz_: http://neo-layout.org/
Axman6 2017-02-01 01:21:53
eklavya: reading the request body in a middleware is pretty unkosher IMO, and usually not done
phz_ 2017-02-01 01:22:09
cocreature: what's your nationality?
cocreature 2017-02-01 01:22:17
phz_: German
phz_ 2017-02-01 01:22:24
ok, I understand then! :)
eklavya 2017-02-01 01:22:28
Axman6: I just wanted a way to look at client data short of using wireshark :(
phz_ 2017-02-01 01:22:47
that's funny
phz_ 2017-02-01 01:22:55
your rest row is almost the same as mine :)
phz_ 2017-02-01 01:23:12
https://download.tuxfamily.org/dvorak/wiki/images/Carte-bepo-complete.png
Axman6 2017-02-01 01:23:12
eklavya: did you read the docs for requestBody? "Get the next chunk of the body. Returns empty when the body is fully consumed."
Axman6 2017-02-01 01:23:34
eklavya: ie, you only get one chance to consume the body
eklavya 2017-02-01 01:23:50
Axman6: but how can it be consumed? Logger is before the app (I assumed)
eklavya 2017-02-01 01:23:58
it's after it seems
eklavya 2017-02-01 01:24:13
Axman6: thanks !!
Axman6 2017-02-01 01:24:16
eklavya: I'm trying to tell you you should not do this at all
eklavya 2017-02-01 01:25:01
Axman6: I am using servant, it doesn't give you a request object (AFAIU)
eklavya 2017-02-01 01:25:19
so how can I go about logging incoming requests?
Axman6 2017-02-01 01:25:42
you do not log the contents of a request, just don't do it
eklavya 2017-02-01 01:26:05
what should i do if I want to take a look at what the client sent?
Axman6 2017-02-01 01:26:07
if you need to do logging of a particular request, do in the handler in servent\
eklavya 2017-02-01 01:27:04
Axman6: ok, then I need to change the type of that handler and API and ... :(
Axman6 2017-02-01 01:27:17
eklavya: like I said, you only ever get onc3 chance to read the body of the request, because it is streamed from the client.
Axman6 2017-02-01 01:27:47
eklavya: well, why would you be sending a request body to an API that doesn't access the requesy body?
Axman6 2017-02-01 01:27:50
t*
piyush-kurur 2017-02-01 01:27:52
Axman6: eklavya is it not possible to have a WAI middle ware or something like that
Axman6 2017-02-01 01:28:08
piyush-kurur: eklavyais using a middleware
piyush-kurur 2017-02-01 01:28:17
okey
Axman6 2017-02-01 01:28:22
the point is, _this is a bad idea_
eklavya 2017-02-01 01:28:28
Axman6: it's json and servant directly gives me a parsed Object
piyush-kurur 2017-02-01 01:28:39
may be just in the debug phase
piyush-kurur 2017-02-01 01:28:43
it might be okey
Axman6 2017-02-01 01:28:50
theer _might_ be ways to do this, but they are going to be a bad idea
eklavya 2017-02-01 01:29:13
Axman6: just to be clear, I am not talking about production logging, I don't see why logging a request is a bad idea while developing though?
piyush-kurur 2017-02-01 01:29:45
Axman6: eklavya will use it only during testing
eklavya 2017-02-01 01:29:52
Axman6: be my guest, traverse through NAT and find my IP nad port, sure :D
Axman6 2017-02-01 01:30:01
eklavya: I understand that, but there are definitely better tools for that
quchen 2017-02-01 01:30:13
cocreature: …_[]^!<>=&ſ :-D
eklavya 2017-02-01 01:31:28
it's so weird I literally copy paste the generated json in curl request and it works, but from the scala client it doesn't
eklavya 2017-02-01 01:31:34
I need to see what's being sent
eklavya 2017-02-01 01:31:37
what's different
eklavya 2017-02-01 01:32:14
I can't believe it but I guess wireshark is the easiest way to go maybe
Axman6 2017-02-01 01:32:18
netcat i> tee -> netcat -> server
Axman6 2017-02-01 01:32:25
>_>
eklavya 2017-02-01 01:32:29
:P
Axman6 2017-02-01 01:32:53
eklavya: si did you say that strictRequestBody is working?
Axman6 2017-02-01 01:33:04
also... if it is, your content is definitely not being sent to your handler
eklavya 2017-02-01 01:33:05
yeah wireshark is easier ( I would have to man netcat)
eklavya 2017-02-01 01:33:10
Axman6: nope
eklavya 2017-02-01 01:33:16
it wasn't
Axman6 2017-02-01 01:33:19
ok
Axman6 2017-02-01 01:33:49
so, you understand that this debugging is almost certainly going to break your app right? like your handlers will never get the request body
reactormonk 2017-02-01 01:35:17
I've got a list of IO () - how do I compose them into a single IO () ?
Axman6 2017-02-01 01:35:25
you could hack it be reading the body using strictRequestBody, and then putting in a new function for the requestBody in the request that's sent to the handler code, which when called the first time returns the content, and returns nothing the second time
reactormonk 2017-02-01 01:35:25
I don't know what to hoogle.
quchen 2017-02-01 01:35:37
?hoogle [IO ()] -> IO ()
Axman6 2017-02-01 01:35:39
:t void . sequence
lambdabot 2017-02-01 01:35:41
Control.Concurrent.ParallelIO.Global parallel_ :: [IO a] -> IO ()
lambdabot 2017-02-01 01:35:41
Prelude print :: Show a => a -> IO ()
lambdabot 2017-02-01 01:35:41
System.IO print :: Show a => a -> IO ()
lambdabot 2017-02-01 01:35:41
(Traversable t, Monad f) => t (f a) -> f ()
reactormonk 2017-02-01 01:35:45
thanks
quchen 2017-02-01 01:36:03
Meh. reactormonk, that's »sequence«.
Axman6 2017-02-01 01:36:22
:t sequence `asAppliedTo` [print True]
lambdabot 2017-02-01 01:36:25
[IO ()] -> IO [()]
eklavya 2017-02-01 01:36:39
Axman6: yeah, I just need to get the request just one time
quchen 2017-02-01 01:36:56
Hm, sequence_ should be enough.
quchen 2017-02-01 01:36:59
:t sequence_
lambdabot 2017-02-01 01:37:01
(Foldable t, Monad m) => t (m a) -> m ()
Axman6 2017-02-01 01:37:10
og that's a thing? how handeh
quchen 2017-02-01 01:37:10
(Requires only Foldable, not Traversable.)
Axman6 2017-02-01 01:37:32
but also requires Monad instead of just Applicative?
reactormonk 2017-02-01 01:37:32
?hoogle IO [()] -> IO ()
lambdabot 2017-02-01 01:37:35
Control.Concurrent.ParallelIO.Global parallel_ :: [IO a] -> IO ()
lambdabot 2017-02-01 01:37:35
Prelude print :: Show a => a -> IO ()
lambdabot 2017-02-01 01:37:35
System.IO print :: Show a => a -> IO ()
quchen 2017-02-01 01:39:48
:t sequenceA_
lambdabot 2017-02-01 01:39:50
(Foldable t, Applicative f) => t (f a) -> f ()
quchen 2017-02-01 01:39:52
Axman6: ^
Axman6 2017-02-01 01:40:09
edvorg: I don't think this is even possible when using the ApacheLogger, you should write write a raw Middleware for this
Axman6 2017-02-01 01:40:14
uh, eklavya
Axman6 2017-02-01 01:40:48
quchen: hysterical raisins?
quchen 2017-02-01 01:41:47
Axman6: Yeah. sequenceA vs. sequence is from a time that did not have Applicative => Monad.
eklavya 2017-02-01 01:42:05
Axman6: thanks :)
Axman6 2017-02-01 01:42:08
could changing its type possibly break any code not we have that?
eklavya 2017-02-01 01:42:13
I am firing up wireshark for now
quchen 2017-02-01 01:43:01
Axman6: You mean generalizing sequence_? Not sure, my gut tells me »no« though
Axman6 2017-02-01 01:43:19
eklavya: basically, if you do want to do this, you need a Middleware which gathers all the body, then changes the request using something like an MVar or IORef to track how many times it's been called
Axman6 2017-02-01 01:43:49
and then return that bytestring only once and then empty afterwards
Axman6 2017-02-01 01:44:18
quchen: yeah the only thing I can see it doing is firing warnings about redundant constraints
quchen 2017-02-01 01:44:56
Axman6: Exactly, and with -Werror that would break. But I don't see how it could introduce a redundant constraint.