<    March 2017    >
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31
00:00 <michalrus> Also, this question might be silly, but should we generally *not* be using the built-in Prelude?
00:00 <YongJoon> You can write `{-# LANGUAGE NoImplicitPrelude #-}`
00:00 <michalrus> Yes, yes, that’s what I’m asking about!
00:00 <jle`> i usually use the built in prelude
00:00 <michalrus> Is it common?
00:00 <michalrus> Mhmmm.
00:00 <jle`> some people (or projects/teams) use custom preludes
00:00 <jle`> there's a bunch of custom prelude libraries on hackage, but i've never found it super necessary
00:01 <YongJoon> Some libraries also use this like Yesod or etc.
00:01 <YongJoon> I've seen this but never used yet
00:01 <michalrus> Okay, thank you. =)
00:01 mkoenig joined
00:02 <michalrus> And… as it got a bit more devopsey… can I somehow make the build fail if some function/symbol is used? Like, for instance, ban System.IO.Unsafe.*?
00:03 <YongJoon> you can use `undefined`
00:03 <michalrus> I could always use grep, but fully-qualified names seem better.
00:03 JamEngulfer joined
00:03 <YongJoon> I'm sorry this is not for failing for build.
00:04 <michalrus> Hmmm. YongJoon, could you elaborate some more? :P I don’t get that.
00:04 <michalrus> Ah!
00:04 <jle`> there's -XSafe and -fwarn-unsafe
00:04 JoshS joined
00:04 <jle`> but that just warns you about a general class of unsafe packages
00:04 <jle`> and it might include some usfeul packages
00:04 <michalrus> Mhmmm.
00:04 theDon_ joined
00:04 <michalrus> What if I wanted to ban X.Y.Z.t explicitly? :)
00:05 <geekosaur> WARNING pragma + -Werror? but that won't ban qualified vs. unqualified
00:05 takle joined
00:05 <geekosaur> th eonly way to do that is to nto import it. some people use a separate Internals module for such things
00:06 <michalrus> Mhmmm, okay! Thank you. :)
00:06 <YongJoon> Not good approach, but how about to use CPP?
00:07 <JamEngulfer> I'm trying to generate a list of the coordinate pairs in a grid up to n by n. The functino
00:07 <JamEngulfer> *whoops
00:07 xaviergmail joined
00:07 <michalrus> Hm, maybe a compiler plugin would be able to do this? I definitely don’t know anything about GHC innards, but it seems like a plugin might have access to fully-qualified names of symbols in AST.
00:07 <michalrus> CPP is C pre-processor?
00:07 <jle`> ghc-mod will probably give you qualified names
00:07 <mzabani> hey everyone! I'm having some issues with an (MVar a) that is passed around: it seems like different code sees different values.. (I'm using this to escape from a monad transformer).. what could this be?
00:07 <YongJoon> Yes, you can use it by `{-# LANGUAGE CPP-#}`.
00:07 <michalrus> Oh, nice!
00:08 <michalrus> (In Scala, there’s Wartremover compiler plugin that does exactly that, among other things.)
00:08 <Rotaerk> I always confuse CPP with C++, since C++ file extension is cpp
00:08 <Welkin> not CCCP?
00:08 <michalrus> OK. *takes notes* I’ll investigate this further on my own! Thank you all once more!
00:08 <jle`> mzabani: can you show a reproducable example?
00:09 <* Welkin> pulls a rabbit out of jle`'s hat
00:09 <JamEngulfer> I'm trying to generate a list of the coordinate pairs in a grid up to n by n. The function signature is "grid :: Int -> [(Int, Int)]" and I currently have "grid n = [(n,n) | n <- [1..n]]", but that's not working properly. I can't seem to get a second axis generator in there without getting a variable out of scope error
00:09 <MarcelineVQ> michalrus: if you know what things you want to fail to compile on why not just hide those things. import Some.Module hiding (neonDemons)
00:09 <* Welkin> watches the rabbit reproduce
00:09 <mzabani> jle`: there's quite a bit of code, let me try to take the parts that matter into a snippet
00:09 takle_ joined
00:09 <Welkin> it asexually creates clones
00:10 <michalrus> MarcelineVQ: I wouldn’t bother if I was working on my own, but with many people, it seems better when the machine is doing as much CR as possible. =P
00:10 mekeor joined
00:11 <YongJoon> You used duplicated n. How about `grid n = [(m,m)|m <- [1..n]]?
00:11 <lpaste_> mzabani pasted “Escaping from my monad” at http://lpaste.net/353510
00:12 _sras_ joined
00:12 <mzabani> jle`: there it is.. I'm not sure it's enough, so just let me know if you need more!
00:12 <Welkin> sounds like an emo punk album
00:12 <jle`> is f a function?
00:13 <YongJoon> I'm sorry. it should be `grid n = [(m,l)|m<-[1..n],l<-[1..n]]`.
00:13 <jle`> if f returns IO, then you can just use liftIO
00:13 <jle`> if TunnelT is MonadIO, then liftIO :: IO a -> TunnelT m a
00:13 <JamEngulfer> YongJoon: What the hell? I did exactly that earlier and it just told me my variables were out of scope. Now your version works fine
00:13 faberbrain joined
00:14 mizu_no_oto joined
00:14 <JamEngulfer> Well, either way, thanks for the help!
00:15 anuxivm joined
00:15 <YongJoon> ^_^!
00:15 doodlehaus joined
00:16 <mzabani> jle`: don't I need to do the inverse? Have something that gives me TunnelT m a -> IO a?
00:17 <Koterpillar> mzabani: how would that help?
00:17 cschneid_ joined
00:17 <Koterpillar> mzabani: you have IO, you need TunnelT
00:21 <mzabani> I need to implement http-client's Connection's send and receive functions, which run in IO. However, my implementation uses functions that run only in TunnelT (and TunnelT requires a PendingConnection to be created). Sorry, but I still don't understand what you're suggesting..
00:21 nbro joined
00:21 <nbro> edwardk: you were right, I had a bug in the moveLeft and moveRight functions…
00:21 benl23 joined
00:22 ljc joined
00:23 <nbro> one question guys
00:23 takle joined
00:24 <nbro> if I declare a data type using the record syntax as follows “data MyData = MyData {myfield :: String, mySecondField :: String }”, when I create a value of this data type, do I always need to specify the name of the fields when inializing them?
00:24 <nbro> @let data MyData = MyData {myfield :: String, mySecondField :: String }
00:24 <lambdabot> Defined.
00:25 <nbro> MyData {“”, “”}
00:25 <Koterpillar> > MyData "" ""
00:25 <lambdabot> error:
00:25 <lambdabot> • No instance for (Show MyData)
00:25 <lambdabot> arising from a use of ‘show_M674606865184440269819466’
00:25 <Koterpillar> well, you get the idea
00:26 <nbro> @undefine
00:26 <lambdabot> Undefined.
00:26 mkoenig joined
00:26 <nbro> @let data MyData = MyData {myfield :: String, mySecondField :: String } deriving (Show)
00:26 <lambdabot> Defined.
00:26 <nbro> MyData { “”, “”}
00:27 <nbro> > MyData { “”, “”}
00:27 <lambdabot> <hint>:1:10: error: lexical error at character '\8220'
00:27 <Welkin> smart quotes :)
00:27 <Koterpillar> > MyData "" ""
00:27 <Welkin> you forgot the double prime marks
00:27 <lambdabot> MyData {myfield = "", mySecondField = ""}
00:27 jdelreal joined
00:28 <Welkin> > MyData "“”" "“”"
00:28 <lambdabot> MyData {myfield = "\8220\8221", mySecondField = "\8220\8221"}
00:28 uglyfigurine joined
00:29 <nbro> Welkin: what do you mean that I forgot “double prime marks”?
00:30 <Welkin> nbro: it looks like your irc client is converting your ascii quotes into unicode quotes
00:30 <Welkin> the ascii quotes are actualy "double prime" marks
00:30 <nbro> ""
00:30 <nbro> ok
00:30 <nbro> I changed it
00:30 <nbro> lol
00:30 <nbro> the encoding
00:31 <nbro> > MyData {??, ??}
00:31 <nbro> lol
00:31 <Welkin> you should be able to use unicode
00:31 <lambdabot> <hint>:1:9: error: parse error on input ‘??’
00:31 <Welkin> there should be a setting to convert quotes to smart quotes
00:31 <Welkin> turn that off
00:31 dan_f joined
00:31 <Welkin> keep unicode encoding on
00:31 <nbro> Welkin: I was using unicode before, now I changed it to Western ASCII
00:31 <Koterpillar> > MyData { "a", "b" }
00:31 <Welkin> that's a bad solution
00:31 <lambdabot> <hint>:1:10: error: parse error on input ‘"’
00:31 <Koterpillar> no, that's not the correct syntax
00:31 <Koterpillar> either use field names, or MyData "a" "b"
00:32 <nbro> can I not use record syntax to create a value of a data type that was declared with record syntax?
00:32 freeside joined
00:32 <nbro> ?hello?
00:32 <lambdabot> Unknown command, try @list
00:32 <nbro> nope
00:33 <Koterpillar> you can
00:33 <nbro> “hell"
00:33 <Koterpillar> > MyData { myfield = "a", mySecondField = "b" }
00:33 takle joined
00:33 <lambdabot> MyData {myfield = "a", mySecondField = "b"}
00:33 <Koterpillar> > [MyData { myfield = "a", mySecondField = "b" }, MyData "c" "d"]
00:33 <lambdabot> [MyData {myfield = "a", mySecondField = "b"},MyData {myfield = "c", mySecond...
00:33 plutoniix joined
00:33 <mzabani> Koterpillar: don't I need something like unlift?
00:34 <Koterpillar> mzabani: no, you need lift
00:34 _jams joined
00:34 m0rphism joined
00:34 <nbro> because someone said before that I couldn’t, so I was searching for shorter way to create values…
00:34 plutoniix joined
00:34 <nbro> btw, is it correct to say that this is a value MyData {myfield = "a", mySecondField = “b”}?
00:35 <mzabani> Koterpillar: wouldn't I need TunnelT m a to be MonadIO m for that?
00:35 <mzabani> oh, just lift, not liftIO
00:35 <Welkin> nbro: MyData is a data constructor (a function)
00:36 <nbro> I know
00:36 <Welkin> once it is fully applied (you give it all of the parameters that it can accept) then it becomes a value
00:36 <nbro> but I’m wondering what’s the correct terminology for this concrete “thing” MyData {myfield = "a", mySecondField = "b"}?
00:36 <Koterpillar> mzabani: yes, liftIO, I meant lift as a generic term. But I thought it already is a MonadIO?
00:36 <nbro> Welkin: ok
00:37 <nbro> whereas, e.g., when you do something like “Just Int”, this is a concrete type, right?
00:37 <Welkin> yes
00:37 <nbro> ok
00:37 <Welkin> if you mean by "concrete type" it has kind *
00:37 <Welkin> :k Just
00:37 <lambdabot> a -> Maybe a
00:38 <freeside> uh, you mean "Maybe Int", or "Just 5", but not "Just Int"
00:38 <Welkin> er yes
00:38 <Welkin> :k Maybe
00:38 <freeside> the first is a concrete type, the second is a ...
00:38 <lambdabot> * -> *
00:38 <Welkin> :k Maybe Int
00:38 <lambdabot> *
00:38 <Welkin> Just is a data constructor
00:38 svgDelux joined
00:39 <nbro> :t "asdasdasdasdas"
00:39 <lambdabot> [Char]
00:39 <mzabani> Koterpillar: sorry, let me correct myself: I did write instance MonadIO m => MonadIO (TunnelT m)
00:39 andyhuzhill joined
00:39 <nbro> no more stupid quotes
00:39 <nbro> lol
00:39 <nbro> *annoying
00:39 <nbro> :D
00:39 <Welkin> nbro: what client are you using?
00:39 <Koterpillar> mzabani: then you have liftIO :: MonadIO m => IO m -> TunnelT m
00:40 <nbro> Colloquy
00:40 <nbro> you?
00:40 <Welkin> ew...
00:40 <Welkin> I tried that for a minute
00:40 <Welkin> I use terminal-based irc clients like irssi, erc (and tried weechat, which is okay)
00:40 <nbro> Welkin: I know Just is a data constructor
00:41 <nbro> but I?m wondering what?s the correct terminology for Just Int
00:41 <nbro> '
00:41 <nbro> I’m
00:41 <nbro> ok
00:41 <nbro> lol
00:42 <Welkin> nbro: a value
00:42 <nbro> Welkin: I will one of those maybe tomorrow ;)
00:42 <Welkin> er
00:42 <Welkin> Just Int is not anything
00:42 <Welkin> it doesn't make sense
00:42 <Welkin> `Just 5` makes sense
00:42 <nbro> wait
00:42 <Welkin> Int is a type
00:42 <freeside> it's an expression. after it gets evaluated, it becomes a value.
00:42 <Welkin> Just requires a value, not a type
00:42 <Welkin> types and values exist in different spaces
00:42 <nbro> suppose you define a function with the following signature: my_f :: Maybe Int -> Int
00:43 <lpaste_> mzabani revised “Escaping from my monad”: “Escaping from my monad” at http://lpaste.net/353510
00:43 <nbro> :t my_f :: Maybe Int -> Int
00:43 <lambdabot> error:
00:43 <lambdabot> Variable not in scope: my_f :: Maybe Int -> Int
00:43 oisdk joined
00:43 <Welkin> :t Just :: Int -> Maybe Int
00:43 <lambdabot> Int -> Maybe Int
00:43 <Koterpillar> :t undefined :: Maybe Int -> Int
00:43 <lambdabot> Maybe Int -> Int
00:43 <Welkin> lol
00:43 <nbro> ok...
00:44 <nbro> in my example
00:44 <Zemyla> Actually, Just Int does make sense in certain contexts.
00:44 louispan joined
00:44 <Zemyla> :t Proxy :: Proxy (Just Int)
00:44 <lambdabot> Proxy ('Just Int)
00:44 <nbro> you can pass to my_f either a Just SOME_NUMBER or nothing
00:44 Rizy joined
00:44 <mzabani> Koterpillar: I may not be explaining myself well enough (I'm a noob :P), would you mind looking at my corrected code to see what I want to achieve?
00:44 tmtwd joined
00:44 <Koterpillar> mzabani: so you want to _return_ a function like that?
00:44 <nbro> isn’t there a way to refer to this particular Just Int, since the compiler already knows it’s going to be a Just Int
00:45 <Koterpillar> nbro: case statement?
00:45 tommd joined
00:46 <Koterpillar> mzabani: I don't understand the purpose anymore, though.
00:46 <mzabani> Koterpillar: yes... precisely!
00:47 <nbro> let x = [1..]
00:47 <nbro> nope
00:47 <mzabani> I need to teach http-client to send its data through a custom built websockets tunnel that I created.. my tunnel's api consists of a runTunnelT function, so everything needs to run inside TunnelT..
00:47 <nbro> > let x = [1..]
00:47 <lambdabot> <no location info>: error: not an expression: ‘let x = [1..]’
00:47 <* nbro> @let x = [1..]
00:47 <Welkin> mzabani: lol, teach it? Like teaching a dog to do tricks?
00:48 <mzabani> Welkin: lol sorry for the words I chose...
00:48 <nbro> thanks again! :D
00:48 prophile joined
00:48 serendependy joined
00:48 FullyFunctional left
00:48 <mzabani> give it functions that do sending and receiving of data, basically
00:49 nakal joined
00:49 <Koterpillar> I don't think TunnelT will help you with that
00:49 <mzabani> the things is: everytime http-client calls the function I gave it it needs to update the TunnelT's internal structures, without running inside it
00:49 zcourts joined
00:50 <mzabani> Koterpillar: hmm what can I do?
00:50 DonComo joined
00:51 takle joined
00:52 <Lazersmoke> mzabani: Does `managerModifyRequest :: Request -> IO Request` do what you want?
00:53 <Lazersmoke> (used with `managerModifyResponse :: Response BodyReader -> IO (Response BodyReader)`)
00:54 that_dude joined
00:54 <that_dude> :D
00:54 markus1209 joined
00:54 markus1219 joined
00:55 mkoenig joined
00:55 <mzabani> Lazersmoke: I guess it could, though I still have to implement ManagerSettings' functions (which is where the trouble lies)
00:56 oaaao joined
00:56 Koterpillar joined
00:56 Stanley00 joined
00:58 wtetzner joined
00:58 oisdk joined
01:02 oisdk joined
01:02 takle joined
01:03 FreeBirdLjj joined
01:03 andyhuzhill joined
01:06 maksim__ joined
01:06 path[l] joined
01:07 oisdk_ joined
01:07 jmcarthur joined
01:08 <freeside> :load ch29a
01:09 <freeside> ahem, sorry, wrong buffer
01:09 <freeside> for a moment there you all looked like ghci
01:10 mbw joined
01:11 <lyxia> target 'ch29a' is not a module name or a source file
01:11 takle joined
01:11 <freeside> haha
01:11 <mbw> What is the conventional way of testing compiled "runner" executables with space leaks, without danger of the machine thrashing? Restricting heap usage via +RTS?
01:12 <Koterpillar> rlimit?
01:12 <monochrom> I recommend +RTS
01:12 <pacak> +RTS. Also it helps to avoid introducing space leaks.
01:13 <mbw> So +RTS -HSomething?
01:13 mkoenig_ joined
01:13 <pacak> -M something
01:14 <monochrom> +RTS -H100M for 100MB.
01:14 <mbw> ah right, -H is minimum heap size :/
01:14 tommd joined
01:15 <monochrom> Don't forget "-rtsopts" at link time (at the latest).
01:15 nighty- joined
01:15 <Tuplanolla> I think M is actually MiB.
01:15 <mbw> monochrom: According to the ghc manual, -H does not put a limit on heap size.
01:15 <pacak> Tuplanolla: Close enuf.
01:16 <mbw> It seems -M<Bytes> is it.
01:16 <mbw> Ok I'll try that, thankx.
01:16 andyhuzhill joined
01:16 <mbw> *thanks
01:17 <monochrom> Oh! Ooops, typo, I meant -M100M
01:17 fkurkows1 joined
01:18 gugah joined
01:18 <mbw> Alright, time to learn me sum Core.
01:18 <pacak> learning sum stg can be nice as well.
01:18 <MarcelineVQ> Tuplanolla: yes
01:19 mkoenig joined
01:19 <mbw> Sturzkampfgeschwader?
01:20 <mbw> or what is stg
01:20 <geekosaur> @google spineless tagless g machine
01:20 <lambdabot> https://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf
01:21 <pacak> -ddump-stg
01:21 notarobot joined
01:21 <geekosaur> the graph reduction engine used by ghc, and the "language" that compiles into graphs for it
01:22 notarobot joined
01:24 <mbw> Skimming over the paper, it does read like Core a little
01:24 <mbw> or rather very much
01:24 <freeside> it's turtles, all the way down!
01:24 <MarcelineVQ> part of the way it's elephants
01:25 <geekosaur> yes, Core is supposed to be fairly close to STG
01:25 <mbw> It never ceases to amaze on how many abstraction levels you can work with Haskell
01:26 alx741 joined
01:26 oisdk joined
01:26 <mbw> On that thought, is there some way to use inline-assembly as well?
01:27 <pacak> foreign import primop
01:27 <geekosaur> not so far as I know but someone could probably do something similar to inline-c
01:27 johnmendonca joined
01:27 <pacak> I'm using it to process data with AVX instructions
01:28 <geekosaur> have you been following https://mail.haskell.org/pipermail/ghc-devs/2017-March/013899.html ?
01:28 <geekosaur> still in the planning phase (and soliciting contributors/help)
01:29 <pacak> I'm trying to read all the mails where Edward gets involved.
01:29 <mbw> How do you manage alignment?
01:29 s3mi0 joined
01:29 <geekosaur> you mean layout? use an editor with half a brain :)
01:30 <geekosaur> nvi can do it with some pain. I personally run emacs (but see /nick :) others use atom or sublime edit with haskell support
01:30 <pacak> mbw: I don't. There is some slight overhead, but even with that AVX code is better than anything I was able to write in haskell
01:30 Levex joined
01:30 <geekosaur> oh, wrong algnment :p
01:30 <mbw> haha
01:31 Fairy joined
01:31 variable joined
01:31 <monochrom> How does /nick tell me about your editor?
01:31 <fnordmeister> You can usually just tell.
01:32 <geekosaur> it tells you I'm of an age to think emacs is a reasonable editor :p
01:33 <pacak> emacs is a reasonable OS that lacks a decent text editor...
01:33 jrm joined
01:33 <MarcelineVQ> does it? your nick might show more to you than to others :>
01:33 <monochrom> No, emacs lack of concurrency makes it an unreasonable OS, at the level of DOS.
01:33 <freeside> on the unreasonable editorness of emacs
01:33 <mbw> Why would layout be a pain? I usually spend more time thinking than writing, so even having to align (now the other one) expressions by hand wouldn't be much of a burden...
01:34 Volt_ joined
01:34 <freeside> safe spaces. they're all the rage.
01:34 <mbw> Still, Emacs Lisp is probably way nicer than Vimscript...
01:34 Argue__ joined
01:35 <mbw> And Python2 vs. Python3
01:35 ajhager joined
01:36 marsam joined
01:39 <okeuday_bak> indenting haskell code with 4 spaces is normal, right?
01:39 <geekosaur> I don't think there's really a normal
01:39 <okeuday_bak> k :-)
01:39 <freeside> if you're lawful good, 4 is fine
01:39 <mbw> According to Linus, 4 Spaces is a meme
01:39 dan_f joined
01:40 <freeside> it all really depends on your alignment
01:40 shoopaloop joined
01:40 <pacak> Look at base or ghc source code
01:40 <okeuday_bak> yeah, good point
01:40 <kadoban> I tend to use 2 or 3
01:40 <Koterpillar> hindent thinks it's 2 and I'm not arguing
01:40 <pacak> 3????? O_O
01:40 a3Dman joined
01:41 <mbw> I thought 2 was a fixed-size fortran thing
01:41 <kadoban> 2 gets a little hard to see the difference of sometimes, 4 seems like too much. So 3 *shrug*
01:42 <kadoban> I probably use 2 more though
01:42 <Tuplanolla> Two is nice, because it forms a square with 1:2 aspect ratio fonts.
01:42 anuxivm left
01:43 jchia_1 joined
01:44 FreeBirdLjj joined
01:47 jchia_1 left
01:49 akts joined
01:50 shoopaloop joined
01:50 <fresheyeball> is there better syntax for this?
01:50 <fresheyeball> class Schema t => DefaultPredicate (t :: SchemaType) where
01:50 <fresheyeball> type DefaultPredicateType t :: PredicateType
01:51 cdg joined
01:53 <Rotaerk> what's SchemaType from?
01:54 <Rotaerk> not familiar with that kind
01:54 rstefanic joined
01:55 nomicflux joined
01:58 mkoenig joined
01:59 a3Dman joined
02:02 takle joined
02:04 Coldblackice joined
02:08 glguy_ joined
02:08 Argue_ joined
02:08 louispan joined
02:09 DataComputist joined
02:10 mkoenig joined
02:10 andyhuzhill joined
02:10 <okeuday_bak> if you have constructors (from data) in some module that are exported, how do you export them in a different module you have imported them into?
02:11 <okeuday_bak> do you have to make values with the same name, to allow you to export them, like making extra functions?
02:12 ajhager joined
02:13 Noldorin joined
02:15 michael4 joined
02:15 <okeuday_bak> nm, think I found how to do it
02:16 <geekosaur> you can just export them, qualified if that's how you imported them, Type(..)
02:16 <geekosaur> they will be named by other imports as if fdefined in your module (i.e. it can't tell you reexported them from elsewhere)
02:17 pikajude joined
02:18 Zialus joined
02:19 <DataComputist> Is stack broken in macOS 10.12.3?
02:19 <DataComputist> $ stack setup
02:19 <DataComputist> dyld: malformed mach-o: load commands size (34520) > 32768
02:19 <DataComputist> [1] 95440 abort stack setup
02:19 cdg joined
02:21 cdg_ joined
02:21 <geekosaur> I don't know if stack has been updated with the fix to that (also requires newer ghc and newer Cabal library)
02:22 <geekosaur> (stack is especially likely to run into it but it's a general Sierra issue)
02:23 conal joined
02:23 <tmciver> Hey all. I'm trying to run the tests for cryptonite (https://github.com/haskell-crypto/cryptonite) which does not use stack, but after running `cabal install` followed by `cabal test`, it complains that all of the tasty related dependencies are missing. Also, doing `cabal install --dependencies-only` didn't have any effect. Any ideas?
02:23 infinity0 joined
02:23 gugah joined
02:23 <geekosaur> cabal install --enable-tests
02:24 <geekosaur> (iirc)
02:24 <tmciver> geekosaur: Let me try.
02:24 <geekosaur> ...yes
02:24 enitiz joined
02:24 <geekosaur> if you omit that it ignores the tests and their dependencies
02:25 <tmciver> Doing something . . . :)
02:25 lordcirth_ joined
02:26 markasoftware joined
02:27 <davean> tmciver: Also, you don't have to install it to test it
02:27 infinity0 joined
02:27 <tmciver> I had earlier tried `cabal configure --enable-tests` which I had seen here: https://www.haskell.org/cabal/users-guide/developing-packages.html#test-suites but that also did not seem to work.
02:28 <tmciver> davean: right, because `cabal install` does not install deps, it install the app locally, correct?
02:28 rkazak_ joined
02:29 the|auriscope joined
02:30 infinity0 joined
02:30 <tmciver> geekosaur: Worked. Thanks!
02:32 <davean> tmciver: install installs it to your system
02:32 <davean> tmciver: you probably want "build"
02:33 infinity0 joined
02:33 <davean> tmciver: I mean, install also installs any dependencies to the system
02:33 <davean> cabal install is similar to make install
02:33 <davean> which *also* builds it
02:34 <davean> but theres no reason to install it to test it
02:34 <tmciver> davean: Got it. Thanks. I think the minimun that I needed to run tests in this case was `cabal install --enable-tests`, `cabal test`.
02:35 FjordPrefect joined
02:37 takle joined
02:37 <geekosaur> sometyimes install is needed for testing to work, if getDataFileName etc. is in play, because support for that in an un-installed program is an utter hack
02:39 <davean> geekosaur: sometimes, but rarely
02:40 crobbins joined
02:40 ContessaTP joined
02:42 raycoll joined
02:44 dfeuer joined
02:47 crobbins joined
02:47 mthek joined
02:48 kungp joined
02:49 electrostat joined
02:51 rstefanic joined
02:54 variable joined
02:56 variable joined
02:56 marsam left
02:57 mthek joined
02:57 DataComputist joined
02:57 sobaken joined
02:58 variable joined
03:00 Goplat joined
03:00 hucksy joined
03:01 mkoenig joined
03:02 variable joined
03:04 <sssilver> hey guys, how much useful information would one derive out of a core dump of a Haskell program?
03:06 sanett joined
03:06 <sanett> hey folks, what are some good books and online tutes for learning haskell?
03:06 ramzifu joined
03:07 <sssilver> sanett http://learnyouahaskell.com is what I started with and since then I loved it so much that I purchased it at least 10 time
03:07 <sssilver> *times
03:07 <sssilver> some people say it's crap, but I think it's marvelous
03:07 <sssilver> those people are also often not fun at parties
03:07 <sssilver> (shots fired)
03:07 <sanett> lol
03:07 <Welkin> it's a fun book to read, like a comic book
03:08 <sanett> thanks that's exactly what i was expecting
03:08 <Welkin> but it's not a great learning resource beyond the superficial aspects of the language
03:08 sobaken joined
03:08 <geekosaur> sssilver, not very much currently (this changed slightly in 8.0.x and should change a bit more in 8.2.x, but Haskell programs are very different from C/C++ and debuggers typically don't handle them well)
03:08 <the|auriscope> I've read LYAH and I'm currently going through Haskell Programming (from first principles)
03:08 <the|auriscope> LYAH was fun but I feel like I'm learning a lot more from the latter
03:09 <geekosaur> basically you are trying to debug an STG graph, not linear code. in theory someone could come up with some gdb helpers to dump STG nodes, but afaik nobody has
03:09 <sssilver> sanett let me put it this way, that book was sufficient for me (as a seasoned programmer) to go from zero to a system in production that works to this day
03:09 <Welkin> in haskell, you are always learning something new
03:09 <sanett> LYAH is an introductory book
03:09 <Welkin> and your perspective/opinions will change with time
03:09 shafox joined
03:09 <geekosaur> LYAH is good for self-starters, otherwise it's a 2-hour movie trailer
03:09 louispan joined
03:09 <MarcelineVQ> geekosaur, sssilver: are you guys talking about the same core
03:10 <sssilver> I'm talking about the contents of process memory at the time of a crash
03:10 <MarcelineVQ> sounds like you are then :>
03:10 jmcarthur joined
03:10 <davean> sssilver: what do you have in production?
03:11 tommd joined
03:12 <sssilver> davean a small web service that takes input from SQS, transforms it, and generates JSON
03:12 <sssilver> davean and does so very correctly, if that makes sense :D :D
03:13 brynedwards joined
03:14 <sssilver> > [22:12:56] okuu: jaziz: Because higher-order functions are so useless.
03:14 <lambdabot> <hint>:1:78: error:
03:14 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
03:14 <sssilver> lambdabot don't bother lol
03:15 Cooler joined
03:15 smwangi joined
03:16 mkoenig joined
03:16 juhp joined
03:17 sanett joined
03:19 govg joined
03:20 variable joined
03:21 takle joined
03:23 variable joined
03:24 variable joined
03:28 buttons840 joined
03:29 cschneid_ joined
03:29 dfeuer joined
03:30 JeanCarloMachado joined
03:31 louispan joined
03:31 eklavya joined
03:37 xaviergmail joined
03:37 takle joined
03:39 mac10688 joined
03:39 govg joined
03:40 xall_ joined
03:42 xall joined
03:43 systemfault joined
03:43 fabianhu_ joined
03:43 takle joined
03:45 eacameron joined
03:47 Mutter joined
03:49 sobaken joined
03:50 exferenceBot joined
03:50 CoolerExtreme joined
03:51 andyhuzhill joined
03:53 subttle joined
03:54 pleax joined
03:54 hexagoxel joined
03:56 grrkit joined
03:58 grrrkit joined
04:00 takle joined
04:00 JeanCarloMachado joined
04:01 <jle`> it'd be nice if there was an EndoM
04:01 <jle`> data EndoM m a = EndoM { appEndoM :: a -> m a }
04:02 <jle`> with appropriate monoid instances
04:07 halogenandtoast joined
04:08 <johnw> jle`: type EndoM m a = Endo (Kleisli m a a)?
04:10 cads joined
04:10 <jle`> yes, but the monoid instance
04:10 buttons840 joined
04:11 <buttons840> https://hackage.haskell.org/package/Spock-0.12.0.0/docs/Web-Spock.html#v:spock -- the type signature of the spock function looks weird to me, it looks like the SpockM portion of it takes 4 type arguments, but the very next line on that page shows SpockM as taking only 3 type arguments?
04:12 tripped joined
04:12 <jle`> it's partial application
04:12 <jle`> @let type MyMaybe = Maybe
04:12 <lambdabot> Defined.
04:13 <jle`> :t undefined :: MyMaybe Int -> Bool
04:13 <lambdabot> MyMaybe Int -> Bool
04:13 <jle`> maybe a bad example
04:13 <jle`> @let type EitherString = Either String
04:13 <lambdabot> Defined.
04:13 <jle`> :t undefined :: EitherString Int -> Bool
04:13 <lambdabot> EitherString Int -> Bool
04:14 <johnw> jle`: n/m, what I wrote makes no sense anyway
04:14 <buttons840> it's a partial application of what? how is it a partial application if there is an extra type argument?
04:14 <buttons840> i could see missing an argument being a partial application, but not an extra
04:14 <Koterpillar> :k Either
04:14 <lambdabot> * -> * -> *
04:15 <jle`> buttons840: do you understand --
04:15 <geekosaur> buttons840, most monad-context things like that take one more parameter which is the current result type
04:15 <geekosaur> for example IO a
04:15 <jle`> @let foo x = (+) x
04:15 <lambdabot> Defined.
04:15 <jle`> > foo 10 3
04:15 <lambdabot> 13
04:15 <geekosaur> here we have SpockM with 3 parameters, but actually 4: so we say something like SpockM ()
04:15 <jle`> i defined foo to take only 1 argument explicitly
04:15 <jle`> but i called it with two arguments
04:15 <geekosaur> to get the complete type
04:16 ChongLi joined
04:16 <jle`> it's a partial application of the SpockCtxM type
04:16 <geekosaur> partial type application is permitted as long as it is *always* resolved after expansion, as it is here
04:16 <buttons840> the source code says "type SpockM conn sess st = SpockCtxM () conn sess st" and "type SpockCtxM ctx conn sess st = SpockCtxT ctx (WebStateM conn sess st)" -- i don't see where theres room for partial application
04:16 structuralist joined
04:17 <jle`> buttons840: SpockCtxT takes three arguments
04:17 <jle`> it's being partially applied to ctx and (WebStateM conn sess st)
04:17 <geekosaur> you have to look for SpockCtxT which is 3 argments
04:17 faberbrain joined
04:17 <geekosaur> of which 2 are provided, just as with SpockM
04:17 <geekosaur> because you would include an additional argument for the result type of a monadic computation
04:17 <buttons840> ok, T != M :)
04:17 <jle`> SpockCtxT is being partially applied
04:18 structuralist joined
04:18 <buttons840> err, T /= M
04:18 <geekosaur> data SpockCtxT ctx m a
04:18 <geekosaur> but this provides only ctx and m, and same for the other aliases. "a" must be supplied at use time of each of these types
04:18 <geekosaur> so SpockM String, or SpockM (), or ,..
04:19 <jle`> it might help to look at the kinds too; SpockCtxT :: * -> (* -> *) -> * -> *
04:19 <jle`> so SpockCtxT ctx (WebStateM conn sess st) :: * -> *
04:20 <buttons840> ok, so SpockCtxM is a partially applied SpockCtxT, and SpockM is reorder of arguments for SpockCtxM ?
04:21 <geekosaur> more or less, yes
04:21 <geekosaur> or adding an additional component you usually don't care about
04:21 <geekosaur> (Parsec does the same thing since almost nobody uses the user state it can carry)
04:23 <geekosaur> in fact I think it also uses the same partial application trick, not mentioning the "a" at the end for the result
04:23 <geekosaur> so in the end you talk about e.g. Parser String, but the tyvar for the String is not mentioned in any of the type aliases
04:24 <geekosaur> er, type variable ("tyvar" is ghc internal shorthand)
04:24 dfeuer joined
04:25 takle joined
04:28 <Welkin> anyone use purescript here?
04:28 <Welkin> do you use pulp or webpack as the build tool?
04:29 <jle`> i use pulp
04:29 path[l] joined
04:30 <Koterpillar> Welkin: webpack
04:30 <buttons840> jle`: you aske me, "do you understand --". Were you asking about my grammar when I use dashes?
04:31 <jle`> oh no, i was talking about the next line
04:31 <buttons840> or just a typo? no worries either way
04:31 <buttons840> ok :)
04:31 <jle`> maybe i tshould have been "-->" or "--v", heh
04:32 takle joined
04:32 govg joined
04:32 JeanCarloMachado joined
04:33 pie_ joined
04:34 diegoksp joined
04:35 variable joined
04:35 DataComputist1 joined
04:36 gfixler joined
04:36 structuralist joined
04:38 DataComputist joined
04:41 otto_s_ joined
04:42 sanett joined
04:43 takle joined
04:43 <Xnuk> @hoogle ByteString -> String
04:43 <lambdabot> Data.ByteString.Char8 pack :: String -> ByteString
04:43 <lambdabot> Data.ByteString.Lazy.UTF8 fromString :: String -> ByteString
04:43 <lambdabot> Data.ByteString.UTF8 fromString :: String -> ByteString
04:44 <jle`> Xnuk: you should decode as Text
04:44 <jle`> using the Data.Text.Encoding module
04:44 <jle`> and then use unpack from Data.Text
04:45 <Xnuk> I know but I'm so lazy
04:45 <Axman6> there should be an unpack function in Data.ByteString{.Lazy}.Char8, but that will assume ASCII encoding, which you may not want
04:45 meiji11 joined
04:46 uglyfigurine joined
04:46 ChongLi joined
04:46 JeanCarloMachado joined
04:46 <jle`> :t T.unpack . T.decodeUtf8
04:46 <lambdabot> BSC.ByteString -> String
04:47 <jle`> :t fmap T.unpack . T.decodeUtf8 -- if you want to catch encoding errors
04:47 <lambdabot> error:
04:47 <lambdabot> • Couldn't match type ‘Text’ with ‘f Text’
04:47 <lambdabot> Expected type: BSC.ByteString -> f Text
04:47 <jle`> :t fmap T.unpack . T.decodeUtf8'
04:47 <lambdabot> BSC.ByteString -> Either Data.Text.Encoding.Error.UnicodeException String
04:47 dsantiag_ joined
04:48 <jle`> is T.unpack . T.decodeUtf8 too much to type ... ?
04:48 <pacak> jle`: You also need to import more stuff
04:50 CurryWurst joined
04:50 systadmin joined
04:51 ubsan_ joined
04:51 <Xnuk> Just converted from ByteString stream to Text stream and problem solved
04:53 <buttons840> in spock, what is the context? is it a type that is "carried through" a single request-response cycle?
04:53 <geekosaur> the context is likely a connection
04:53 <geekosaur> also any cached resources you might use, such as databases or logging
04:53 subttle joined
04:54 Xanather joined
04:54 <buttons840> "SpockCtxM ctx conn sess st" -- there's apparently a context, connection, session, and state
04:54 pleax joined
04:55 <buttons840> the connection uses a resource pool and is holding my database connections (though the resource pool can hold anything i suppose), web sessions are well understood, and the application state is a global state for the entire server -- i don't know what the context is though
04:56 Xanather_ joined
04:57 <buttons840> geekosaur: do you still think the context is a connection? any idea how it differs from the "connection" type parameter?
04:57 daniel-s joined
04:57 Xanather joined
04:58 <geekosaur> I have no idea what it is now
04:58 <geekosaur> because inside Spock.Core things generally use type SpockT = SpockCtxT ()
04:58 <geekosaur> so it's usually unit meaning "unused"...
04:59 <buttons840> yeah, i was noticing that just now -- looks like it's probably for internal use?
04:59 <geekosaur> suggest you ask the developer(s)
04:59 JeanCarloMachado joined
05:02 path[l] joined
05:02 <buttons840> ok, this article explains contexts: https://www.spock.li/2015/08/23/taking_authentication_to_the_next_level.html (in case of any interested observers)
05:05 takle_ joined
05:05 CurryWurst joined
05:07 boombanana joined
05:07 <Cale> Haha, the font used in Spock's logo is vaguely reminiscent of Star Wars
05:11 lithie joined
05:11 cschneid_ joined
05:15 robertkennedy joined
05:17 xtreak joined
05:18 takle joined
05:18 fresheyeball joined
05:18 sanitypassing joined
05:19 faberbrain joined
05:20 howdoi joined
05:22 regis_ joined
05:24 <Welkin> Cale: wrong sci-fi epic?
05:24 <Welkin> lol, you are right
05:24 <Welkin> that must be a new logo
05:24 <Welkin> I don't remember that a couple months ago
05:24 takle joined
05:26 AleXoundOS joined
05:26 <geekosaur> maybe just to psych Paramount lawyers or something
05:31 xaviergmail joined
05:32 Swizec joined
05:35 d34df00d left
05:38 JeanCarloMachado joined
05:39 pie_ joined
05:41 <sanitypassing> hi, people from ##math suggested I ask here: can anyone recommend undergraduate-friend papers on lambda calculus beta reduction strategies?
05:43 doodlehaus joined
05:45 exferenceBot joined
05:45 takle_ joined
05:48 robkennedy joined
05:50 sanett joined
05:51 vlatkoB joined
05:52 gcross_ joined
05:53 osa1 joined
05:53 osa1 joined
05:53 unenforcer joined
05:54 armyriad joined
05:54 JeanCarloMachado joined
05:55 pleax joined
05:56 takle joined
05:57 benl23 joined
06:01 RGamma joined
06:02 ahri joined
06:04 dec0n joined
06:04 <Axman6> sanitypassing: hmm, I'm surprised there isn't more info on the lambda calculus wikipedia page
06:05 JeanCarloMachado joined
06:06 ramzifu joined
06:07 <ahri> hi, i'm learning haskell by writing a bomberman clone. i was representing the "Board" as a [[Cell]] but as i need to change elements within that 2D list, i'm refactoring towards a (Seq (Seq Cell)) instead. that's going alright (especially with Views... man, that's awesome!) however my Show instance was: intercalate "\n" $ convertCellsToChars cells. what should my refactoring strategy be in order to go from
06:07 <johnw> how can I serve raw JSON in servant? That is, instead of having a data type Foo that I serve with Get '[JSON] Foo, I have a block of JSON text (that I've not decoded), that I just want to serve directly. If I serve it as Get '[JSON] Text, then servant escapes the JSON, making it invalid. Do I need to use an OctetStream?
06:07 <ahri> (Seq (Seq Cell)) to something "Show"able? i want to keep it reasonably performant as i want to use this function to display my game on the linux console. should i just "toList" it or is there a more nuanced approach i should take?
06:07 <Axman6> sanitypassing: http://www.cs.cornell.edu/courses/cs6110/2014sp/Handouts/Sestoft.pdf touches on some different strategies
06:08 dev_ joined
06:08 <Axman6> ahri: I would just use toList . fmap toList unless you have evidence that that is slowing your code down
06:09 <ahri> (i'm vaguely aware of the alternatives to String such as Text and ByteString but i've never used them and don't know if they're relevant to what i'm doing)
06:09 <Axman6> johnw: you just use Get '[JSON] Value
06:09 <johnw> thx, trying now
06:09 <Axman6> (where Value is the Aeson Value type)
06:09 <ahri> Axman6: cool, i've not done any testing yet, i just didn't want to do anything obviously stupid!
06:10 <sanitypassing> thanks, I'll take a look at that now
06:11 <Welkin> Cale: /quit
06:11 <Welkin> lol oops
06:11 <Axman6> hey, that's not nice
06:12 eacameron joined
06:13 DataComputist joined
06:13 uglyfigurine joined
06:13 dev_ joined
06:13 eacameron joined
06:14 DataComputist joined
06:14 takle joined
06:14 DataComputist joined
06:15 DataComputist joined
06:15 louispvb joined
06:16 DataComputist joined
06:17 louispan joined
06:18 Jesin joined
06:20 takle joined
06:21 Prutheus joined
06:21 castlelore joined
06:21 castlelore joined
06:21 shafox left
06:22 Jesin joined
06:22 Kim3 joined
06:23 Wizek joined
06:23 Wizek_ joined
06:24 nbtiwires joined
06:24 <nbtiwires> hello
06:25 fre joined
06:25 <liste> hello nbtiwires
06:25 <nbtiwires> I've built yesod sample following http://www.yesodweb.com/page/quickstart on ubuntu 14.04
06:26 <nbtiwires> but when I run stack exec -- yesod devel -p 3333, I'm getting "Executable named nix-shell not found on path"
06:26 takle joined
06:26 <nbtiwires> I cannot install nix, is there way to disable it?
06:27 JeanCarloMachado joined
06:28 <nbtiwires> Also I have nix: enable: false in ~/.stack/config.yaml
06:28 sanett joined
06:28 <nbtiwires> it didn't help
06:30 raichoo joined
06:30 systadmin joined
06:30 <Axman6> hmm, you might try #haskell-stack
06:32 systadmin joined
06:32 systadmin joined
06:34 hexagoxel joined
06:34 danvet joined
06:34 uglyfigurine joined
06:35 <nbtiwires> thx Axman6
06:36 a3Dman joined
06:37 fotonzade joined
06:37 insitu joined
06:41 systadmin joined
06:42 takle joined
06:44 YongJoon left
06:44 caumeslasal joined
06:47 halogena1dtoast joined
06:49 [scrooge] joined
06:49 YongJoon joined
06:50 ThomasLocke_ joined
06:50 ThomasLocke_ joined
06:51 mda1 joined
06:52 ThomasLocke joined
06:52 systadmin joined
06:54 zcourts joined
06:54 takle joined
06:54 Jesin joined
06:54 systadmin joined
06:55 meandi_2 joined
06:56 pleax joined
06:57 shafox joined
06:58 KamaKama joined
06:59 Dagnabit joined
06:59 JeanCarloMachado joined
07:00 takle joined
07:00 andyhuzhill joined
07:01 mkoenig joined
07:04 edsko joined
07:06 av joined
07:06 <av> good morning everyone, here's my question of the day:
07:07 <av> I've defined my own data type, operations on which create and use file(s) on the hard drive
07:08 <av> now when an instance of that data type gets garbage collected, I can make sure that all memory related to it is freed, but how do I make sure the temporary files are also deleted?
07:08 <av> what's the best/cleanest way of doing this?
07:08 fkurkows1 joined
07:08 takuan joined
07:09 jutaro joined
07:10 <KamaKama> Hi guys, just joined this channel. Learning Haskell. Hope to learn a lot from you guys.
07:11 <halogena1dtoast> Anyone use Yi, I've installed it, but I don't even know where to begin, I just have a window that says *console*
07:13 sivteck joined
07:13 vlatkoB joined
07:14 eacameron joined
07:14 sphinxo joined
07:14 Mortomes|Work joined
07:14 louispan joined
07:15 razi1 joined
07:15 <cocreature> av: you might be able to hack something together using StablePtr and ForeignPtr but usually tying external resources (such as temporary files) to the lifetime of some haskell data is not a good idea since you want to guarantee that external resources are freed at some point
07:16 <halogena1dtoast> Answered my question, the default is similar to emacs.
07:18 <halogena1dtoast> KamaKama: Good luck!
07:18 andyhuzhill joined
07:18 <halogena1dtoast> av: I agree with cocreature, for the most part, you should probably ignore the fact the GC even exists.
07:19 <halogena1dtoast> s/, for the most part/. For the most part/
07:20 mkoenig joined
07:21 <ongy> av: something like 'withTempFile :: (TempFile -> IO a) -> IO a' is usually better, since you can be sure that things are freed somewhat soon (but it's also more restricted)
07:22 vaibhavsagar joined
07:22 <av> cocreature: thanks for pointing out StablePtr, though I'm not sure how it's of any use in this case, but it might be useful in the future
07:22 <av> halogena1dtoast: thanks
07:23 <ongy> also, I doubt that all finalizers are run when the application ends, so you'd leave around some temporary files after execution aswell
07:23 <cocreature> av: foreignptr is the useful part, but you need something to point the foreignptr to and that could be a stableptr
07:23 <av> ongy: that's my other option, it makes the code a little more restricted, as you say, but that's probably just how it has to be, I'll probably go that route
07:24 <av> cocreature: yes, but I was alreay aware of ForeignPtr, but never heard of StablePtr :)
07:24 takle joined
07:24 bjz joined
07:25 t0by joined
07:25 t0by joined
07:27 kritzcreek_ joined
07:29 plutoniix joined
07:31 jhrcek joined
07:33 <ahri> i'm getting an error that confuses me: it says it's expecting Seq but getting ViewL on this line: "convertRow S.EmptyL _ = S.empty" -- have i misunderstood how the views work?
07:33 <jle`> ahri: can you put more context...?
07:34 <cocreature> you can’t just use ViewL in place of Seq, you need to call viewl first
07:34 <jle`> my guess is that convertRow's first argument should be a Seq but you're giving it S.EmptyL, which is a constructor for the ViewL type
07:34 <cocreature> you can use view pattern and to something like "convertRow (viewl -> S.EmptyL)"
07:34 robertkennedy joined
07:35 louispan joined
07:35 <jle`> @let import qualified Data.Sequence as Seq
07:35 <lambdabot> Defined.
07:35 <jle`> :t Seq.EmptyL
07:35 <lambdabot> Seq.ViewL a
07:35 <ahri> https://github.com/ahri/bombastic-hs/blob/master/src/Bombastic.hs#L160
07:36 <jle`> yes, you can use the 'viewl' function, like cocreature mentioned
07:36 <jle`> as a view pattern or using explicit pattern matching
07:36 <jle`> convertRow s coords = case viewl s of
07:36 <jle`> S.EmptyL -> S.empty
07:36 <jle`> c :< cs -> ...
07:37 <jle`> s/explicit pattern matching/explicit case statement
07:37 <ahri> https://gist.github.com/ahri/82bb0290487ac579efc2e8cb3395bb4e is the error, in case i was not clear. i'll try to tweak it as you say :) thanks!
07:37 raichoo joined
07:37 OnkelTem joined
07:37 <jle`> does view patterns optimize the case where the same view is used twice?
07:37 <cocreature> jle`: heh, I’ve just been wondering the same
07:37 <jle`> it'd be nice, but i am not sure if i trust the compiler to do that
07:38 <jle`> if it's an explicitly documented feature then that'd be nice
07:38 ubsan_ joined
07:38 <jle`> i think i've read about it somewhere but i can't recall :|
07:38 mszczygiel joined
07:39 <dmwit> "Efficiency: When the same view function is applied in multiple branches of a function definition or a case expression (e.g., in size above), GHC makes an attempt to collect these applications into a single nested case expression, so that the view function is only applied once."
07:39 <dmwit> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#view-patterns
07:39 oberstein joined
07:39 <cocreature> nice!
07:39 eacameron joined
07:39 <jle`> sweet
07:40 <cocreature> “makes an attempt” sounds like these might fail. under what conditions is GHC unable to do this?
07:40 <ahri> so... obviously i don't know what i'm doing, but i thought https://github.com/ahri/bombastic-hs/blob/master/src/Bombastic.hs#L1 meant that i could directly substitute for (x:xs) :\
07:40 <dmwit> cocreature: Read the rest of the paragraph. =)
07:40 <jle`> ahri: what about line 1 are you thinking about?
07:40 <ahri> i'm not familiar with language extensions at all though
07:40 uglyfigurine joined
07:41 <cocreature> dmwit: ah sry :)
07:41 castlelore joined
07:41 castlelore joined
07:41 <jle`> ahri: do you mean Pattern Synonyms?
07:41 <jle`> or View Patterns
07:41 <jle`> or {-# LANGUAGE ... #-} pragmas in general
07:41 <dmwit> ahri: You can read about the ViewPatterns extension at the link I posed above.
07:41 <dmwit> *posted
07:42 <jle`> or did you just highlight line 1 by accident
07:42 biglama joined
07:42 <ahri> erm, i hoped that the combination of those two extensions would allow a direct substitution based on something i read on stackoverflow. i'm clearly mistaken!
07:42 Ayey_ joined
07:42 <cocreature> PatternSynonyms would work
07:42 cardboard64 joined
07:42 <cocreature> but that would require EmptyL to be declared as a patern synonym
07:42 <jle`> pattern synonyms would let you if :</EmptyL were defined as pattern synonyms
07:42 <cocreature> it doesn’t magically substitute things
07:43 <jle`> which they werne't, unfortunately
07:43 <dmwit> To be fair, some extensions do magically substitute things.
07:43 <jle`> ahri: pattenr synonyms doesn't let you subistute types for other types
07:43 <jle`> but it lets you define custom abstract "constructor-like things" for types
07:43 seveg joined
07:43 <jle`> in another universe, Empty might have been defined as a pattern synonym for Seq
07:44 <jle`> and so you could directly match on Empty :: Seq a
07:44 <ahri> is https://github.com/ahri/bombastic-hs/blob/master/src/Bombastic.hs#L34-L36 what's required then? i pasted it in but didn't really understand what it's for, and the compiler complained so i got rid of it again
07:44 <jle`> but the key is that the type of Empty would be Seq
07:44 <jle`> oh, yeah, that should do it.
07:45 <jle`> it's not clear because of the missing type signatures, but Empty :: Seq a, and (:<) :: a -> Seq a -> Seq a
07:45 mkoenig joined
07:45 tfc joined
07:45 <jle`> so that's why you can use it to pattern match on a Seq
07:45 uncertainty joined
07:45 <jle`> but :< and EmptyL/EmptyR from Data.Sequence aren't defined as pattern synonyms; they are constructors for altogether different types, ViewL and ViewR
07:46 <halogena1dtoast> *sigh* I want to use language-c-inline but it looks like that project is kind of dead.
07:46 <jle`> ahri: i wouldn't use pattern synonyms in this case though
07:46 <liste> @inline-c -- halogena1dtoast ?
07:46 <lambdabot> Unknown command, try @list
07:46 <liste> @hackage inline-c -- halogena1dtoast
07:46 <lambdabot> http://hackage.haskell.org/package/inline-c -- halogena1dtoast
07:46 <liste> is that good?
07:46 <jle`> just using viewl and pattern matching on S.EmptyL and S.:< should be nice enough
07:47 <halogena1dtoast> oh no I've been ghosted...
07:47 <ahri> jle`: oh, ok, yes, i think it's clear that i'm trying to run before i can walk here...
07:47 <jle`> the reason why i shy away from pattern synonyms for this situation is that we don't have support for coverage annotations yet in GHC
07:47 <jle`> and i -Wall
07:47 <halogena1dtoast> inline-c doesn't support objc I think.
07:47 <jle`> there's no way to let GHC know that matching on Empty and x :< xs is exhaustive, and GHC will complain about an inexhaustive pattern match
07:47 <jle`> :'(
07:48 <halogena1dtoast> I guess I should have said I wanted to inline objc and not c.
07:48 robertkennedy joined
07:48 <Jello_Raptor> :/ the only type of bugs I've had in the past month that weren't caught by the type system were either me typing "f a b" when I meant "f b a" or "x" instead of "not x".
07:48 <jle`> pattern synonyms are a minor convenience here but they don't clean up anything too much imo
07:48 <halogena1dtoast> I want access to stuff in AppKit on OSX.
07:49 <ahri> jle`: oh that sucks as i'm heavily leaning on -Wall to force myself to question things a bit more
07:49 <jle`> you should -Wall
07:50 <jle`> it's because of this that i consider unidirectional pattern synonyms an incomplete feature
07:50 oberstein joined
07:50 Argue__ joined
07:50 <jle`> but yeah, if you're just learning, using a pattern synonym barely adds anything here heh
07:50 <jle`> using a view pattern like cocreature mentioned should already be plenty clean
07:50 mkoenig joined
07:51 <jle`> convertRow (viewl->S.empty) _ = S.empty
07:51 <halogena1dtoast> Another dead project seems to be HOC...
07:51 <jle`> convertRow (viewl -> c :< cs) coords = ...
07:51 sz0 joined
07:51 <jle`> or just using explicit case statements and function application like i mentioned earlier requires no extensions and is also fairly readable
07:51 <jle`> s/fairly/just as
07:52 _sras_ joined
07:52 hackebeilchen joined
07:52 <Cale> halogena1dtoast: this looks relevant https://github.com/mchakravarty/language-c-inline/blob/master/tests/objc/app/AppDelegate.hs
07:52 <jle`> the undesirable aspect of explicit application of viewl/a case statement is that it requires you to make up a name for the seq parameter
07:52 <jle`> whereas the view patterns and pattern synonym approaches don't
07:52 <halogena1dtoast> Cale: it does, but I can't seem to add language-c-inline in a way that makes stack happy
07:53 <halogena1dtoast> `language-c-quote-0.11.7.1 must match >=0.8 && <0.9 (latest applicable is 0.8.0)`
07:53 guiben joined
07:53 <_sras_> How can I make ghci to stop printing errors as soon as it prints the first one?
07:54 <jle`> i have some habit ingrained in me to avoid unnecessarily naming parameters, mostly because i'm very bad at picking names for parameters
07:54 <jle`> too many x', x'', x''', inconsistent choices for x/y/z and parameter names between similar functions v.v
07:54 <halogena1dtoast> jle`: that seems to be a common problem in the world of mathematics.
07:54 <ahri> jle`: good point about the naming :\
07:55 zcourts joined
07:55 <jle`> i have a bad habit of going out of my way to avoid ahving to name parameters to an extreme degree though
07:55 <jle`> so don't learn from my example :)
07:55 <jle`> i'm just discussing the tradeoffs
07:55 freusque joined
07:55 <ahri> i find it somewhat attractive to not use language extensions yet, though - as i'm early in my learning
07:55 uglyfigurine joined
07:56 udsbotu1 joined
07:56 <halogenandtoast> ahri: You'll break that habit really quickly.
07:56 <ahri> so i think i can live with having to name a variable
07:56 <jle`> it can help to sort of feature-freeze what you want to learn
07:56 <Cale> halogenandtoast: If you need it to work with a newer language-c-quote, you may have to edit its .cabal file and relax the version constraint (and then fix any resulting issues)
07:56 <jle`> learning normal haskell + extended haskell all at once can be daunting
07:56 <ahri> halogenandtoast: that's fine, i don't mind using them when i feel the pain :)
07:56 <jle`> s/can be/is undeniably
07:56 <Cale> Otherwise, the older one is still available from hackage
07:56 <halogenandtoast> jle`: True, but I've found that anytime I want to write something useful, I want language extensions.
07:57 pleax joined
07:57 <halogenandtoast> Cale: Do you mean editing language-c-inlines cabal file?
07:57 castlelore joined
07:57 <Cale> yeah
07:57 <jle`> yes, not saying language extensions aren't useful and a part of everyday haskell
07:57 <jle`> but just as a pedagogical process
07:57 <halogenandtoast> jle`: Even in my simple command line tool I used NamedFieldPuns and DeriveGeneric
07:58 <jle`> if you're learning anything, you usually start with learning a simplified subset and gradually expanding it
07:58 <halogenandtoast> I'm hoping one day NamedFieldPuns will just be baked in.
07:58 andyhuzhill joined
07:58 <ahri> halogenandtoast: i imagine you're approximately a million times better at Haskell than i am though ;)
07:59 <jle`> language extensions aren't bad, but it's reasonable to start with a subset of useful haskell and start gradually expanding it when you're comfortable
07:59 <jle`> just as a learning process
07:59 <jle`> nobody intends to stick with training wheels forever
07:59 <halogenandtoast> ahri: That's questionable, but I'm just saying not to fight against them
07:59 <Cale> halogenandtoast: It encourages people to shadow names, so it's sort of in a grey area for me. It's better than RecordWildCards at least, in that you get to see what you're binding
08:00 MoALTz joined
08:00 <halogenandtoast> Sometimes you'll write code and the compiler will say, "You can't do this without X extension"
08:00 <halogenandtoast> and so I just use the extension
08:00 <halogenandtoast> Rather than try to work around it.
08:00 <halogenandtoast> Cale: that's fair.
08:01 lambda-11235 joined
08:02 <jle`> some extensions you can turn on because they're how you expected things to have worked in the first place
08:02 <jle`> like TupleSections
08:02 <Cale> I usually will just bind the record to a single variable and then apply the field extractors to that.
08:02 <jle`> FlexibleContexts, FlexibleInstances
08:02 <ahri> halogenandtoast: ah yes, if i hit those scenarios i'm willing to naturally ease into using the ones the compiler says i should
08:03 thc202 joined
08:03 <jle`> like, those are extensions you just have to turn on you know that's how things are supposed to work, but haskell-the-language-spec is kinda bizarrely narrow
08:03 <jle`> > (,4) 10
08:03 <halogenandtoast> ahri: that's perfect then.
08:03 tomphp joined
08:03 <lambdabot> (10,4)
08:03 castlelore joined
08:03 castlelore joined
08:04 <Cale> good buddy
08:04 <jle`> i wouldn't say that TupleSections/FlexibleContexts/FlexibleInstances/etc. add language features as much as they let haskell match your expectations
08:04 <halogenandtoast> > flip (,) 10 4
08:04 <lambdabot> (4,10)
08:04 wei2912 joined
08:04 <halogenandtoast> I just wanted to try out lambdabot, that has no significance
08:04 variable joined
08:04 mkoenig joined
08:05 Cooler joined
08:05 <jle`> InstanceSigs too maybe
08:05 <pacak> halogenandtoast: you can /query lambdabot and try other stuff in direct message
08:05 <halogenandtoast> pacak: Thanks, that sounds less fun though.
08:06 fotonzade joined
08:07 <jle`> those are the only ones i can think of at the moment
08:07 CoolerExtreme__ joined
08:09 oish joined
08:09 <halogenandtoast> I feel like I see `ExistentialQuantification` a lot as well
08:09 <halogenandtoast> Although I don't quite understand it and have never used it myself.
08:09 Iskarlar joined
08:09 takle joined
08:10 <jle`> my list is just of extensions that fix unexpected surprises in the literal haskell spec, that make things work as you would have expected haskell to work
08:11 <halogenandtoast> I don't know why but I would have expected `forall` to be one of those things.
08:11 <jle`> ExistentialQuantification has its use cases, but it's more often the wrong solution heh
08:12 <halogenandtoast> I take that as useful insight in case I ever reach for it.
08:12 <jle`> ScopedTypeVariables would probably count as making haskell work the way you would have expected it to work
08:13 <jle`> like if you have a type variable 'a' in a top-level type signature, you probably would expect that all "a"s in the type signatures of bindings inside would refer to the same 'a'
08:13 <jle`> instead of always shadowing it
08:13 freusque joined
08:14 takle joined
08:14 vektorweg1 joined
08:15 xaviergmail joined
08:15 louispan joined
08:16 ragepandemic joined
08:16 alfredo joined
08:16 freusque joined
08:18 raichoo joined
08:19 cluzz joined
08:19 eklavya joined
08:19 Tharbakim joined
08:20 mmn80 joined
08:20 uglyfigurine joined
08:20 tkcrib joined
08:21 prophile joined
08:21 thibaud_ joined
08:22 FreeBirdLjj joined
08:23 albertid joined
08:24 xtreak joined
08:25 xtreak_ joined
08:26 xall joined
08:26 oish joined
08:28 mkoenig joined
08:29 <sphinxo> quit
08:29 sphinxo joined
08:29 <sphinxo> How do people feel about use of the maybe fn?
08:30 <halogenandtoast> sphinxo: it has its use cases
08:30 <Rembane> sphinxo: How come you ask?
08:30 <halogenandtoast> sphinxo: https://github.com/halogenandtoast/nhk-reader-haskell/blob/0ccc208436de326720355553d67495684d3a81ef/Model/Story.hs#L19
08:31 <Rembane> sphinxo: maybe is a oneliner, the case expression isn't. :)
08:31 cspollard joined
08:31 <sphinxo> ahh nice
08:32 sivteck joined
08:33 cspollard joined
08:33 louispan joined
08:33 <halogenandtoast> I also like `either` for its use cases
08:33 <halogenandtoast> https://github.com/halogenandtoast/nhk-reader-haskell/blob/f7a70f3acf51c2b66e8f9d206dc4a430bcef5847/Util/Redis.hs#L11
08:33 <halogenandtoast> https://github.com/halogenandtoast/nhk-reader-haskell/blob/6e28be090db17f9308ae74e82c74aa9b7e5c5fef/Util/Nhk.hs#L80
08:33 mkoenig joined
08:33 <Cale> They're nice in cases where you feel that you'll never have to return to that code
08:34 <Cale> When I start editing code, often the first thing that happens if there's a maybe or either is that it gets replaced by a case expression.
08:34 <Rembane> When you don't care about Nothing fmap is quite nice too.
08:35 robkennedy joined
08:36 cardboard64 joined
08:36 connrs joined
08:39 _sg joined
08:40 rgr joined
08:40 SpinTensor joined
08:41 <ezyang> lol I'm so awful, I made use of Functor (,) e
08:41 <Cale> Is that awful?
08:41 <ezyang> I think so! :)
08:41 <Cale> I've used its Traversable instance quite profitably
08:41 guiben joined
08:42 <Cale> performRequestsAsync :: (Traversable f, MonadWidget t m) => Event t (f XhrRequest) -> m (Event t (f XhrResponse))
08:42 <Cale> Picking f = (,) SomeTag
08:43 <Cale> will have the responses be tagged with the same value as the request when they come back in the future
08:43 <ezyang> i feel like it usually means you should have made a data type
08:43 <Cale> Which means that we don't need some special function for that case
08:43 <Cale> I dunno, I've just gotten used to thinking of pairs as containers with a label (the first part) and an element (the second part)
08:44 hdeshev joined
08:45 <Cale> Then again, sometimes you really do want a custom datatype with an instance of Functor for some reason anyway. I think if you start writing your own instances of other things, that's probably the right way to go.
08:45 zero_byte joined
08:46 <Cale> (rather than using some sketchy FlexibleInstances)
08:46 <Cale> I mean, instances with the first component fixed at something monomorphic
08:46 takle joined
08:47 <Rembane> Keep it simple?
08:47 <Cale> Weird, Chrome's element inspector seems much much slower today than yesterday.
08:49 dcoutts_ joined
08:50 <cardboard64> anyone familiar with scotty here?
08:50 <Cale> How familiar do you need?
08:50 <Cale> (better yet, just ask a question)
08:50 <ph88_> how can i upgrade a global installed package with stack ?
08:50 <Cale> ph88_: I don't think stack does that?
08:51 takle_ joined
08:51 <Cale> Could be wrong, I haven't really found any opportunity to use stack
08:52 <ph88_> when you install a package outside of a stack directory it's installed in the global project
08:52 <kadoban> ph88_: In what context are you using the package? You just change what you are depending on, usually in the stack.yaml file you'd specify it as an extra-dep, or change the extra-dep or whatever.
08:52 <kadoban> ph88_: That's more of an accident of implementation than anything, AFAIK. 'stack install' is supposed to be for installing the executables that a package contains.
08:52 <ph88_> maybe i need to update the resolver to update the packages ?
08:52 <Cale> ph88_: Does it have a command to remove the package?
08:53 <ph88_> Cale, there is no remove/uninstall command
08:53 <cardboard64> I'm trying to use sqlite-simple with scotty, but I have a type error I can't solve: https://zerobin.net/?353c9b8d4408c816#6m0bSkHLKB057Ll6KTKaILYWNrLChEqVGjZkaD21UV8=
08:53 <Cale> ph88_: right, when I tried that, it told me that it doesn't manage installations in global locations
08:54 eacameron joined
08:54 uglyfigurine joined
08:55 <Cale> cardboard64: I don't need to be familiar with Scotty to tell you that you need liftIO
08:55 <Cale> liftIO $ createAuthor ...
08:55 ph88 joined
08:55 <Cale> liftIO turns an IO action into an action in some other monad (which will necessarily be built in terms of IO somehow)
08:55 zcourts joined
08:55 <Cale> :t liftIO
08:56 <lambdabot> MonadIO m => IO a -> m a
08:56 moongazer joined
08:56 <Cale> In this case, you want an action of the monad ActionT Text IO
08:56 <halogenandtoast> by "which will necessarily be built in terms of IO somehow" do you mean "which will necessarily be built in terms of MonadIO somehow"
08:57 <Cale> Well, any good instance of MonadIO will involve IO itself internally in some fashion
08:57 <halogenandtoast> I'm asking to clarify my understanding, not saying you're wrong.
08:57 marfoldi joined
08:58 pleax joined
08:58 <kadoban> ph88_: In what context are you trying to use the package in question?
08:58 <Cale> This is just because IO is an opaque data type -- there's no way to pick apart IO actions and interpret them yourself somehow.
08:58 <cardboard64> I've already tring using liftIO, but then I get another error: https://zerobin.net/?cad9419194158634#KUIunNvAU2zX9Q8n9QDrBAa6siIVBgcwHZY5rVwZPZI=
08:58 <Cale> (there could be in principle, but there isn't)
08:58 <ph88_> kadoban, oh sorry i was mistaken the package was not added to lts, i need to download it first https://github.com/jameysharp/corrode#alternate-instructions-stack
08:58 <halogenandtoast> Cale: I'd assume it would be up to the compiler
08:59 <Cale> cardboard64: It doesn't know what types name, pass, pic, and desc are supposed to have
08:59 Miroboru joined
08:59 takle joined
08:59 <Cale> cardboard64: and so it doesn't know which parser to use for param
08:59 <cardboard64> they are supposed to be Text
08:59 <Cale> cardboard64: Using those variables in a way which makes it clear they're Text should fix that
08:59 <Cale> For instance, just adding an explicit type signature to createAuthor ought to fix it
08:59 <halogenandtoast> cardboard64: Cale is on point.
09:00 <Cale> Something like createAuthor :: Text -> Text -> Text -> Text -> IO ()
09:02 <Cale> I would typically feel slightly embarrassed typing that because of all the indistinguishable Text parameters, and would probably want to define a new record data type as soon as convenient, so that it could be something like createAuthor :: Author -> IO ()
09:02 BartAdv joined
09:03 <ph88_> kadoban, i follow the instructions, do you know why this happens ? https://bpaste.net/show/54417bbab64c
09:04 balor joined
09:04 <ph88_> corrode uses lts-6.6 which has the right version of language-c https://www.stackage.org/lts-6.6/package/language-c-0.5.0
09:04 andyhuzhill joined
09:05 <ph88_> i don't know where the requirement of ==0.6.* comes from
09:05 <halogenandtoast> Cale: Would that be a higher-kinded type?
09:05 <halogenandtoast> Again checking my terminology here.
09:05 <Cale> no, just a plain record with 4 Text fields
09:05 <kadoban> ph88_: It looks like the maintainer of that package updated the requirements in the .cabal file and never fixed the stack.yaml.
09:05 <Cale> Nothing fancy at all, kind would be *
09:05 <halogenandtoast> Cale: True, fair enough.
09:05 <kadoban> ph88_: The reslover that's set in the stack.yaml file gives language-c = 0.5.0 The .cabal file requires language-c >= 0.6
09:06 <cardboard64> it works now, thanks!
09:06 <ph88_> ah yes i see it now, i will open an issue
09:06 <kadoban> ph88_: Or it was broken in the first place, I didn't check the history. But that's my guess.
09:06 <Cale> cardboard64: great!
09:07 eacameron joined
09:07 ptek joined
09:08 TheEpsylon joined
09:08 faberbrain joined
09:08 Tuplanolla joined
09:08 uglyfigurine joined
09:10 <Cale> A really solid rule of thumb is that any time it's hard to tell what a parameter to a function ought to mean based on its type alone, it's strongly worth considering defining a new data type for the parameters to your function - obviously a bit of taste is required, but you could do worse than to apply that rule blindly.
09:11 pleax joined
09:11 <halogenandtoast> Cale: That's a good rule of thumb.
09:16 stpl joined
09:17 dunx joined
09:18 merijn joined
09:19 <stpl> hi, I was trying create my own type class, where on of the instance throws an error and forces to enable FlexibleInstances. I'm trying to achive the funcationality without using FlexibleInstances. Can someonw help. this is my code http://lpaste.net/353522
09:21 <ezyang> FlexibleInstances is pretty harmless
09:21 <merijn> stpl: That example isn't going to work as-is, since the instance on line 22 overlaps with everything
09:21 <ezyang> oh but that's not going to help you
09:22 \rand joined
09:23 <infinity0> typeclassopaedia says "Someone in the #haskell IRC channel used (***), and when I asked Lambdabot to tell me its type, it printed out scary gobbledygook that didn’t even fit on one line! Then someone used fmap fmap fmap and my brain exploded."
09:23 <infinity0> what's this in reference to
09:23 <infinity0> Prelude Control.Arrow> :t (***)
09:23 <infinity0> (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
09:23 <infinity0> that seems ok to me
09:24 <merijn> infinity0: Well, then clearly you've transcended and become a Haskell adept :)
09:24 <infinity0> well it fits on one line :) was wondering if there was some older thing with less clean constraints or something
09:24 <merijn> Naah
09:24 <merijn> It's mostly "oh god, the large number of type variables!"
09:25 <merijn> infinity0: Also, some people find it counter-intuitive/hard to see that 'a' can be '->'
09:25 tomphp joined
09:25 <infinity0> ah ok
09:27 <infinity0> fmap fmap fmap is easier to understand rewritten as \f -> fmap (fmap f) and similar for the (.).(.) boob tricks
09:28 <merijn> infinity0: Honestly, like many things in Haskell those two things aren't fundamentally difficult
09:28 <infinity0> yeah, for me it just takes actively playing with the expressions and refactoring into stuff that "looks" more familiar but turns out was actually the same
09:28 takle joined
09:28 <merijn> infinity0: It is, however, not uncommon for people to gloss over how the types work and getting a feeling for how to unify them in your head, to sort of see how things fit together. And obviously, if you skip that or some other fundamental steps things look very confusing
09:29 systadmin joined
09:29 Miroboru joined
09:29 <merijn> infinity0: Right, if you make a habit of doing that, you will find out that, except for the latest bleeding-edge extensions most things are pretty predictable and simple
09:30 <merijn> infinity0: Lemme also take the time to recommend reading the actual Haskell Report. It's an incredibly readable language spec and once you get past the "beginner syntax" levels of haskell you can learn a lot from it
09:30 <infinity0> oh cool, thanks
09:30 <merijn> @where report
09:30 <lambdabot> http://www.haskell.org/onlinereport/haskell2010/ (more: http://www.haskell.org/haskellwiki/Definition)
09:31 <merijn> infinity0: Especially if you've ever seen the insanity that is ISO C, you'll be surprised how readable a spec can be :p
09:31 xtreak joined
09:32 <infinity0> yes i'm familiar enough with c/c++ to know that i don't want to be more familiar with them, and likewise unfortunately for some other languages :(
09:32 dunx_ joined
09:33 <merijn> Haskell Report and R6RS are up there as "shining beacons of what language specs should aspire to be" :p
09:37 whald joined
09:38 mfukar joined
09:38 eugenez joined
09:40 robertkennedy joined
09:41 <eugenez> Hello, friends! I often end up having to go over the list and apply some function on n and n+1 elements of the list consecutively, is there any simpler way to do that? I usually do map (\(x,y) -> ...) $ zip <*> tail xs
09:41 FullyFunctional joined
09:41 hexagoxel joined
09:41 uncertainty joined
09:41 FreeBirdLjj joined
09:42 oish joined
09:42 <Rembane> eugenez: zipWith, but the tail remains.
09:42 <kgadek> eugenez: zipWith
09:43 uglyfigurine joined
09:43 <eugenez> Thank you!
09:43 <merijn> See the usual neat fibonacci example ;)
09:43 Guest24575 joined
09:43 <merijn> > let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in fibs
09:43 <lambdabot> error:
09:43 <lambdabot> Ambiguous occurrence ‘zipWith’
09:43 <lambdabot> It could refer to either ‘Data.List.zipWith’,
09:43 <merijn> wut
09:43 <kgadek> eugenez: btw, I think that's one of the things that hlint will happily suggest
09:44 <merijn> @undefine
09:44 <lambdabot> Undefined.
09:44 <merijn> > let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in fibs
09:44 <lambdabot> [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,...
09:46 FreeBirdLjj joined
09:46 Phyx- joined
09:48 Renesat joined
09:48 fweth joined
09:48 Sampuka joined
09:50 Iskarlar joined
09:50 balor joined
09:51 <eugenez> btw, is there some trick or version of scanl/fold for example where instead of acc you have n-1th element ?
09:52 systadmin joined
09:53 trolling joined
09:54 marr joined
09:54 ub joined
09:56 ramzifu joined
09:56 zcourts joined
09:57 <Cale> eugenez: zip xs (tail xs)?
09:57 <ph88_> in ghci how do find out the type of the exception ?
09:59 oish joined
09:59 pleax joined
09:59 sanett joined
09:59 phaji joined
10:01 <Cale> ph88: Let me know if you find a really good way. You kind of just have to know it.
10:01 <Cale> Which exception is it?
10:02 Nik05 joined
10:02 <Cale> ph88: A lot of the basic things you'll run into will be of type IOException
10:03 jaspervdj joined
10:03 <Cale> At least, the ones you're likely to want to catch
10:03 takle joined
10:03 Rizy joined
10:03 farao joined
10:05 <farao> hi, I'm looking for a function that takes a Map and paritions it in n pieces, does anyone know if there is a library function that helps? I have only found "partition" but it takes a filter function instead of a number of partitions and produces only 2 partittions
10:06 pleax joined
10:08 <ongy> farao: then by what metric would you want the map to be devided? Same size chunks?
10:08 eacameron joined
10:08 <ph88_> Cale, ok i will let you know if i find a way
10:08 soLucien joined
10:08 <farao> ongy: equal size (more or less). I don't even really care which entries go into which partitions
10:09 uglyfigurine joined
10:09 <ph88_> in php i code put code like this https://bpaste.net/show/34e42f91ee45 i read here http://stackoverflow.com/a/6009807 that in haskell i can also check the type of the exception with tryJust, is it possible to get similar syntax as php where it tries a few types of exceptions and then goes to the default case ?
10:09 <ahri> i've got a problem with my cabal file, and the error stack gives me is confusing me: "containers-0.5.7.1 must match >=0.5.8 && <1 (latest applicable is 0.5.10.1)" -- i understand that i have 0.5.7.1 installed, but if it found a "latest applicable" version that fits my predicate, why doesn't it upgrade to that version?
10:10 <ahri> i assume i'm misunderstanding the error
10:11 allenj12 joined
10:11 <ph88_> ahri, which stack resolver are you using ?
10:12 <Cale> ph88: You can nest a bunch of uses of handle or catch
10:12 <ph88_> how can i nest them without the code getting ugly ?
10:12 <ph88_> i think php has nice syntax here
10:12 <zomg> ph88_: it would probably be easy to do if you can group your error into a data type, Err1 | Err2 | Err3, then you could pattern match on the errors you care about
10:13 <Cale> `catch` \(e :: Foo) -> ...
10:13 <Cale> `catch` \(e :: Bar) -> ...
10:13 <Cale> etc.
10:13 <ph88_> ok i will try it
10:13 augur joined
10:13 nilof joined
10:13 <Cale> If you look for `catch` on https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Exception.html you'll find some like that
10:14 <Cale> oh, yeah, there's also catches
10:14 <Cale> which might be better (for reasons given on that page)
10:14 <ahri> ph88_: i'm not sure; how can i find out? (i'm a bit new to haskell)
10:14 <ph88_> ahri, look in stack.yaml file
10:14 <Cale> also note that if you have standard ways to handle the errors, you can make a definition of a new function that does that
10:15 <ph88_> Cale, i think you are refering to this piece https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Exception.html#v:catches
10:15 <Cale> yeah
10:15 <Athas> Is it usual to see parallel Haskell programs have very high CPU utilisation, even when there is no parallelism in the program?
10:15 <ahri> ph88_: ah! lts-7.5
10:15 <ph88_> ahri, look here https://www.stackage.org/lts-7.5/package/containers-0.5.7.1
10:15 <ahri> sorry, i went over the cabal file and couldn't find it. silly me :\
10:15 <Cale> Athas: Well, what makes it a parallel Haskell program if there's no parallelism?
10:16 <ph88_> ahri, you have to upgrade your lts version to get new version of containers
10:16 gregman_ joined
10:16 <Athas> Cale: running it with +RTS -N.
10:16 <Cale> and building with -threaded?
10:16 <Athas> Rather, there is *some* parallelism, early in the program, but the program keeps having very high multi-core utilisation even later on.
10:16 <Athas> Yes.
10:16 <Cale> Well, the garbage collections will be parallel at least
10:17 mkoenig joined
10:17 <Athas> Yeah, I guess that could be it.
10:17 <ahri> ph88_: oh no, looks like it's only available on hackage, not stackage. i guess i'll have to do my own bounds checking + "index", rather than using "lookup"
10:17 <Athas> I thought it didn't really pay off, though.
10:17 <ph88_> ahri, eh actually that's not true, because i check the latest lts for you https://www.stackage.org/lts-8.5/package/containers-0.5.7.1 and here it's still on the same containers version, so you must manually override the version of the lts by specifying extra-deps in your stack.yaml file
10:17 <Cale> Athas: Well, GHC's garbage collector is parallel
10:17 <ph88_> ahri, you can get newest version from hackage with stack if you specify it in extra-deps
10:17 <Cale> (but it's also stop-the-world)
10:18 <ahri> ph88_: oh, cool. i'll give that a whirl!
10:18 <ph88_> ahri, can you do everyone a favor and open an issue here https://github.com/haskell/containers and ask if they can upgrade the containers package on stackage ?
10:18 <Cale> I wouldn't expect that to produce "very high" CPU usage for most programs
10:18 rcat joined
10:18 <Cale> Usually the amount of time spent in the GC is a pretty small fraction
10:19 pleax joined
10:19 sphinxo joined
10:19 <Cale> There's also the potential for foreign calls to execute at the same time as Haskell code is evaluating that way
10:19 <ahri> ph88_: absolutely. also, wow, that was way easier than i thought it might be :D
10:19 <Athas> There are no foreign calls in this program. I guess it does generate a large amount of garbage, though, so that seems the likely explanation.
10:19 DataComputist joined
10:20 <Athas> But this mostly-sequential program is pegging three-to-four cores for most of its run.
10:20 <Athas> It must be spinning a lot.
10:20 <Cale> Athas: There's a tool called threadscope you might want to try
10:20 <merijn> Athas: Actually, high amount of garbage wouldn't take many GC cores
10:20 <Cale> https://wiki.haskell.org/ThreadScope
10:20 <merijn> Athas: It's lots of non-garbage that would use lots of cores
10:20 <merijn> Cale: I've never been able to reliably build that :\
10:21 <Athas> Well, it's not a big problem for me, yet. I was just curious about whether I'm messing something up badly.
10:21 <ph88_> Cale, is there a default type for Exceptions? in PHP there is a type Exception from which ALL exceptions must inherit
10:21 <Athas> I'm not very experienced at parallel Haskell, really.
10:21 <merijn> ph88_: SomeException is a wrapper for all exceptions
10:21 <Cale> I've managed to successfully build it a couple times... but it's just enough trouble that it's not something I usually have handy
10:21 <ph88_> ok thank you merijn
10:21 <Cale> ph88: SomeException
10:21 <Cale> ah, yeah, already answered :)
10:22 <merijn> Cale: Too slow ;)
10:22 unK_ joined
10:22 <Cale> ph88: You might want to take a close look at the Exception type class
10:22 <ahri> ph88_: issue logged. thanks a bunch for your help :)
10:22 <ph88_> np
10:22 <Cale> It's actually pretty interesting how it works
10:22 uncertainty joined
10:22 deepfire` joined
10:23 <Athas> I can't decide whether the Haskell exception system is elegant or a hack.
10:23 <Cale> Basically, the important bit is fromException :: (Exception e) => SomeException -> Maybe e
10:23 <Cale> It's elegant, but Haskell programmers are usually picky enough that they don't find a lot of uses for throwing exceptions.
10:23 <merijn> Athas: It's nice, the only problem is lack of checked exceptions
10:23 <ph88_> well for a novice it's a bit confusing with all the ways to handle errors http://blog.ezyang.com/2011/08/8-ways-to-report-errors-in-haskell-revisited/
10:23 <Cale> Well, we sort of do have checked exceptions
10:23 <ph88_> i was gonna try openFile and then catch exceptions
10:24 uglyfigurine joined
10:24 <merijn> Cale: Not in the "transparently propagated up" kind
10:24 <Cale> Well, there are various monads you can employ for that... depending on your definition of "transparently"
10:24 tommd joined
10:25 <merijn> Cale: I can't pass an expression of type Int that might throw division by zero to a function expecting Int and infer that this function might throw "division by zero"
10:25 <Cale> Well, okay
10:25 <Cale> and division by zero is of a sort of exception that you wouldn't ever want to catch in Haskell
10:25 <merijn> Cale: I've been sketching (with large breaks) a language where you could do that, but I'm not sure how well it could ever be retrofitted into haskell
10:25 <Cale> Exceptions thrown by expression evaluation aren't worth trying to catch
10:25 <merijn> Cale: Not in Haskell's current design, no
10:26 <merijn> Cale: Which IMO is a flaw in Haskell's design, not in throwing expressions
10:26 <ph88_> Cale, in that example of catches what do they mean with handleIO ex ? is that just a placeholder for a function that the user is suppose to write ?
10:26 <Cale> merijn: Well, there should almost be another word for them
10:26 <Cale> merijn: Those exceptions are sort of a different kind of thing altogether from exceptions thrown by execution of IO actions
10:26 raduom joined
10:26 <merijn> Cale: Are they, though?
10:27 <merijn> Cale: Why?
10:27 <ph88_> merijn, if you want to infer that the function might throw division by zero doesn't that go into the realm of dependent types ?
10:28 <ongy> exceptions from pure code with laziness are a bit different
10:28 mou joined
10:28 xtreak joined
10:28 <Cale> merijn: Well, personally, I think of exceptions thrown from evaluation as being like a fast way to run forever.
10:28 augur joined
10:28 <Cale> We could have written fix id
10:29 <Cale> But instead we're doing something that gives you some indication the program is fundamentally broken.
10:29 <Cale> Catching such exceptions will violate the usual referentially transparent semantics of expression evaluation.
10:30 <ph88_> i put import Control.Exception (catches, Handler) and ghci still gives Data constructor not in scope Handler Perhaps you want to add ‘Handler’ to the import list in the import of ‘Control.Exception’ i don't understand, i already put it in the import list
10:30 <Cale> and doing it reliably at all requires making some low-level assumptions about how evaluation and execution get interleaved
10:30 <Cale> (Control.Exception.evaluate helps a bit, but only if the thing wasn't already evaluated!)
10:30 <merijn> Cale: In waht way does it violate referential transparency?
10:30 hello joined
10:31 danza joined
10:31 <merijn> Cale: No, it just means you need to propagate the exception to everywhere the lazy value gets propagated
10:31 <Cale> merijn: Well, which exception gets thrown from an expression will depend on the evaluation order.
10:31 <merijn> Cale: i.e. "f :: Int -> Bool" needs to infer that if I pass in a throwing Int, 'f' returns a throwing Bool
10:31 sidei joined
10:32 <merijn> Cale: How is that different from the current bottom semantics?
10:32 <Cale> and the evaluation order may depend on the external context
10:32 <Cale> The one where we identify all the exceptions and infinite loops with _|_?
10:32 <merijn> Cale: If I pass in undefined the result also depends on evaluation order (if you distinguish bottoms) or just 'bottom' if you don't
10:33 Iskarlar joined
10:33 louispan joined
10:33 <merijn> Cale: Right, but why is that semantics impossible with checked exceptions?
10:33 <Cale> You don't distinguish them, if you want a denotational semantics rather than just an operational one
10:34 <Cale> Because which exception you hit first lets you determine things about how your value was consumed
10:34 <merijn> Cale: How is this different from the current imprecise exception semantics we have?
10:36 <Cale> How is what different from it? I'm describing what happens when you let expression evaluation just throw exceptions from anywhere: if you want the semantics to capture information about which exception you'll obtain, it becomes operational
10:36 <Cale> (or I suppose you could have a nondeterministic semantics)
10:37 <merijn> Cale: How is what you're describing "I can tell what was evaluated first" different from the current semantics of imprecise exceptions?
10:37 <Cale> We usually don't want to tolerate thinking operationally about Haskell evaluation unless we *really* have to
10:37 <Cale> I'm not describing anything that doesn't already exist.
10:38 <merijn> Cale: Right, so if it exists, then what's the issue with making the compiler check it at compile time?
10:38 <Cale> To understand which exceptions you'll catch when they're thrown by evaluation of an expression, you need to understand the expression in an operational way.
10:39 <merijn> Cale: Why?
10:39 <Cale> Well, I wasn't really talking about an issue with checking
10:39 <Cale> I was talking about an issue with actually making use of catching exceptions from otherwise-pure expressions.
10:39 <merijn> Cale: Then I don't understand what you're arguing. You don't disagree with checking, you agree that we can already do this
10:40 eacameron joined
10:40 <merijn> Cale: That's all fine and well in theoretical fairy land. But I'm sick and tired of having libraries throw exceptions in my face that I don't know can happen
10:40 <Cale> Well, the thing I was originally trying to argue for was that exceptions thrown by expression evaluation are a different sort of thing from exceptions thrown from IO execution
10:40 <merijn> Because no one bothers to document edge cases
10:41 takle joined
10:41 <Cale> I would be *reasonably* content if there were no way at all to catch such exceptions, apart from the fact that it might bite me when using some poorly designed proprietary library
10:41 <merijn> Cale: I disagree, since from the perspective of pure code those expressions are just bottom
10:41 <Cale> (but already, I'd fork someone's project over catching an exception thrown from evaluation)
10:42 <merijn> Cale: So why does it matter if we can observe them in, e.g. IO?
10:42 <Cale> I'm not saying it hurts things all that much -- it's a pragmatic escape hatch to have
10:42 <merijn> Cale: It doesn't restrict evaluation order at all, it just means that at runtime we MIGHT observe a specific order of evaluation from IO
10:42 <Cale> But designing your programs that way is terrible
10:43 <Cale> Because you end up caring about the operational semantics of evaluation in ways that make the program fragile to changes in e.g. compiler optimisations
10:43 <merijn> Cale: I'm not advocating the use of throwing expressions. But either we don't have them (which is unrealistic unless you go to a total language) OR we have reasonable tooling for dealing with them
10:43 oisdk joined
10:43 <merijn> Cale: I disagree
10:43 uglyfigurine joined
10:43 deepfire` joined
10:44 <Cale> Compiler optimisations can and do change the evaluation order
10:44 <Cale> and can change which exception will get thrown from the evaluation of an expression
10:44 <merijn> Cale: If I have an expressions that can throw any exception E from some set of exceptions, I don't get to care about order "oh, E1 will never happens since E2 gets thrown first"
10:44 <merijn> Cale: So?
10:44 <Cale> You might -- people do that kind of thing in ML
10:44 <Cale> and get away with it
10:45 <merijn> Cale: Like I said, you get to observe a specific evaluation order that happened at runtime. That doesn't mean your semantics have to depend on that ordering
10:45 <Cale> (because they think operationally about evaluation all the time)
10:45 <Cale> People use exceptions to indicate success :)
10:45 <merijn> Cale: Even if, at runtime, the evaluation order is a coin flip between exception E1 and E2, how does knowing that both E1 and E2 might get thrown 1) restrict the compiler 2) harm my reasoning about the program 3) restrict/hurt the semantics
10:46 <ph88_> this is my program so far with the data constructor Handler not in scope ?! https://bpaste.net/show/18c27719bf26
10:46 <Cale> Well, depending on which exception gets caught, you will carry on with a different situation.
10:46 <Cale> and the rest of the program might behave differently
10:46 <Cale> So to understand what the program will do, you need to know which exception will be caught
10:47 <merijn> Cale: But if we have our handler in IO how is that different from what we have now?
10:47 o`connor joined
10:47 <Cale> It's not different from what we have now. I'm describing something that's bad about what we have now
10:47 ramzifu joined
10:47 <Cale> But which culture discourages us from exploiting
10:47 <merijn> Cale: That's bogus. That's like saying I need to know what number input I get from stdin to predict what a program that reads a number and checks if it's even does
10:48 <ahihi> ph88_: you've imported the type, but not its data constructor. try e.g. Handler(..)
10:48 <ph88_> ah yes that helps :P
10:48 mkoenig joined
10:49 <Cale> Well, you know that whatever you read from stdin is going to be the number that was provided to the program as input. It's not just random chance or the whim of some low level detail of your compiler
10:49 <merijn> Anyway, I need to take a break from this and somehow beat this python code into working
10:50 <Cale> If you test a program which catches exceptions thrown from evaluation, you might find that it works. Then you upgrade your compiler, and some evaluation happens sooner by accident, before the handler happens, and now your program crashes.
10:50 <ph88_> what is handleIO supposed to be here ?? https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Exception.html#v:catches
10:50 <Cale> This isn't terribly likely, but it's possible.
10:50 <ph88_> i tried making my own function for it handleIO ex = putStrLn "something here" but that doesn't type match
10:50 [swift] joined
10:50 <merijn> Cale: How could it happen before the handler happens without a compile error?
10:51 <merijn> Cale: And if the compiler isn't tracking that, then we still don't have what I'm arguing for
10:51 <Cale> merijn: Because the compiler arranged to evaluate something a bit sooner. Perhaps the strictness analyser was improved.
10:51 <merijn> Cale: That mistaken can only happen in the current setup, because the current setup is stupid
10:51 aib joined
10:51 c-rog joined
10:52 <Cale> ph88: Well, it's got to return something of the same type as the original action that it's catching an exception for
10:52 <merijn> Anyway, some other time :)
10:52 thc202 joined
10:52 <Cale> catches :: IO a -> [Handler a] -> IO a
10:52 <Cale> ^^ the a's have to match
10:53 chaptastic joined
10:53 Levex joined
10:54 mkoenig joined
10:54 seveg_ joined
10:55 kosorith joined
10:55 silver joined
10:55 ggVGc joined
10:55 ggVGc joined
10:56 systadmin joined
10:57 uglyfigurine joined
10:57 zcourts joined
10:57 sivteck joined
10:58 deepfire` joined
10:59 fetter_oml joined
11:00 <ahri> holy crap. i just used a monadic bind to solve an actual problem and it actually solved my actual problem. time for a celebration drink. this haskell stuff isn't so crazy after all!
11:00 Iskarlar joined
11:01 <zomg> ahri: I'm using a functor-inspired pattern to solve something different in JavaScript (and our codebase is far from FP style JS), so I wouldn't say Haskell stuff is crazy at all =)
11:02 lavalike joined
11:02 Snircle joined
11:03 descender joined
11:04 <ahri> hehe, i'm kidding, it's just taken me a while to find my own problem to solve involving monads, so until now i've been a bit scared of them
11:04 ramzifu joined
11:05 <cspollard> hey does anyone know of a (nominal+variations) structure already available?
11:05 <ongy> ahri: one of my favorite moments was when I got my first (non-trivial) monad instance done and could clean up quite a bit of other code
11:05 <cspollard> i.e. data Tmp b a = Tmp a (Map b a)
11:06 <Cale> cspollard: There's a really old package http://hackage.haskell.org/package/total-map
11:07 <cspollard> where x <*> y "fills in" the default value if keys are missing in the two maps
11:07 <Cale> But it's probably still fine
11:07 eacameron joined
11:07 <cspollard> thanks will have a look!
11:07 <Athas> Cale: that package is not even a year old!
11:07 <Athas> Does Haskell move that quickly nowadays?
11:08 <Cale> Oh, sorry, I read the wrong date :)
11:08 <Cale> The copyright wasn't updated
11:08 <Cale> 2012 would be quite old by now
11:08 <Cale> May 2016 isn't so old ;)
11:09 pleax joined
11:09 <cspollard> hm the applicative instance is not so easy to comprehend ;-)
11:10 faberbrain joined
11:10 <* ongy> really needs a commit-hook that autofixes copyright notices in source files...
11:10 louispan joined
11:12 sanett joined
11:12 c-rog joined
11:12 <Cale> cspollard: Well, given some fs :: TMap k v, it helps to see that (!) fs :: k -> v is the corresponding ordinary function
11:14 <Cale> cspollard: and tabulate, given a default value, a set of points to measure, and a function, produces a TMap which potentially varies from the default at the given points by having the given function's value there
11:14 <Cale> So it just uses tabulate with the default just being the default function applied to the default argument
11:15 <cspollard> got it
11:15 <Cale> and the set of keys to tabulate at being the union of the set of keys on which function might vary and the value might vary
11:15 tabaqui1 joined
11:16 <cspollard> I suppose this might predate Data.Map.mergeWithKey, which is what I have in my implementation
11:16 <cspollard> and if I'm not mistaken does the same thing
11:17 <cspollard> Cale: (sorry have not been tagging you)
11:17 ggVGc joined
11:17 ggVGc joined
11:17 <Cale> It might, but also there's a much newer bunch of stuff in containers which you might prefer to use instead of mergeWithKey
11:17 <Cale> http://hackage.haskell.org/package/containers-0.5.10.1/docs/Data-Map-Merge-Lazy.html
11:18 JeKs joined
11:19 worch joined
11:19 eklavya joined
11:19 Rizy joined
11:19 <cspollard> Cale: damn not available in my current stack snapshot
11:19 yellowj joined
11:20 <cspollard> Cale: but thanks for the link I will keep this in mind in the future
11:21 harfangk joined
11:22 <Cale> Yeah, it's quite new, I bugged dfeuer to implement something to solve the general problem of merging maps efficiently in various ways -- there are a lot of various Map operations which come up in our real world applications.
11:22 <Cale> It implements the operations by simultaneously walking down both tree structures, and uses the tactics you give it to decide what to do.
11:22 sidei joined
11:22 <Cale> So it'll be rather efficient generally :)
11:23 shayan_ joined
11:23 uglyfigurine joined
11:24 JeanCarloMachado joined
11:24 <eugenez> Friends! Is there a conditional iterate, that applies function until result "converges" so to speak and stops changing?
11:24 mkoenig joined
11:24 <Cale> Not in the Prelude at least
11:25 <Cale> You might just take the list you obtained from iterate
11:25 <Cale> and zip it with its own tail
11:25 <Cale> and then takeWhile (\(x,y) -> x /= y)
11:26 <eugenez> Cale: Yep, I was thinking of doing something like that, thank you very much!
11:26 <Cale> or some other condition which indicates convergence, like (\(x,y) -> abs (x - y) < epsilon)
11:26 worch joined
11:27 sword865 joined
11:28 <Unhammer> http://bildr.no/image/dHVDMkU2.jpeg
11:28 cschneid_ joined
11:28 <Unhammer> – not confidence inspiring
11:28 Miroboru joined
11:29 <Cale> oh, that's odd
11:29 moongazer joined
11:29 <Cale> I just get "Time limit exceeded" for that -- which is also very strange.
11:30 <Cale> > putStrLn "hi"
11:30 <lambdabot> <IO ()>
11:30 <Cale> ^^ Would have expected something like that
11:30 <Unhammer> http://bildr.no/image/dkZ5K1lW.jpeg
11:30 <Unhammer> there we go
11:30 yoneda joined
11:30 <Unhammer> even better
11:30 xaviergmail joined
11:30 fragamus joined
11:30 deepfire` joined
11:30 <Cale> I wonder what they have in scope in the sandbox
11:31 <Cale> IO actions aren't going to do much even if they fix this issue :)
11:31 JeKs joined
11:31 <Cale> oh, apparently they *do* allow some IO
11:31 <Cale> that's curious
11:31 <Cale> ah, via this pure-io library which fakes things for you
11:31 <Cale> hmm
11:31 <Unhammer> they have "putStrLn line" as an example ;)
11:32 <Cale> ahh
11:32 <Cale> Interestingly, the example works
11:32 <Cale> Just not... literal strings?
11:34 mda1 joined
11:35 <Unhammer> haha :(
11:35 maksim__ joined
11:36 <Cale> Definitely weird.
11:36 a3Dman joined
11:36 uglyfigurine joined
11:37 worch joined
11:37 emc2 joined
11:37 asthasr joined
11:38 cyborg-one joined
11:38 <Unhammer> https://github.com/haskell-infra/hl/issues/203
11:38 <Unhammer> reported 23 days ago
11:39 nyuszika7h joined
11:50 deepfire` joined
11:53 halogenandtoast joined
11:53 jomg joined
11:55 moongazer joined
11:58 zcourts joined
11:59 HoierM joined
12:02 uglyfigurine joined
12:02 twanvl joined
12:03 moongazer joined
12:03 <ph88_> Cale, when i use catches what can i use for handleIO ? https://bpaste.net/show/69faf915cb93
12:04 <Cale> ph88_: any... anything of the appropriate type?
12:05 <Cale> The type of the handler depends on the type of the action you're catching exceptions in
12:05 slomo joined
12:05 <Cale> It's going to take the exception, and it needs to produce a result of the same type the original action was going to produce
12:05 <ph88_> i use openFile do you mean that with action ?
12:06 <Cale> Yeah, so with openFile, it returns a Handle, so your handler needs to do so as well
12:06 <ph88_> but in case of exception i don't have a valid handle
12:06 <Cale> You might want to catch the exception in a larger block of code than that in that case
12:07 ramzifu joined
12:07 <ph88_> on a block that prints an io string ?
12:07 <ph88_> so then i can print the normal string in case all went fine or the exception string otherwise ?
12:07 <halogenandtoast> Do you suggest uses `catches` over something like `try` for example: https://github.com/halogenandtoast/nhk-reader-haskell/blob/6e28be090db17f9308ae74e82c74aa9b7e5c5fef/Util/Nhk.hs#L79
12:07 sanett joined
12:07 <halogenandtoast> s/uses/using/
12:08 <Cale> Something like that would work
12:08 <Cale> halogenandtoast: catches is primarily useful if you want to catch a variety of different exceptions
12:08 <halogenandtoast> Ah I see
12:09 mak` joined
12:09 chaptastic joined
12:09 <ph88_> Cale, maybe it's a good idea to create a type that can be handle or a string ?
12:10 jmcarthur joined
12:11 moongazer joined
12:12 AndreasK joined
12:12 <ph88_> something like handle <- (Left <$> openFile path ReadMode) `catches` [Handler (\(ex :: IOException) -> Right <$> show ex)]
12:13 JeanCarloMachado joined
12:13 <merijn> ph88_: Isn't that just 'try'?
12:14 <ph88_> well try doesn't allow to match the type of exception
12:14 <merijn> It does
12:14 <ph88_> in catches you can put more handlers for each type of exception
12:15 meck joined
12:15 <merijn> You can either catch a specific exception using try, or just catch 'SomeException' and use fromException to check what it is
12:17 soLucien joined
12:17 <ph88_> handle <- (try $ openFile path ReadMode) :: SomeException ?
12:17 smwangi joined
12:18 <ph88_> oh no i found it should be this handle <- (try $ openFile path ReadMode) :: IO (Either SomeException Handle)
12:19 <ph88_> quite large type signature, Handle could be infered, any way to put just SomeException ?
12:20 <merijn> ph88_: you can leave out the entire type signature, as long as you use handle later so it can infer the type
12:20 <ph88_> ah ok
12:20 pleax joined
12:21 <ph88_> why does fromException return Maybe e and not e ?
12:21 <merijn> ph88_: Well, what if the exception is NOT 'e'?
12:21 <ph88_> e is just a placeholder, no ?
12:21 <merijn> i.e. what if you catch some custom exception, rather than IOException?
12:21 <ph88_> for the value of the exception
12:21 <merijn> ph88_: No
12:22 <ph88_> i can't do fromException on custom exceptions ?
12:22 <merijn> fromException :: Exception e => SomeException -> Maybe e
12:22 <ph88_> https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Exception.html#v:fromException
12:22 <ph88_> ye i saw it
12:22 <merijn> But that SomeException can be ANY exception
12:23 gawen joined
12:23 <merijn> ph88_: I can recommend reading Simon Marlow's paper, Haskell exceptions are a lot more flexible than many people think, but it's not necessarily obvious: https://pdfs.semanticscholar.org/85c6/306c27cbd7e241e3989f3fb72ce3d6bc02d7.pdf
12:24 fendor joined
12:24 <ph88_> ew what happened to the formatting :|
12:24 ebcz joined
12:24 <merijn> You can actually introduce "classes of exceptions" like "MyLibrary" which has 10 different exceptions and then you can catch either a specific one or all 10 (but not others)
12:24 <merijn> ph88_: Here's a better one: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.78.205&rep=rep1&type=pdf
12:25 <merijn> ph88_: I just grab free URLs of Google Scholar, since not everyone has access to the paid copies
12:25 dfeuer joined
12:25 tommd joined
12:25 <ph88_> didn't know about Google Scholar
12:25 Boomerang joined
12:25 lukaramu joined
12:26 <merijn> Google Scholar is amazing
12:26 <merijn> For finding papers and for finding free copies of said paper
12:26 ziocroc joined
12:27 sdothum joined
12:27 lep_ joined
12:28 mkoenig joined
12:28 Prutheus joined
12:29 xtreak joined
12:29 Prutheus joined
12:30 sidei joined
12:31 <liste> google scholar + sci-hub is a great combination
12:32 CurryWurst joined
12:32 kosorith joined
12:33 koneko joined
12:35 <merijn> bleh
12:35 FjordPrefect joined
12:35 <merijn> Travis tests are too verbose to see the actual error >.<
12:35 Guest92877 joined
12:37 raduom joined
12:37 Rodya_ joined
12:38 cfricke joined
12:39 <ph88_> merijn, could you take a look? it's not really going well with the exceptions https://bpaste.net/show/a047fd81eafb
12:39 uncertainty joined
12:40 <cocreature> :t maybe
12:40 <lambdabot> b -> (a -> b) -> Maybe a -> b
12:40 <merijn> ph88_: Well, that's not working because you're basically asking GHC to *guess* what kinda exception it should try and convert 'e' too
12:40 <cocreature> ph88_: you are using "maybe a b" in a place where IO () is expected and you are passing a string literal as "a"
12:40 <merijn> eh, 'ex'
12:40 <merijn> Also that
12:40 <ph88_> oh ye i put this now: putStrLn $ maybe "unknown type of exception" show (fromException ex)
12:40 CurryWurst joined
12:40 eacameron joined
12:41 <ph88_> merijn, yes i was thinking the type of the actual exception ! it's known at runtime
12:41 mkoenig joined
12:41 <lpaste_> merijn pasted “No title” at http://lpaste.net/353525
12:41 <merijn> That still breaks due to lack of conversion annotation
12:41 <merijn> But cleans up some noise
12:42 moongazer joined
12:42 Miroboru joined
12:43 <ph88_> this totally defeats the purpose of using SomeException if i need to give the type of the specific exception i want to match on
12:43 CurryWurst joined
12:43 <merijn> ph88_: Well, if you're only printing, why are you converting at all?
12:44 ThomasLocke joined
12:44 <merijn> ph88_: If you're not only printing, then GHC would be able to infer the type from whatever you're doing with it
12:45 albel727 joined
12:46 nyuszika7h joined
12:46 Baughn_ joined
12:47 <ph88_> when i do show ex i get openFile: inappropriate type (is a directory) how can i match on this ?
12:47 <ph88_> openFile: does not exist (No such file or directory)
12:47 <ph88_> everything is IOException here
12:48 farao joined
12:49 aarvar joined
12:50 <merijn> You want to use stuff like 'isIllegalOperationErrorType' from System.IO.Error
12:50 <ph88_> ok
12:51 nomicflux joined
12:52 <lpaste_> merijn revised “No title”: “No title” at http://lpaste.net/353525
12:52 sepp2k joined
12:52 <merijn> ph88_: Like that
12:52 <merijn> ph88_: And the use of isIllegalOperationErrorType will result in GHC inferring "IO (Either IOException Handle)" for try
12:52 Baughn joined
12:53 <farao> hi, I want to write a haskell program, that reads data to the form of [(key, value)] and groups this by key so that it becomes [(key, Set value)] and puts it out in another file. I have a first solution that puts everything in a Data.Map (updating the map using "insertWith (Set.union)...") but it consumes gigabytes of memory on a 100M input file. So I thought about using Data.HashTable.IO but I'm struggling with finding a good pattern to f
12:53 <farao> old over a list putting (key,value) and (value,key) in the hashtable since this needs to be monadic. how do I do this?
12:54 Baughn joined
12:54 juhp joined
12:56 <farao> clarification: putting (key, value) and (value, key) in the hashmap so that if there is no entry, the entry will be (key, Set(value)) otherwise (key, Set(value,previousvalues...))
12:59 zcourts joined
12:59 nee``` joined
12:59 uncertainty joined
13:00 _sras_ joined
13:00 ramzifu joined
13:00 <_sras_> What is the proper way to do logging of errors from a servant web application?
13:04 dan_f joined
13:04 <lyxia> farao: were you using a lazy map
13:05 chlong joined
13:07 <farao> yes, I tried with Data.Map.Lazy and Data.Map.Strict with the same result. I don't know if I'm doing something wrong elsewhere, I'm reading the file, doing "lines" on it, using "concatMap" to produce [(key,value),(value,key)] from each line and putting those with a fold in a Data.Map.[Lazy|Strict]. Then I use toList on the map and produce outputlines to write to another file
13:07 <Cale> Are you using String?
13:07 a3Dman joined
13:08 <Cale> If so, then use Text instead
13:08 <farao> yes, readFile is giving me Strings
13:08 dni joined
13:08 carlomagno1 joined
13:08 <Cale> String is a lazy linked list of 32 bit wide characters
13:08 <farao> ah
13:08 thc202 joined
13:09 <farao> ok, I'll try that, thanks for the tip :-)
13:09 <farao> *advice
13:09 <ph88_> farao, what function will you be using to read from file and get Text ?
13:09 mkoenig joined
13:09 zero_byte joined
13:10 <farao> I just saw, that there is a readFile that gives me Text, I'll just change the type of my reader function I guess
13:10 <Cale> The Data.Text one will read the entire file into memory at once.
13:11 <farao> how can I prevent that?
13:11 <Cale> It might be worth trying Data.Text.Lazy there, if you're going to be parsing it.
13:11 Ferdirand joined
13:11 <farao> ah ok, that makes sense
13:12 pleax joined
13:12 mizu_no_oto_work joined
13:12 faberbrain joined
13:13 LordDeath joined
13:13 <Cale> Lazy I/O isn't always the nicest thing, but for one big file that you want to process in a streaming fashion, it's not too bad. The alternatives are using strict Text and reading smaller bits at a time, or using a fancy library such as pipes or conduit to manage streaming for you (but those are somewhat heavy tools)
13:14 <Cale> The downsides of lazy I/O are that you give up control over when the file handle is closed (which can matter if you're reading a lot of files), and that it's awkward if you want to handle exceptions.
13:14 <Cale> (that occur in the middle of reading the file)
13:14 mkoenig joined
13:14 <Cale> But the upside is that you write the program which gets the whole file at once and does a bunch of stuff with that, and it gets read only as needed.
13:16 contiver joined
13:16 <farao> yeah, that's what I want :-) I'll try with lazy Text instead of String and see if there's a difference
13:18 balor joined
13:18 pavonia joined
13:19 <ph88_> when using optparse-applicative how can i make it so that i don't need to specify a flag when using stdin https://github.com/pcapriotti/optparse-applicative#alternative ?
13:20 cfricke joined
13:21 <merijn> ph88_: You want to default to stdin and only use a flag to overwrite it?
13:21 <ph88_> i was thinking that if i don't give a filename that it would try to read from stdin automatically
13:21 hexagoxel joined
13:22 <merijn> Just use "Maybe FilePath" and use stdin when Nothing?
13:22 <ph88_> ok i will try that
13:24 Aruro joined
13:25 mattyw joined
13:25 mkoenig joined
13:27 eacameron joined
13:27 doodlehaus joined
13:27 yellowj joined
13:28 Boomerang joined
13:32 eklavya joined
13:32 eacameron joined
13:32 eklavya joined
13:33 <Aruro> is it worth installing HaRe? it looks like it depends on ghc-mod, and ghc-mod is scary.
13:33 <merijn> What's scary about ghc-mod?
13:33 doodlehaus joined
13:34 lukaramu_ joined
13:35 martinhez joined
13:36 mojjo joined
13:36 Rizy joined
13:36 <farao> how can i cast a Data.Text.Lazy to an Int? there seems to be no "read :: Text -> Int"
13:37 <cocreature> read . Text.unpack
13:37 <merijn> Nah, there's a text specific one
13:37 <cocreature> oh? I only know of a bytestring one
13:37 <farao> where?^^
13:37 <merijn> https://hackage.haskell.org/package/text-1.2.2.1/docs/Data-Text-Read.html
13:38 <merijn> farao: You need to puzzle a bit with the type to figure it out
13:38 dni joined
13:38 <merijn> type Reader a = IReader Text a
13:38 dbmikus joined
13:38 <merijn> type IReader t a = t -> Either String (a, t)
13:38 halogenandtoast joined
13:38 <merijn> Simple enough to work with
13:39 <farao> ah ok. wow that's much more complicated than "read str :: Int" :D
13:39 eacameron joined
13:39 <jhrcek> I'm reading "Haskell programming from first principles" it states that "Functor instances for a datatype are unique". Is that really so? How about following example:
13:39 <jhrcek> data Weird a = Weird a a
13:39 <jhrcek> is the following not valid instance of Functor? Do functor laws FORCE me to also apply f to x?
13:39 <jhrcek> instance Functor Weird where
13:39 <jhrcek> fmap f (Weird x y) = Weird x (f y)
13:39 <merijn> jhrcek: Won't type check
13:39 <cocreature> you don’t even need the laws for that :)
13:39 <merijn> jhrcek: Imagine if you had "Weird 1 2" and did "fmap even"
13:40 <merijn> jhrcek: Then you'd have "Weird 1 True" which is not ok since they should be the same type
13:40 <merijn> jhrcek: More relevantly what the text means is *lawful* Functors are unique
13:40 <merijn> jhrcek: So if there exists a lawful functor for a type, then it is the ONLY lawful functor for that type
13:40 <jhrcek> Ah, so I'm actually forced to apply to all occurences of a :)
13:40 <halogenandtoast> instance Functor (Weird a) where
13:40 <merijn> jhrcek: As opposed to, say, applicative, since types can have multiple different lawful applicatives
13:41 <cocreature> jhrcek: you can of course define data Weird b a and then it works out, that’s isomorphic to a tuple (a,b)
13:41 <jhrcek> merijn, cocreature: I get it. Thanks
13:41 <merijn> jhrcek: More realistically we *could* do "instance Functor [] where fmap f (x:xs) = [x]" <- this type checks, but it not a lawful functor
13:42 eschnett joined
13:42 <cocreature> merijn: do you mean [f x]? otherwise this doesn’t typecheck
13:42 <merijn> jhrcek: GHC will happily let you write that, but it's also obvious that it doesn't obey the functor law of "fmap id == id" since "fmap id [1,2,3,4,5]" would end up as '[1]', rather than [1,2,3,4,5]
13:42 <merijn> cocreature: Eh, yes
13:42 <merijn> cocreature: Typing is hard
13:42 <ph88_> if i do "cat myFile.txt" | myHaskellProgram how can i read that stream of bytes into my haskell program ?
13:43 Gurkenglas joined
13:43 <merijn> ph88_: Pipes just write input to stdin
13:43 <ph88_> ya i search for stdin
13:43 <cocreature> :t getContents
13:43 <merijn> ph88_: Incidentally, that's a "Useless Use of Cat Award"
13:43 <lambdabot> IO String
13:43 <jhrcek> Right, that would break the identity law, because it "touches the structure" which functor instance shouldn't modify
13:43 chaptastic joined
13:43 wtetzner joined
13:43 <merijn> "myHaskellProgram <myFile.txt" :)
13:44 <ph88_> oh this one https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString-Lazy.html#v:getContents
13:44 meba joined
13:44 <merijn> jhrcek: Fun trivia fact, despite there being 2 functor laws (as described almost everywhere), you only need to prove "fmap id == id" since the 2nd law is a free theorem (i.e. given Haskell's parameteric type system you get a free proof that it holds, iff you have a proof for the first law)
13:46 <jhrcek> merijn: nice. Where can I read more?
13:46 <jhrcek> Found ekmett's article: https://www.schoolofhaskell.com/user/edwardk/snippets/fmap
13:46 <merijn> jhrcek: Well there's Wadler's "Theorems for Free!" paper, but I'm not sure how readable that is
13:46 kylefang joined
13:46 HaskellLord69 joined
13:46 <halogenandtoast> Not that anyone said anything but my line `instance Functor (Weird a) where` was wrong since the type would have had to have been `Weird a b`
13:47 <halogenandtoast> as I've learned...
13:47 <ph88_> COOL !! B.getContents >>= \str -> B.putStr (B.reverse str)
13:47 <merijn> jhrcek: In general, if you wanna read about proving things about programs, there's the excellent (free & including exercises!) Software Foundations book
13:47 <merijn> @where sf
13:47 <lambdabot> "Software Foundations" by Pierce,Casinghino,Greenberg,Sjöberg,Yorgey in 2011-06 at <http://www.cis.upenn.edu/~bcpierce/sf/> about "the mathematical theory of programming and programming languages",
13:47 <lambdabot> "It develops basic concepts of functional programming, logic, operational semantics, lambda-calculus, and static type systems, using the Coq proof assistant."
13:47 <halogenandtoast> If it's `Weird a a` then you'd have to have `instance Functor Weird where fmap f (Weird a b) = Weird (f a) (f b)`
13:48 laz joined
13:48 mson joined
13:48 <jhrcek> ph88_: try B.interact B.reverse
13:48 <kylefang> halogenandtoast: what does `Weird a a` mean?
13:48 <Cale> merijn: Though ironically, you won't be able to use parametricity as a principle to prove anything with Coq/SF :)
13:49 <halogenandtoast> kylefang: I was just using the example type `data Weird a = Weird a a`
13:51 vaibhavsagar joined
13:53 ramzifu joined
13:54 kylefang joined
13:56 eacameron joined
13:57 skapazzo joined
13:57 mkoenig joined
13:58 danharaj joined
13:58 ystael joined
14:00 zcourts joined
14:00 bweston92 joined
14:02 <ph88_> merijn, i want to show you my program so far https://bpaste.net/show/8b09440e2735
14:03 ChristopherBurg joined
14:03 <ph88_> it's cool bcz it can handle input from stdin or from file
14:03 worch joined
14:04 mkoenig joined
14:05 wlemuel joined
14:06 yellowj joined
14:11 Levex joined
14:11 descender joined
14:12 rekahsoft joined
14:18 revtintin joined
14:18 tromp joined
14:18 allenj12 joined
14:18 erisco joined
14:19 cfricke joined
14:19 cdg joined
14:20 <ph88_> hey guys on line 55 i still have to put an implementation https://bpaste.net/show/8b13941dce02 so i can combine the implementations from line 43 and line 49 and duplicate some code, or is it possible to put that logic into a function somehow ?
14:20 sssilver joined
14:21 pleax joined
14:21 <ph88_> hhmm i think i will try to make some functions there that yield IO actions
14:21 MarioBranco joined
14:23 hive-mind joined
14:23 <lpaste_> allenj12 pasted “foldM error?” at http://lpaste.net/353528
14:25 jrajav joined
14:26 tommd joined
14:26 dfeuer joined
14:26 <lyxia> allenj12: (rem + elem) mod 10, did you mean `mod` instead of mod ?
14:27 <allenj12> yes i did actually
14:27 HarveyPwca joined
14:27 <ahri> ph88_: https://github.com/haskell/containers/issues/420 doesn't look like containers will get an update on Stackage
14:27 <ph88_> :(
14:28 wraithm joined
14:29 sidei joined
14:31 Deadhand joined
14:31 eschnett joined
14:31 dsh joined
14:32 cdg joined
14:33 <ph88_> that thing i was just asking i made an implementation now https://bpaste.net/show/aef70f7bf30b can anyone check if it can be done more cleanly, or is this as good as it gets ?
14:34 fragamus joined
14:35 niklasb joined
14:35 <ph88_> hahaha i created a bug by calling byteswap on both input and output function
14:35 Perspicaciosity joined
14:36 eklavya joined
14:38 <ph88_> should i remove byteswap from readFromFileToWrite or from writeToFile ?
14:39 Levex joined
14:39 <ph88_> hmm both seems to be the best :P
14:40 coltfred_ joined
14:43 marcopullo joined
14:43 mkoenig joined
14:43 Rizy joined
14:47 cfricke joined
14:49 al-damiri joined
14:50 crobbins joined
14:50 bennofs joined
14:50 ccomb joined
14:51 cschneid_ joined
14:55 simukis__ joined
14:57 ocalm joined
14:57 eschnett joined
14:58 Ayey_ joined
14:58 Michael_ joined
14:59 JeanCarloMachado joined
15:00 zcourts joined
15:01 wraithm joined
15:02 mkoenig joined
15:02 coot joined
15:05 marsam joined
15:05 pleax joined
15:05 hive-mind joined
15:06 mmn80 joined
15:06 doodlehaus joined
15:07 Ayey_ joined
15:08 andyo joined
15:09 theelous3 joined
15:11 <ph88_> i have a bytestring and i want to "handle" 5 bytes at a time, i want to swap some characters and then to the same to the next 5 bytes, should i work with the index function can keep track of a counter that points into the bytestring ? or is there a more functional way to do this ?
15:11 xaviergmail joined
15:12 Shatnerz0 joined
15:12 <ph88_> or maybe use splitAt ?
15:13 faberbrain joined
15:14 coot joined
15:14 sidei joined
15:15 mizu_no_oto joined
15:15 doodleha_ joined
15:16 netheranthem joined
15:16 skeet70 joined
15:16 trism joined
15:19 steeze joined
15:20 uglyfigurine joined
15:20 uglyfigurine joined
15:20 dan_f joined
15:20 Ayey_ joined
15:21 robkennedy joined
15:21 Shatnerz0 joined
15:21 <ph88_> i tried with splitAt but i ran into a little problem with my byteswap function https://bpaste.net/show/3460cd2b9357 someone mind taking a look ?
15:22 <ph88_> this needs to be really fast as well, because it's the processing function that takes the most time
15:23 Lord_of_Life joined
15:24 raycoll joined
15:24 structuralist joined
15:24 etehtsea joined
15:29 <shapr> ph88_: could you use one of the B.fold options?
15:30 <ph88_> shapr, i think the fold goes character by character, i need to by 5 characters at a time
15:30 coot joined
15:32 coot joined
15:32 coot joined
15:33 the|auriscope joined
15:35 ramzifu joined
15:36 coot_ joined
15:37 jaspervdj joined
15:37 mkoenig joined
15:37 DataComputist joined
15:38 JagaJaga joined
15:39 uncertainty joined
15:41 moongazer joined
15:41 raichoo joined
15:41 sssilver joined
15:42 wlemuel joined
15:42 thunderrd joined
15:42 eklavya joined
15:43 jaspervdj joined
15:44 nomicflux joined
15:44 tommd joined
15:45 pleax joined
15:45 danza joined
15:47 <lpaste_> allenj12 pasted “very small style review?” at http://lpaste.net/353531
15:48 jaspervdj joined
15:48 sidei joined
15:51 moongazer joined
15:52 soLucien joined
15:52 bodisiw joined
15:52 Ayey_ joined
15:52 sssilver joined
15:52 yellowj joined
15:52 Fairy joined
15:53 augur joined
15:53 <eugenez> Friends, how to reduce this? filter (\x -> numOfFactors x == 2) [1..1000], my first thought was something like filter (numOfFactors <*> == 2) [1..1000] but that unfortunately does not work. May be it cannot be simplified?
15:54 <ph88_> eugenez, hows that even shorter
15:54 <glguy> eugenez: Your first version looks great
15:54 <ph88_> eugenez you can use list comprehensios too
15:55 mkoenig joined
15:55 <eugenez> Okay, thank you, friends!
15:56 <ph88_> glguy, perhaps you have any idea how i can work with that bytestring ?
15:56 ikke joined
15:56 mizu_no_oto joined
15:57 <glguy> ph88_: If you want it to terminate you'll need to write it so that it has a reason to terminate
15:57 fosskers joined
15:57 osa1 joined
15:57 osa1 joined
15:57 <glguy> and I'd use a Builder instead of repeated appends
15:57 <ph88_> a Builder ?
15:57 <glguy> http://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString-Builder.html
15:58 <ph88_> is there an opposite of a Builder, so that i can first take the bytestring that i have apart ?
15:58 nee``` left
15:58 cdg joined
15:58 <glguy> unpack :: ByteString -> [Word8]
15:58 jaspervdj joined
15:58 <ph88_> wouldn't that create a linked list ?
15:59 <glguy> yeah, but it'd be short lived
15:59 <glguy> the whole list wouldn't need to exist at once
15:59 <glguy> You can just index the bytestring
15:59 <glguy> index :: ByteString -> Int -> Word8
15:59 <ph88_> would indexing the bytestring be faster than splitAt ?
16:00 <glguy> yeah
16:00 <ph88_> Builders therefore take special care to ensure that the average chunk size is large enough. The precise meaning of large enough is application dependent. The current implementation is tuned for an average chunk size between 4kb and 32kb, which should suit most applications.
16:00 <glguy> or the same depending on how the optimizations work out (if the splitAt optimizes away)
16:00 <ph88_> i have just pieces of 5 bytes, maybe Builder is not the right choice for me ?
16:00 sssilver_ joined
16:00 <glguy> No, the 5 byte number is irrelevant to that previous statement
16:01 <glguy> unless you're saying you literally only have 5 bytes in total
16:01 <ph88_> the total is many megabytes
16:01 <ph88_> but i need to process 5 bytes at a time
16:01 <glguy> yeah, then your 5 bytes don't matter
16:01 zcourts joined
16:01 koneko joined
16:02 <glguy> Builder also allows you to specify the final size if you know it ahead of time, which you do
16:03 <ph88_> glguy, my program can also read from stdin with getContents, how do i know the final size of that ?
16:03 <glguy> Oh, in that case Builder will work out just fine in its default arrangement
16:04 <ph88_> glguy, what kind of check could i create to see if i need to do recursion or reached the end of the bytestring ?
16:04 <glguy> If you're not sure, then this is a good exercise that you shouldthink about
16:05 <ph88_> ya i feel like the ideas i have are stupid
16:05 <ph88_> like checking all 5 bytes if they are EOF
16:05 sanett joined
16:05 <glguy> There won't be any EOF bytes
16:05 mkoenig joined
16:06 <ph88_> also little mention about EOF on https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString-Lazy.html
16:06 mengwong joined
16:06 <ph88_> should i check the length on each iteration ? it will be expensive
16:06 <c_wraith> there's... no such thing as an EOF byte.
16:06 caumeslasal joined
16:07 jaspervdj joined
16:07 Rodya_ joined
16:07 <c_wraith> all possible byte values are data, not signaling.
16:08 <ph88_> so length checking then ?
16:08 medicijnman joined
16:09 boombanana joined
16:10 <glguy> Why is checking the length expensive?
16:10 Noldorin joined
16:10 <ph88_> it says O(n/c) in the docs, and i have to do that on every 5 bytes
16:10 <glguy> If you're streaming from stdin you probably wouldn't want to check that, though
16:10 <ph88_> well either from stdin or from file
16:11 <glguy> You don't need to know how long it is anyway
16:11 Sonolin joined
16:11 <ph88_> why is that ?
16:11 <cocreature> just wait until an exception is thrown and check for isEOFError
16:12 jaspervdj joined
16:12 <glguy> There wouldn't be an EOFError processing a ByteString
16:12 thc202 joined
16:13 ziocroc joined
16:16 conal joined
16:17 Jesin joined
16:18 <cocreature> ph88_: btw if you are doing IO, you might just want to read small chunks of strict bytestrings at each step. length is O(1) on those
16:18 <glguy> or just check that there are at least 5 bytes available
16:18 jaspervdj joined
16:18 <glguy> null . drop 5
16:19 chaptastic joined
16:19 Deadhand joined
16:19 <ph88_> i didn't run this yet, but just for the idea ... https://bpaste.net/show/53bd05b2556b
16:20 <ph88_> fixed types https://bpaste.net/show/359eb6d567dc
16:22 <m4lvin[m]> is there a well-known type class for types that have only one value?
16:22 Deide joined
16:23 dni joined
16:24 cdg_ joined
16:24 <cocreature> m4lvin[m]: afaik there isn’t
16:25 guampa joined
16:25 sobaken_ joined
16:27 Levex joined
16:28 codesoup joined
16:28 <ph88_> glguy, cocreature i implemented the suggestions you gave me https://bpaste.net/show/a4f439123caf it type checks, but when i run it byteswap2 "1234 5678 " i get an endless string "3412 3412 3412 3412 3412 3412 3412 3412 i don't know why because i recurse on the part when already 5 are dropped
16:29 <cocreature> ph88_: you don’t recalculate rest in each iteration
16:30 Luke joined
16:31 marfoldi joined
16:31 Levex joined
16:31 eatman joined
16:32 pera joined
16:32 <ph88_> ah yes ok now it works well
16:32 <ph88_> so this is the fastest thing i can make ?
16:33 <ph88_> version that seems to work https://bpaste.net/show/55bbe22e964e
16:34 <ph88_> hhmm there is still a problem with this version .. it can happen that i get as input "f120 f3" or something like that, it should then output "20f1 f3" but now it throws an exception that the index is not valid
16:35 <m4lvin[m]> cocreature: ok, still thanks!
16:36 <cocreature> m4lvin[m]: what do you need that for? I can’t see any useful operations that you can implement in terms of that typeclass
16:38 robotroll joined
16:38 faberbrain joined
16:40 urodna joined
16:41 mkoenig joined
16:41 <m4lvin[m]> Okay, I'll try to explain. I think I want something like a family of newtypes that are also Functors.
16:42 Wizek joined
16:42 Wizek_ joined
16:42 TCZ joined
16:43 raichoo joined
16:43 <cocreature> if your type has only a single inhabitant, then the Functor instance is going to be pretty boring
16:43 Rodya_ joined
16:44 Ayey_ joined
16:44 mr_sm1th joined
16:45 the|auriscope joined
16:45 <m4lvin[m]> yes, it is trivial and basically the Identity functor.
16:45 mstruebing joined
16:45 <cocreature> no it’s Const
16:46 <Sornaensis> @info Const
16:46 <lambdabot> Const
16:46 <cocreature> hm I guess Identity () works too
16:46 <m4lvin[m]> ah, let me look at Const
16:46 infandum joined
16:46 <cocreature> and for Const you also need Const () if you only want a single inhabitant
16:47 <cocreature> so basically your type is isomorphic to ()
16:47 WizJin joined
16:47 <cocreature> so I don’t really understand what you get out of knowing that
16:47 mizu_no_oto joined
16:49 <m4lvin[m]> I used the different (but yes, isomorphic) types to label different newtypes. Maybe I did just reinvent "Const a b" here? http://lpaste.net/4108449596617785344
16:50 atk joined
16:50 Levex joined
16:51 gienah_ joined
16:51 leat joined
16:52 <freeside> m4lvin[m]: have are you familiar with http://chris-taylor.github.io/blog/2013/02/10/the-algebra-of-algebraic-data-types/ ?
16:52 <freeside> s/have //
16:52 mkoenig joined
16:52 <cocreature> you never really use your Vocab typeclass. the only place where it’s used is in the applicative instance of "InVocab v" but you could get the value there just by pattern matching on one of the arguments if you assume it’s unique
16:52 Ayey_ joined
16:53 <cocreature> it’s not Const however
16:54 <cocreature> it’s a special case of (a,b)
16:54 Qfwfq joined
16:55 <cocreature> the monoid doesn’t really matter if you assume the value is unique so you can just use (First a, b) to get a monoid instance for any value
16:56 jgertm joined
16:56 cardboard64 joined
16:56 wahrsagevogel joined
16:57 keemyb joined
16:57 jophish_ joined
16:58 jophish_ joined
16:59 Ayey_ joined
16:59 <m4lvin[m]> freeside: thanks, I know some of this but will read the series. already clarifies the role of ()
16:59 <m4lvin[m]> cocreature: so i am doing (a,b) where a is a type isomorphic to () ?
17:00 <cocreature> m4lvin[m]: I think so :)
17:00 <cocreature> m4lvin[m]: it looks like you don’t really care about the value and just want a type to differentiate things, so maybe "Tagged" is what you’re looking for
17:00 <cocreature> https://hackage.haskell.org/package/tagged-0.8.5/docs/Data-Tagged.html#t:Tagged
17:01 <m4lvin[m]> my motvation was having two things of type b (BDDs) that should not be combined, so i want to label them with something on the type level.
17:01 <cocreature> yeah Tagged is exactly that
17:01 <m4lvin[m]> aha!
17:01 <m4lvin[m]> great :-)
17:02 jathan joined
17:02 the|auriscope joined
17:02 <cocreature> it doesn’t even have a value for the first type parameter. it just adds an additional type paramater
17:02 zcourts joined
17:02 revprez joined
17:03 <m4lvin[m]> yes, perfect. i can ignore the "experimental" though?
17:04 <cocreature> nobody cares about the stability field on hackage :)
17:04 <cocreature> Tagged has been there for quite some time :)
17:04 <freeside> m4lvin[m]: also, are you familiar with GF?
17:05 <cocreature> freeside: galois fields?
17:05 <freeside> http://www.grammaticalframework.org/
17:05 <m4lvin[m]> grammatical framework?
17:06 <cocreature> I’ve clearly been studying too much for my algebra exam :)
17:06 <m4lvin[m]> cocreature: good luck with that then :-) (my only galois theory lecture is too long ago)
17:06 <cocreature> thanks :)
17:07 gillesmajor joined
17:07 <m4lvin[m]> freeside: not really (met some people working on GF at a summer school once and tried the android app...) why are you asking? is there a connection to my question?!
17:07 koneko joined
17:08 Kreest__ joined
17:08 <freeside> dunno, it looks like you're doing linguistic type things?
17:08 chaptastic joined
17:09 coot joined
17:09 Swizec joined
17:09 joncfoo joined
17:10 <m4lvin[m]> ah, not really. I'm mainly in model checking modal logics.
17:10 uncertainty joined
17:10 <freeside> oh, ok, i misunderstood.
17:11 <freeside> have you found any haskell libraries that are useful for that sort of thing? Kripke structures, CTL/LTL, etc
17:11 ypwu1 joined
17:11 zdenal joined
17:12 <cocreature> m4lvin[m]: do you work on model checkers or do you apply model checkers to various problems?
17:13 mthek joined
17:13 <m4lvin[m]> i am writing a (symbolic) model checker, mainly for dynamic epistemic logic (DEL)
17:13 sellout- joined
17:13 <m4lvin[m]> for temporal logics i do not know anything in haskell
17:14 <m4lvin[m]> (DEMO-S5 and SMCDEL are the epistemic model checkers made by us here, explicit and symbolic respectively)
17:15 <m4lvin[m]> </advertisement> ;-)
17:15 <freeside> thanks, i will go read your paper http://homepages.cwi.nl/~jve/papers/16/pdfs/2016-05-23-del-bdd-lori-journal.pdf
17:17 <freeside> i'm working on a project to formalize legal contracts, and it looks like DEL will be relevant to the aspects of contracts that have to do with giving notices, making public announcements, and responding to globally announced state changes, e.g. blockchain oracles.
17:17 path[l] joined
17:17 Ayey_ joined
17:19 Destol joined
17:22 Soif[m] left
17:22 Soif[m] joined
17:22 mizu_no_oto joined
17:25 gcross_ joined
17:26 <m4lvin[m]> oh, nice!
17:27 faberbrain joined
17:28 cdg joined
17:29 kosorith joined
17:29 <freeside> yeah, are you guys seeing any interest from industry in commercial applications of your work?
17:30 Luke joined
17:30 wraithm joined
17:30 sphinxo joined
17:32 <freeside> i wonder if the intersection between anonymity blockchains (e.g. zcash) and smart contract oracles (as in ethereum) offers an opportunity for your work to assess privacy preservation properties
17:33 <freeside> if i know that a smart contract performs some action based on information that is available to the smart contract but not to me, then when i observe that action, i deduce the original information.
17:33 <freeside> and then you can start bringing in ideas of differential privacy
17:33 Argue_ joined
17:36 gawen joined
17:36 Ayey_ joined
17:37 sidei joined
17:38 marsam joined
17:39 freeside_ joined
17:39 _sg joined
17:40 replay joined
17:40 preyalone joined
17:41 ner0x652 joined
17:42 Ayey_ joined
17:42 fxrs_ joined
17:42 merijn joined
17:42 DataComputist joined
17:43 <m4lvin[m]> i don't know of any industry interests for DEL ... model checking there is all temporal logics afaik. which makes sense if things like synchronizity matter. but if the focus is epistemic and a fixed sort of time (with perfect recall) is applicable, then DEL might actually be easier and more efficient.
17:43 robotroll joined
17:43 dni joined
17:45 <m4lvin[m]> what should i read to understand zcash / how it differs from bitcoin?
17:48 <jle`> m4lvin[m], cocreature: Const () is just `Proxy`
17:49 <cocreature> jle`: yeah good point
17:49 tabaqui1 joined
17:50 takle_ joined
17:52 sphinxo joined
17:53 mmhat joined
17:53 Ayey_ joined
17:53 Guest____ joined
17:53 jophish joined
17:53 hm02 joined
17:54 <hm02> greetings
17:54 sobaken joined
17:54 marfoldi joined
17:55 <dylukes> Is anyone here familiar with configuring neco-ghc with deoplete? I'm running into an issue with completions of module contents.
17:55 hm02 left
17:55 <dylukes> import Control.Monad (<C-x><C-o>) ⇒ "Omni completion ^O^N^P Pattern not found"
17:55 <dylukes> import Control.Monad (<C-x><C-o> *
17:56 <dylukes> If I then add a space following the open parentheses, backspace, and complete, it works as expected.
17:56 <dylukes> If I exit insert mode, and then renter and complete, it also works.
17:56 <shapr> now I want to try neco-ghc
17:56 <dylukes> It looks to me like neco-ghc is lazily loading modules.
17:56 <dylukes> Also long time no see shapr. Hope life is finding you well.
17:57 <shapr> howdy dylukes! Yeah, life is good.
17:57 <shapr> How's code with you?
17:57 <dylukes> Pretty good! Currently working in a structural biology lab, as grad school applications haven't panned out.
17:57 mda1 joined
17:57 <dylukes> Crystallographic analysis type stuff.
17:57 <shapr> Do you get to write Haskell for that?
17:58 <dylukes> Gold nanoparticles, Pol2 (RNA polymerase), and soon a network theory approach to hydrogen bond coordination.
17:58 DrHaribo1 joined
17:58 <dylukes> Currently no, it's all Python. But that might change :).
17:58 zzz joined
17:58 <dylukes> There's certainly no restriction on using Haskell. It's just a matter of library support.
17:58 <shapr> hm, I thought I saw a bond graph library in Haskell
17:59 <shapr> not sure if that would help for hydrogen bond coordination
17:59 <dylukes> The goal is basically to model hydrogen-coordinations in proteins as a network.
17:59 <dylukes> Which they are,
17:59 <dylukes> in the sense that small permutations in one position can have *very* large effects at a distance.
18:00 <shapr> sounds interesting, but I am unfamiliar with that flavor of problem.
18:00 <dylukes> Think about the way a flower blooms. A very small exertion of force at the sepals and along the base of the petals results in an "unfurling" motion
18:00 <dylukes> Me too!
18:00 <dylukes> That's why it's so exciting!
18:01 <shapr> does sound like fun
18:01 <dylukes> Well, I'm still puzzling out how it's going to work.
18:02 <dylukes> Anything graph/network related is almost always going to come down to very unsavory asymptotics :)
18:02 MP2E joined
18:03 zcourts joined
18:03 <dylukes> No reason I can't compile static haskell binaries against OpenMPI and deploy on the research cluster though.
18:03 <dylukes> 48h+ runs aren't unusual.
18:04 meoblast001 joined
18:04 minn joined
18:05 zcourts joined
18:05 <dylukes> shapr: one of the most fascinating things is that while you'd think proteins are in general big squiggly messes, there are actually high level functional motifs that are still being found.
18:05 <dylukes> Which can be identified via loosely connected (but compact) sub graphs of the hydrogen bond graph.
18:06 alx741 joined
18:06 <dylukes> Anyhow, anyone know if it's possible to have necoghc reload modules live?
18:06 taksuyu joined
18:07 <dylukes> Having to exit insert mode isn't so bad, it's just a bit of a snag.
18:07 <shapr> dylukes: got any survey papers on that motif?
18:07 <dylukes> There's not really any one particular motif.
18:07 cardboard64 joined
18:07 <shapr> I really did think protein folding depended on all of the nearby state
18:07 <dylukes> It does. It's still an n-body problem in a sense.
18:09 zcourts joined
18:10 BlueRavenGT joined
18:10 pera joined
18:10 uglyfigurine joined
18:10 zcourts joined
18:11 balor joined
18:11 <dylukes> shapr: this isn't about folding though, it's about allosteric effects.
18:11 sidei joined
18:11 <shapr> had to look that up, but neat!
18:12 <dylukes> For example, when ATP coordinates with Pol2 (RNA polymerase II), there's very substantial movement. If you imagine a flint-lock pistol, it's rather similar.
18:12 <dylukes> An entire "arm" (trigger loop) bends/rotates almost 180 to seal off a channel.
18:12 <zennist> I was just reading the new Retrofitting Linear Types paper (great read by the way); and wondering: does anyone have any idea how to actually implement: withQueue :: (PQ a -. IO a) -. IO a
18:12 <dylukes> So basically, you can observe these large-scale movements, but the question is, how do they happen?
18:13 <shapr> interesting question
18:14 <dylukes> It's the same sort of problem as tracking neuronal activations, and trying to understand how they result in activity patterns.
18:14 <dylukes> That is, a network.
18:14 <dylukes> Each individual coordination is relatively minor, but they can *leverage* each other, which seems to me key.
18:14 <Tuplanolla> I was expecting "that is, a mess".
18:14 <zennist> my motivation for the question: if you just allocate a normal object like what currently in haskell: e.g., PQ.fromList elements, that would be in the dynamic heap right? At which point can I put that into the linear heap instead?
18:14 <dylukes> Tuplanolla correct :p.
18:15 t7 joined
18:15 pebblexe joined
18:15 <dylukes> What I'd like to look at initially is where small movements magnify each other.
18:15 <dylukes> For example if you had some rigid ball and stick thing A == B == C, where the == bend.
18:16 <pebblexe> how do I use a locally cloned github project (not on hackage) as a library in my cabal file?
18:16 <dylukes> Then a small movement of the A == B could leverage a B == C movement (changes the frame of reference).
18:16 <Tuplanolla> You can Cabal install it and simply refer to it by name after that, pebblexe.
18:16 <pebblexe> Tuplanolla: thanks!
18:16 <Tuplanolla> Point the installer to the Cabal file.
18:18 <dylukes> What's the long term direction with Cabal/Stack?
18:18 moongazer joined
18:18 the|auriscope joined
18:19 <cocreature> dylukes: they’ll probably coexist for a long time :)
18:19 <bennofs> dylukes: don't write Cabal like that. There's two projects: Cabal (the library) and cabal-install (user interface to this library + the solver). Stack uses Cabal (the library)
18:19 <dylukes> That's what I mean.
18:19 moongazer joined
18:20 <dylukes> I assume Stack is still using Cabal, and the Cabal format isn't going anywhere.
18:20 <dylukes> It's the cabal-install solver that I'd rather not have to use.
18:20 <cocreature> cabal-install is also not going anywhere for the foreseable future
18:20 <bennofs> dylukes: replacing Cabal would be a huge effort with what benefits?
18:20 crobbins joined
18:20 <dylukes> I'm not suggesting replacing it?
18:20 <bennofs> dylukes: oh that's what you said, sorry
18:21 dtornabene joined
18:21 <bennofs> dylukes: well stack's solver command requires cabal-install, and I think quite a few people use it. And there's also users that just prefer cabal-install. So I don't think cabal-install will go away in the future
18:23 dni joined
18:24 tessier joined
18:24 tessier joined
18:24 goldfire joined
18:24 <bennofs> dylukes: I assume that long-term, both tools with coexist. I don't see why that would be bad thing
18:25 <dylukes> Good!
18:25 sssilver joined
18:25 <dylukes> I was just wondering, not passing any judgement. I've been out of the toolchain loop.
18:25 Levex joined
18:26 jaspervdj joined
18:26 worch joined
18:26 Guest____ joined
18:26 <dylukes> Hm.
18:27 oisdk joined
18:27 xall joined
18:28 cads joined
18:28 <pebblexe> does "Bad file descriptor during read" mean I have a disk problem?
18:29 <pebblexe> I got it as a slime error
18:29 <pebblexe> sorry wrong channel
18:30 worch joined
18:30 tessier joined
18:30 tessier joined
18:35 Ayey_ joined
18:37 S_Daedalus joined
18:38 Levex joined
18:38 doomlord joined
18:39 connrs joined
18:40 vikaton joined
18:40 freechips joined
18:40 uncertainty joined
18:40 stoopkid joined
18:42 takle joined
18:42 path[l] joined
18:43 Prutheus joined
18:43 phyrex1an joined
18:45 osa1 joined
18:45 osa1 joined
18:46 Shatnerz joined
18:52 marfoldi joined
18:54 skeuomorf joined
18:54 TCZ joined
18:55 HoierM joined
18:55 dni joined
18:56 HoierM joined
18:57 P1c4p4l joined
18:57 HoierM joined
18:57 unK_ joined
18:57 Levex joined
18:58 HoierM joined
18:58 <AWizzArd> Are there Foldable alternatives/variants, for data types with the kind * ?
18:59 <lyxia> MonoFoldable
18:59 <AWizzArd> Ah good, will have a look, thx.
19:01 zero_byte joined
19:02 JuanMiguel joined
19:03 <AWizzArd> There is this trick, than when using a certain language extensions, one can simply derive Foldable.
19:04 ubsan_ joined
19:04 <AWizzArd> Is there a way to make own type classes derivable? Or is this something that requires GHC support?
19:07 <geekosaur> currently requires support within ghc
19:07 <geekosaur> 8.2 will change this (or begin to change it; unsure if that part will be in 8.2) with deriving strategies
19:08 <lyxia> Generics go a long way though.
19:09 xaviergmail joined
19:09 freechips joined
19:09 <jle`> AWizzArd: the way people usually do that is with Generics
19:09 nadirs joined
19:10 niteria joined
19:10 merijn joined
19:10 <jle`> for example, the 'binary' library uses Generics to "derive" serialization instances and strategies
19:10 <jle`> the aeson library uses it to derive JSON representation for types
19:10 <jle`> you could use generics to derive Show/Ord/Eq/Foldable/Traversable too I believe
19:10 Ayey_ joined
19:11 <jle`> generics can be considered a tool for deriving custom typeclasses
19:11 osa1 joined
19:11 osa1 joined
19:12 <AWizzArd> Is Quickcheck also using Generics, to be able to produce instances of any data type?
19:13 <lyxia> It can't produce an instance of any data type though
19:13 Coldbla2 joined
19:14 <shapr> hurrah! https://github.com/MichaelXavier/quickcheck-generic
19:15 <shapr> now I want to try that this evening after word
19:15 <shapr> oh, speaking of which ... I want to put a PR to add tau to the Prelude, since it's pi day.
19:15 rstefanic joined
19:15 <lyxia> I didn't see that one before I wrote my own generic-random
19:16 <shapr> lyxia: Is that the name on hackage? generic-random?
19:17 <Tuplanolla> Tau's a crap name though, shapr.
19:17 _sras_ joined
19:17 <shapr> Tuplanolla: what's a better name?
19:17 <lyxia> And for product types one-liner and product-profunctors provide a much more general pattern for generic stuff
19:17 <Tuplanolla> Anything that's not a letter that's all over math and physics.
19:17 <lyxia> shapr: yeah mine's on hackage
19:17 <Tuplanolla> Even `twopi`.
19:19 Ayey_ joined
19:19 nbro joined
19:19 <nbro> hi
19:20 <nbro> can someone explain me what does this: "updateRec Rec {name = uname@"Bob", uid = idn@42} = …" actually mean?
19:20 <jle`> nbro: how familiar are you with record types
19:20 <jle`> or functions
19:21 <jle`> do you know how to declare functions in haskell?
19:21 <nbro> jle`: go ahead, and let’s see what I understand
19:21 <jle`> or how pattern matching works?
19:21 <jle`> Rec is probably a record type with the fields "name" and "uid"
19:21 alx741 joined
19:21 <nbro> jle`: yes, I just don’t know what that syntax means
19:21 marsam joined
19:21 <nbro> the "@"…
19:21 <jle`> updateRec (Rec { name = "Bob", uid = 42 } = ...
19:21 cyborg-one joined
19:21 <jle`> it matches a rec with name "Bob" and uid 42
19:22 <jle`> as patterns let you name the result of the pattern
19:22 <geekosaur> the term you are looking for is as-pattern
19:22 <jle`> > let f t@(x,y) = (t, (x, y))
19:22 <lambdabot> <no location info>: error:
19:22 <lambdabot> not an expression: ‘let f t@(x,y) = (t, (x, y))’
19:22 <jle`> > let f t@(x,y) = (t, (x, y)) in f (1,2)
19:22 <lambdabot> ((1,2),(1,2))
19:22 <jle`> in the above pattern, the tuple is pattern matched on, and 'x' and 'y' are the named fields
19:22 <jle`> but the tuple itself can be bound to 't'
19:23 <jle`> > let f xs@(y:_) = y:xs in f [1,2,3]
19:23 <lambdabot> [1,1,2,3]
19:23 <jle`> so there we match on the (y:_) pattern, the non-empty list
19:23 <jle`> and y is the head
19:23 <jle`> but we can also name the entire list xs
19:23 Luke joined
19:23 <nbro> so essentially we’re doing pattern matching and at the same time we have kind of a reference to the field
19:23 <jle`> yes
19:24 <jle`> it's kinda silly in the case you wrote, because 'uname' is always going to be "Bob"
19:24 the|auriscope joined
19:24 <jle`> because the "Bob" pattern only matches on "Bob"
19:24 <jle`> literally
19:24 <geekosaur> makes sense if someone copied code that expects those names bound
19:24 sphinxo joined
19:24 <eacameron> How do I derive a client for a nested Servant API? I can't use servant-client's new generic module since I'm still on servant 0.9.1.1
19:24 <jle`> but if it was name = uname@('b':'o':'b':_)
19:24 <geekosaur> (workaround for where not scoping over multiple cases)
19:24 Luefer joined
19:24 <jle`> then itn would match on any string that started with the letters bob
19:24 honeymead joined
19:25 <jle`> and the entire string would be bound to 'uname'
19:25 twanvl joined
19:25 <geekosaur> *my* problem with it is hardcoding usernames like that is questionable security :)
19:27 <freeside> just don't tell Alice and Carol
19:27 <Luefer> Reading about Lenses and Traversals at hackage I came across the following sentences: "A Lens' has a Functor constraint and Traversal' has an Applicative constraint. This means that any Lens' is automatically also a valid Traversal' (since Functor is a superclass of Applicative)." Shouldn't it be the other way around?
19:27 Ayey_ joined
19:28 <lyxia> which way around
19:28 LeCamarade joined
19:28 <Luefer> I mean since the Functor is the superclass all Travesals are Lenses.
19:28 <nbro> and can these as-patterns be used everywhere on the left side of the equals of functions?
19:28 <Luefer> But that does not imply that all Lenses are Traversals.
19:28 <geekosaur> nbro, they can be used anywhere a pattern is valid, so that and also case ... of
19:28 <lyxia> Luefer: a lens has to work for all Functors, and a Traversal for all Applicatives
19:29 <nbro> ok
19:29 <lyxia> Luefer: since a Lens works with all Functors, it also works for all Applicatives
19:29 <nbro> geekosaur: honestly I still need to see more examples of pattern macthing that aren’t on the left side of the equals
19:29 <geekosaur> there are some syntactic restrictions if you have TypeApplications enabled, because it also uses @ (iirc this means that while you could normally have spaces around the @, you must not have them with TypeApplications ebnabled)
19:30 <Luefer> lyxia: To me that feels like all Traversals are Lenses?
19:30 <geekosaur> nbro, case, let, and the left of a <- in do notation
19:30 <lyxia> Luefer: no because there are functors which a Traversal can not handle
19:32 <nbro> geekosaur: I’ve seen <- in the case and in list comprehensions, but not in the do notations
19:32 <nbro> but I’m also still not familiar with the do notations
19:32 <nbro> so far I’ve just written pure functions
19:32 <Luefer> lyxia: So I can have a Lens which is not a Traversal, no? I still don't get it.
19:33 <lyxia> Luefer: No, every Lens is a Traversal.
19:33 jbiesnecker joined
19:34 longjump joined
19:34 <lyxia> Luefer: A better way to understand this is that a lens is basically an accessor for a single field. a Traversal is an accessor for zero, one, or many fields.
19:35 <Luefer> lyxia: There is something fundamental that I don't get here. It makes sense that all Lenses are Traversals but when I read the definitions to me it feels that every Traversal is a Lens.
19:35 <nbro> guys, from a certain point of view, the fact that functions in haskell heavily use recursion may be a limitation, in the sense that if you do not have a good compiler or a computer with a good amount of resources, you can’t go everywhere you want
19:35 <byorgey> Luefer: I think maybe you are getting tripped up by the fact that the class constraint is like a function argument, so it is contravariant. A Lens is something that can *accept* any Functor. A Traversal can *accept* any Applicative.
19:35 <freeside> nbro, can you explain that point of view?
19:35 <byorgey> Luefer: something that can accept *any* functor can certainly accept Applicative ones. So every Lens is a Traversal.
19:36 <byorgey> On the other hand something which *requires* an Applicative may not be happy with just any old Functor.
19:36 <geekosaur> nbro, the same is true of graph reduction in general tbh
19:36 <freeside> you are right that one would not want to run a Haskell program on, say, an Arduino
19:36 <geekosaur> (also "recursion" in the sense most people mean is not relevant in the context of graph reduction
19:36 <nbro> freeside: what if you have a recursive function which requires a lot of computation resources, i.e. the recurses for a long time
19:36 serendependy joined
19:36 Natch joined
19:36 <nbro> *it recurses
19:37 <Luefer> byorgey: That makes sense. I kind of had a feeling it was something along those lines but I couldn't quite grasp it. I will make another attempt with this in mind.
19:37 <byorgey> nbro: what if you have an iterative function which requires a lot of computational resources, i.e. loops for a long time?
19:37 <freeside> mmm. you might enjoy reading https://wiki.haskell.org/Tail_recursion
19:38 <freeside> the problem you are thinking about is optimized away by any sensible language
19:38 vaibhavsagar joined
19:38 <geekosaur> nb ro, the key here is graph reduction. if that means nothing to you, I suggest you learn about it; how Haskell works, and why tail recursion is an almost meaningless concept in Haskell, will make no sense to you until you understand graph reduction
19:38 <nbro> byorgey: yes, but in Haskell the recursion would occur on the stack, in a loop, you may do other things outside of the stack, moreover recursion requires more resources that iterative equivalent functions in order to keep track of variables, return values, etc
19:38 <rstefanic> I've crashed C programs nesting 8 loops inside of each other before. Resource management is a problem with any limited system.
19:39 <geekosaur> here eis exactly why you need ot learn about graph reduction
19:39 edsko joined
19:39 <geekosaur> there is no call stack
19:39 <geekosaur> there is a *pattern* stack
19:39 caumeslasal joined
19:39 <geekosaur> it is not just the same idea renamed, it does something completely different
19:39 <nbro> rstefanic: 8 nested loops?
19:39 <nbro> nobody writes down 8 nested loops
19:39 <byorgey> nbro: right, that isn't true though. See what others have said.
19:40 <freeside> about 8 years ago, byorgey wrote: https://mail.haskell.org/pipermail/haskell-cafe/2009-March/058607.html
19:40 <byorgey> woah
19:41 Jesin joined
19:41 oberstein joined
19:42 <c_wraith> foldr doesn't sound right there. did you mean something like map, or was that in reference to a specific use of foldr?
19:42 connrs joined
19:42 mwilly joined
19:44 pleax joined
19:48 <byorgey> c_wraith: you're right, foldr doesn't sound right. I have no clue what I meant, it was 8 years ago!
19:48 <byorgey> Just for fun let's assume I meant "map".
19:49 jsgrant- joined
19:50 <c_wraith> let's see.. 8 years ago.. I had at least started learning haskell.
19:51 rkazak_ joined
19:53 <geekosaur> well, the thread was about folds...
19:53 <* geekosaur> assumes braino
19:55 cardboard64 joined
19:55 dni joined
19:57 jbiesnecker joined
19:58 thibaud joined
19:58 subttle joined
19:59 <freeside> http://stackoverflow.com/questions/4092864/tail-recursion-in-haskell and http://stackoverflow.com/questions/13042353/does-haskell-have-tail-recursive-optimization go on and on about this
20:00 joncfoo joined
20:01 theelous3 joined
20:01 oisdk joined
20:01 t0by joined
20:01 t0by joined
20:02 jbiesnecker_ joined
20:02 alexbiehl joined
20:02 tag joined
20:03 bjz joined
20:03 Ayey_ joined
20:04 freusque joined
20:04 arawack joined
20:05 jbiesnecker joined
20:06 JeanCarloMachado joined
20:06 b4ff3r joined
20:07 henriksod joined
20:07 PennyNeko joined
20:08 Jaak joined
20:08 oisdk joined
20:08 <shapr> lyxia: would you recommend generic-random over quickcheck-generic?
20:10 uncertainty joined
20:11 louispan joined
20:12 cdg joined
20:13 path[l] joined
20:13 <lyxia> shapr: it's the same for product types, but for sums you can specify custom distributions with generic-random
20:14 <shapr> ok, I'm convinced.
20:14 BrambleG joined
20:15 Ayey_ joined
20:15 mizu_no_oto_work joined
20:16 louispan joined
20:19 skapazzo joined
20:19 rcschm joined
20:19 freusque joined
20:20 balor joined
20:20 pleax joined
20:21 latro`a joined
20:22 techieAgnostic joined
20:23 oish joined
20:23 <techieAgnostic> Would anyone be able to help me with hdevtools and Vim? Can't get them to play nice
20:25 ggVGc joined
20:26 mstruebing joined
20:26 schell joined
20:26 BrambleG left
20:28 skapazzo joined
20:29 <kadoban> techieAgnostic: Personally I found it not worth the effort to maintain, if that's considered help.
20:30 <techieAgnostic> Fair, are there any you'd reccomend instead?
20:30 Ayey_ joined
20:31 connrs joined
20:32 pera joined
20:32 V3 joined
20:33 <kadoban> techieAgnostic: I just use ghci in a terminal, along with very minor haskell-specific stuff in vim, like a syntax checker and hlint really (using syntastic)
20:33 tromp joined
20:33 <kadoban> And my usual bunch of nonsense, like completion in non-language-specific mode.
20:33 gabe4k joined
20:33 <techieAgnostic> gotcha
20:34 P1c4p4l left
20:34 c0dehero joined
20:34 zzz joined
20:34 raid joined
20:35 <kadoban> To be fair, I do plan to figure out more integration some day, but I'm mostly waiting for someone to make something more mature and stable. Some of it was cool, it just ate up way too much time trying to keep it working and figure out why it wasn't working and etc.
20:36 zeroed joined
20:36 zeroed joined
20:39 SuperTux88 joined
20:39 Jesin joined
20:40 <freeside> in most languages, documentation takes the form: "here is how you use the language and its libraries." in Haskell, documentation seems to prefer the form: "here is how you reimplement the language and its libraries."
20:40 <freeside> not a criticism, just an observation.
20:41 marsam joined
20:41 <schell> is it inherently wrong to implement Applicative in terms of Monad?
20:42 <schell> mf <*> mx = do{ f <- mf; x <- mx; return $ f x }
20:42 <lyxia> not at all
20:42 <kadoban> schell: Not really, no. 'ap' exists, by the way
20:43 <kadoban> :t ap
20:43 <lambdabot> Monad m => m (a -> b) -> m a -> m b
20:43 <kadoban> :t (<*>)
20:43 <lambdabot> Applicative f => f (a -> b) -> f a -> f b
20:43 <schell> as in - does it violate the Applicative laws?
20:43 <schell> hmm that would make it a nice one liner
20:43 pie_ joined
20:44 <kadoban> I don't think it even can violate the laws, if you use (<*>) = ap and pure = return from an already existing lawful Monad implementation, though I could be missing something.
20:44 <tdammers> https://wiki.haskell.org/Functor-Applicative-Monad_Proposal
20:45 <tdammers> basically, any lawful Monad is also a lawful Applicative, and ap == (<*>) and return == pure
20:46 Ayey_ joined
20:48 Levex joined
20:48 vydd joined
20:48 vydd joined
20:49 zzz joined
20:50 balor joined
20:50 justicefries joined
20:51 faberbrain joined
20:52 <schell> kadoban, lyxia, tdammers: okay, thanks - here’s another argument - this implementation throws away the ability to parallelize
20:52 conal joined
20:54 pleax joined
20:55 <lyxia> QuickCheck's (>>=) can be run in parallel.
20:55 IRCFrEAK joined
20:56 ptek joined
20:58 lamer14895245690 joined
20:58 <platz> 'parallelization in theory' seems to succumb to 'never in practice' in the current haskell libs
20:58 <platz> there are exceptions like haxl/fraxl etc..
20:59 lamer14895246260 joined
20:59 lamer14895246260 joined
20:59 HoierM joined
20:59 coot joined
21:00 <platz> haven't seen any other applicative instances do this though... Concurrently from Async is the only one i can think of
21:00 <ezyang> embarassing parallelism is still profitable
21:00 <platz> and I'm not sure Concurrently really counts because it's hiding it under IO
21:01 <platz> hiding/implementing
21:01 mizu_no_oto joined
21:01 dc0de joined
21:02 <platz> yeah explicit parallelism is effective via accelerate/repa
21:02 P1RATEZ joined
21:03 whaletechno joined
21:03 fre joined
21:03 <platz> but that is different from implicit parallisim under applicative instances
21:03 IRCFrEAK joined
21:04 <platz> i guess Control.Parallel.Stratagies is the big one that does count in this regard
21:04 OS-19881 joined
21:05 sveit joined
21:05 Ayey_ joined
21:05 merijn joined
21:06 IRCFrEAK joined
21:06 IRCFrEAK joined
21:07 takuan joined
21:07 <michalrus> @hoogle m a -> m b -> m (a, b)
21:07 <lambdabot> Control.Concurrent.Async.Lifted concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b)
21:07 <lambdabot> Control.Concurrent.Async.Lifted.Safe concurrently :: (MonadBaseControl IO m, Forall (Pure m)) => m a -> m b -> m (a, b)
21:07 <lambdabot> Yesod.WebSockets concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b)
21:07 <michalrus> Where is “normal” zip? :P
21:08 <sveit> typically to fold down to a single value the strict foldl' is used to avoid allocating extra memory. that said, it seems natural to write "and = foldr (&&) True". is this memory efficient (i.e. as compared to explicit recursion)? More generally (assuming that (&&) is strict in its first argument) are functions that are strict in the first argument and lazy in the second folded efficiently by foldr?
21:10 mizu_no_oto_work joined
21:10 sphinxo joined
21:10 IRCFrEAK joined
21:10 alx741 joined
21:11 bjz_ joined
21:11 Destol joined
21:13 mekeor joined
21:14 <byorgey> michalrus: normal zip has a more specialized type, so it's farther down in the search results
21:14 <byorgey> @hoogle [a] -> [b] -> [(a,b)]
21:14 <lambdabot> Prelude zip :: [a] -> [b] -> [(a, b)]
21:14 <lambdabot> Data.List zip :: [a] -> [b] -> [(a, b)]
21:14 <lambdabot> GHC.OldList zip :: [a] -> [b] -> [(a, b)]
21:14 <michalrus> byorgey: yeah, but what is one for general `m` called?
21:15 <michalrus> Or do other preludes have it defined for `m`?
21:15 <byorgey> oh, I see, you are looking for mzip from the MonadZip class
21:15 <michalrus> Yes! Wonderful.
21:15 <michalrus> Thank you!
21:15 <byorgey> https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Monad-Zip.html
21:15 <shapr> byorgey: have you written generic-random part 2?
21:15 Ayey_ joined
21:16 <byorgey> michalrus: you're welcome
21:16 <shapr> I'm going to use part 1 this evening, so I'm curious.
21:16 dni joined
21:16 <byorgey> shapr: not yet. It's on my list but I keep putting it off.
21:16 <shapr> also, thanks for all the great blog posts :-)
21:16 Antonet joined
21:16 <byorgey> The problem is it's probably going to require some more research on my part and it might turn into multiple blog posts. So I'm kind of intimidated by it.
21:17 <byorgey> shapr: sure =)
21:17 <shapr> you implied generic-random can produce examples for non-QC purposes
21:17 <shapr> that sounds exciting
21:17 <shapr> but then, so do the other implications for later part(s)
21:18 <lyxia> I ended up splitting boltzmann-samplers as its own package BTW
21:18 contiver joined
21:18 <lyxia> which is the part that is compatible with non-QC random stuff
21:19 <shapr> oh, interesting
21:19 ph88^ joined
21:19 <lyxia> and I would like to rewrite it with GHC.Generics instead of Data.Data
21:20 oish joined
21:20 ninjazoete joined
21:21 peterbecich joined
21:21 <byorgey> lyxia: oh, nice, I will have to take a look
21:21 <lyxia> The problem is it's so slow compared to testing-feat
21:21 conal joined
21:22 <byorgey> interesting, any intuition as to why?
21:22 mson joined
21:22 <byorgey> maybe it's only faster when n is very large?
21:23 <schell> lyxia, platz, ezyang: thanks guys
21:23 <byorgey> obviously they are using very different generation strategies. In theory Boltzmann sampling is asymptotically faster than testing-feat, but...
21:23 <lyxia> I wrote about it here https://github.com/Lysxia/generic-random/issues/6
21:24 anton joined
21:25 <lyxia> I suspect the constant factor is just too large
21:26 <Sornaensis> @info &&
21:26 <lambdabot> <unknown>.hs: 1: 1:Parse error: &&
21:26 <Sornaensis> @info (&&)
21:26 <lambdabot> (&&)
21:28 Fairy joined
21:28 subttle joined
21:32 <byorgey> lyxia: hmm, that makes sense, but it's rather disappointing
21:32 freeside joined
21:32 <byorgey> lyxia: I wonder if we can perhaps identify a special class of problems where Boltzmann sampling actually pays off, i.e. some kind of worst case for testing-feat's approach
21:33 <byorgey> then at least we could say something intelligent about when you might want to pick which approach.
21:33 <sphinxo> Have I got my usage of mapM wrong? http://lpaste.net/1618438411226447872
21:34 ninjazoete joined
21:34 <sphinxo> I'm a bit confused by the error message
21:35 <lyxia> byorgey: That sounds good. Another possibility is to somehow "recycle" the randomness that is being discarded.
21:36 <byorgey> lyxia: ah, interesting idea. So it wouldn't be faster to generate a *single* random thing but you might be able to get a nice "pipelined/streaming" algorith if you want to generate a sequence of random things?
21:36 Johannes13 joined
21:36 jgertm joined
21:37 <lyxia> I was imagining the recycling going into the single object you want to generate
21:37 tag joined
21:37 <byorgey> oh, OK
21:37 <geekosaur> sphinxo, mapM used without the return would map the IO through. with the return, the monad it operates on is [] because the IO isn't available there
21:38 <sphinxo> geekosaur: so somethings wrong in my testFiles implementation
21:38 <sphinxo> ?
21:39 <geekosaur> why did you use a return in tests?
21:39 LuckyRawApe joined
21:40 <sphinxo> geekosaur: I'm just returning the testCase?
21:40 conal joined
21:40 <geekosaur> what do you think return does?
21:40 <geekosaur> (hint: it is not flow control)
21:40 <sphinxo> oh wait
21:41 <sphinxo> for some reason I thought takeBaseName required it, but that makes no sense
21:41 <freeside> what does "return" do? "return" causes every Haskell novice who has an imperative programming background to make mistakes that could have been avoided if "return" had been named something else. :)
21:41 uncertainty joined
21:41 fuzzy_id joined
21:42 <sphinxo> takeBaseName required IO, that is
21:43 <geekosaur> um
21:43 <geekosaur> you still do not understand
21:43 <freeside> :t mapM
21:43 <lambdabot> (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
21:43 takle_ joined
21:43 <sphinxo> where tests = return ... bit right?
21:43 <geekosaur> return lifts a pure value into a monad. in the case of `tests` that monad is IO; therefore the thing you are returning is *not* in IO
21:44 <geekosaur> and the error iss telling you that mapM had to use [] because IO is *not there*
21:44 Tuplanolla joined
21:44 <geekosaur> because the `return` provided the IO
21:44 <sphinxo> ahh
21:45 takle joined
21:45 tromp joined
21:46 <geekosaur> sin ce I don't know any of the types of the things in mkTest, I don't know if it actually needs IO; but it is not getting IO. ghc didn't get far enough to notice because mapM was already producing a type error
21:46 <sphinxo> well testFiles is the only thing that needs io
21:46 Ayey_ joined
21:47 <geekosaur> then you (a) probably want to ditch the return in `tests` (b) and likewise in `mkTest` because you did the same thing again and there is no IO context for anything being `return`d
21:47 rcat joined
21:48 aib joined
21:49 <sphinxo> how do I map mkTest :: FilePath -> TestTree over testFiles :: IO [FilePath]
21:49 <lyxia> (fmap . fmap) mkTest testFiles
21:50 <lyxia> or is there IO in TestTree?
21:50 <sphinxo> no
21:51 wtetzner joined
21:52 <lyxia> ok so what I said just before would make IO [TestTree]
21:53 hiratara joined
21:53 <sphinxo> so I need to thread IO all down to here?
21:54 <sphinxo> or get testFiles at the top level, and pass it down
21:54 <freeside> fmap (mapM mkTest) testFiles
21:54 thc202 joined
21:55 <freeside> wait, what are you doing again now?
21:55 <freeside> is mkTest returning an IO now or not
21:55 <lyxia> the type of mkTest seems to have changed in the meantime :)
21:55 <lyxia> not anymore
21:56 systadmin joined
21:56 <sveit> sorry to repeat. typically to fold down to a single value the strict foldl' is used to avoid allocating extra memory. that said, it seems natural to write "and = foldr (&&) True". is this memory efficient (i.e. as compared to explicit recursion)? More generally (assuming that (&&) is strict in its first argument) are functions that are strict in the first argument and lazy in the second folded efficiently by foldr?
21:56 <sphinxo> if it did then that'd give me IO (IO [TestTree])
21:56 <freeside> oh, then fmap . fmap would be right
21:56 mada joined
21:57 <freeside> fmap (fmap mkTest) testFiles ?
21:57 darjeeling_ joined
21:58 <lyxia> sveit: I think it is the same
21:58 <sveit> lyxia: what is the same? :) it's certainly not the same as using foldl' since it works on infinite lists
21:58 <freeside> see http://stackoverflow.com/questions/4092864/tail-recursion-in-haskell and http://stackoverflow.com/questions/13042353/does-haskell-have-tail-recursive-optimization
21:59 <lyxia> sveit: I mean, foldr (&&) True and a hand written recursive and
22:00 <freeside> http://stackoverflow.com/questions/3429634/foldl-is-tail-recursive-so-how-come-foldr-runs-faster-than-foldl
22:00 <sveit> lyxia: ah ok, that's what I hoped. is the general pattern that "&&" is strict in first argument and lazy in second?
22:02 alphor joined
22:02 <Enigmagic> @src and
22:02 <lambdabot> and = foldr (&&) True
22:02 raycoll joined
22:02 cdg joined
22:02 tomphp joined
22:02 <lyxia> sveit: yes
22:03 eacameron joined
22:03 <lyxia> like in every programming language, except that in Haskell it's not built-in
22:04 <c_wraith> @src &&
22:04 <lambdabot> True && x = x
22:04 <lambdabot> False && _ = False
22:04 <sveit> Enigmagic: interesting, clicking "source" on hackage gives a different definition (in terms of foldMap)
22:04 _ashbreeze_ joined
22:04 <c_wraith> lyxia, notice how the first argument is pattern matched, but the second isn't in either case?
22:04 <c_wraith> lyxia, that's what determines how strict it is, and in which argument
22:05 <sveit> so a related question, is a legitimate implementation of foldl': foldl' f = foldl f' where f' !a x = f a x?
22:06 stephA joined
22:06 aib joined
22:06 <c_wraith> sveit, nope.
22:06 <sveit> or foldl' f = foldl f' where f' a x = a `seq` f a x
22:07 <sveit> c_wraith: i figured not, but i can't see why. doesn't that only ever store at most one thunk?
22:07 <freeside> hm, following a strict interpretation of "strict", aren't you actually talking about the fact that pattern-matching forces evaluation of the first argument but not the second -- which is a different notion than "strict" forcing evaluation at time of construction?
22:07 <c_wraith> sveit, that is only strict when the result of f' is evaluated.
22:07 <stephA> hello everyone. What is the most haskellish way t?o transform a [Maybe MyType] into |MyType] while ignoring Nothing ? for the moment I do something with filter and a predicate that does the pattern matching, but I wonder if there's not a more direct way
22:07 <peddie> :t catMaybes
22:07 <lambdabot> [Maybe a] -> [a]
22:07 <stephA> perfect !
22:07 <lyxia> sveit: http://lpaste.net/353545 shows that both compile to the same Core
22:08 <c_wraith> sveit, foldl', on the other hand, puts the evaluation dependency on the recursive call to foldl'
22:08 <sveit> c_wraith: i'm confused because won't the next call to f' force the evaluation of the previous f completely (since 'a' becomes 'f a x', and 'a' gets evaluated)
22:08 _ashbreeze_ joined
22:08 <c_wraith> sveit, only if something forces f' to be evaluated.
22:09 <c_wraith> sveit, and the whole problem with foldl is that it doesn't do that.
22:11 sa11 joined
22:11 <c_wraith> sveit, consider x `seq` x
22:11 <c_wraith> sveit, do you know why that doesn't do anything?
22:11 <sveit> c_wraith: yes
22:12 <c_wraith> sveit, well, this is the same underlying idea.
22:12 eschnett joined
22:12 <Enigmagic> sveit: just need to go back a few versions, e.g. https://hackage.haskell.org/package/base-4.6.0.0/docs/src/GHC-List.html#and
22:13 <c_wraith> sveit, if nothing evaluates an expression, the internal evaluation dependencies of that expression don't matter.
22:13 <sveit> c_wraith: i'm still a bit confused. can you explain where the following picture goes wrong (i'm sure it is)? call foldl'' f = foldl f where f' !a x = f a x (my "wrong" foldl'). then if i call foldl'' f x0 xs, i will get ONE unevaluated thunk. when i ask for that thunk everything gets evaluated strictly.
22:14 <c_wraith> the problem is that you don't get one evaluated thunk.
22:15 <c_wraith> foldl builds up a whole chain of thunks.
22:15 <c_wraith> that's just what it does.
22:15 skapazzo joined
22:15 <c_wraith> > foldl f z [a, b, c]
22:15 <lambdabot> f (f (f z a) b) c
22:16 doomlord joined
22:16 louispan joined
22:16 JagaJaga joined
22:16 <c_wraith> so, first it creates (f z a). then it uses that as an argument to f (..) b, and so on.
22:16 <sveit> but doesn't your second f force (f z a) if it's strict in the first argument?
22:17 <c_wraith> only if something causes it to be evaluated.
22:17 minn joined
22:17 Koterpillar joined
22:17 troydm joined
22:17 <c_wraith> that's the thing. if nothing forces the expression to be evaluated, *nothing* will be evaluated.
22:18 <sveit> ah i think i'm starting to understand. so function arguments only get evaluated, even if strict, when the value of the function is actually requested.
22:18 <c_wraith> more specifically, when the result of the function is evaluated.
22:19 <sveit> so adding a bang pattern before an argument is redundant if the function uses the value of the argument?
22:19 <sphinxo> How to apply 2 functions to something and make a tuple of the results?
22:19 <sphinxo> ( usage: carrying a filename, with the files content )
22:19 <c_wraith> for a sufficiently precise definition of "uses", sure. :)
22:19 <sveit> c_wraith: forces to be evaluated :)
22:20 <lyxia> sphinxo: Control.Arrow.(&&&)
22:20 <sveit> that seems like a strange convention though. of course if i add a bang pattern i want the argument to get evaluated as soon as possible. what is the reason for building it this way?
22:20 sepp2k joined
22:20 <sveit> i could evaluate arguments without evaluating the function
22:21 <c_wraith> sveit, it's the same thing as x `seq` x, in that sense.
22:21 <lyxia> sphinxo: liftA2 (,)
22:21 chrisdotcode joined
22:21 <c_wraith> sveit, seq doesn't cause evaluation. it *links* the evaluation of two expressions.
22:22 <c_wraith> sveit, bang patterns desugar to calls to seq within the function body.
22:22 _ashbreeze_ joined
22:23 <sveit> makes a lot more sense! is there a way to cause evaluation?
22:23 <freeside> https://ghc.haskell.org/trac/ghc/wiki/StrictPragma
22:24 doodlehaus joined
22:24 <sphinxo> thanks
22:24 ramzifu joined
22:24 <c_wraith> if you follow the chain all the way up.. the only thing that truly causes evaluation is IO. in every other case, evaluation is the result of demand from something else.
22:25 HoierM joined
22:26 HoierM joined
22:27 HoierM joined
22:28 HoierM joined
22:29 Moyst joined
22:31 hiratara joined
22:31 HoierM joined
22:32 rcat joined
22:34 <sphinxo> Any reason why my test suite ( which has my main library as a build-depends ) would not have a package that my main library has?
22:35 <c_wraith> things that are only transitive dependencies aren't exposed to be imported directly.
22:35 <sveit> is there a reason that GHC doesn't use the function "foldl f x0 (x:xs) = foldl f (f x0 x) xs" to only build ONE thunk, then evaluate the chain when the value is requested? this would allow f being strict in one argument to have the same behavior as foldl'
22:36 <lyxia> sphinxo: you must relist dependencies separately for test suites/benchmarks/executables
22:37 <sphinxo> so how do I import my library from my test suite?
22:37 <sphinxo> as a package or something?
22:37 <lyxia> like any other package
22:37 Ayey_ joined
22:39 moth joined
22:41 mizu_no_oto_work joined
22:41 freusque joined
22:42 <sveit> basically my question is if i have "foldl f x0 (x:xs) = foldl f (f x0 x) xs", why can't i not evaluate ANYTHING (including building thunks) until evaluation is forced?
22:43 louispan joined
22:43 <lyxia> GHC doesn't have a fine enough analysis to tell that f x0 x will be needed.
22:44 <c_wraith> it isn't always needed.
22:44 <c_wraith> it depends on f
22:45 <sveit> hm, still a bit confused. another example: "let s = foldl (+) 0 [1..100000] in print s"; why is the language structured so that /all/ the thunks are built first, then we get a value for s?
22:45 <c_wraith> for instance, one of the few cases in which foldl is fine: reverse = foldl (flip (:)) []
22:45 <lyxia> it could make that analysis depend on f
22:46 Voldenet joined
22:46 Voldenet joined
22:46 uglyfigurine joined
22:46 doodlehaus joined
22:47 <c_wraith> sveit, can you provide an alternate language semantics that would be better? I mean the details of it, not just "it gets this one situation right"?
22:47 <sveit> c_wraith: are you saying the advantage there is that i can reverse a list without evaluating the elements? if that's the only feature you want to preserve my picture of not building up the thunks first, but only building one is compatible.
22:48 <sveit> c_wraith: at most one thunk is built up until a value is requested
22:48 jathan joined
22:48 <c_wraith> sveit, I mean, the real answer to your question is that no one else has provided better semantics, either.
22:48 nshepperd joined
22:48 <c_wraith> sveit, that's not an operational semantics
22:48 <sveit> c_wraith: let me try again :) tail recursive functions only recurse once until they are forced
22:49 skapazzo joined
22:49 <c_wraith> sveit, actually, my point with reverse is that the thunks being built up are the (:) constructors.
22:49 <lyxia> let s = foldl (+) 0 [1 .. n] in ... already takes constant space until s is needed
22:50 <c_wraith> sveit, so.. how does graph reduction proceed when the result is demanded?
22:50 ziocroc joined
22:50 anuxivm joined
22:51 <c_wraith> sveit, I mean, haskell is open-ended on reduction strategy, as long as the result is maximally defined.
22:51 <lyxia> sveit: so I find what you're asking confusing. It's already just one thunk before being evaluated.
22:52 <sveit> now i'm confused too. let me try to be a bit more precise.
22:54 mizu_no_oto joined
22:54 Rodya_ joined
22:55 farao joined
22:56 conal joined
22:57 <sveit> let's focus on foldl'' f = foldl f' where f' a x = a `seq` f a x. currently, let s = foldl'' (+) 0 [1..n] in print s evaluates by (1) building the thunk (...((0 + 1) + 2)... + n), (2) evaluating it inside out. instead, since f' is strict in the first argument, and we know the value of the fold is being requested, it will always be consistent to evaluate the inner function application first instead of building the thunk, righ?
22:58 mmn80 joined
22:58 steeze joined
22:59 <c_wraith> sveit, out of curiosity, are you testing this with optimizations? ghc actually tries to do that rewrite when you tell it to optimize.
22:59 RusAlex joined
22:59 patbecich joined
22:59 <c_wraith> sveit, but as with most optimizations, it's heuristic-driven.
23:01 ptvirgo joined
23:02 cyphase joined
23:07 <AWizzArd> I have my own data structure, a tree. Can a Lens be used to remove the nth element of the tree?
23:08 <c_wraith> if you have the right lens... maybe.
23:08 <c_wraith> does your tree have values in the internal nodes?
23:09 <glguy> There isn't a single "tree" type, so it will help to be more specific
23:09 balor joined
23:10 <AWizzArd> Well, my tree is a Program, that my GP system wants to evolve.
23:10 emmanuel_erc joined
23:10 <AWizzArd> I just want to ask in general, if this could be done. I don’t need something concrete right now.
23:10 <c_wraith> the big problem is with deleting elements from a tree in general.
23:10 <AWizzArd> But for the mutation function it would be interesting to delete or insert elements, or to change/mutate them.
23:10 <glguy> There's no general answer. It's unlikely that "nth element of a tree" will support a lens
23:11 <AWizzArd> (obviously by mutation I mean genetic mutation, and not a side effect)
23:11 conal joined
23:11 <c_wraith> that's not a defined operation unless you provide more details.
23:11 <AWizzArd> Okay, I see. In that case I will simply implement it myself.
23:11 <c_wraith> for instance, if you have an expression tree for (2+(3*4)), what does it mean to delete the + node?
23:12 <AWizzArd> It would result in (2 (3*4)) – in my case.
23:12 <c_wraith> so the tree becomes a forest?
23:12 <AWizzArd> One can delete the 2, the + the (3*4) subtree, the 3, the * or the 4
23:13 <glguy> can I delete a left parenthesis?
23:13 <AWizzArd> glguy: nope
23:13 Ch3ck joined
23:13 <AWizzArd> c_wraith: yes, probably that’s the name.
23:13 <c_wraith> AWizzArd, I mean, in some sense you're not even deleting that node - just changing it to a sequence operation.
23:14 <glguy> so deleting the * from c_wraith's example leads to (2+(3 4))?
23:14 <AWizzArd> It’s fine (and expected) that mutations of genes are typically not very beneficial.
23:14 <glguy> The subtree 3*4 is replaced by a "forest"?
23:14 <AWizzArd> glguy: exactly!
23:14 oisdk_ joined
23:14 <glguy> Yeah, so you've got something that isn't a "tree"
23:14 <AWizzArd> My GP system can still make use of this.
23:14 <freeside> http://learnyouahaskell.com/zippers
23:15 <glguy> so you'll have to be much more specific about what you *do* have for questions like if it can have a lense
23:15 tromp joined
23:15 geekosaur joined
23:17 <AWizzArd> Oki, makes sense. I will delay the Lens thing then and simply implement it by hand, for now, and come back to this a bit later.
23:17 tfc joined
23:19 ystael joined
23:21 DS709 joined
23:23 ij joined
23:25 tag joined
23:30 zero_byte joined
23:31 <jle`> AWizzArd: lens doesn't let you define new actions; it is a way of phrasing/encoding actions things in a composable way
23:31 <jle`> s/is a/can be used as a
23:31 Ayey_ joined
23:32 dcoutts_ joined
23:32 <jle`> AWizzArd: so once you define your deletion function, you can make it more composable with other functions, and lens would probably help with that
23:33 eacameron joined
23:33 mr_sm1th joined
23:35 gcross_ joined
23:35 ricky_clarkson joined
23:36 gcross_ joined
23:38 BlueRavenGT joined
23:39 Habib joined
23:39 gcross_ joined
23:39 xaviergmail_ joined
23:39 coltfred joined
23:40 rekahsoft joined
23:40 <Habib> Hey, anyone know a version of <*> where the type signature is more like Functor f => f (a -> b) -> a -> f b? I know I can just use pure to wrap the value up before operating on it with <*>, but surely there's a function that will just take care of that for me?
23:40 <Tuplanolla> @hoogle Functor f => f (a -> b) -> a -> f b
23:40 <lambdabot> Prelude fmap :: Functor f => (a -> b) -> f a -> f b
23:40 <lambdabot> Prelude (<$>) :: Functor f => (a -> b) -> f a -> f b
23:40 <lambdabot> Control.Monad fmap :: Functor f => (a -> b) -> f a -> f b
23:40 <Tuplanolla> I'm sure I've seen it around.
23:41 peterbecich joined
23:41 ali_bush joined
23:41 ali_bush joined
23:41 <Habib> Yeah, I searched hoogle, but it didn't turn up anything useful.
23:41 <Tuplanolla> @hoogle (??)
23:41 <lambdabot> Control.Lens.Lens (??) :: Functor f => f (a -> b) -> a -> f b
23:41 <lambdabot> Control.Lens.Operators (??) :: Functor f => f (a -> b) -> a -> f b
23:41 <lambdabot> Control.Error.Util (??) :: Applicative m => Maybe a -> e -> ExceptT e m a
23:41 <Habib> Holy crap, the first one looks promising.
23:42 <Tuplanolla> This makes Hoogle look broken.
23:42 mnislaih joined
23:42 <Habib> Does that mean I'll have to start learning about Lens? I've been trying to avoid that until after this project.
23:42 <shapr> lens is wonderful
23:42 <Tuplanolla> You can just yoink that one function.
23:43 <Habib> I'm aware of its benefits, but I feel like I don't have a handle on understanding it, and so would prefer to avoid using it for now.
23:44 <glguy> The ?? operator just happens to be in Control.Lens. It's not "using lens" in any interesting way beyond the coincidence of using Functor
23:44 <Habib> But yes, if this function does what I want, it seems to be easily understandable.
23:44 gcross_ joined
23:44 yamadapc joined
23:45 gcross_ joined
23:46 wlemuel joined
23:47 Rodya_ joined
23:47 <dmwit> :t let f ?? x = fmap ($x) f in (??)
23:47 <lambdabot> Functor f => f (a -> b) -> a -> f b
23:47 <Habib> Is it reasonable to pull in lens for just this one thing when I could just use pure to wrap the value? It's just annoying because I have to actually do pure . fromString on the value, because I want an IsString instance.
23:48 <glguy> No, it's not reasonable to pull lens in for this
23:48 dan_f joined
23:48 <dmwit> It is not reasonable to pull in lens for this.
23:48 <Habib> lol
23:48 <Habib> ok, ok, i got it.
23:48 <dmwit> Just write the definition above in a file and be done.
23:48 <Habib> Ay, I didn't think of that.
23:48 <Tuplanolla> You can even name that module `Control.Lens`.
23:48 <jle`> learn the lessons of left-pad :)
23:49 <Habib> I think I'll name it Control.Functor
23:49 <Tuplanolla> You could play pretend without ten-hour compile times.
23:49 <Habib> What does the Control name actually stand for.
23:49 <jle`> nothing, really
23:49 <dmwit> Re: "ok, ok, i got it." -- not trying to swamp you with advice. It's just coincidence that we happened to have the same answer and type at about the same speed.
23:49 YongJoon joined
23:49 <Habib> Yeah, I know. I'm just trying to be funny :)
23:50 mysticjohn joined
23:50 <dmwit> okay =)
23:51 <robkennedy> Which type I could wrap around functions whose output type depends on the input type? Ie listToMaybe, typeRep (constant relationship).
23:51 <dmwit> You will need to be more specific.
23:52 <jle`> you mean functions of the form 'f a -> g a', that work for any 'a'?
23:52 <Habib> listToMaybe returned value depends on the input value, not the type.
23:52 <jle`> they're commonly called natural transformations
23:52 <jle`> type Nat f g = forall a. f a -> f g
23:52 <dmwit> :t typeRep
23:52 <jle`> er, type Nat f g = forall a. f a -> g a
23:52 <lambdabot> forall k (proxy :: k -> *) (a :: k). Typeable a => proxy a -> TypeRep
23:52 <jle`> but i'm not sure that's what you actually mean
23:53 <dmwit> The output type of `typeRep` does not appear to depend on the input type.
23:53 ertes joined
23:53 vaibhavsagar joined
23:54 <robkennedy> I tried `newtype F fo = F (forall i. i -> fo i)`, where you could construct a type family `ListToMaybe` and write `H listToMaybe :: H ListToMaybe`
23:54 <robkennedy> Sorry, I switched from F to H there
23:54 tfc joined
23:55 <freeside> the old switcferoo
23:55 mwilly joined
23:55 <glguy> ListToMaybe is a type family with no parameters?
23:55 the|auriscope joined
23:55 halogenandtoast joined
23:55 <robkennedy> Well there's the rub: it won't work that way
23:55 <dmwit> Presumably it is a family with `type instance ListToMaybe [a] = Maybe a`.
23:55 <glguy> That's just a type synonym
23:56 <Habib> @type listToMaybe
23:56 <robkennedy> dmwit intuited correctly thanks
23:56 <lambdabot> [a] -> Maybe a
23:56 <glguy> robkennedy: You can't omit the parameters when you use a type family, so "H ListToMaybe" indicates that it has no parameters
23:58 <dmwit> Why do you want this?
23:58 <robkennedy> Right, I understand that. So `newtype H fo = H (forall i. i -> fo i)` doesn't seem like the right type wrapper
23:58 <dmwit> Perhaps there is a solution which avoids needing to create `F` (or `H` or whatever).
23:59 strykerkkd joined
23:59 <robkennedy> Yeah, I'm looking to use functions on heterogeneous collections