mniip 2017-02-09 03:45:12
I'm learning pure CT because I realized that Hask limits your understanding
mniip 2017-02-09 03:45:20
pretty much in the same way as Set does
mniip 2017-02-09 03:45:28
they're very similar after all
merijn 2017-02-09 03:45:31
byorgey: My problem is usually that many people explaining things about CT seem to arbitrary drop "irrelevant" parts of the category their discussing
merijn 2017-02-09 03:45:36
Which always trips me up
merijn 2017-02-09 03:45:49
Additionally, they fail to point out things which are, to me, not obvious
merijn 2017-02-09 03:46:00
Such as the notion that morphisms have an identity
mniip 2017-02-09 03:46:16
e.g, can you express a Kernel in haskell?
byorgey 2017-02-09 03:46:29
merijn: yes, I know what you mean.
mniip 2017-02-09 03:46:41
much simpler, can you express a null morphism in haskell
merijn 2017-02-09 03:46:44
Even the programmer friendly ones like Bartosz'
mrkgnao 2017-02-09 03:47:45
merijn: I just looked at weechat and had my mental parser hang on Bartosz'
mrkgnao 2017-02-09 03:48:06
I have been trying to make sense of pipes for the last couple hours, which may be relevant
lpaste_ 2017-02-09 03:48:10
scipianus pasted "Functor instance" at http://lpaste.net/352276
zennist 2017-02-09 03:48:30
okay reading through the doc in persistent lib I feel like there is significant leakage of state related code expressed in 'impure' mode - e.g., you can use persistent's defined 'update' actions to update data in database but obviously this is going to make it hard to test this transition with randomly generated pure data
mniip 2017-02-09 03:48:33
scipianus, are you aware that you can't say that
maksim_ 2017-02-09 03:48:35
i'm having trouble figuring out exactly (precisely) what's happening here because i don't know how bind is defined for io http://pastebin.com/nWePKyae
scipianus 2017-02-09 03:49:00
can somebody help me with this? http://lpaste.net/352276 which should be the way to make Audit instance of Functor?
maksim_ 2017-02-09 03:49:05
i understand that filterM basically filters over a list but with side effects
c_wraith 2017-02-09 03:49:11
scipianus: you can't make type aliases instances.
zennist 2017-02-09 03:49:19
can someone recommend an approach of persisting data such that there is good compatibility outside haskell (e.g., database) && there is strong separation between pure logic code and things that only deal with storing
c_wraith 2017-02-09 03:49:23
scipianus: (with some weird exceptions around String)
mniip 2017-02-09 03:49:23
:t filterM -- maksim_: does this type signature explain the function?
lambdabot 2017-02-09 03:49:25
Applicative m => (a -> m Bool) -> [a] -> m [a]
maksim_ 2017-02-09 03:49:43
mniip, yes i understand the semantics completely
scipianus 2017-02-09 03:50:00
c_wraith : I should make Audit data or class?
c_wraith 2017-02-09 03:50:17
scipianus: data seems best. data Audit a = Audit a String
maksim_ 2017-02-09 03:50:36
mniip, i would like to understand the >>= thoroughly
byorgey 2017-02-09 03:50:49
maksim_: it's just filtering the list, but testing each element of the list may have some I/O effects
maksim_ 2017-02-09 03:51:02
byorgey, yes i understand that
mrkgnao 2017-02-09 03:51:05
is there anyone here who's experienced with pipes? I'm looking at some code that uses it, but I'm not sure if there have been any improvements to the library since that it doesn't use
mniip 2017-02-09 03:51:05
@do getRecursiveContents path >>= filterM check
lambdabot 2017-02-09 03:51:05
do { a <- getRecursiveContents path; filterM check a}
mniip 2017-02-09 03:51:17
is this clearer?
mrkgnao 2017-02-09 03:51:30
https://github.com/BartAdv/pipes-game/blob/master/test.hs if anyone would like to have a look
maksim_ 2017-02-09 03:51:31
you just sugared >>=
mniip 2017-02-09 03:51:34
yes
byorgey 2017-02-09 03:51:36
maksim_: I'm not sure what you're confused about then, there's really nothing to understand beyond that
mniip 2017-02-09 03:51:46
what he said ^
c_wraith 2017-02-09 03:51:48
maksim_: do you want to know what >>= does for a specific type, or in general?
byorgey 2017-02-09 03:51:58
maksim_: I don't see how understanding how >>= is defined for I/O would help
c_wraith 2017-02-09 03:52:06
maksim_: because in general, all you know about >>= is what the monad laws and its type tell you.
mrkgnao 2017-02-09 03:52:13
also, is simulating FRP-ish things (which to me means something like event-driven programming) with pipes a good idea?
merijn 2017-02-09 03:52:41
mrkgnao: Not really, FRP is really not anything like pipes
maksim_ 2017-02-09 03:52:45
i see many functions. i would like to know what each one of them does exactly
maksim_ 2017-02-09 03:52:51
getRecursiveContents is a function
merijn 2017-02-09 03:52:53
mrkgnao: FRP is also not really related to event-driven either
maksim_ 2017-02-09 03:52:53
i know what it does
c_wraith 2017-02-09 03:52:55
mrkgnao: pipes is fundamentally pull-based. event-driven usually means push-based.
maksim_ 2017-02-09 03:52:59
check is a function
maksim_ 2017-02-09 03:53:01
i know what it does
BartAdv 2017-02-09 03:53:10
mrkgnao: that code you looking at was essentially my exploration to answer similar questions
maksim_ 2017-02-09 03:53:15
>>= is a function whose operation i'm not clear on
merijn 2017-02-09 03:53:16
c_wraith: That's not true
maksim_ 2017-02-09 03:53:18
same for filterM
merijn 2017-02-09 03:53:24
c_wraith: pipes has both push and pull based
mrkgnao 2017-02-09 03:53:27
BartAdv: whoa, didn't expect this coming
merijn 2017-02-09 03:53:36
c_wraith: Are you perhaps conflating pipes and conduit?
maksim_ 2017-02-09 03:53:38
any other time i'm interested in what a function does i go and i look up its implementation
c_wraith 2017-02-09 03:53:49
merijn: oh, does it? I was assuming it worked the same way as machines and conduit, yes.
byorgey 2017-02-09 03:53:53
maksim_: >>= for IO runs its first argument, then passes its output as input to the second argument, then runs the resulting IO action
mrkgnao 2017-02-09 03:54:01
I actually planned to play around with your code. did you find it a bad idea?
BartAdv 2017-02-09 03:54:10
mind that I know very little about pipes and maybe I shouldn't even put that on github, it was really just learning experience
merijn 2017-02-09 03:54:17
c_wraith: pipes actually explicitly tracks push vs pull, it's why I prefer it to conduit
BartAdv 2017-02-09 03:54:37
I don't even recall how it went, was probably result of some overnight/early morning hacks
byorgey 2017-02-09 03:54:37
maksim_: does that help?
scipianus 2017-02-09 03:54:39
c_wraith : and after having some parameterized data type, how do i make instance of Functor ?
c_wraith 2017-02-09 03:54:42
merijn: ie, the combinators you use to hook things together determine whether it uses push or pull?
mrkgnao 2017-02-09 03:54:43
merijn: could you take a look at the link? I'm interested in what someone experienced with pipes thinks
maksim_ 2017-02-09 03:54:49
byorgey, yes but i have a follow up question
Eduard_Munteanu 2017-02-09 03:55:15
Does WAI allow the request body to be streamed? I recall Yesod didn't.
c_wraith 2017-02-09 03:55:21
scipianus: Overall, I'd say you should figure this out on your own. I can give you hints, but I think you'd learn a lot from not being handed a full solution.
maksim_ 2017-02-09 03:55:46
byorgey, " then runs the resulting IO action" which exactly is the resulting IO action? the entire composition or, here for example `filterM check contents`
Welkin 2017-02-09 03:55:50
scipianus: instance Functor MyDataType a where fmap f (MyDataType a b) = MyDataType a (f b)
c_wraith 2017-02-09 03:56:04
scipianus: start with the what are given, and what you need. What are the arguments to fmap? What are their types? What type does the result need to be?
Welkin 2017-02-09 03:56:06
something like that
byorgey 2017-02-09 03:56:17
maksim_: filterM check contents
byorgey 2017-02-09 03:56:36
maksim_: generally, x >>= f means 'run x, call its output a, then run (f a)'
byorgey 2017-02-09 03:57:03
(For IO specifically.)
maksim_ 2017-02-09 03:57:36
byorgey, `output` doesn't mean output right? it means a in IO a?
merijn 2017-02-09 03:57:38
c_wraith: Yeah, see for example https://hackage.haskell.org/package/pipes-4.3.2/docs/Pipes-Core.html#g:5
Welkin 2017-02-09 03:58:12
maksim_: the `a` in `Monad m => m a`
byorgey 2017-02-09 03:58:13
maksim_: yes, the a in IO a. You're right, output is probably a bad word. How about 'result'.
maksim_ 2017-02-09 03:58:30
yes. i was thinking produce
merijn 2017-02-09 03:58:34
mrkgnao: Which link?
byorgey 2017-02-09 03:59:05
maksim_: as for filterM, you can indeed look up its implementation
byorgey 2017-02-09 03:59:26
but of course it is implemented in terms of >>=
mrkgnao 2017-02-09 03:59:36
merijn: https://github.com/BartAdv/pipes-game/blob/master/test.hs
merijn 2017-02-09 03:59:55
mrkgnao: fwiw, I'm not that experiences with pipes either
c_wraith 2017-02-09 04:00:01
Was filterM not changed to only require an Applicative instance?
Welkin 2017-02-09 04:00:19
I was reading up on logic symbols last night, and it seems that `=>` is used as a lambda function arrow instead of haskell's `->`. Why is that?
Tuplanolla 2017-02-09 04:00:45
That's weird, Welkin.
Welkin 2017-02-09 04:00:51
is it similar to the arbitrary decision of swapping (:) and (::)?
c_wraith 2017-02-09 04:00:58
Welkin: "logic" is underspecified. It can mean many different things with many different symbol sets.
Tuplanolla 2017-02-09 04:01:11
I've seen mathematicians mostly use |-> for anonymous functions.
mrkgnao 2017-02-09 04:01:14
hm, jle`'s auto looks pretty interesting.
Welkin 2017-02-09 04:01:20
yeah, I've seen that one too Tuplanolla
maksim_ 2017-02-09 04:01:22
thank byorgey
maksim_ 2017-02-09 04:01:25
*thanks
Welkin 2017-02-09 04:01:56
in my abstract algebra book from maclane is uses |->
c_wraith 2017-02-09 04:02:04
Ah. In recent versions of GHC, filterM does in fact only require Applicative
merijn 2017-02-09 04:03:03
mrkgnao: This looks more like something along the lines of FRP than something really suited to pipes
mrkgnao 2017-02-09 04:03:43
merijn: I see.
Welkin 2017-02-09 04:04:43
mrkgnao: I keep thinking "mr magoo" when I see your name
mniip 2017-02-09 04:04:50
ok, I think I pieced the definition together http://mathb.in/126509
mrkgnao 2017-02-09 04:04:51
So what I'm trying to do right now is make a game server with an API that people can connect bots to. It's all the rage nowadays.
Welkin 2017-02-09 04:05:07
and then I imagine you are a short bald man with his eyes closed tightly
mrkgnao 2017-02-09 04:06:17
I plan to think of the internet-connected bit later, and just implement the game bit now while doing it so that going to the server model won't require huge amounts of refactoring
BartAdv 2017-02-09 04:06:40
merijn, mrkgnao yes. This is what led me eventually to learn FRP and nowadays I'd just choose FRP for things like that
Welkin 2017-02-09 04:07:16
lol
merijn 2017-02-09 04:07:18
mrkgnao: I could see using pipes to turn a network connection into a sequence of events that you then feed to an FRP framework, though
Welkin 2017-02-09 04:07:21
trying to build a game using pipes?
Welkin 2017-02-09 04:07:34
pipes is only for streaming data
Tuplanolla 2017-02-09 04:07:44
What a coincidence. I just built a server too, mrkgnao.
mrkgnao 2017-02-09 04:08:10
Welkin: https://en.wikiquote.org/wiki/Ulysses_(novel), Ctrl-F my username. I haven't out-PageRank-ed Joyce yet :)
Tuplanolla 2017-02-09 04:08:13
Although the usual happened and I got lost in abstracting modules and elevating everything to the type level.
mrkgnao 2017-02-09 04:08:23
Tuplanolla: the usual indeed
mrkgnao 2017-02-09 04:08:58
inevitably to end in large-scale kill-buffer-rudely and "Idris or nothing from now on" declarations
Tuplanolla 2017-02-09 04:09:01
It's more educational anyway.
mrkgnao 2017-02-09 04:09:17
merijn, Welkin: what do you think of auto?
mrkgnao 2017-02-09 04:09:19
, auto
mniip 2017-02-09 04:09:25
merijn, so back to my question
Welkin 2017-02-09 04:09:29
I haven't read about it in probably 2 years
Welkin 2017-02-09 04:09:36
but yeah, jle's blog is good
mniip 2017-02-09 04:09:39
we have a whatever transformation between 2 profunctors
mrkgnao 2017-02-09 04:09:40
I should learn how to use lambdabot properly
mrkgnao 2017-02-09 04:09:45
,auto
mniip 2017-02-09 04:09:49
what does "x -''-> S" mean
Welkin 2017-02-09 04:09:52
@where auto
lambdabot 2017-02-09 04:09:52
I know nothing about auto.
mniip 2017-02-09 04:10:01
where x \in Ob(Cod(S))
merijn 2017-02-09 04:10:05
mniip: oh, I'm not the right person to ask CT questions, I just said the *someone* here probably is :p
mrkgnao 2017-02-09 04:10:27
is FRP "active", for lack of a better word?
Welkin 2017-02-09 04:10:42
mrkgnao: what do you mean?
Welkin 2017-02-09 04:10:53
there are many, many FRP libraries in haskell, all for different use cases
mrkgnao 2017-02-09 04:11:28
for whatever reason, I had this idea that nobody did FRP anymore, although I can't place why this ever came to be. :/
Welkin 2017-02-09 04:11:38
reflex is the most "pure" FRP library (in terms of fitting the formal definition of FRP)
Welkin 2017-02-09 04:11:52
mrkgnao: you can join #reflex-frp
mrkgnao 2017-02-09 04:12:52
I'm really interested in a library that would a) be easy to integrate with, say, servant, and b) be easy to get help about
Welkin 2017-02-09 04:13:16
reflex is used with reflex-dom to build web front-ends
Welkin 2017-02-09 04:13:20
people have used it for games too
mrkgnao 2017-02-09 04:13:57
no, I mean a headless API backend thing that people send commands to.
Welkin 2017-02-09 04:14:19
I'm not sure how that would work
Welkin 2017-02-09 04:14:24
you could ask in the other channel
Welkin 2017-02-09 04:14:43
I'm only familiar with the request -> response model for web servers over http
Welkin 2017-02-09 04:15:09
maybe using http2 or websockets you could do something here
mrkgnao 2017-02-09 04:15:12
is there a way to integrate reflex with servant?
mrkgnao 2017-02-09 04:15:19
I'm looking for something like that
Welkin 2017-02-09 04:15:25
dunno, go ahead and ask
takanuva 2017-02-09 04:15:26
shouldn't this work? http://pastebin.com/b419HiWT
mrkgnao 2017-02-09 04:15:36
or websockets, yeah. (I haven't thought this through, as you can see.)
mrkgnao 2017-02-09 04:15:40
yeah
biglama 2017-02-09 04:15:55
hi guys, I've read a small parser for reading and writing floats using megaparsec
tsahyt 2017-02-09 04:16:10
writing using megaparsec?
biglama 2017-02-09 04:16:23
i found the result to be slower than a dumb C++ program : 30s to manage a file of 190 000 lines
biglama 2017-02-09 04:16:33
yes, using megaparsec to write my parser
biglama 2017-02-09 04:16:50
but i could use some help with the profiling
merijn 2017-02-09 04:16:52
biglama: megaparsec isn't really optimised for speed, but for flexibility/quality of errors
tsahyt 2017-02-09 04:17:03
megaparsec is built to handle complex grammars and user-facing parsers with good error handling
tsahyt 2017-02-09 04:17:07
what you want is probably attoparsec
merijn 2017-02-09 04:17:08
biglama: i.e., for things like programming language
Welkin 2017-02-09 04:17:13
if you want speed, you want attoparsec
Welkin 2017-02-09 04:17:19
also, don't use String
Welkin 2017-02-09 04:17:22
instead use Text
Welkin 2017-02-09 04:17:27
if you want speed
tsahyt 2017-02-09 04:17:31
or even Data.Attoparsec.Zepto if it's really simple input
merijn 2017-02-09 04:17:37
ALso that
merijn 2017-02-09 04:17:42
String is awful for speed
mrkgnao 2017-02-09 04:17:46
Welkin: I imagine String is probably a far bigger problem than megaparsec
merijn 2017-02-09 04:17:51
Yeah
mrkgnao 2017-02-09 04:17:53
merijn: what FRP library do you use?
merijn 2017-02-09 04:18:05
Actually try that first, switch to Text, try again and then try attoparsec
takanuva 2017-02-09 04:18:18
could anyone please explain to my why the type variables couldn't be unified on my code? http://pastebin.com/b419HiWT
biglama 2017-02-09 04:18:19
okay thanks
merijn 2017-02-09 04:19:33
biglama: For some context, since String is literally a linked list of Char it uses ~24 bytes per letter on 64bit. Text uses ~2-4 bytes per letter plus a few bytes overhead every few kilobyte if using lazy Text)
Welkin 2017-02-09 04:19:42
takanuva: remove everything before the => (including the =>) in your instance declaration
Welkin 2017-02-09 04:19:57
you don't give the type when declaring an instance, only when defining the class
merijn 2017-02-09 04:20:02
And all the other cache downsides of linkedlists
Welkin 2017-02-09 04:20:48
or you can remove it on the class definition
Eduard_Munteanu 2017-02-09 04:20:54
Actually they probably want to remove the constraints on the class method.
Welkin 2017-02-09 04:20:55
try both, see what happens
mniip 2017-02-09 04:21:02
ooooohhh
mniip 2017-02-09 04:21:09
an extranatural transformation is just
takanuva 2017-02-09 04:21:15
Welkin: not my code, actually, I'm trying to help a friend, but I didn't understand the error; on the instance he's qualifying the type variables, as in instance Eq a => Eq (Foo a)... shouldn't it work?
Profpatsch 2017-02-09 04:21:18
Welkin: Every time I read your nick I'm reminded that I should finish Vakyria Chronicles some time.
Welkin 2017-02-09 04:21:20
(the constraints I mean)
mniip 2017-02-09 04:21:35
forall a b c d. (a -> b) -> (c -> d) -> p b a -> q c d
mrkgnao 2017-02-09 04:21:37
I often wonder why GHC couldn't internally nix String and replace it with Text under the hood, although you'd probably have to add special cases for head and such things
merijn 2017-02-09 04:21:55
mrkgnao: Because they're suitable for entirely different things
Welkin 2017-02-09 04:21:57
Profpatsch: me too
mniip 2017-02-09 04:21:57
"ent id id" recovers the original eta
Profpatsch 2017-02-09 04:22:02
hehe
mrkgnao 2017-02-09 04:22:07
and end up reimplementing a String wrapper over Text
merijn 2017-02-09 04:22:12
mrkgnao: String is nice for easy matching and stream processing
Eduard_Munteanu 2017-02-09 04:22:18
mrkgnao, more likely ByteString than Text.
merijn 2017-02-09 04:22:37
mrkgnao: Incidentally, GHC *does* store literals as dense encodings and converts to String from there
Eduard_Munteanu 2017-02-09 04:22:40
POSIX things are bytestrings.
mrkgnao 2017-02-09 04:22:47
merijn: oh?
mrkgnao 2017-02-09 04:23:07
wow, reflex uses Nix
merijn 2017-02-09 04:23:20
mrkgnao: iso something encoded binary blobs which are dynamically turned into String. Text abuse this by having a rewrite rule that overwrites the conversion function and skips going through String
merijn 2017-02-09 04:23:30
mrkgnao: Which is what makes OverloadedStrings not suck
mrkgnao 2017-02-09 04:24:53
merijn: that rewrite rule fact is cool.
merijn 2017-02-09 04:25:26
mrkgnao: Lots of cool stuff if you dive into the low level bits of GHC :)
merijn 2017-02-09 04:25:40
Just browsing GHC.Exts and ghc-prim package you can find lots of neat things
mrkgnao 2017-02-09 04:26:23
I actually wish to contribute to GHC someday, once I have something a little more real-world than this Chromebook :)
jophish 2017-02-09 04:26:31
I wonder how long it'll be until we have a better 'FilePath' in widespread usage...
mrkgnao 2017-02-09 04:26:35
merijn: what do you use for FRP?
merijn 2017-02-09 04:26:47
mrkgnao: I'm not really using FRP at the moment
merijn 2017-02-09 04:27:03
mrkgnao: I used netwire (obsoleted by wires, I think?) and reactive-banana
biglama 2017-02-09 04:27:27
merijn: I'm using Text.Megaparsec.ByteString.Lazy
maksim_ 2017-02-09 04:27:28
why do you need $ here for the first argument of handle in saferFileSize http://stackoverflow.com/questions/10578572/the-handle-function-and-real-world-haskell (nevermind the question itself)
biglama 2017-02-09 04:27:40
merijn: so it should use bytestring internally and not string, right ?
biglama 2017-02-09 04:27:56
here is my profiling if anyone's interested http://pastebin.com/Ysi78FXT
merijn 2017-02-09 04:28:29
biglama: No clue, can you lpaste your parser?
merijn 2017-02-09 04:28:46
biglama: oh...
kubbe 2017-02-09 04:28:53
mniip, are you up for a bit of a challenge? :D
merijn 2017-02-09 04:28:59
biglama: You're using Read to convert to Double?
Welkin 2017-02-09 04:29:03
maksim_: what? You mean the $ before the `do`?
merijn 2017-02-09 04:29:06
biglama: Read has shit performance
mniip 2017-02-09 04:29:06
uhh
maksim_ 2017-02-09 04:29:08
Welkin, yes
mniip 2017-02-09 04:29:10
I'm challenged myself
Welkin 2017-02-09 04:29:19
maksim_: that is just a replacement for parentheses
Welkin 2017-02-09 04:29:23
:t ($)
lambdabot 2017-02-09 04:29:25
(a -> b) -> a -> b
Welkin 2017-02-09 04:29:32
it is function application
Welkin 2017-02-09 04:29:42
it acts like parentheses in this case
kubbe 2017-02-09 04:29:45
Haha, that answer is good enough.. Alright so if its not to much of a problem, would you look at this: http://pastebin.com/AMPbytHt
merijn 2017-02-09 04:30:23
biglama: So, since that's the first line in your profile, I'm pretty sure that's the issue
kubbe 2017-02-09 04:30:28
My question here is: Is it possible to use my insert function and sort the list so that the lowest rank is at the beginning at all times?
maksim_ 2017-02-09 04:30:30
Welkin, it wraps the do in parens?
kubbe 2017-02-09 04:31:10
Without a aux-function. Or do I need to create a sortfunction that will sort the values so that the lowest ranks is first? I want the least function just to take out the first value and it will be correct at all times.
lpaste_ 2017-02-09 04:31:28
biglama pasted "Slow parsing ?" at http://lpaste.net/1806074898049662976
Welkin 2017-02-09 04:31:33
maksim_: yes
biglama 2017-02-09 04:31:49
merijn: here is my source code if you are kind enough to help me
Welkin 2017-02-09 04:32:02
no the `do`, but the `do` and everything right of it
biglama 2017-02-09 04:32:03
merijn: i'm not using read directly though
merijn 2017-02-09 04:32:13
biglama: That
merijn 2017-02-09 04:32:25
That's weird...dunno why readPrec is so high, then...
merijn 2017-02-09 04:32:42
oh...
merijn 2017-02-09 04:32:47
Megaparsec is using read...
maksim_ 2017-02-09 04:32:59
Welkin, yes but from the signature i don't understand how that's the case. what is the (a->b) and what is the a in $ do ...
mangobot 2017-02-09 04:33:09
could someone give me a tip here please? there is an input string of the form: "b,b,b,b/b,b,b/b,,b,b/,,/w,w,bw,w/w,w,w/w,w,w,w w e3-d4" which represents the gamestate (laska/ sort of checkers). b stands for black/w = white player. "," stands for another column, and slash for a new row. the "w" after space is next player and the tokens e3-d4 is the last move. is it possible to parse the string into a 2D list which will also conta
mangobot 2017-02-09 04:33:13
and the positions int int
mangobot 2017-02-09 04:34:01
and the iterate through the field ie somehow find the coordinates of each player, if the field is 7x7
merijn 2017-02-09 04:35:23
biglama: Yeah, I'd try switching to attoparsec and using Data.Attoparsec.Text.double
merijn 2017-02-09 04:35:37
biglama: attoparsec should (mostly) be a drop-in replacement for megaparsec
BernhardPosselt 2017-02-09 04:35:56
whats the usage difference between a reader monad and partial application?
mniip 2017-02-09 04:36:42
oh my
biglama 2017-02-09 04:36:43
merijn: thanks a bunch !
mniip 2017-02-09 04:36:45
I think I got it
BernhardPosselt 2017-02-09 04:36:46
is a reader DRYer for things needing the same type of parameter?
mniip 2017-02-09 04:36:49
wow this is deep
biglama 2017-02-09 04:36:58
merijn: do you think my code can be easily ported to attoparsec (at a glance) ?
merijn 2017-02-09 04:37:07
biglama: Yeah
mniip 2017-02-09 04:37:11
when we say that 'forall' is a kind of an end,
Eduard_Munteanu 2017-02-09 04:37:12
BernhardPosselt, you can only use the same type of parameter, anyway
merijn 2017-02-09 04:37:18
biglama: Like, if you're lucky you'd only have to replace the imports
mniip 2017-02-09 04:37:33
do we mean to interpret forall a. F(a) as a profunctor P(a, a)
mniip 2017-02-09 04:37:37
and take the end of that profunctor?
merijn 2017-02-09 04:37:39
biglama: attoparsec has almost the same design as parsec/megaparsec, so should be trivial to adapt
BernhardPosselt 2017-02-09 04:38:06
Eduard_Munteanu: i mean you could partially apply two functions which take a different type as their first parameter
mniip 2017-02-09 04:38:10
wow
mniip 2017-02-09 04:38:21
stunning
BernhardPosselt 2017-02-09 04:38:26
whereas i suppose for a reader you need the types to line up
Eduard_Munteanu 2017-02-09 04:39:20
BernhardPosselt, no... "a -> Reader r b" is like "a -> r -> b". It doesn't matter if you vary "a".
BernhardPosselt 2017-02-09 04:39:41
i see
BartAdv 2017-02-09 04:39:55
mrkgnao: you might want to check the https://github.com/BartAdv/hackslash
Eduard_Munteanu 2017-02-09 04:39:57
Because "a" is always explicitly applied.
BartAdv 2017-02-09 04:40:06
just another learning project of mine that I don't have time to finish ;)
biglama 2017-02-09 04:41:13
merijn: would be great :)
mpickering 2017-02-09 04:47:55
Has anyone had any success using the lz4 bindings to decompress externally compressed strings?
mpickering 2017-02-09 04:48:09
It seems they write some additional information into the bytestring
mpickering 2017-02-09 04:48:30
which the decoding function then expects to be there
maksim_ 2017-02-09 04:49:09
i don't understand $ with two argument functions; for `f:: a->b->c` how does f 1 $ \x -> 2 work?
maksim_ 2017-02-09 04:49:34
actually
maksim_ 2017-02-09 04:50:12
i don't understand $ with two argument functions; for `f:: a->IO b->IO c` how does `f 1 $ do return 2` work?
merijn 2017-02-09 04:50:16
maksim_: "($) f x = f x", but because $ has extremely low precedence it effectively turns "f 1 $ ..." into "(f 1) ..."
maksim_ 2017-02-09 04:51:02
so it creates a section of f?
maksim_ 2017-02-09 04:51:15
and then applies it to `...`
cocreature 2017-02-09 04:51:15
no that's not a section
merijn 2017-02-09 04:51:20
No, it just affects how applications are grouped
cocreature 2017-02-09 04:51:22
it's just partial application
cocreature 2017-02-09 04:51:39
a -> IO b -> IO c is the same as a -> (IO b -> IO c)
maksim_ 2017-02-09 04:51:40
what's the difference between a section and a partial application?
merijn 2017-02-09 04:51:52
I dislike the term partial application
Eduard_Munteanu 2017-02-09 04:52:05
f a b $ g c d simply parses as (f a b) (g c d)
merijn 2017-02-09 04:52:11
It doesn't make that much sense in anything other than an operational context
maksim_ 2017-02-09 04:52:21
merijn, ah
merijn 2017-02-09 04:52:44
maksim_: "f :: a -> b -> c" is the same as "f :: a -> (b -> c)"
merijn 2017-02-09 04:53:02
maksim_: So if "x :: a" we get "f x :: b -> c"
maksim_ 2017-02-09 04:53:19
okay
Eduard_Munteanu 2017-02-09 04:53:43
Similarly f a b + g c d parses as (f a b) + (g c d).
merijn 2017-02-09 04:53:51
maksim_: So if "f :: a -> IO b -> IO c" and we have "f 1 :: IO b -> IO c"
maksim_ 2017-02-09 04:55:10
to be concrete what is happening here? http://pastebin.com/c6pbA8Wt
maksim_ 2017-02-09 04:55:37
to the left of $ we get a partial application of handle? then that partial application is applied to the do?
merijn 2017-02-09 04:55:45
maksim_: Yes
merijn 2017-02-09 04:56:04
maksim_: Remember that do is just syntactic sugar for a bunch of >>= and >> expressions
maksim_ 2017-02-09 04:56:21
merijn, yes that's fine
merijn 2017-02-09 04:56:29
@undo do { h <- openFile path ReadMode; size <- hFileSize h; hClose h; return (Just size) }
lambdabot 2017-02-09 04:56:29
openFile path ReadMode >>= \ h -> hFileSize h >>= \ size -> hClose h >> return (Just size)
maksim_ 2017-02-09 04:56:47
desugaring doesn't actually make it more readable
merijn 2017-02-09 04:56:54
maksim_: So it's basically just doing "handle (\_ -> return Nothing) (openFile path ReadMode >>= \ h -> hFileSize h >>= \ size -> hClose h >> return (Just size))
maksim_ 2017-02-09 04:57:01
yes
Welkin 2017-02-09 04:57:03
@pl openFile path ReadMode >>= \ h -> hFileSize h >>= \ size -> hClose h >> return (Just size)
lambdabot 2017-02-09 04:57:03
liftM2 (>>=) hFileSize ((. (return . Just)) . (>>) . hClose) =<< openFile path ReadMode
Welkin 2017-02-09 04:57:06
lol
merijn 2017-02-09 04:57:15
Which, if you hate parentehesis could also be written "handle (\_ -> return Nothing) $ openFile path ReadMode >>= \ h -> hFileSize h >>= \ size -> hClose h >> return (Just size)
Eduard_Munteanu 2017-02-09 04:57:20
maksim_, it's the same thing if you wrap the whole do block in parens instead of $
maksim_ 2017-02-09 04:57:34
yes that was clear from the beginning - the question was how exactly it was working
Tuplanolla 2017-02-09 04:57:34
What's the Haskell way to do `ioctl(fd, SIOCGIFINDEX, &ifr)`?
maksim_ 2017-02-09 04:57:51
Eduard_Munteanu, it couldn't be anything else since handle takes two arguments
Tuplanolla 2017-02-09 04:58:14
I'm looking at sending raw network packets.
merijn 2017-02-09 04:58:48
maksim_: Well, ($) is literally defined like this: "f $ x = f x" :) But because of the low precedence the 'f' part can be a compound expression, like 'handle (\_ -> return Nothing)'
merijn 2017-02-09 04:58:59
Tuplanolla: unix package?
Tuplanolla 2017-02-09 04:59:20
There's `System.Posix.IOCtl`, but the types seem incompatible, merijn.
maksim_ 2017-02-09 04:59:25
merijn, yes. thank you for the explanation
merijn 2017-02-09 04:59:34
Tuplanolla: In what way?
sternmull 2017-02-09 05:00:26
maksim_: see here for an easy to understand explanation of $: http://learnyouahaskell.com/higher-order-functions#function-application
Tuplanolla 2017-02-09 05:00:44
I need a file descriptor and a `struct ifreq` somehow.
merijn 2017-02-09 05:00:44
Tuplanolla: oh...that's an ugly/weird binding...
mangobot 2017-02-09 05:00:45
has anyone created a laska game in haskell by any chance?:)
merijn 2017-02-09 05:01:41
Tuplanolla: honestly, it might be easier to write your own wrapper for ioctl and call that?
Tuplanolla 2017-02-09 05:02:07
Surely someone has done this before.
merijn 2017-02-09 05:02:19
Tuplanolla: Presumably, but I'm not aware of where :)
mpickering 2017-02-09 05:02:20
How can I construct a Ptr Word8?
merijn 2017-02-09 05:02:39
mpickering: Foreign.C.Marshal.Alloc or whatever it's called?
Eduard_Munteanu 2017-02-09 05:02:40
Tuplanolla, can't you use raw sockets from 'network'?
cocreature 2017-02-09 05:02:48
mpickering: construct based on what? an integer representing the address?
Tuplanolla 2017-02-09 05:03:09
I thought I'm using those, Eduard_Munteanu.
mpickering 2017-02-09 05:03:22
well, I have no idea, this is probably the problem.
mpickering 2017-02-09 05:03:28
I am trying to use this API https://hackage.haskell.org/package/lz4-0.2.3.1/docs/Codec-Compression-LZ4.html#v:c_LZ4_uncompress
merijn 2017-02-09 05:03:28
Tuplanolla: tbh, if you know enough C to write that example you gave it should be trivial to write, I've got an example for vtys
merijn 2017-02-09 05:03:35
Tuplanolla: https://github.com/merijn/posix-pty
merijn 2017-02-09 05:04:47
mpickering: You get Ptr Word8 by mallocing them :p
Tuplanolla 2017-02-09 05:06:06
That may be, merijn, but I don't really know or care how to deal with structures and constants.
cocreature 2017-02-09 05:06:54
mpickering: "allocaBytes" probably does the job
merijn 2017-02-09 05:07:03
Tuplanolla: Dealing with those on the haskell side is generally even more painful.
cocreature 2017-02-09 05:07:13
or "mallocBytes" but in that case you need to manually call free
merijn 2017-02-09 05:07:20
cocreature: Do you like stackoverflows? Because that's how you get stackoverflows...
cocreature 2017-02-09 05:07:58
merijn: hm?
merijn 2017-02-09 05:08:29
cocreature: Allocating a byte array on the stack for writing compressed data into seems like it invites every single classic stackoverflow exploit in existence
cocreature 2017-02-09 05:09:05
merijn: are you sure that newPinnedByteArray allocates on the stack?
mpickering 2017-02-09 05:09:21
This API is so foreign to me
mpickering 2017-02-09 05:09:28
and I also suspect this will cause problems as I am using ghcjs
merijn 2017-02-09 05:09:32
cocreature: hmmm, maybe allocaBytes is different from alloca I'm thinking off
merijn 2017-02-09 05:09:55
mpickering: oh...I'm not sure you can even get Ptr's using GHCjs
cocreature 2017-02-09 05:09:57
merijn: alloca just calls allocaBytes
cocreature 2017-02-09 05:10:10
merijn: are you talking about C alloca?
mpickering 2017-02-09 05:10:12
but I guess I can use javascript libraries somehow
merijn 2017-02-09 05:10:25
cocreature: alloca definitely suggest stack allocation
cocreature 2017-02-09 05:10:43
merijn: I would be really surprised if the Haskell "alloca" does stack allocation
Tuplanolla 2017-02-09 05:10:57
I'll just put this project on hold until someone comes up with a better `ioctl` binding.
cocreature 2017-02-09 05:10:58
but I'm happy to be proven wrong :)
slx 2017-02-09 05:20:40
join #clojure
slx 2017-02-09 05:20:48
whoops...
Reisen 2017-02-09 05:21:45
Is it possible to enable extentions on the command line with `stack runhaskell`? `stack runhaskell foo.hs -- -XTemplateHaskell` for example?
Reisen 2017-02-09 05:21:58
Can't seem to get anything to work
sternmull 2017-02-09 05:23:04
i think it is "stack runahskell -XTemplateHaskell foo.hs --" and arguments for your program after the --
Reisen 2017-02-09 05:23:41
I get invalid option trying to pass anything like that to stack though
kgadek 2017-02-09 05:25:43
tried --ghc-options -XTemplateHaskell ?
Wizek 2017-02-09 05:26:00
Hey! With GHC 8.0.2, is `{-# OPTIONS_GHC -fno-defer-out-of-scope-variables #-}` supposed to work on a file-by-file basis if in .cabal `-fdefer-type-errors` is specified? in my case the file-specific flag seems to be ignored.
Reisen 2017-02-09 05:27:42
kgadek, yeah, seems its not an available option with `runhaskell`
kgadek 2017-02-09 05:30:56
Reisen: this works for me: stack runhaskell -- -XTemplateHaskell
kgadek 2017-02-09 05:31:35
Reisen: which stack version?
Reisen 2017-02-09 05:31:47
Are you sure that's actually enabling the extension? Because when I try to use it in the file it doesn't work
Reisen 2017-02-09 05:31:55
1.2.0
kgadek 2017-02-09 05:32:04
ohhh, I know
kgadek 2017-02-09 05:32:21
`stack runhaskell -- -XTemplateHaskell foo.hs`
kgadek 2017-02-09 05:32:31
foo.hs has to be after --
kgadek 2017-02-09 05:32:43
I have stack v1.3.2 fwiw
Reisen 2017-02-09 05:32:49
You're a king, thank you so much
Reisen 2017-02-09 05:32:51
That got it
nut 2017-02-09 05:32:52
with stack how to list all installed pacakges and their versions?
CindyLinz 2017-02-09 05:33:13
nut: stack list-dependencies
CindyLinz 2017-02-09 05:33:27
... in a stack project's directory
nut 2017-02-09 05:33:35
i mean the global
nut 2017-02-09 05:33:44
global package
CindyLinz 2017-02-09 05:35:08
no idea.. sorry
nut 2017-02-09 05:35:36
it's ok