<     May 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 _2_5 26 27  
28 29 30 31
00:00 bydo joined
00:00 <dmj`> slack1256: you’d probably need to recompile xmonad (or maybe just your config), to log those stats
00:01 atk joined
00:01 <slack1256> I see
00:01 MP2E joined
00:01 infinity0 joined
00:02 <dmj`> main = do
00:02 <dmj`> forkIO $ forever (threadDelay (1000 * 1000) >> (hPutStrLn stderr =<< show <$> getGCStats))
00:02 <dmj`> xmonadMain
00:04 infinity0 joined
00:04 saussure joined
00:04 <moly> dmj`: much thanks
00:04 mizu_no_oto joined
00:06 mavihs joined
00:06 Trendrrr joined
00:07 infinity0 joined
00:10 infinity0 joined
00:11 Fairy joined
00:11 gestone joined
00:12 <dmj`> moly: np, let me know how it goes
00:12 <dmj`> moly: *
00:12 infinity0 joined
00:13 joco42 joined
00:13 tefter joined
00:14 Lord_of_Life joined
00:14 buglebudabey joined
00:15 saussure joined
00:15 <hanna> https://0x0.st/EK5.hs I wonder if there's a better way of writing this
00:15 <hanna> feels needlessly verbose
00:16 gmhafiz_ joined
00:16 louispan joined
00:16 butterthebuddha joined
00:17 mjora7 joined
00:17 Rodya_ joined
00:18 <glguy> hanna: It looks like none of the code is redundant, what's the verbosity that you're imagining you could get rid of? You could improve the code by not using flip or =<< on the last line
00:19 <hanna> glguy: I guess I'm just surprised it takes this much boilerplate to POST stdin to a website
00:19 <hanna> seems like it would be like 1-2 lines in something like python
00:19 <hanna> idk though, haven't tried
00:19 <glguy> Which part is the boiler plate?
00:19 anuxivm left
00:19 eSVG joined
00:20 <hanna> partFileRequestBody "file" "stdin.txt" . requestbodySourceChunked $ sourceHandle stdin -- this is the line that bothers me
00:23 samtay joined
00:23 dual joined
00:24 nighty-- joined
00:25 plutoniix joined
00:26 flatmap13 joined
00:26 castlelore joined
00:26 plutoniix joined
00:26 takle joined
00:27 Trendrrr joined
00:29 wroathe_ joined
00:29 buglebudabey joined
00:29 <samtay> Can someone help me with handling the stdin :: System.IO.Handle? Let's say I want to accept text from stdin and output it uppercase to stdout. I'd also like to implement a timeout limit, such that if no input is given within 5s then it errors out. On the other hand, I'd also like to support a direct pipe such as "echo 'test' | hsprogram"
00:31 <glguy> samtay: You can detect that stdin is a terminal device with System.IO.hIsTerminalDevice
00:31 jmcarthur joined
00:32 hybrid joined
00:32 <samtay> The problem is to handle the pipe, I need to test for isEOF, but to handle the timeout, I need to test via hWaitForInput.
00:32 <glguy> System.Timeout.timeout can help with the timeout
00:32 andyhuzhill joined
00:32 romank joined
00:32 <glguy> Oh, or hWaitForInput is better
00:33 <samtay> Ah... let me look into that and see if I have any more questions. Just using the two functions I mentioned, you can't order them successfully (isEOF will block but if it's put after the hWaitForInput then hWaitForInput errors out when it encounters EOF)
00:33 <glguy> You can catch the error, so that's OK
00:33 joco42_ joined
00:33 waltervargas[m] joined
00:34 <samtay> I figure there _has_ to be a way to do this without throwing and catching an error...
00:35 <EvanR> low level IO stuff prefers IO exceptions to C-style Bool reeturns
00:35 <glguy> Why would you figure that?
00:35 <samtay> Haha I guess I base that on nothing.
00:36 <EvanR> for better or worse
00:36 <glguy> I'm surprised that on my computer I get "fdReady: msecs != 0, this shouldn't happenAbort trap: 6" when I try to use hWaitForInput on stdin
00:36 <EvanR> with the exception way you can handle errors in one place, if at all
00:36 <samtay> Yup I've had that one too. Forget exactly why, I've permuted the code a ton of times at this point.
00:37 <EvanR> Abort trap: 6... nice
00:37 <samtay> (For reference, this is for the Haskell Book From First Principles, Chapter 29 IO, Exercise 1)
00:37 <samtay> And, that exercise doesn't indicate that I should reach for the exception module, but that's okay, probably a good thing for me to learn about anyway. Thanks for the tip.
00:38 <glguy> https://ghc.haskell.org/trac/ghc/ticket/13525
00:38 andyhuzhill1 joined
00:38 <EvanR> low level IO is not as convenient as it could be, i see catching these exceptions as a way to make a nicer higher level Io action
00:39 takle joined
00:41 filterfish joined
00:42 saussure joined
00:43 jackjackjack joined
00:44 urdh joined
00:44 yamad joined
00:44 ofdm joined
00:45 jackjackjack left
00:46 Trendrrr joined
00:46 <hanna> are there any pattern synonyms in base for string prefix/suffix matching?
00:46 <lpaste> glguy pasted “for samtay” at http://lpaste.net/355744
00:46 <hanna> I know I can use stripPrefix and view patterns but it seems like in 2017 we should have better
00:46 <glguy> there's isPrefixOf and stripPrefix
00:48 jackjackjack joined
00:48 cschneid_ joined
00:51 ph88^ joined
00:53 takle joined
00:54 Welkin joined
00:56 drewbert joined
00:57 eacameron joined
00:58 lambda-11235 joined
01:00 juanpaucar joined
01:00 saussure joined
01:00 takle joined
01:00 drewbert joined
01:01 cpennington joined
01:02 SenpaiSilver joined
01:05 dbmikus joined
01:07 vaibhavsagar joined
01:07 romank joined
01:09 takle joined
01:11 dan_f joined
01:12 exarkun joined
01:13 tristanp joined
01:14 baldrick joined
01:15 dbmikus joined
01:19 takle joined
01:20 andyhuzhill joined
01:23 jship joined
01:24 Welkin joined
01:25 Goplat joined
01:25 Goplat joined
01:30 <jle`> it'd be nice if you could use type applications with overloaded literals
01:30 juhp joined
01:30 <jle`> 5 @Int, "hello" @String
01:30 romank joined
01:30 systadmin joined
01:32 <geekosaur> propose it. (I'm actually a bit surprised it doesn't work...)
01:32 romank joined
01:35 Trendrrr joined
01:35 <jle`> i wonder if there's still time to get it in before 8.2
01:36 <jle`> what's the best way to propose it?
01:36 romank joined
01:36 yamad_ joined
01:36 <Lokathor> using linear for openGL is trickier than expected :/
01:36 <jle`> oh nvm https://ghc.haskell.org/trac/ghc/ticket/11409
01:37 <Welkin> jle`: what do you mean by type applications?
01:37 <jle`> -XTypeApplications
01:37 <Welkin> link?
01:37 <jle`> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#visible-type-application
01:38 <jle`> like, for fmap :: Functor f => (a -> b) -> (f a -> f b), you can write `fmap @[]` to know that you want fmap :: (a -> b) -> [a] -> [b]
01:38 <jle`> and `read @Int "123"` to let ghc know you want read :: String -> Int
01:38 <Welkin> how is `read @Int 5` different from `(read :: Int) 5`
01:38 <Welkin> er
01:39 <jle`> it's the same, but there are situations when giving a full type signature is inconvenient
01:39 <Welkin> okay
01:39 <jle`> like the fmap example
01:39 <jle`> and being able to write (Proxy @5) instead of (Proxy :: Proxy 5)
01:39 <jle`> it also associates in a nicer way than type signatures
01:41 <lyxia> @5 instead of Proxy @5 once you give up on non-ambiguity
01:41 <lambdabot> Maybe you meant: v @ ? .
01:41 <lyxia> lambdabot: sorry
01:43 LHoT10820 joined
01:44 meba joined
01:45 samtay joined
01:46 romank joined
01:47 <Welkin> I don;t understand the use case for something like this https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#implicit-parameters
01:48 jedws joined
01:48 Trendrrr joined
01:49 peterbecich joined
01:49 <Welkin> the example looks forced
01:49 lambdamu joined
01:49 romank joined
01:50 <geekosaur> it is forced
01:50 <Welkin> How is the `sort` function there any different from just writing `sort = sortBy`
01:50 <Welkin> ?
01:50 <geekosaur> the use cases are somewhat rare in my experience, but for example the new "stack trace" support uses it (hidden inside a HasStack constraint)
01:51 <geekosaur> effectively it's a way to pass data via the context instead of the parameters
01:51 spacecadetbrown joined
01:51 otulp joined
01:52 takle joined
01:52 <geekosaur> which ... if you have control over the parameters than using parameters is usually easier, and if you don't then the context likely won't be any more controllable, but.
01:52 <jle`> Welkin: it's basically usable in most situations where you'd want Reader/ReaderT
01:52 <jle`> except it's implicit
01:52 <geekosaur> so about the only time I use it is for ghci / lambdabot hacks
01:52 waltervargas[m] left
01:53 <jle`> Welkin: i use it for configuring big projects with a global configuration
01:53 <jle`> ports, hostnames, etc.
01:53 dan_f joined
01:53 <Welkin> how would you pass this parameter in that situation?
01:53 <jle`> the only downside really (if your thing is global) is that you can't use them in typeclass instances
01:53 <Welkin> where does it get defined
01:54 <geekosaur> in a let, usually
01:54 <Welkin> oh
01:54 <Welkin> inside the function?
01:55 <jle`> Welkin: as long as `?config` is in scope somewhere, it'll be picked up by implicitparams
01:56 <jle`> so like `do ?config <- loadConfig :: IO Config; ... stuff ...`
01:56 <jle`> ?config here working like a normal variable identifier
01:56 <lambdabot> Unknown command, try @list
01:56 <jle`> sorry lamdabot
01:57 <jle`> i prefer it over ReaderT/reflections in this case since you can just return normal unwrapped data types and the parameter composition gets passed globally
01:57 seagreen joined
01:57 <jle`> but unlike with 'reflections', you can't use implicit parameters in typeclass instances
01:58 renzhi joined
01:58 <geekosaur> oh, and if you think this is weird, try on https://downloads.haskell.org/~ghc/6.4.1/docs/html/users_guide/type-extensions.html#linear-implicit-parameters :)
01:58 <jle`> it's probably only useful if your configuration is global too since mixing implicit parmeters in the same project is kind of awkward
01:58 Supersonic112_ joined
01:59 Trendrrr joined
01:59 <jle`> geekosaur: haven't seen these before :O
01:59 wroathe joined
01:59 saussure joined
01:59 takle joined
01:59 <geekosaur> you can still trigger a warning about their removal if you use a % in the wrong place iirc
02:00 <geekosaur> > let %x = 5 in %x
02:00 <lambdabot> <hint>:1:5: error: parse error on input ‘%’
02:00 <jle`> sounds like a piece of haskell lore
02:00 <geekosaur> hm, right, hint doesn;'t have that code
02:00 GreenSands joined
02:00 hucksy_ joined
02:01 koserge joined
02:03 svgDelux joined
02:06 romank joined
02:06 Trendrrr joined
02:07 takle joined
02:08 jerbome_ joined
02:09 andyhuzhill joined
02:11 romank joined
02:11 daniel-s joined
02:11 zcd joined
02:14 romank joined
02:16 romank joined
02:19 exferenceBot joined
02:20 wroathe joined
02:21 zcd joined
02:22 nomeata joined
02:23 hexagoxel joined
02:25 ALX joined
02:26 <ALX> hello
02:26 flatmap13 joined
02:26 <dmj`> ALX: o/
02:26 <dmj`> jle`: the lore of yore
02:26 yobohohoz joined
02:27 <ALX> absolute noob here... new to both IRC and Haskell... is learn you a haskell a good place to start?
02:28 drewbert joined
02:30 <vaibhavsagar> ALX: don't do it!
02:30 <vaibhavsagar> http://bitemyapp.com/posts/2014-12-31-functional-education.html
02:30 <ALX> vaibhavsagar: Suggestions?
02:31 cyborg-one joined
02:31 <vaibhavsagar> haskell programming from first principles is a better one to start with
02:31 systemfault joined
02:31 <vaibhavsagar> http://haskellbook.com/
02:31 <glguy> If you're buyign something, hutton's Programming in Haskell
02:31 pyx joined
02:32 <glguy> Learn you a Haskell won't teach you Haskell, but it will certainly introduce you to some of the things that are in Haskell
02:33 <AerialBoundaries> Is Real World Haskell decent?
02:33 <glguy> It hasn't been kept up to date since its release years ago
02:34 <AerialBoundaries> ok
02:34 <glguy> So some of the libraries have changed since, some of the code samples won't work
02:34 Pilfers joined
02:34 Trendrrr joined
02:35 darlan joined
02:35 nshepperd joined
02:36 owickstrom joined
02:37 <dmj`> AerialBoundaries: good reference material http://dev.stephendiehl.com/hask/
02:37 <dmj`> @typeclassopedia
02:37 <lambdabot> Unknown command, try @list
02:37 <geekosaur> @where typeclassopedia
02:37 <lambdabot> http://www.haskell.org/haskellwiki/Typeclassopedia
02:37 <dmj`> geekosaur: thanks
02:38 takle joined
02:40 wroathe joined
02:40 <AerialBoundaries> thank you
02:41 baldrick1 joined
02:43 cschnei__ joined
02:44 pavonia joined
02:44 saussure joined
02:45 yamad_ joined
02:45 romank joined
02:46 eacameron joined
02:46 Trendrrr joined
02:46 wedens joined
02:50 andyhuzhill joined
02:51 takle joined
02:51 shangxiao joined
02:51 systadmin joined
02:53 Snircle joined
02:54 cschneid_ joined
02:55 andyhuzhill joined
02:57 baldrick1 joined
02:57 Trendrrr joined
02:58 takle joined
03:00 andyhuzhill joined
03:00 wroathe joined
03:01 sword865 joined
03:02 tommd joined
03:05 takle joined
03:05 otulp joined
03:06 cschneid_ joined
03:06 dan_f joined
03:07 neoo joined
03:09 neoo joined
03:10 gpampara joined
03:10 neoo joined
03:10 thimoteus joined
03:10 andyhuzhill1 joined
03:10 romank joined
03:11 cschneid_ joined
03:12 neoo joined
03:13 neoo joined
03:13 alicemaz joined
03:14 felixsch__ joined
03:14 Trendrrr joined
03:15 <DataComputist> The channel #haskell-beginner seems usually empty?
03:15 justanotheruser joined
03:15 wroathe joined
03:15 CoderPuppy joined
03:15 <EvanR> ah
03:16 <EvanR> #haskell-beginners
03:16 neoo joined
03:16 <EvanR> with an S
03:16 <EvanR> but this channel should be good for beginners
03:17 brynedwardz joined
03:18 neoo joined
03:18 thimoteus left
03:19 dmj` joined
03:22 Trendrrr joined
03:22 andyhuzhill joined
03:23 takle joined
03:23 baldrick1 joined
03:25 wroathe joined
03:26 darjeeli1 joined
03:27 jerbome_ joined
03:28 <dunx> it is
03:28 esph joined
03:29 afarmer joined
03:29 <DataComputist> On macOS, how to let stack use the newest released GHC? Mine shows ghc 7.10
03:30 andyhuzhill joined
03:31 <geekosaur> compiler is determined by the resolver, and you're probably using the same resolver that was current LTS when you installed it.
03:31 <DataComputist> https://www.irccloud.com/pastebin/5GKWjCL6/code
03:32 <geekosaur> trying to look up how you tell it to update resolver
03:32 afarmer_ joined
03:32 <DataComputist> How to let the resolver use the latest release versin of ghc?
03:32 aweinstock joined
03:32 <MarcelineVQ> for outside for a project you update it at .stack/global-project/stack.yaml
03:33 <DataComputist> Just manually edit a version number in .stack/global-project/stack.yaml?
03:33 Xanather joined
03:34 <MarcelineVQ> if you want that to be the default for using stack outside of a project then yes, something like resolver: lts-8.15
03:34 Trendrrr joined
03:34 takle joined
03:34 <DataComputist> The file has a line saying
03:34 <DataComputist> https://www.irccloud.com/pastebin/osTegNDc/line
03:35 <DataComputist> https://www.irccloud.com/pastebin/hAg40ESm/configline
03:35 fizruk joined
03:35 <MarcelineVQ> afaik that's for more special custom setup
03:36 <DataComputist> OK, so my file current has 'resolver: lts-5.5'. Where does one get the right number to replace that '5.5'?
03:36 t joined
03:37 <MarcelineVQ> you can check out the list of the latest per ghc here here https://www.stackage.org/
03:37 <Guest40286> such a shame this doesn't work anymore: http://ircbrowse.net/browse/haskell
03:37 romank joined
03:37 <Guest40286> Anybody know why?
03:38 <DataComputist> So one just have to manually read off the latest version number and manually edit the config file?
03:38 juanpaucar joined
03:38 <DataComputist> Why there isn't a way to update to the latest release version by running a command ... this doesn't seem natural
03:39 <c_wraith> DataComputist: the purpose of stack is to not update.
03:39 <MarcelineVQ> because the resolver is the central concept of stack, updating it willy-nilly is against the point of stack which is stability
03:43 <DataComputist> No, i mean when it's outside of any project, isn't it natural to be able to use the latest release version?
03:43 <c_wraith> DataComputist: there's a reason I don't use stack. It's not designed for that.
03:43 <glguy> DataComputist: The closest thing that comes to find is to use: stack solver --resolver=ghc-8.0
03:44 <DataComputist> If it's in some project, it is useful to keep a set of mutually compatible software versions by not allowing individual softwares to automatically updating to their own newest versions.
03:44 Trendrrr joined
03:45 meba joined
03:45 <DataComputist> But when it's not in any purposefully protected subenvironment, upgrading to the latest released version seems more natural ...
03:45 takle joined
03:45 wroathe joined
03:47 <DataComputist> So I followed the first instruction and manually changed .stack/config.yaml to use 'resolver: lts-8.15'
03:47 <DataComputist> now I have
03:47 <DataComputist> https://www.irccloud.com/pastebin/bjZzDduv/ghc8
03:47 <DataComputist> It's still not the latest released version of ghci
03:48 saussure joined
03:48 <MarcelineVQ> hmm? yes it is
03:48 <DataComputist> No, take it back. It IS.
03:48 <DataComputist> I was mixing up ghc and ghci.
03:48 <DataComputist> I'm good now. Tks.
03:49 <MarcelineVQ> that's the latest released ghc as well, ghci is ghc
03:49 gestone joined
03:50 <DataComputist> Right, for some reason I remembered it was 8.10 or something.
03:50 takle joined
03:50 <EvanR> we got a time traveler over here
03:51 bsmt joined
03:52 <DataComputist> :S
03:52 <Welkin> DataComputist: you are thinking of 7.10
03:53 <Welkin> oh
03:53 <Welkin> stackage lts versions are not the same as ghc versions
03:53 saussure joined
03:53 afarmer joined
03:55 sleffy joined
03:56 wroathe joined
03:57 Trendrrr joined
03:57 isenmann joined
03:59 Koterpillar joined
04:00 romank joined
04:01 takle joined
04:02 <DataComputist> Is there a slight memory saving to define a function anonymously as compared to a named function definition?
04:02 <EvanR> you mean, named function at the top level?
04:03 <glguy> Sure, the top-level one needs a name. that could be as much as 10 more bytes
04:03 <glguy> in your file
04:03 rickygee joined
04:03 yamad_ joined
04:04 <EvanR> for a one argument function, i guess theres not much of a difference
04:05 <EvanR> for currying you need a heap object and a context either way
04:05 <glguy> it doesn't matter at runtime
04:06 wroathe joined
04:09 romank joined
04:09 <EvanR> you would really hope that slight surface syntax choices dont drastically affect performance
04:09 louispan joined
04:09 <EvanR> especially when theres no semantic difference
04:10 descender joined
04:10 takle joined
04:11 mzf joined
04:11 leat joined
04:12 tristanp joined
04:14 romank joined
04:15 infinity0 joined
04:16 systemfault joined
04:16 wroathe joined
04:17 augur joined
04:19 romank joined
04:22 lavalike joined
04:22 afarmer joined
04:23 halogenandtoast joined
04:23 exarkun joined
04:25 CyberShadow joined
04:26 <lpaste> halogenandtoast pasted “SpockHelpCleanup.hs” at http://lpaste.net/4352731754272915456
04:26 <halogenandtoast> If anyone is interested in some refactoring help ^^
04:29 Trendrrr joined
04:30 romank joined
04:32 omilu joined
04:34 romank joined
04:36 andyhuzhill joined
04:39 lambda_foo joined
04:39 romank joined
04:41 kantokomi joined
04:41 eacameron joined
04:41 wroathe joined
04:42 romank joined
04:42 takle joined
04:42 filterfish joined
04:43 rstone joined
04:44 filterfish joined
04:45 rblaze joined
04:46 ilpincy joined
04:46 ilpincy left
04:46 connrs joined
04:47 sleffy joined
04:48 ndrei joined
04:48 aarvar left
04:49 Trendrrr joined
04:50 gestone joined
04:51 Lokathor joined
04:52 wroathe joined
04:53 takle joined
04:53 saussure joined
04:55 StianL joined
04:56 <* halogenandtoast> afk
04:56 <halogenandtoast> apparantly I forgot how to just issue that command.
04:57 <halogenandtoast> s/apparantly/apparently/
04:58 eklavya joined
04:59 systemfault joined
05:00 jerbome_ joined
05:01 wroathe joined
05:03 caumeslasal joined
05:04 takle joined
05:04 tommd joined
05:05 romank joined
05:05 juanpaucar joined
05:06 Trendrrr joined
05:07 ndrei joined
05:07 xall joined
05:09 falafel joined
05:12 wroathe joined
05:15 romank joined
05:17 [scrooge] joined
05:17 jaziz1 joined
05:18 Trendrrr joined
05:18 romank joined
05:18 flatmap13 joined
05:19 Welkin joined
05:19 meandi_2 joined
05:20 takle joined
05:21 tromp joined
05:22 wroathe joined
05:24 zcourts joined
05:25 <EvanR> manatee 0.2.2 uploaded 2011
05:25 cschneid_ joined
05:26 gestone joined
05:26 <EvanR> docs not built...
05:26 flatmap13 joined
05:26 sternmull joined
05:27 spacecadetbrown joined
05:28 <DataComputist> Is the ':{' syntax mentioned in http://stackoverflow.com/questions/8443035/multi-line-commands-in-ghci a Haskell thing or a GHCi thing?
05:28 yirabbit joined
05:29 <EvanR> ghci
05:29 osa1 joined
05:29 <DataComputist> Why the command prompt is called 'Prelude'?
05:30 <EvanR> it changes depending on what you import
05:30 nwf joined
05:30 <EvanR> Prelude is the module implicitly loaded first anywhere
05:30 <EvanR> https://hackage.haskell.org/package/base-
05:30 sz0 joined
05:30 Trendrrr joined
05:31 rickygee joined
05:34 Welkin joined
05:35 mark__ joined
05:36 takle joined
05:36 mavihs joined
05:36 mavihs joined
05:37 <mark__> Hi, in "Haskell programming from first principles" it mentions how a -> a -> a has only two implementations (after saying that a -> a has a single one, id). What are these? I've only managed to think of a -> (a -> a) and (a -> a) -> a, but this seems wrong due to -> being right-associative.
05:37 dec0n joined
05:37 <mark__> and of course, in typing that out I figured out my answer (f a b = a and f a b = b). Thanks I guess?
05:37 <glguy> mark__: An "implemntation" of (a -> a -> a) is a value that has that type
05:38 <MarcelineVQ> yw
05:38 Kuros` joined
05:38 Trendrrr joined
05:40 anodium joined
05:41 romank joined
05:42 macrover joined
05:44 RouxTheDay joined
05:45 Trendrrr joined
05:45 sdx231 joined
05:47 wroathe joined
05:49 takle joined
05:49 noan_ joined
05:52 merijn joined
05:53 AfC joined
05:54 <halogenandtoast> I tried an hour or so ago, so hopefully it doesn't feel spammy for me to ask again. I was hoping to get some feedback / refactoring help on this paste: http://lpaste.net/4352731754272915456 if anyone was interested in providing feedback. Mainly the `getProvider` method and extracting the DB type like that.
05:54 <halogenandtoast> Took me a little bit of type-tetris to figure out what type `DB` was supposed to be.
05:55 <lyxia> looks like you might want to reach for MaybeT
05:56 saussure joined
05:56 tommd joined
05:56 fotonzade joined
05:56 zcourts joined
05:57 ThomasLocke joined
05:57 ThomasLocke joined
05:57 paolino joined
05:57 <lyxia> or just throw an exception that you catch at the end...
05:58 danvet joined
05:58 Trendrrr joined
05:58 wroathe joined
05:58 <cocreature> here’s how that example would look like with MaybeT http://lpaste.net/355745 (untested)
05:59 juhp joined
05:59 ericsagnes joined
06:01 <halogenandtoast> Thanks lyxia and cocreature checking it out.
06:01 <halogenandtoast> I don't want it to eventually throw an exception, if it fails I want it to redirect to the base website
06:02 ErinvanderVeen joined
06:02 <halogenandtoast> oh man the runMaybeT is beautiful
06:02 <halogenandtoast> I was wondering how to use `<-` in a Maybe monad when my top level monad was the `DB` type.
06:02 <cocreature> halogenandtoast: if you have control over the definition of selectFirst and getDomain you might want to put the wrapping inside MaybeT in there. if not, you probably still want to write separate wrapper functions "getDomain = MaybeT . Qualified.getDomain" instead of wrapping it at the use site
06:03 <halogenandtoast> selectFirst comes from persistent, I control getDomain.
06:03 <halogenandtoast> well control as far as it is present in the paste.
06:04 Deide joined
06:06 balor joined
06:06 takle joined
06:06 mbuf joined
06:07 Trendrrr joined
06:07 wroathe joined
06:09 juanpaucar joined
06:09 hurkan joined
06:11 macrover joined
06:12 takle joined
06:12 darjeeli1 joined
06:14 quchen joined
06:14 conal joined
06:14 flatmap13 joined
06:15 Trendrrr joined
06:15 winter_ joined
06:18 fakenerd joined
06:21 FreeBirdLjj joined
06:21 <DataComputist> The hyperlink to the "Kronos Haskell Notebook ..." in https://wiki.haskell.org/Distributions#Kronos_Haskell_Notebook_for_Mac is now an invalid link.
06:22 Mortomes|Work joined
06:23 connrs joined
06:24 <halogenandtoast> lyxia and cocreature: I'm still amazed by the use of MaybeT, thanks for the suggestion.
06:25 Robin_Jadoul joined
06:25 vlatkoB joined
06:27 takle joined
06:27 exferenceBot joined
06:28 wroathe joined
06:29 <vaibhavsagar> hey, how do I statically link postgres to a binary?
06:29 <vaibhavsagar> i.e. what GHC options should I add?
06:30 eklavya joined
06:34 <vaibhavsagar> optl-static and optl-pthread are not enough
06:34 takle joined
06:35 jutaro joined
06:35 ertes-w joined
06:35 Trendrrr joined
06:36 romank joined
06:37 <Axman6> vaibhavsagar: you might want to take a look at: https://www.fpcomplete.com/blog/2016/10/static-compilation-with-stack
06:37 <Axman6> it's not trivial...
06:37 mohsen_ joined
06:38 <vaibhavsagar> Axman6: Hi! I have looked at that already
06:39 exarkun joined
06:39 <Axman6> Then you know as much as anyone :)
06:39 <vaibhavsagar> I did the crtbeginT swap and everything
06:39 <vaibhavsagar> but I need additional linker options? to get it to work
06:40 ycz0926 joined
06:40 ycz0926 left
06:40 baldrick1 joined
06:40 <Axman6> do you have static libraries for postgresql instaslled?
06:40 ycz0926 joined
06:41 ycz0926 left
06:41 ycz0926 joined
06:41 CurryWurst joined
06:42 <vaibhavsagar> hmm, maybe not? I will try that
06:42 ycz0926 left
06:42 ndrei joined
06:42 <* Axman6> wonders if baldrick1 is the same baldrick from #llvm and might actually know something about static compilation... unlike the rest of the Haskell community
06:43 <baldrick1> Yes, the same
06:43 <baldrick1> Why?
06:43 <halogenandtoast> cocreature: sadly with your example I get Expected type: ReaderT SqlBackend (LoggingT IO) (Maybe Text) Actual type: Maybe (Maybe Text) on the res <- part. For some reason I thought it compiled.
06:43 <halogenandtoast> > Why? > and might actually know something about static compilation... unlike the rest of the Haskell community
06:43 <lambdabot> <hint>:1:6: error: parse error on input ‘>’
06:44 Xanather joined
06:44 <halogenandtoast> having to do with the postgres linking question above.
06:46 <cocreature> halogenandtoast: I think I need some minimal example that I can play around with in ghci to figure out that error
06:46 <baldrick1> what time was the postgres linking question asked, because I don't immediately see one (I was disconnected for a bit - could explain it)?
06:46 <cocreature> playing type tetris without using a typechecker is too hard
06:46 <vaibhavsagar> baldrick1: just me asking how to statically link libpq to an executable
06:47 <halogenandtoast> cocreature: this is my entire (relatively small) application: https://gist.github.com/halogenandtoast/eb854f673d19870fb82475f9a1bd4655
06:48 P1RATEZ joined
06:48 <vaibhavsagar> here is the output I'm getting: http://lpaste.net/355746
06:48 wroathe joined
06:48 Trendrrr joined
06:48 <halogenandtoast> cocreature: I took out a return to try something
06:48 ertes-w joined
06:49 <halogenandtoast> that doesn't fix the issue
06:49 <cocreature> halogenandtoast: I’m compiling the deps atm, I’ll get back to you once I can try it
06:49 xall joined
06:49 <halogenandtoast> cocreature: You're an awesome human being, thanks for taking the time!
06:50 romank joined
06:51 takle joined
06:51 takuan joined
06:52 dm3 joined
06:54 <baldrick1> vaibhavsagar: libpq makes use of many other libraries, you need to link with them too
06:54 alfredo joined
06:54 <baldrick1> running ldd on libpq.so will show you a very long list :)
06:54 <vaibhavsagar> I have libpq.a
06:54 dewzer joined
06:55 <vaibhavsagar> which is a static library(?), so no luck there
06:55 <vaibhavsagar> nvm I found libpq.so
06:56 <baldrick1> As for this kind of warning: "warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking". Well, it's true :) As long as you run only on the machine you built the program on you should be OK
06:57 Trendrrr joined
06:57 <baldrick1> This kind of thing:
06:57 <baldrick1> /usr/lib/x86_64-linux-gnu/libpq.a(fe-connect.o): In function `parseServiceFile':
06:57 <baldrick1> (.text+0xbe2): undefined reference to `ldap_init'
06:58 <baldrick1> is just telling you that libpq itself makes use of libldap, so you also need to link with libldap
06:58 <vaibhavsagar> ahh, I see
06:58 <vaibhavsagar> and the order matters?
06:58 guiben joined
06:59 <baldrick1> with the GNU linker (which you are surely using), order matters
06:59 saussure joined
06:59 <vaibhavsagar> and e.g. for libldap, do I have to pass '-lldap'?
06:59 <vaibhavsagar> because `ld` can't find that
06:59 <baldrick1> Just sort out the first error (i.e. find the library it is in and append that to the link line), then repeat
06:59 <baldrick1> Yes, you need -lldap
07:00 <baldrick1> Try installing libldap2-dev if you are on a Debian based system
07:01 CacoS joined
07:01 jerbome_ joined
07:02 <vaibhavsagar> okay, I did that (on the Ubuntu VM I'm using) and I am still getting the same error about the undefined reference to ldap_init
07:02 <vaibhavsagar> the command I'm running is stack build --ghc-options '-optl-static -optl-pthread -lssl -lcrypto -lldap -lpq -fPIC' --force-dirty
07:03 xtreak joined
07:03 <cocreature> halogenandtoast: http://sprunge.us/hXVj?haskell
07:03 freusque joined
07:03 <baldrick1> vaibhavsagar: append to link line: it should go after -lpq
07:03 <halogenandtoast> cocreature: oh
07:03 <halogenandtoast> I don't think I ever would have guessed that
07:03 <halogenandtoast> I'm bad at type-tetris it seems
07:04 <vaibhavsagar> ah, no wonder, thanks baldrick1
07:04 <vaibhavsagar> wait, same error though
07:04 <cocreature> halogenandtoast: you need this because getDomain is just of type Maybe a and not of type IO (Maybe a)
07:04 Trendrrr joined
07:04 <Axman6> baldrick1: sorry, for running aray after pinging you, my machine went crazy just as I had to run away to a meeting! Looks like you and vaibhavsagarmanaged to (maybe) sort things out, so all good!
07:04 <cocreature> halogenandtoast: there is also a hoistMaybe function that you can use instead of MaybeT . return
07:04 <baldrick1> maybe!
07:05 <vaibhavsagar> now my command is `stack build --ghc-options '-optl-static -optl-pthread -lpq -lssl -lcrypto -lldap_r -fPIC' --force-dirty`
07:05 takle joined
07:06 <vaibhavsagar> thanks for your help with this :), definitely feel free to eject at anytime
07:06 bvad joined
07:06 <halogenandtoast> cocreature: Thanks so much, I'll check it out
07:08 louispan joined
07:08 <halogenandtoast> Going to spend some time reading the previous error message until I can understand to add the `return` there.
07:12 ventonegro joined
07:12 jrn1024 joined
07:12 matrium joined
07:13 rickygee joined
07:13 m0rphism joined
07:14 <matrium> hi, is there some kind of until that iterates as long as the accumulated value changes (old != new)?
07:14 <vaibhavsagar> matrium: sounds like `fix`
07:15 vlatkoB_ joined
07:16 <vaibhavsagar> you could use `iterate`
07:16 romank joined
07:17 juanpaucar joined
07:18 <matrium> vaibhavsagar: Thanks, fix seems to be what I was looking for! I'll give it a try as soon as my haddock-build is finished :-)
07:18 theorb joined
07:20 <matrium> vaibhavsagar: just looked at the fixed implementation and it's kind of ... unexpected. Does it rely on lazy evaluation and memoization?
07:20 Trendrrr joined
07:21 <vaibhavsagar> matrium: lazy evaluation
07:21 tromp joined
07:22 <bartavelle> is there a fundamental reason why HList hasn't been updated, or just lack of manpower?
07:24 osa1 joined
07:24 osa1 joined
07:26 wroathe joined
07:27 neoo joined
07:28 <ertes-w> matrium: neither… 'fix' is really just a way to write a recursive function anonymously
07:29 romank joined
07:29 neoo joined
07:30 dewzer joined
07:30 neoo joined
07:31 acidjnk22 joined
07:31 acyed joined
07:31 NinjaTrappeur joined
07:32 mattyw joined
07:32 <Axman6> :t let f g = takeWhile (uncurry (/=)) . zipWith g `ap` tail in f
07:32 <lambdabot> error:
07:32 <lambdabot> Precedence parsing error
07:32 <lambdabot> cannot mix ‘.’ [infixr 9] and ‘ap’ [infixl 9] in the same infix expression
07:33 <Axman6> :t let f g = takeWhile (uncurry (/=)) . (zipWith g <*> tail) in f
07:33 <lambdabot> Eq a => (a1 -> a1 -> (a, a)) -> [a1] -> [(a, a)]
07:33 bollu joined
07:33 neoo joined
07:33 <Axman6> :t let f g = takeWhile (uncurry (/=)) . (zip <*> tail) . map g in f
07:33 <lambdabot> Eq b => (a -> b) -> [a] -> [(b, b)]
07:34 Yuras joined
07:34 <Axman6> :t let f g = takeWhile (uncurry (/=)) . (zip <*> tail) . iterate g in f
07:34 <lambdabot> Eq a => (a -> a) -> a -> [(a, a)]
07:34 neoo joined
07:34 <Axman6> :t let f g = head . dropWhile (uncurry (/=)) . (zip <*> tail) . iterate g in f
07:34 <lambdabot> Eq a => (a -> a) -> a -> (a, a)
07:36 neoo joined
07:36 <quchen> matrium: There is no »repeat until unchanged« function, no.
07:36 <quchen> You can easily write it yourself though.
07:36 joco42 joined
07:37 zero_byte joined
07:37 <Axman6> (I think) the above does that... but would not recommend using it because I probably wouldn't understand it in a day
07:37 <quchen> Prelude has the related »until«, but that checks a predicate instead of comparing the last two values.
07:37 <quchen> :t until
07:37 <lambdabot> (a -> Bool) -> (a -> a) -> a -> a
07:37 <quchen> > until (== 0) (subtract 1) 100
07:37 <lambdabot> 0
07:38 <matrium> quchen: currently my expression looks like this: "coreOf' = until (null . removable) (\g -> G.delNodes (removable g) g)"
07:38 <Axman6> need a (a -> a -> Bool) I think
07:38 neoo joined
07:39 <matrium> "As long as there are deletable nodes in the graph, delete them"
07:39 mschristiansen joined
07:40 <matrium> but that requires two evaluations of "removable", first in the predicate and then in the function
07:41 Wizek joined
07:41 Wizek_ joined
07:42 Trendrrr joined
07:43 <opqdonut> matrium: I'd just write out the recursive function: coreOf' g | null r = coreOf' (delNodes r g) | othwerwise = g where r = removable g
07:44 thc202 joined
07:44 fizruk joined
07:44 RouxTheDay joined
07:45 marr joined
07:46 meba joined
07:46 ErinvanderVeen joined
07:46 dni joined
07:46 wroathe joined
07:48 fbergmann joined
07:49 connrs joined
07:52 <ertes-w> matrium: note that you can write something like that using 'until'
07:52 <ertes-w> you just need some post-processing
07:53 biglama joined
07:54 saussure joined
07:54 <quchen> > reverse (until (\(x:_) -> x == 1) (\(x:xs) -> (if even x then x `div` 2 else 3*x+1) : x : xs) [15])
07:54 <ertes-w> > until (uncurry (==)) (\(x, _) -> (x^2, x)) (9 :: Word16, 3)
07:54 <lambdabot> [15,46,23,70,35,106,53,160,80,40,20,10,5,16,8,4,2,1]
07:54 <lambdabot> (1,1)
07:54 <ertes-w> > fst $ until (uncurry (==)) (\(x, _) -> (x^2, x)) (9 :: Word16, 3)
07:54 romank joined
07:54 <lambdabot> 1
07:54 juhp joined
07:54 <ertes-w> matrium: pretty much the same pattern you would use with 'iterate' e.g. to construct the fibonacci sequence
07:55 <quchen> »until plus postprocessing« is probably the same work, but less clear, than just going directly for it.
07:55 louispan joined
07:55 <ertes-w> > map fst (iterate (\(x, y) -> (y, x + y)) (0, 1))
07:55 <lambdabot> [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,...
07:55 moongazer joined
07:56 <matrium> my goal was to avoid passing additional "artificial" arguments around
07:56 kirelagin joined
07:56 <ertes-w> i don't think there is anything artificial about it… your state *is* 2-dimensional
07:56 alexelcu28 joined
07:56 <quchen> Or you can just define your own until function that has a predicate on the last two values.
07:56 <quchen> :t let until2 p f x = let fx = f x in if p x fx then x else until2 p f fx in until2
07:56 <lambdabot> (t -> t -> Bool) -> (t -> t) -> t -> t
07:57 alexelcu28 joined
07:57 <quchen> > let until2 p f x = let fx = f x in if p x fx then x else until2 p f fx in until2 (==) cos 1
07:57 <lambdabot> 0.7390851332151607
07:57 <quchen> > cos it
07:57 <lambdabot> error:
07:57 <lambdabot> • Variable not in scope: it
07:57 <lambdabot> • Perhaps you meant one of these:
07:58 <quchen> > cos 0.7390851332151607
07:58 <lambdabot> 0.7390851332151607
07:58 alexelcu joined
07:58 nickolay_ joined
07:58 <quchen> (Crazy that cos has a fixed point, by the way)
07:58 <vaibhavsagar> > fixed f x = if (f x) == x then [] else (x : fixed f (f x))
07:58 <lambdabot> <hint>:1:11: error:
07:58 <lambdabot> parse error on input ‘=’
07:58 <lambdabot> Perhaps you need a 'let' in a 'do' block?
07:58 <vaibhavsagar> > let fixed f x = if (f x) == x then [] else (x : fixed f (f x))
07:58 <lambdabot> <no location info>: error:
07:58 <lambdabot> not an expression: ‘let fixed f x = if (f x) == x then [] else (x : fixe...
07:58 <vaibhavsagar> :(
07:59 <matrium> let s = iterate (^2) [0..] in fst $ find (uncurry (==)) (s, tail s)
07:59 <ertes-w> > sin 0
07:59 <lambdabot> 0.0
07:59 <ertes-w> quchen: sin has one, too =)
07:59 <vaibhavsagar> let fixed f x = if (f x) == x then [] else (x : fixed f (f x))
07:59 <quchen> ertes-w: :-þ
07:59 <ertes-w> not that crazy if you consider what they mean
07:59 Trendrrr joined
08:00 <ertes-w> also not that crazy, if you consider that they are continuous
08:00 osa1 joined
08:00 osa1 joined
08:00 <quchen> ertes-w: It’s not crazy that the cosine function has a fixed point, but it’s crazy that (cos :: Double -> Double) has one
08:00 <ertes-w> ah
08:00 <ertes-w> yeah, indeed
08:01 <ertes-w> but i think that's a 1/2 chance… either you land in the half bit that will flip-flop, or you land in a stable half-bit =)
08:01 <ertes-w> matrium: don't use lists for this
08:02 <quchen> > let until2 p f x = let fx = f x in if p x fx then x else until2 p f fx in until2 (==) (\x -> cos (x + 0.1)) 1
08:02 <lambdabot> 0.698081601397311
08:02 <ertes-w> matrium: use streams, if you want something data-like
08:02 <quchen> ertes-w: BREAKING NEWS physicist shows that probably all trigonometric functions have fixed points
08:02 <quchen> For physicist’s value of »all« and »trigonometric«.
08:03 Gloomy joined
08:04 <ertes-w> haskell programmers are physicists in that regard
08:04 <ertes-w> :t toRational
08:04 <lambdabot> Real a => a -> Rational
08:04 cloudhead joined
08:05 mjora7 joined
08:07 wroathe joined
08:10 mjora7 joined
08:11 romank joined
08:11 bollu joined
08:12 Trendrrr joined
08:13 Itkovian joined
08:13 mmn80 joined
08:13 ccomb joined
08:15 ewrwe joined
08:15 dm3 joined
08:17 alexelcu joined
08:17 seanparsons joined
08:18 jakub_ joined
08:19 alexelcu joined
08:19 Silox| joined
08:19 RayNbow`TU joined
08:20 exarkun joined
08:20 <jakub_> Hi, why do I need to give Typeable constraints in https://pastebin.com/igRBmKvJ when X is always typeable (I especially despise the constraint in SB constructor, is there a way to not pollute the data SX with constraints like this)?
08:20 alexelcu joined
08:20 saussure joined
08:22 alexelcu joined
08:22 jutaro joined
08:23 alexelcu joined
08:27 Trendrrr joined
08:30 bollu joined
08:30 <Philonous> jakub_, Class-constraints are implicit arguments that pass the class dictionary around. Without them you can't use the class methods
08:31 exarkun joined
08:32 morsicus joined
08:33 filterfish joined
08:34 filterfish joined
08:35 Trendrrr joined
08:35 koserge joined
08:35 juanpaucar joined
08:37 lep-delete joined
08:37 wroathe joined
08:37 alexelcu joined
08:38 louispan joined
08:38 alexelcu joined
08:39 saussure joined
08:39 <Philonous> jakub_, In your program, the class dictionaries carry the (runtime representation) of the types for you. Types are erased during compilation, that's why you need to pass them around as (implicit) arguments.
08:40 <Philonous> So, the compiler may know your types are all in Typeable, but it can't invent the class dictionary from whole cloth, that's why yo have to pass it around
08:42 augur joined
08:42 <jakub_> Philonous: ok, so there is no trick to keep typeable constraint separated from the data declaration?
08:43 <Philonous> Not unless your want to make your data type parametric in it's arguments.
08:45 <Philonous> Why does it bother you, though>
08:45 <Philonous> ?
08:45 mclaren joined
08:45 RouxTheDay joined
08:46 kuribas joined
08:46 MitchW joined
08:46 <kuribas> what's a recommended library for doing image manipulation (for example canny edge detection)?
08:47 <kuribas> repa?
08:47 sfcg joined
08:47 Trendrrr joined
08:47 Elhamer joined
08:47 fizruk joined
08:48 takle joined
08:49 <quchen> kuribas: Lumiguide has bindings op libopencv
08:49 <quchen> s/op/to/
08:49 <quchen> They use it to detect whether there is a bicycle in a picture. :-)
08:49 Rodenbach joined
08:49 <kuribas> right
08:50 <kuribas> this one?https://github.com/LumiGuide/haskell-opencv
08:51 <kuribas> Is lumiguide completely written in haskell?
08:52 alexelcu joined
08:52 <quchen> kuribas: Most of it. They had a Python prototype initially, but I think they’ve been using Haskell exclusively for new features, with a strong focus on migrating away from Python, for over two years.
08:52 twanvl joined
08:52 <quchen> You’d have to ask Bas about the details.
08:52 <quchen> Or Roel.
08:53 mjora7 joined
08:53 <kuribas> Nice
08:53 filterfish joined
08:53 alexelcu joined
08:53 <quchen> I’d say they’re Haskell-only.
08:53 <kuribas> I want to build a system for converting scanned music scores to vector formats.
08:53 <kuribas> Preferably in haskell.
08:53 Elhamer_ joined
08:54 drcode joined
08:54 <kuribas> Well the prototype at least.
08:54 Trendrrr joined
08:55 bjz joined
08:56 <kuribas> There has been interest from the IMSLP project, so funding may be possible.
08:56 andyhuzhill joined
08:57 saussure joined
08:57 <jakub_> Philonous: it bothers me, because the data itself (SX) does not care about typeable and yet I need to include this constraint to be able to use the data in some particular context
08:58 wroathe joined
08:58 MitchW joined
08:59 DDR joined
08:59 abhiroop joined
08:59 JagaJaga joined
08:59 <jakub_> Philonous: I would like to separate all dynamic "typeable" pollution from the nice statically typed things
09:00 louispan joined
09:01 dni joined
09:02 Trendrrr joined
09:04 padre_angolano joined
09:05 simukis joined
09:05 oish joined
09:08 wroathe joined
09:08 romank joined
09:09 bollu joined
09:10 Trendrrr joined
09:10 dni joined
09:11 skeuomorf joined
09:12 <Philonous> jakub_, Well, you _can_ recover the Typeable instances by pattern-matching on SX
09:13 <Philonous> jakub_, Like this http://lpaste.net/355750
09:13 <jakub_> Philonous: I can show you my entire codebase if you want (and are willing to take a look at it), maybe it would be more clear to you
09:13 rossberg joined
09:14 <Philonous> Actually, you don't need the Typeable constraint on the function in that case, edited it
09:14 bluepixel joined
09:15 saussure joined
09:15 freusque joined
09:16 ilyaigpetrov joined
09:17 <jakub_> Philonous: http://goo.gl/MBd8sp this is where I actually need to know something is Typeable
09:18 raichoo joined
09:18 <jakub_> Philonous: There is an existential DynamicallySorted data containing something of type array and I want to match the array index type with another argument and the array element type with the return type (performing access to the array under a given index)
09:19 Myrl-saki joined
09:19 <bartavelle> what's the extension that gives puts in scope all records content when you pattern match on Record{} already?
09:20 <Axman6> RecordWildcards?
09:20 <bartavelle> yes!
09:20 <bartavelle> thanks
09:20 prophile joined
09:21 ycz0926 joined
09:21 ycz0926 left
09:21 Trendrrr joined
09:21 ycz0926 joined
09:21 <Axman6> might also find record puns useful
09:22 TheFuzzball joined
09:22 <Philonous> jakub_, Looking at it, might take a moment, that's a lot of stuff going on there :)
09:22 Kuros` joined
09:22 <bartavelle> Axman6: wildcards is sufficient here, just couldn't remember its name :/
09:23 ycz0926 joined
09:23 <jakub_> Philonous: i totally understand, i tried to simplify but the resulting example may have obscured some of my intentions, I am very grateful for your effort to help me, I am in no big hurry
09:24 ycz0926 left
09:25 unK_ joined
09:25 bennofs joined
09:25 ycz0926 joined
09:25 augur joined
09:26 <Philonous> jakub_, SSort is the singleton for Sort, isn't it?
09:26 <jakub_> Philonous: yes
09:26 <Philonous> jakub_, Well in that case you can recover the Typeable instance just by pattern-matching on it
09:26 ycz0926 left
09:27 <Myrl-saki> f (C {a, b = 4}) = a
09:27 <Myrl-saki> What pattern is that? ._.
09:27 <jakub_> I seem to be unable to do that, I tried and tried
09:27 louispan joined
09:27 <Philonous> jakub_, Did you see my paste?
09:28 <Philonous> jakub_, http://lpaste.net/355750
09:28 <Philonous> See toSomeX
09:28 <jakub_> I am already pattern matching on it on line 158, I did see your paste, maybe I missed something
09:28 wroathe joined
09:28 Trendrrr joined
09:29 <jakub_> I fail to see how typeable would be recovered for the arguments i and e of SArraySort
09:29 mclaren joined
09:30 <Philonous> jakub_, You have to actually take the singleton apart. GHC (statically) knows the type of the scrutinee on the right hand side of pattern matches.
09:30 oisdk joined
09:31 <Philonous> Let me write an example for SSort, sec
09:33 <jakub_> Philonous: thx i will have to leave for a moment but i will read the example as soon as possible
09:33 psmmr joined
09:33 saussure joined
09:33 merijn joined
09:34 dni joined
09:34 zariuq joined
09:36 CoderPuppy joined
09:38 ziocroc joined
09:44 inad922 joined
09:45 Trendrrr joined
09:49 wroathe joined
09:50 jerbome_ joined
09:51 alexelcu joined
09:51 saussure joined
09:52 Trendrrr joined
09:55 jedws joined
09:56 romank joined
09:56 <merijn> So, suppose I want to put all Prelude shadowing names into a separate module intended to be imported qualified, what'd be a good name for that module? Foo.Prelude (like pipes), Foo.Traversal (it's mostly traversals like folds/maps), something else...
09:57 toby joined
09:58 oisdk joined
09:58 juanpaucar joined
09:59 angelos joined
10:00 jedws joined
10:00 Trendrrr joined
10:03 alexelcu joined
10:03 dewzer joined
10:07 Trendrrr joined
10:09 tjayanth joined
10:09 wroathe joined
10:10 xall joined
10:11 saussure joined
10:11 halogenandtoast joined
10:11 rcat joined
10:12 exarkun joined
10:12 yirabbit_ joined
10:14 <Myrl-saki> `($ x) . f` or `flip f x` ?
10:15 <mauke> (`f` x)
10:17 jao joined
10:18 <quchen> \y -> f y x
10:18 <Myrl-saki> mauke: Oh true, that also exists.
10:18 <Myrl-saki> quchen: Not PF. 0/10
10:18 dni joined
10:19 Trendrrr joined
10:19 <quchen> Neither were your suggestions.
10:19 <quchen> ?pl \x f -> ($ x) . f
10:19 <lambdabot> flip flip
10:20 <quchen> There you go.
10:20 <mauke> quchen++
10:20 <Myrl-saki> Pointfree with bound variables?
10:20 nighty-- joined
10:21 <mauke> flip ask x <$> f
10:21 filterfish joined
10:22 gawen joined
10:22 tty11 joined
10:23 cschneid_ joined
10:24 wroathe joined
10:24 gawen joined
10:24 <CyberShadow> Hello
10:24 <CyberShadow> Here, where is the value of sys coming from? https://github.com/koalaman/shellcheck/blob/master/ShellCheck/Parser.hs#L1847
10:25 <CyberShadow> Mr is 'import qualified Control.Monad.Reader as Mr'
10:25 im0nde joined
10:26 <quchen> CyberShadow: SCParser is a Reader it seems. Reader gives you »ask«, which allows you to query your environment.
10:26 <quchen> CyberShadow: The value is »put into« the ask when running the reader.
10:26 mattyw joined
10:26 <quchen> In this case, there ought to be a »runSCParser« function somewhere that executes the parse.
10:27 <mauke> https://github.com/koalaman/shellcheck/blob/master/ShellCheck/Parser.hs#L2803
10:27 Elhamer__ joined
10:27 <quchen> Side remark, that code is some of the uglier Haskell I’ve seen :-s
10:28 <CyberShadow> How does readSource have access to the SCParser? I only see it figuring in the return type
10:28 yirabbit_ joined
10:28 asthasr joined
10:28 <mauke> what do you mean, access to?
10:28 <mauke> it creates/returns an SCParser
10:29 <CyberShadow> Sorry, I'm very new to Haskell
10:29 Kreest__ joined
10:30 mattyw joined
10:30 saussure joined
10:30 <quchen> CyberShadow: In Java-like notation, it’s signature is SCParser<m, Token> readSource(SourcePos …, Token …)
10:31 <Philonous> jakub_, I've created a commit in which I got of the Typeable in DynamicSort : https://github.com/Philonous/sorted-expressions-ala-carte/commit/1eadc31d0315c1c9bf05e2aefd7b30d07106c2a7
10:31 <quchen> s/it’s/its/
10:31 <CyberShadow> Ah, OK, that's what I thought too. I don't see where the return value is initially created though
10:31 <Philonous> jakub_, (Also the ones on SArraySort)
10:31 <Philonous> jakub_, I've added two examples that show how to construct Typeable dictionaries.
10:32 <CyberShadow> But... if SCParser is created in that function, how could that function get the value of sys from its caller?
10:32 sighingnow joined
10:32 <mauke> CyberShadow: it doesn't
10:32 <mauke> the SCParser does
10:32 <Philonous> jakub_, However, I'm fairly sure you don't need Typeable anywhere, you can just work with the singletons directly. See sortEq
10:33 <mauke> CyberShadow: the return value is created in https://github.com/koalaman/shellcheck/blob/master/ShellCheck/Parser.hs#L1827: it starts with 'do' and continues for the rest of the body
10:33 <quchen> CyberShadow: A Reader carries a »hole to fill« around, that’s its entire point. It’s similar to how (\x -> foo x) does not require »x« to be there, it is left open as a parameter.
10:33 <quchen> CyberShadow: »ask« gives you access to the hole’s contents.
10:33 filterfish joined
10:33 Xalphor joined
10:34 wroathe joined
10:34 <Philonous> jakub_, Feel free to ask questions ;)
10:34 <quchen> And when running the reader (via parseShell or what it’s called), you have to specify what to put into the hole (here: sys).
10:34 Kreest_ joined
10:34 <CyberShadow> Thanks. I'm going to need to stare at this for a while longer... :)
10:35 <quchen> CyberShadow: Reader on its own is pretty simple, but the code is a) written with no taste in style whatsoever, and b) the reader is packed togehter with other stuff, making the »this is reader« part a bit hard to see if you’re not familiar with it.
10:36 <CyberShadow> That makes sense
10:36 Kreest joined
10:36 <CyberShadow> FWIW my goal is to make an expression in that function conditional on a value I need to pass from another part of the program
10:37 phaji_ joined
10:38 TheFuzzball joined
10:39 alexelcu joined
10:39 osa1 joined
10:39 osa1 joined
10:39 Levex joined
10:40 <quchen> Passing a value from one part of the program arbitrarily to another is pretty hard in Haskell. (It should be.)
10:41 systadmin joined
10:42 saep joined
10:43 Kreest__ joined
10:44 Kreest_ joined
10:45 Yuras joined
10:45 mclaren joined
10:46 tsmish joined
10:46 RouxTheDay joined
10:47 drcode joined
10:47 <merijn> So, suppose I want to put all Prelude shadowing names into a separate module intended to be imported qualified, what'd be a good name for that module? Foo.Prelude (like pipes), Foo.Traversal (it's mostly traversals like folds/maps), something else?
10:47 Trendrrr joined
10:48 dewzer joined
10:51 <hanna> Is there a way to force-import hidden packages from ghci? I want to poke around in some .Internals
10:51 netheranthem joined
10:51 <hanna> hidden module, I mean
10:52 Kreest joined
10:52 <CyberShadow> Aah, monad transformers
10:53 <Philonous> hanna, You can grab the whole package and load it into ghci
10:53 <Philonous> Then you have access to all modules
10:53 <quchen> CyberShadow: Monad transformers are just a way of combining different effects; in your example, Reader is one of them.
10:53 <quchen> CyberShadow: But transformers are an orthogonal concept to Reader.
10:53 <CyberShadow> Yeah. I was confused how it was able to do all these different things with a single monad
10:53 <quchen> :-)
10:54 <Philonous> hanna, AFAIK there's no way to import hidden packages from dependencies, though
10:54 <CyberShadow> (I hadn't gotten to that chapter yet)
10:54 wroathe joined
10:54 rockfordal joined
10:55 <hanna> fair enough; in this case the constructors are fortunately exported as well so I can just copy paste the utility functions I'm interested in
10:56 ddere joined
10:56 erikd joined
10:56 <Philonous> hanna, I had to resort to that a few times myself. If you need that function, someone else might as well, so you could create a PR? :>
10:57 saussure joined
10:58 Trendrrr joined
10:59 <bollu> cocreature: you have new issues :)
11:01 Elhamer joined
11:02 Snircle joined
11:06 <jakub_> Philonous: thanks a lot, soon i will be back at my computer to read it
11:07 alexelcu joined
11:07 fragamus joined
11:07 juanpaucar joined
11:07 TheFuzzball joined
11:07 DeepSpawn joined
11:07 alexelcu left
11:08 alexelcu joined
11:10 __paul0 joined
11:10 DeepSpawn joined
11:10 acarrico joined
11:11 Trendrrr joined
11:11 jhrcek joined
11:12 marinelli joined
11:12 buglebudabey joined
11:14 will_ joined
11:14 wroathe joined
11:15 Yuras joined
11:16 <will_> I'm trying to write a simple parser using Parsec. I expected the following code to work on "blahfirst" and "blahfore", but it only works on "blahfirst" - on "blahfore" it gives "Unexpected end of input, expecting 'first' or 'fore'".
11:16 <will_> manyTill anyChar (string "first" <|> string "fore")
11:16 saussure joined
11:16 <will_> Can anyone tell me what's wrong?
11:16 <bollu> I believe you need a "try", since the <|> will alternate between parsers that may consume input
11:16 exarkun joined
11:17 <bollu> I believe that the "first" parser will consume the "f"
11:17 <bollu> and then when the "fore" parser kicks in, it will not have access to the "f" anymore
11:17 yirabbit_ joined
11:17 <bollu> manyTill anyChar (try (string "first") <|> string "fore") should work IIRC
11:18 zero_byte joined
11:18 buglebudabey joined
11:19 fakenerd joined
11:19 yirabbit_ joined
11:20 <will_> bollu: Thanks a lot, that works perfectly
11:20 <bollu> will_: you're welcome
11:20 <bollu> will_: keep in mind that try will lead to worse error messages
11:20 <bollu> will_: so use it sparingly, and try to factor out the backtracking
11:20 <tobiasBora> Hello,
11:20 <bollu> will_: and another thing: I'd recommend MegaParsec
11:21 qguv joined
11:21 <bollu> will_: it seems to be more actively developed. In fact, I'm personally migrating from Parsec to MegaParsec as well :)
11:21 <will_> bollu: OK, thanks for the tip!
11:21 <bollu> tobiasBora: hey
11:22 yirabbit_ joined
11:22 tommd joined
11:22 <tobiasBora> I'd like to generate all the possible lists that have n elements chosen in a given list of reference L
11:23 <tobiasBora> for small n, I can do of course:
11:23 <tobiasBora> [[i,j] | i <- l, j <- l]
11:23 <exarkun> Why is `let a = (System.Process.proc "foo" []){ std_in = CreatePipe, std_out = CreatePipe }` leading to `‘std_in’ is not a (visible) constructor field name`?
11:23 <tobiasBora> but it does not scale for a random n
11:24 <tobiasBora> By the way, I would like to produce a lazy list, because the list will be too big to stay in my memory...
11:24 fakenerd joined
11:24 <tobiasBora> (and if possible, I'd love to be able to use multicore/multithreading capabilities to apply a function on it)
11:24 <Philonous> exarkun, Seem slike you have imported them qualified, try System.Process.std_in and System.Process.std_out
11:25 wroathe joined
11:25 <tobiasBora> but let's first focus on doing such a list for a given n
11:25 <Philonous> or import them unqualified: import System.Process (std_in, std_out)
11:25 <exarkun> Philonous: Ah. Because they're just more functions in some module. I see. Thanks.
11:25 rickygee joined
11:25 <Philonous> exarkun, Yeah, exactly
11:26 akermu joined
11:26 saussure joined
11:26 Trendrrr joined
11:26 <Philonous> Well, truthfully they are actually more than functions, you can also use them in record syntax, but they behave like other values wrt. importing
11:27 cpennington joined
11:31 bjz_ joined
11:33 ericsagnes joined
11:33 mfukar joined
11:34 Kreest_ joined
11:35 locallycompact joined
11:35 c4r50nz joined
11:36 saussure joined
11:37 TheFuzzb_ joined
11:37 LnL joined
11:38 Rodenbach joined
11:38 Gloomy joined
11:39 oisdk joined
11:39 ContessaTP joined
11:40 neoo joined
11:41 sdothum joined
11:41 HoierM joined
11:41 neoo joined
11:43 neoo joined
11:43 Kreest joined
11:43 juanpaucar joined
11:44 phaer joined
11:45 dewzer joined
11:45 neoo joined
11:46 zero_byte joined
11:47 RouxTheDay joined
11:47 rickygee joined
11:47 yellowj joined
11:47 neoo joined
11:48 <merijn> Is there an up-to-date vim syntax highlight file for cabal somewhere?
11:48 Wizek_ joined
11:49 juanpaucar joined
11:50 wroathe joined
11:50 neoo joined
11:52 sirreal joined
11:52 neoo joined
11:53 asm_ joined
11:53 twomix joined
11:54 saussure joined
11:54 fakenerd joined
11:55 Trendrrr joined
11:55 mattyw_ joined
11:55 fakenerd joined
11:55 Trendrrr joined
11:59 <zaquest> merijn, is haskell-vim not up to date?
12:00 jerbome_ joined
12:01 <merijn> zaquest: What do you mean by haskell-vim? There's several different repo's with similar, but not quite that name
12:01 darlan joined
12:01 <zaquest> merijn, https://github.com/neovimhaskell/haskell-vim
12:01 saeidw joined
12:02 <merijn> zaquest: I've just been using the files that shipped with vim so far, lemme try that
12:03 <saeidw> hi everyone, I'm confused about some type class syntax I found in a blog post: http://lpaste.net/355754
12:03 Jordack joined
12:04 <saeidw> I don't understand what `type Vertex g` means when it's inside the type class definition like that
12:04 <mauke> associated type
12:04 <hpc> look up type families
12:04 <saeidw> I couldn't find anything online that talks about it, even in the haskell report under type definitions
12:05 <hpc> it's a language extension
12:05 saussure joined
12:05 <saeidw> ah, thanks, that helps!
12:05 <mauke> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#type-families
12:05 <saeidw> somehow putting "haskell type" into google wasn't very helpful ;)
12:06 <hpc> yes... somehow :P
12:06 <zaquest> saeidw, https://wiki.haskell.org/GHC/Type_families#An_associated_type_synonym_example
12:07 jutaro joined
12:07 juanpaucar joined
12:08 Yuras joined
12:08 <Logio> tobiasBora: I think you might want something like concat . permutations . subsequences
12:09 Elhamer joined
12:09 <Logio> filtering the subsequences by length
12:10 wroathe joined
12:12 <Logio> ah nvm, that's not right
12:12 <Logio> you want all the combinations, not just subsequences
12:13 Trendrrr joined
12:13 oish joined
12:13 parsnip left
12:14 kuribas` joined
12:15 Elhamer_ joined
12:15 <osa1> :k reduces type families, right?
12:15 <lambdabot> error: parse error on input ‘type’
12:16 <wz1000> osa1: I think you need to use :kind!
12:16 <osa1> wz1000: ahh, right. thanks
12:16 dewzer joined
12:17 Elhamer__ joined
12:18 Shatnerz0 joined
12:18 Mortomes|Train joined
12:19 <jakub_> Philonous: thanks for the commit, I am very much interested in your statement that I don't need typeable, you refer to sortEq but that uses (:~:) and Refl, I also use gcast in my code, could you elaborate?
12:19 Elhamer joined
12:20 flatmap13 joined
12:21 <Philonous> jakub_, :~: and Refl aren't specific to Typeable
12:22 sighingnow joined
12:22 <Philonous> (:~:) is just a GADT: data a :~: b where (a ~ b) => Refl
12:24 <mauke> data Lol a b where (a ~ b) => Rofl
12:24 spacecadetbrown joined
12:24 <Philonous> Errr data a :~b where Refl :: (a ~ b) => a :~: b
12:25 <mauke> oh, I should have remembered that parameters in the head are decoration
12:25 <jakub_> Philonous: I got it the first time, no worries
12:25 <jakub_> :)
12:25 <ertes-w> or simply: data a :~: b where Refl :: a :~: a
12:25 <Philonous> Yeah, same thing
12:25 <ertes-w> which is why i don't like using variables in GADT syntax
12:26 <ertes-w> data (:~:) :: * -> * -> * where Refl :: a :~: a
12:26 <mauke> data (:~:) :: * -> * -> * where Refl ... dammit
12:28 <jakub_> Philonous: what does the comment "this shouldn't be necessary..." mean?
12:29 <Philonous> DynamicallySorted shouldn't need the Typeable either, so you don't have to bring the instance into scope to use the Constructor. But I only changed DynamicSort, so you can have some of the fun ;)
12:30 rickygee joined
12:30 chlong joined
12:30 <Philonous> It's the same trick, though: Remove the "Typeable s" from DynamicallySorted and bring Typeable inso scope with e.g. withTypeableSort instead
12:30 <Philonous> Where it's needed
12:30 <Philonous> Or work with singletons directly
12:31 wroathe joined
12:31 Kreest_ joined
12:31 Trendrrr joined
12:32 <jakub_> Philonous: thanks a lot, I really appreciate it
12:33 Itkovian joined
12:34 <Philonous> jakub_, gcast is a little trickier. You need to reify the return type into a singleton to pattern-match on it. For that you need a class. (Typeable fulfills that role at the moment).
12:36 <Philonous> jakub_, You could define that class by hand, or you can just use the singletons library which has TH to auto-derive it (and other things like propositional equality) for you.
12:36 beanbagula joined
12:37 paolino joined
12:37 <jakub_> Philonous: ok, I have exactly zero experience with singletons library so this will take time :) expect to here from me :D (just kidding)
12:37 <jakub_> *hear
12:38 <Philonous> jakub_, Well, it does pretty much the exact thing we've been doing.
12:39 <jakub_> Philonous: yes, but I have been doing it for mere hours, I am not sure I know what all the implications of having a singleton type are :)
12:39 MitchW joined
12:41 Elhamer_ joined
12:42 saussure joined
12:43 Elhamer_ joined
12:43 oisdk joined
12:43 juanpaucar joined
12:43 <jakub_> Philonous: since you did read my code, could you please tell me your impression? I never got a review of non-trivial haskell code base (I know this is probably still trivial but less trivial than snippets I posted on SO)
12:45 Trendrrr joined
12:45 <Philonous> jakub_, I didn't see any atrocities. Two things I notices: You're using "rec" as a variable, which I would have avoided because it's a reserved word in some extension or another and your line width is > 80, which makes my editor wrap them
12:47 paolino joined
12:47 Itkovian joined
12:47 eacameron joined
12:48 trevorriles joined
12:48 Kreest joined
12:49 pie_ joined
12:50 <pie_> anyone know any good intro for z notation?
12:50 <jakub_> Philonous: line length is something I didn't bother with, true, I intend to polish it later, and I didn't know about rec, I thought more about bad FP design, non-idiomatic code
12:50 <pie_> or whatever i should read wrt that and not knowing much about verification and the like
12:50 <jakub_> no attrocities sounds fine :)
12:51 jabesed joined
12:51 wroathe joined
12:51 xall joined
12:51 <Maxdamantus> My editor wraps at 80 characters so I think it's only fair that the wrapping be hardcoded into the file so everyone else has to suffer as I do.
12:51 BernhardPosselt joined
12:52 Kreest__ joined
12:52 <BernhardPosselt> is extensible effects in haskell a thing?
12:52 Trendrrr joined
12:53 levex_ joined
12:53 <Philonous> Maxdamantus, Line length of 80 is a common convention. See also https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
12:54 <quchen> BernhardPosselt: Not really. There exist implementations, but I found them impractical. In practice I think most people still use transformers.
12:54 Myrl-saki joined
12:55 Itkovian joined
12:55 <quchen> Not that we don’t want extensible effects, it’s just hard to get right, and never as streamlined as in e.g. Idris.
12:55 <BernhardPosselt> is idris lazy as well?
12:55 <quchen> Idris is eager by default.
12:56 <quchen> It supports laziness with a wrapper.
12:56 jathan joined
12:56 <BernhardPosselt> i see
12:56 juhp_ joined
12:56 juhp_ joined
12:56 <quchen> (&&) :: Bool -> Lazy Bool -> Bool
12:56 dx__ joined
12:56 <quchen> This is what it would look like in Haskell notation. (Well, Idris notation is almost identical.)
12:56 <Maxdamantus> s/::/:/
12:56 <BernhardPosselt> laziness seems to have big downsides which seems to make it impractical for production use
12:56 yqt joined
12:56 <Maxdamantus> oh, nvm
12:57 <quchen> BernhardPosselt: That’s FUD spread by nobody-knows. It has very clear upsides, but all you ever hear about is ominous space leaks.
12:57 <quchen> I’ve never had one, and I don’t know anyone who’s had one for longer than half a day.
12:57 <BernhardPosselt> quchen: right thats what i was hearing
12:58 <quchen> Laziness has saved me an infinite amount of work multiple times – literally.
12:58 <BernhardPosselt> like?
12:58 <quchen> > head [1..]
12:58 <lambdabot> 1
12:58 <quchen> Infinite work saved!
12:58 <BernhardPosselt> i mean compared to explicit laziness
12:58 <capisce> being too lazy to go to work
12:58 <cocreature> has anybody tried getting wordsBy into Data.List in base? it seems unlikely to cause a lot of breakage and I find myself using that function quite often and I get annoyed everytime I have to add split to my deps just for that
12:59 <BernhardPosselt> you would use generators for that in other languages, right?
12:59 <Philonous> quchen, *cough*Bob Harper*cough*
12:59 dx__ left
12:59 <quchen> Philonous: You mean Harrop?
12:59 eklavya joined
12:59 <BernhardPosselt> or iterators
12:59 <quchen> BernhardPosselt: Plus it’s fairly easy to make a lazy language eager, but very hard to make an eager one lazy.
12:59 <BernhardPosselt> quchen: eager as in?
13:00 <BernhardPosselt> lambdas?
13:00 <quchen> BernhardPosselt: The opposite of lazy.
13:00 Trendrrr joined
13:00 <BernhardPosselt> i mean how you make it eager :)
13:00 <quchen> »Strict« is not the opposite of lazy, it’s the opposite of non-strict. ;-)
13:00 <quchen> Oh, by adding bangs and seqs.
13:00 saussure joined
13:01 Elhamer joined
13:01 buglebudabey joined
13:01 <BernhardPosselt> oh, compiler flag
13:01 <exarkun> these writes don't ever seem to happen (according to strace). <https://github.com/LeastAuthority/spake2-interop-test/blob/master/TestInterop.hs#L42-L44>. I'm not really sure why.
13:01 <quchen> seq is standard Haskell.
13:01 yirabbit_ joined
13:01 wroathe joined
13:01 <quchen> BangPatterns is nicer syntax for it, but nothing new otherwise.
13:01 <Philonous> quchen, Dunno, is that his pseudonym? I mean the CM prof
13:01 jerbome_ joined
13:02 <bollu> cocreature: so you don't know how to fix it?
13:02 <cocreature> bollu: no
13:02 <bollu> cocreature: hm, unfortunate
13:02 <quchen> Philonous: Oh, nevermind then. Harrop is a troll (intellectually dishonest business idiot) that loves to write crap about Haskell. He then usually continues promoting F# and his consulting firm.
13:03 Myrl-saki joined
13:03 <Philonous> quchen, Oh no, Harper is a serious guy. He's actually really worth listening to, but he has this (IMO irrational) antipathy towards Haskell
13:03 <quchen> Yes, I know Harper, I have nothing bad to say about him.
13:04 <opqdonut> his blog is certainly food for thought
13:04 <quchen> But he’s sometimes confused with Harrop and his incoherent rambling.
13:04 <quchen> Poor clash of names I guess :-/
13:04 bananu7 joined
13:05 <BernhardPosselt> btw, found this one last week https://philipnilsson.github.io/Badness10k/posts/2017-05-07-escaping-hell-with-monads.html
13:05 theelous3 joined
13:05 <BernhardPosselt> very well explained
13:05 <bananu7> is it another Monad tutorial?
13:05 <BernhardPosselt> not really
13:05 <BernhardPosselt> as in it shows what issue they solve
13:05 plutoniix joined
13:05 <Philonous> Ah, that one was cute. I liked the punchline where the Haskell code looks identical in all the examples
13:06 <BernhardPosselt> and doesnt throw around mathematical laws
13:06 <bananu7> I wrote something similar a while ago actually
13:06 <cocreature> bollu: I can’t even reproduce it atm. "stack ghci" fails for me but it fails with a different error and "cabal new-repl" works
13:06 <bananu7> non-theoretical PoV
13:06 <bollu> cocreature: interesting
13:06 <bollu> cocreature: this is so weird
13:07 <cocreature> bollu: but please upgrade llvm-hs, I really don’t want to spend time figuring out why things break in older versions :)
13:07 <bollu> cocreature: yes, I will :) I went back because some of my code brke
13:07 <bollu> cocreature: s/broke/didn't compile
13:07 <bollu> cocreature: I was fixing my parser
13:07 <BernhardPosselt> and this one made me go "ah, wow functors are useful" https://www.youtube.com/watch?v=R4w-ITMOOBY
13:07 <bollu> cocreature: now that that's done, I'll upgrade
13:07 <BernhardPosselt> basically shows that you can have functors of functors and make it compose well
13:08 <BernhardPosselt> as in: recursive map
13:08 <bananu7> BernhardPosselt: next up - Free and recursion schemes ;)
13:08 <Philonous> How do I export a data family instance
13:08 <Philonous> ?
13:09 <BernhardPosselt> the theory is nice if you already understand it :D
13:09 <quchen> BernhardPosselt: Unfortunately, monads do not compose – two monads nested are not a monad, while two functors nested are again a functor.
13:09 <BernhardPosselt> however the "why" seems to be lacking in most docs
13:09 dihuteno joined
13:09 <bananu7> quchen: that's why we have transformers
13:10 <BernhardPosselt> quchen: yep, thats the essence of the talk
13:10 <bollu> quchen: are not / may not be?
13:10 <cocreature> bollu: but tbh, given the number of linker errors triggered in llvm-hs that turned out to be ghc bugs, I doubt there is anything we can do in llvm-hs itself to fix this.
13:10 <bollu> cocreature: I see
13:10 eacameron joined
13:10 <quchen> bollu: Cannot be
13:10 <bollu> cocreature: well, if it's a GHC bug, then it is a GHC bug
13:10 <BernhardPosselt> but monad transformers are tedious once you need to compose more than 2
13:10 <quchen> bollu: Applicative on the other hand composes
13:10 <bollu> quchen: I haven't seen this Applicative composing stuff. Do tell?
13:10 <quchen> bananu7: Yes, but transformers aren’t generic.
13:10 <bananu7> in what sense?
13:11 dsh joined
13:11 fendor joined
13:11 <cocreature> bollu: the problem is that if you want a reasonable chance of getting GHC bugs fixed you need a minimal example and llvm-hs is _very_ far away from that and isolating it takes a shitload of time
13:11 buglebudabey joined
13:11 <cocreature> bollu: given that stack and cabal seem to behave differently it might also be a bug in one of those
13:11 <bananu7> quchen: MonadTrans seems pretty "generic", don't know how you define it in this context
13:11 <quchen> bollu: instance (Applicative f, Applicative g) => Applicative (f . g) where pure = pure . pure; (<*>) = liftA2 (<*>) -- *any* two Applicatives composed are a new Applicative
13:11 wroathe joined
13:11 <bollu> quchen: ah, neat
13:12 <quchen> bananu7: You have to write a new transformer for each monad, you can’t have one thing that puts together any two monads and gives you a new monad
13:12 <bollu> quchen: right
13:12 <bananu7> I see
13:12 <BernhardPosselt> so tl;dr: thats the reason for applicative fucntors?
13:12 <BernhardPosselt> composition
13:12 <quchen> bananu7: Compare that to the above Applicative code: it’s one piece of code and works for all Applicatives
13:12 Trendrrr joined
13:12 <quchen> bananu7: That’s why we don’t have ApplicativeTrans :-)
13:12 <BernhardPosselt> "weaker" than monads but more composable?
13:12 <bananu7> fair enough I suppose
13:12 saussure joined
13:12 Bhootrk_ joined
13:12 <bananu7> now that we have ApplicativeDo it starts to make way more sense anyway
13:13 <bollu> quchen: Is there a monad from which we can derive every other monad by quotienting?
13:13 pie_ joined
13:13 <quchen> BernhardPosselt: It’s one reason. Applicative has other benefits.
13:13 <bollu> quchen: the way we do with free groups
13:13 <quchen> bollu: I know some of these words.
13:13 <bananu7> I mean, to consciously use Applicative. I never bought into "but this requires less" - so what, if I know I'm working on monads?
13:13 <bollu> quchen: :)
13:14 <BernhardPosselt> quchen: like?
13:14 <bollu> quchen: like, if you have a group, you can write it by taking the free group and then imposing constraints on it. Don't think this works on all groups (finitely generated?)
13:14 <bollu> quchen: is there something similar you can do for monads?
13:14 <bananu7> bollu: isn't that what Free tries to do?
13:14 <BernhardPosselt> saving you from pattern matching Maybes?
13:14 <tsani> You can't generate every monad with Free though
13:14 <tsani> (You can generate a lot of them though)
13:14 <quchen> Applicative often means that you can parallelize things. Applicative means your grammar is context-free. Applicative can be inspected more by the compiler (since you don’t have an unknown function call like bind does).
13:15 <bollu> bananu7: is it? I don't see the "quotienting". Free seems to "add" structure on top of a functor. I want to be able to impose constraints
13:15 <bollu> tsani: example of monad which cannot be written as Free <some functor> ?
13:15 <fendor> hey, i'm trying to write a program using the 2dstencil module of the repa library. But i can't write double values in the quasiquoter, is there any reason for this behaviour or do i miss someting?
13:15 tuusj joined
13:15 <quchen> Having a <- in code that’s otherwise applicative means you’re using a new kind of power that you may not need. Monads should be avoided if you can, just like Applicative should be avoided when Functor is enough.
13:16 <tsani> bollu: I don't remember the specific example, but if I had to guess: Cont
13:16 <bollu> tsani: lol
13:16 <bananu7> quchen: Again, I don't buy that. The code doesn't necessarily strictly benefit from that, esp. if you don't have AppplicativeDo
13:16 <glguy> Proxy
13:17 <bollu> glguy: is that the monad that cannot be written as functor?
13:17 <tsani> Also you can parse non context-free languages using applicative by using an infinite grammar
13:17 <bananu7> <- is there for one reason and the reason is readability
13:17 <bananu7> just because you can infix fmap everything doesn't mean you should
13:17 <quchen> <- or >>=, whatever you like
13:17 <glguy> that's the simplest example that comes to mind
13:18 <bananu7> quchen: I think the best bikeshed example is <- vs liftA2/liftM2 (,)
13:18 <bananu7> (in real use)
13:18 <quchen> I don’t follow.
13:18 <* shapr> hops
13:19 <bananu7> From the pure "what's clearer to the reader" perspective
13:19 <quchen> If you have a monad, do-notation is fine. If you don’t have a monad, it’s a code smell.
13:19 Trendrrr joined
13:20 <quchen> Because with do-notation you get the Monad constraint despite not doing anything that requires monad.
13:20 <cocreature> quchen: just use ApplicativeDo :)
13:20 Kreest_ joined
13:20 <quchen> cocreature: Sure, that often helps!
13:21 <bananu7> quchen: and what I'm trying to say (aside from ApplicativeDo) that the constraint can be worth added readability
13:21 <quchen> cocreature: But this is independent of do-notation, really.
13:21 saussure joined
13:21 wroathe joined
13:22 bennofs joined
13:22 <quchen> cocreature: If a parser says »monad« I get a hunch it’s hard to understand the grammar. If it says Applicative I’m good ;-)
13:22 sheaf joined
13:22 <bananu7> All of my parsers are "monads" :F
13:23 <bananu7> I guess the only time I actually utilised that fact was for traceShowM
13:23 iAmerikan joined
13:24 <quchen> many :: Monad m => m a -> m [a] -- Why Monad? Does it inspect the »a«? It can’t … maybe it forces it?
13:24 Kreest__ joined
13:24 <quchen> MonadPlus, rather.
13:25 <quchen> many :: Alternative m => m a -> m [a] -- okay
13:25 mr_sm1th joined
13:25 <quchen> Stuff like that.
13:27 Trendrrr joined
13:27 `^_^v joined
13:28 bananu7 joined
13:28 svgDelux joined
13:28 bluepixel joined
13:31 qguv joined
13:32 dni joined
13:32 wroathe joined
13:32 Cale joined
13:32 joco42 joined
13:33 <Philonous> jakub_, I took the liberty of porting the code to the singletons library. Should get you started to play around with it: https://github.com/Philonous/sorted-expressions-ala-carte/commit/d7fb7c7be98584faefacb00199a39bc73677e270
13:33 hanna joined
13:33 marvin2 joined
13:33 jabesed joined
13:34 <jakub_> Philonous: This is great, it will take me a lot of time to study the change but I am ever so grateful!
13:37 <Philonous> jakub_, Btw. with any luck with the next major release GHC will get proper pi types and won't have to tolerate singletons any longer :D
13:37 pie_ joined
13:38 Kreest_ joined
13:39 <bollu> Philonous: what? :O seriously?
13:39 oisdk joined
13:39 <bollu> Philonous: haskell is getting more dependant typed? :)
13:39 mclaren joined
13:41 buglebudabey joined
13:42 <jakub_> Philonous: I know very little about dependent types, but I think I heard someone say that Haskell would never get really dependently typed (I might have misunderstood terribly, it might have been exaggeration, someone being too harsh, ...)
13:42 wroathe joined
13:42 infinity0 joined
13:42 <Philonous> bollu, Yes! See Richard Eisenberg's thesis http://cs.brynmawr.edu/~rae/papers/2016/thesis/eisenberg-thesis.pdf
13:43 <cocreature> Philonous: is that really planned for the next release? I thought it was still a few years away
13:43 <jakub_> Philonous: still, next major release is probably very far
13:43 ystael joined
13:44 Trendrrr joined
13:44 <Philonous> jakub_, You can already write dependently typed programs in Haskell. In fact, that's what you've been doing.
13:44 cretiq joined
13:44 carlomagno joined
13:44 tlaxkit joined
13:44 Sh4rPEYE joined
13:45 biglama joined
13:46 <jakub_> Philonous: well, as is the case with many different math objects, trivial instances are still instances, so any "regular" type falls under dependent types (or is this not true?). the question is whether what one can express in haskell can in reality represent arbitrary dependent type
13:46 <Philonous> cocreature, goldfirere said he planned on implemented it withing a year. Of course it's still vaporware es of yet
13:47 Taneb joined
13:47 <Sh4rPEYE> I'm going through the "20 Intermediate Haskell Problems", where you basically rewrite common monadic (and other) functions. Is there any way to simplify "moppy" (= traverse)?
13:48 RouxTheDay joined
13:48 <cocreature> Philonous: between having some prototype implementation and having a ghc release that contains it, there can still be some time :)
13:48 <jakub_> Philonous: and of course I realise you meant that there are facilities (like singletons) that allow you to express dependent types
13:48 <Sh4rPEYE> unicorn = return, banana = bind, Misty = Monad
13:48 <Sh4rPEYE> moppy :: (Misty m) => [a] -> (a -> m b) -> m [b]
13:48 <Sh4rPEYE> moppy [] _ = unicorn []
13:48 <Sh4rPEYE> moppy (a:as) f = jellybean $ banana (\ b -> unicorn (banana (\ bs -> unicorn $ b:bs) (moppy as f))) (f a)
13:48 <shapr> I like those names.
13:48 <Sh4rPEYE> Oh, and jellybean = join (I think)
13:49 <Sh4rPEYE> Yeah it is pretty fun :-D
13:49 saussure joined
13:49 <shapr> have you seen the bananas and lenses paper?
13:49 <Philonous> jakub_, Haskell has been able to express more than HM for a long time. And It's been etching ever closer to full-spectrum dependent types. With 8.0 and the arrival of TypeInType and lifted GADTs I think it's possible to encode arbitrary DT programs.
13:49 <Philonous> Although I'm not sure of that, so don't hold me to it :>
13:49 <Sh4rPEYE> Nope. I've yet to finish the Haskell Book - I'm complete beginner. No lenses for me
13:50 <Sh4rPEYE> I'm glad I finished these Intermediate exercises; so I'm technically Intermediate now (no lenses for some while anyway, though)
13:50 <Philonous> cocreature, We can hope :>
13:51 <cocreature> Philonous: I haven’t even used TypeInType in actual code yet :)
13:51 cdg joined
13:51 Trendrrr joined
13:51 <shapr> Sh4rPEYE: Jeremy Gibbons chose a bunch of names similar to yours in his bananes, lenses, and barbed wire paper.
13:51 <Sh4rPEYE> shapr: Sounds fun. I can't wait to dive in this more advanced stuff!
13:52 <shapr> yeah, there's so much cool stuff!
13:52 <halogenandtoast> If I want to concat two texts, should I use (<>) from Data.Monoid?
13:52 <exarkun> This doesn't actually seem to write anything to a_stdin, b_stdin - https://github.com/LeastAuthority/spake2-interop-test/blob/e46fdb293c9b519d772d0f6730dc61f4bf3b89f8/TestInterop.hs#L47-L52 - What am I missing?
13:52 <Sh4rPEYE> shapr: Any idea about the simplifying?
13:52 juanpaucar joined
13:52 <BernhardPosselt> is there some sort of record inheritance?
13:52 <Philonous> cocreature, I've been meaning to go through some of McBride's old stuff and implement it in Haskell, but I haven't had the time yet :/
13:52 <Philonous> Spent it all procrastinating on IRC :(
13:52 <BernhardPosselt> e.g. User record and Employee record
13:53 <BernhardPosselt> employee is a user record + a few additional fields
13:53 <BernhardPosselt> so you dont have to redefine type class instances as well
13:53 <bollu> shapr: that paper is horrible, it introduces so much notation
13:54 <mniip> aren't haskell summer results supposed to be published today
13:54 <byorgey> BernhardPosselt: no
13:54 <shapr> bollu: yeah, I found it very frustrating at first, but I asked a bunch of questions here and learned much.
13:54 meba joined
13:54 <shapr> Sh4rPEYE: not off the top of my head, sorry
13:54 <bollu> shapr: I see
13:54 <bollu> shapr: perhaps I should do the same
13:54 <jakub_> Philonous: you helped me to understand these first steps toward dependent types so much!
13:55 <exarkun> BernhardPosselt: Put a user record in your employee record. Composition.
13:55 tromp joined
13:55 <jakub_> Philonous: would you recommend using the purely singleton approach or typeable approach to casting things?
13:55 coot____ joined
13:55 <Philonous> jakub_, Well, now I've got you hooked there's one more voice pestering Richard to implement pi types. Mission accomplished :P
13:55 <BernhardPosselt> exarkun: thats what i thought too
13:55 <Sh4rPEYE> shapr: No problem. Well, whatever, I can do with this. On to Parser Combinators!
13:55 <shapr> Sh4rPEYE: w00t!
13:56 <Philonous> jakub_, Well since you've already gone to the trouble of using Singletons, I'd go all the way with them.
13:56 <jakub_> Philonous: :D count me in! :)
13:56 <BernhardPosselt> exarkun: then you have to use lenses right?
13:56 <BernhardPosselt> to update record fields
13:56 <byorgey> Sh4rPEYE: you can write that much more simply if you have fmap and ap
13:56 <exarkun> BernhardPosselt: You probably don't _have_ to but maybe it's helpful.
13:56 <byorgey> Sh4rPEYE: I don't know if you have already implemented combinators with those types
13:56 <exarkun> BernhardPosselt: Not that I really know much about lenses.
13:57 <byorgey> BernhardPosselt: right, you don't have to, but if you compose records by nesting them, the way to access/update them compositionally is with lenses.
13:59 Trendrrr joined
13:59 <byorgey> Sh4rPEYE: anytime you have a unicorn (return) immediately following a banana (bind) you might as well use fmap instead
13:59 <byorgey> halogenandtoast: sure
13:59 <halogenandtoast> byorgey: ha thanks, I almost figured my question would go unanswered.
14:00 <halogenandtoast> So many options to do the same thing it seems
14:00 <byorgey> halogenandtoast: it almost did, I just happened to glance back and notice it =)
14:00 <halogenandtoast> mconcat, mappend, Text.append, Text.concat
14:00 <shapr> monoids for all the things!
14:00 <halogenandtoast> (<>)
14:00 <shapr> tie fighter operator
14:00 sirreal joined
14:01 <Philonous> (<>) and mappend are the same
14:01 <ertes-w> halogenandtoast: i always use (<>)
14:01 <BernhardPosselt> no idea why ¯\_(ツ)_/¯ is not yet an infix operator
14:01 <BernhardPosselt> for asum
14:01 <ertes-w> halogenandtoast: mostly because i can use it unqualified, and because i don't need to change anything when i switch Text flavours
14:02 <Sh4rPEYE> byorgey: I do have both
14:02 juanpaucar joined
14:02 <halogenandtoast> ertes-w: it conflicts with Data.Semigroup
14:02 <ertes-w> halogenandtoast: yet =)
14:02 <halogenandtoast> If you care about that kind of thing.
14:02 Itkovian joined
14:02 <Philonous> (<>) It also works on ByteStrings and Strings (and other lists). One operator to append them all
14:03 <ertes-w> halogenandtoast: not overly worried about that, because i'm pretty sure that conflict is going away sooner or later
14:03 <Philonous> -It
14:03 <byorgey> Sh4rPEYE: should I tell you the simpler way to implement moppy, or do you want to think about it some more? You can do it using only fmap, ap, and recursion
14:03 wroathe joined
14:03 peterhil joined
14:03 <halogenandtoast> I've only recently learned what a Semigroup was, not sure I'll ever use them myself.
14:03 <halogenandtoast> I like my lists empty
14:03 <* shapr> surreptitiously empties all of halogenandtoast's lists
14:04 <shapr> oh man, no mutation :-(
14:04 <halogenandtoast> Yay now I have no chores left!
14:04 <halogenandtoast> Also no money in my bank account
14:04 <shapr> whoops!
14:04 <shapr> halogenandtoast: how'd you get into Haskell?
14:04 cdg joined
14:04 <ertes-w> halogenandtoast: you're using semigroups all the time
14:05 <halogenandtoast> shapr: When I used to work at thoughtbot I had a bunch of coworkers who got on the Haskell bus. At first I thought they were crazy (as a Rubyist) but eventually I saw the light.
14:05 <halogenandtoast> Too many ways for Ruby to go critically wrong.
14:05 <halogenandtoast> ertes-w: You don't know me.
14:05 <ertes-w> halogenandtoast: but i know that you're using semigroups =)
14:05 <BernhardPosselt> well the issue is more that its very hard to write good OO code
14:05 maarhart joined
14:06 <BernhardPosselt> we basically write functional OOP all the time
14:06 <halogenandtoast> BernhardPosselt: it's very hard to write good code.
14:06 <BernhardPosselt> where our objects are either data and our functions are "services"
14:06 <shapr> Yeah, I get paid to write Python, and I end up using lits comps where others build a fake ADT with objects and work with that.
14:06 <shapr> list comprehensions*
14:06 <ertes-w> "functional OOP" =)
14:06 Trendrrr joined
14:06 <ertes-w> "negative natural number"
14:06 <halogenandtoast> shapr: I'm trying to get my current company using more Haskell
14:06 <BernhardPosselt> whats the point in OO when using OO like it was intended is bad practice :D
14:06 <ertes-w> "composite prime"
14:07 <halogenandtoast> I just built a small service I'm going to try to make them use/launch for internal things.
14:07 <shapr> halogenandtoast: yeah, code is hard, I always want more crutches.. anything that catches my mistakes so I can go faster and try more options.
14:07 <ertes-w> "smart PHP lover"
14:07 <ertes-w> ok, sorry… that was inappropriate
14:07 <shapr> halogenandtoast: that's awesome! I've written some Haskell for simple network traffic analysis, that saved us a bunch of time.
14:08 <shapr> Hold my coffee and watch me write a parser and analyzer in three hours!
14:08 <halogenandtoast> shapr: That's pretty cool. Most of my stuff has been fairly lame. A bunch of command line games, one yesod app, and one spock app.
14:08 drewbert joined
14:09 <shapr> oh, I'm writing a simple exercise tracking rest api in both spock/python flask for a talk I'm giving in three weeks.
14:10 <shapr> This is the first time I've done a detailed comparison of duplicate features, I now have far more detail on why I prefer writing Haskell over Python.
14:10 <halogenandtoast> Nice if you have any questions about Spock I've done some of the simple stuff.
14:10 <ertes-w> halogenandtoast: the way i do it is: come up with something that will bring value (a.k.a. money), implement it in haskell… by the time anyone objects to doing it in haskell, it will already be done, so rewriting it in something else will be pointless
14:11 <shapr> I made about fifteen typos while writing the Python Flask code, and found them all at runtime :-(
14:11 sproingie joined
14:11 <* shapr> hops around sproingie
14:12 <shapr> I made a few typos in the spock code, but the compiler immediately complained.
14:13 <exarkun> The answer: no explicit hFlush.
14:13 wroathe joined
14:13 Trendrrr joined
14:13 <halogenandtoast> shapr: Most of my errors with Spock was figuring out types.
14:14 <halogenandtoast> I decided to add Persistent and Data.Yaml.Config
14:14 <halogenandtoast> my old friends from Yesod
14:14 tlaxkit joined
14:15 <halogenandtoast> If you're interested: https://github.com/halogenandtoast/mirin/blob/master/app/Main.hs
14:15 <halogenandtoast> Always thankful for feedback on making it better.
14:15 <halogenandtoast> but not required of course.
14:15 <athan> Am I correct in thinking that MVars can only be "used productively" if there are a symmetric number of `take`s and `put`s across the active threads interacting with the MVar? I heard that GHC will throw BlockedIndefinitelyOnMVar to threads if it believes there isn't enough symmetry in the `take`s and `put`s
14:16 <merijn> athan: No, that's attributing too much intelligence to GHC
14:16 qguv joined
14:16 <sproingie> every producer eventually needs a consumer. ensuring that happens is up to you
14:16 <quchen> BlockedIndefinitely means that there is no thread that can reach the MVar but someone is waiting for it, or something simple along those lines
14:16 <athan> merijn: do you know how exactly that exception is thrown?
14:16 <sproingie> statically verifying that would be an interesting problem. probably impossible with just MVar alone
14:16 <quchen> Basically »this could be GC’d if only nothing was waiting for it«
14:16 <merijn> athan: BlockedIndefinitelyOnMVar triggers when: an MVar has no references *EXCEPT* threads currently blocking on it
14:17 <merijn> athan: i.e. if all threads with live references to an MVar are blocked on that same MVar, it's obviously impossible any of them will ever wakeup
14:17 <athan> quchen: yeah, I'm calling `put` at some asynchronous time, when I thought I could `forever $ r <- takeMVar ...` or something, to block until the receiving end arrives
14:18 <halogenandtoast> shapr: what was the path that led you to Haskell (since you asked me).
14:18 <merijn> athan: Counter example where you'll get screwed over: you have a thread that does "forever (putStrLn "hey!") >> takeMVar mvar"
14:18 asm_ joined
14:18 <merijn> athan: That thread holds a reference to the MVar and isn't blocked on it, so GHC will never tell that other threads blocked on that MVar are stuck
14:18 <merijn> Despite out thread never actually reading from the MVar
14:19 <shapr> halogenandtoast: Ah, I was writing a bunch of Python, and was somewhat influenced by elisp. I slowly started writing purely functional Python code but had never heard the term. A friend of mine asked me why I was writing Haskell in Python.
14:19 <shapr> So I started reading about Haskell and WOW
14:19 <merijn> athan: So if you have a reference to the MVar alive somewhere (so that you can asynchronously "put" to it), GHC will never see that MVar as blocked indefinitely
14:19 shesek joined
14:19 shesek joined
14:20 <byorgey> halogenandtoast: shapr is too modest to mention it, but you should ask him what year that was =)
14:20 <athan> thanks merijn & quchen, I think I'm understanding :S
14:20 <merijn> Since the alive reference, could theoretically do something with it at any point
14:20 <ertes-w> athan: if you just go with the default behaviour, then a thread that is killed due to indefinite MVar blocking will be indistinguishable from a thread that just blocks forever, except that the former is able to free resources
14:20 <ertes-w> athan: so if you don't need any special handling, just ignore it
14:20 <halogenandtoast> byorgey: sure, shapr what year was that?
14:20 <ertes-w> athan: caveat: make sure it doesn't happen in the main thread
14:21 <shapr> halogenandtoast: ha, that was 1999
14:21 <Sh4rPEYE> byorgey: Thanks. This is the function it simplified to:
14:21 jathan joined
14:21 Trendrrr joined
14:21 <Sh4rPEYE> moppy :: (Misty m) => [a] -> (a -> m b) -> m [b]
14:21 <Sh4rPEYE> moppy [] _ = unicorn []
14:21 <Sh4rPEYE> moppy (a:as) f = apple (moppy as f) (furry' (:) (f a))
14:21 <shapr> I had a bunch of trouble trying to learn Haskell, so I figured I'd start an irc channel for it and see if I could get people to show up and chat.
14:21 qguv joined
14:21 <byorgey> Sh4rPEYE: that's it =)
14:22 <Sh4rPEYE> Thanks a lot :-)
14:22 <byorgey> Sh4rPEYE: moppy and apple both have strange argument orders, but that's not your fault of course
14:23 <halogenandtoast> shapr: That's a good way to learn.
14:23 cdg_ joined
14:23 <shapr> yeah, lots of people here chatting :-)
14:23 wroathe joined
14:24 HarveyPwca joined
14:24 <halogenandtoast> I'm planning on starting a (second) meetup about Haskell in Tokyo.
14:24 Cerise joined
14:24 Cerise joined
14:24 <halogenandtoast> Thinking about giving a talk about Spock.
14:24 <shapr> halogenandtoast: oh, I was going to ask if you were near Atlanta, but I guess not.
14:24 <halogenandtoast> shapr: I used to live there
14:24 <sproingie> i'm liking that new monad "tutorial" recently linked on reddit. unlike a lot of folks, i like reasoning from use cases to the underlying theory and not the reverse.
14:24 <halogenandtoast> About 7 or 8 years ago now.
14:24 <shapr> yeah, I like spock. I'm sad scotty is no longer maintained, but spock is better overall.
14:25 <shapr> sproingie: Escaping Hell with Monads?
14:25 <Sh4rPEYE> Oh, I forgot to ask. Is there anyone here from Czech Republic?
14:25 <sproingie> shapr: that's the one
14:25 <Sh4rPEYE> (I don't have my hopes high, but... one never knows)
14:25 <shapr> sproingie: I agree, problem -> solution
14:25 xall joined
14:25 kritzcreek joined
14:25 <sproingie> it follows the process that anyone not formally trained uses: concrete to abstract
14:25 <shapr> sproingie: the comments on lobste.rs are good, someone gave a short description of how to build monads in C
14:26 tommd joined
14:26 <sproingie> hell i invented Writer in perl before i'd even heard of functional programming
14:26 Khisanth joined
14:27 Achylles joined
14:27 royal_screwup21 joined
14:28 <james9999> link?
14:28 <shapr> james9999: https://lobste.rs/s/xl0jik/escaping_hell_with_monads
14:28 <shapr> That's the lobste.rs comment thread, you can get to the article at the top
14:28 maarhart joined
14:28 Trendrrr joined
14:28 <shapr> james9999: or did you specifically want the comment on monads in C?
14:29 <ertes-w> monads in C?
14:29 <james9999> yes
14:29 <shapr> james9999: this one: https://lobste.rs/s/xl0jik/escaping_hell_with_monads#c_hc3hi3
14:30 <james9999> thx
14:30 <ertes-w> void *bind(void *m, void *c, void *(*f)(void *));
14:30 <ertes-w> have fun =)
14:30 <byorgey> Sh4rPEYE: I think there is actually a #haskell.cz IRC channel. I don't know if anyone is there
14:30 cobreadmonster joined
14:30 yellowj joined
14:31 <Sh4rPEYE> I'll check it out
14:31 <halogenandtoast> ertes-w: sadly I wrote a lot of c in my day, mainly due to trying to write compilers, and I can understand that line without a problem :(
14:31 <byorgey> there is also a haskell.cz website, but I don't know if it is maintained. I think it might have been a single person that created it
14:31 <ertes-w> i maintain that monads are pointless in a language without HKT, but if it doesn't even have good support for functions in the first place, then don't even bother
14:31 <shapr> HKT?
14:31 <MitchellSalad_> higher-kinded types
14:31 <shapr> ohh
14:32 <ertes-w> in other words: yes, F# does have monads, but they're pointless
14:32 <ertes-w> because you can't abstract over them
14:32 <sproingie> the Monad type is fairly useless then. composing kleisli arrows is something you can do anywhere
14:33 <sproingie> you don't always need fully generic code
14:33 <* shapr> fills his quiver with kleisli arrows.
14:33 peti joined
14:33 <shapr> oh hai peti!
14:33 wroathe joined
14:33 <c_wraith> I remember a paper titled something about Kleisli Arrows of Outrageous Fortune, but I have no idea what the paper was about..
14:34 rickygee joined
14:34 <ertes-w> well, you can use some abstractiosn for the sake of using something well known and well understood, but with monads it's a different story: they require a fair bit of language support in order to be useful even on this level
14:34 <shapr> wow that's a great title, I must find that paper.
14:34 <ertes-w> c_wraith: the title isn't exactly enlightening either =)
14:34 <shapr> oh man: https://personal.cis.strath.ac.uk/conor.mcbride/Kleisli.pdf
14:34 <c_wraith> Conor McBride? Then you know it's gonna be good. :)
14:35 <MitchellSalad_> that paper is about indexed monads that get close to dependent-typed seeming stuff
14:35 <MitchellSalad_> tho now we have baaasically have dependent types, so *shrug*
14:35 <ertes-w> i wish that were true
14:35 <sproingie> been going back and reading a lot of old papers now that i can understand them. long as they're not stuffed with pages of greek anyway
14:35 <MitchellSalad_> it is true, with singletons!
14:35 <* peti> has a question about FFI. My understanding is that a "newtype Foo = Foo (Ptr ())" is essentially the same thing as a "Ptr ()". That this mean that I can import a C function that returns a void pointer -- Ptr () -- as returning a type Foo instead?
14:36 <shapr> Are there codependent types?
14:36 <ertes-w> MitchellSalad_: not really… they are as expressive as DTs, but they aren't DTs… they're incredibly verbose and awkward to work with
14:36 <geekosaur> peti: that sounds like you are confused somewhere
14:37 <MitchellSalad_> as-expressive-but-aren't is what i meant by "baaasically" :P
14:37 <sproingie> shapr: hm, two types that can't function without each other. add some fun methods and you have an Acme module :)
14:37 <c_wraith> For what it's worth, I think there's value in knowing about the Monad pattern in languages that don't support abstracting over it. It lets you know what principled combinators behave like, so you can avoid almost-but-not-quite monadic abstractions that fall over in some way. Like, say, the upcoming javascript Promises stuff.
14:37 <geekosaur> however that convention is used to mean we get an opaque pointer to be kept distinct from other pointer types, so if that is what you meant, then yes
14:37 <shapr> broken promises
14:38 <peti> shapr: Hi there. :-)
14:38 maarhart joined
14:38 <peti> geekosaur: Care to elaborate?
14:38 <sproingie> c_wraith: just call it a Design Pattern and yer all set ;)
14:39 wroathe joined
14:39 <c_wraith> sproingie: how can it be a design pattern? It doesn't have any boilerplate! :)
14:39 <sproingie> not when it's built-in, eh?
14:39 <geekosaur> peti, not sure how to elaborate without some context. the problems are (a) C is not strongly typed, and (void *) is a hack of sorts (b) which means hacks on the Haskell side if you want to simulate strong typing or just try to keep the C-side merry tangle of nonsense straight
14:40 ChristopherBurg joined
14:40 dbmikus_ joined
14:40 tlaxkit joined
14:41 fakenerd joined
14:41 Trendrrr joined
14:42 <sproingie> monads in C++ are doable (and been done). more syntax sugar and better type system too
14:42 <sproingie> (than C that is)
14:42 Wuzzy joined
14:42 fakenerd joined
14:42 <peti> geekosaur: OpenSSL has function EVP_MD_CTX_new() that allocates and returns an opaque pointer type EVP_MD_CTX*. Now, my question is can I define a "newtype Foo = Foo (Ptr ())" and use that type everywhere instead of the naked pointer and rely on the fact the the newtype is just a pointer when it's passed forth and back from/to C?
14:42 <geekosaur> peti, yes
14:43 <peti> geekosaur: Is that guarateed by the standard? Or does it "just work"?
14:43 juanpaucar joined
14:44 <mauke> hah. which standard?
14:44 aarvar joined
14:44 <geekosaur> peti, ... ok, I guess that is your confusion then. the standard doesn't guarantee anything because there is nothing to guarantee. the guarantee is that Ptr represents a C pointer and carries a possibly phantom type that Haskell code can use if marshaling/demarshaling of the pointer is needed.
14:44 <geekosaur> beyond that, you;d need guarantees on the C side which is impossible
14:45 <peti> geekosaur: OK. Thank you.
14:45 <geekosaur> (because Haskell doesn't get to dictate to arbitrary C code)
14:45 <mauke> I'm pretty sure the Haskell FFI isn't compatible with full standard C
14:46 <mauke> so what you get is basically "it happens to work on some common platforms"
14:46 <merijn> GHC follows the ABI of the platform
14:46 <merijn> At least, that's what it's supposed to
14:46 bluepixel joined
14:47 bluepixel joined
14:47 <mauke> what if the ABI actually uses different kinds of pointers?
14:48 <merijn> mauke: Well, GHC only supports posix platforms, so that doesn't happen on supported platforms :p
14:48 acertain joined
14:48 Trendrrr joined
14:48 <sproingie> if one's platform has differing pointer widths, usually there's one that's "suitable for export" for a FFI
14:49 <cocreature> merijn: if you claim ghc only supporst posix platforms, Phyx will come and find you :)
14:49 bluepixel joined
14:49 RouxTheDay joined
14:49 <mauke> wait, since when is Windows POSIX?
14:49 <sproingie> and it's up to the one compiling it on the C side to get it right
14:49 <mauke> sproingie: not just widths. widths are the easy part :-)
14:49 <merijn> ok, posix + windows :p
14:50 <sproingie> mauke: can't think of other pointer types that a C compiler would output
14:50 <mauke> sproingie: isn't the whole point of a FFI to be able to bind to existing interface without having to write glue code?
14:50 <sproingie> ideally. sometimes it needs help.
14:51 FreeBirdLjj joined
14:51 <sproingie> varargs is often a sticky wicket
14:51 <mauke> basically there are the following pointer kinds: function pointers, byte pointers (char * variants and void *), struct pointers, and every other type of pointer
14:52 <cocreature> you already need glue code if the C code passes structs by value
14:52 <tobiasBora> Logio: I found sequences, it's what I want right ?
14:52 flatmap13 joined
14:52 <mauke> i.e. AFAIK int * and double * aren't required to have anything in common
14:52 <mauke> or int * and int **
14:53 <sproingie> that's what the ABI is all about
14:53 <mauke> merijn: do you have a link to what POSIX says about pointer requirements?
14:53 <merijn> mauke: Pretty sure the only pointers that get to be different are function pointers
14:53 <merijn> (in C11)
14:53 <mauke> that would surprise me
14:54 <Myrl-saki> Fundep. `| (n, v, s) -> t, (n, t) -> v`
14:54 <mauke> because that would break compatibility with C99/C89 in a major way
14:54 <Myrl-saki> Is there a clearer way to represent that?
14:54 <merijn> mauke: Well, at the very least void* can represent everything pointer to non-functions
14:54 <sproingie> pretty sure posix doesn't say anything about ABIs
14:54 <merijn> mauke: And void* can be directly cast to the relevant pointer type
14:54 <mauke> merijn: well, yes. but that just means void * is a common serialization format
14:54 <merijn> So, if your ABI deals with void* you're fine
14:54 <mauke> that does not follow
14:54 <merijn> posix further requires that void* is big enough to store function pointers too
14:55 <Myrl-saki> If you ABI is void*, that seems even worse...
14:55 <mauke> you still have to apply the right serialization/deserialization steps
14:55 <Myrl-saki> From an API perspective.
14:55 coltfred joined
14:55 <Myrl-saki> (And like, technically, every ABI is void*)
14:56 <sproingie> merijn: the C standard doesn't require that, not sure where posix would
14:56 Trendrrr joined
14:56 <merijn> sproingie: The last bit I'm 100% sure about
14:56 <merijn> posix mandates void* can hold function pointers
14:56 <mauke> sproingie: dlsym()
14:57 <Myrl-saki> Interesting.
14:57 <sproingie> posix needs that for dlsym (and a lot of other things) to work at all, yes
14:57 <sproingie> not sure it spells it out chapter and verse, but i obviously haven't read the whole thing
14:57 geekg_000 joined
14:57 <Myrl-saki> Question. How can it be impossible for void* to hold a function pointer?
14:58 mjora7 joined
14:58 eyck joined
14:58 <mauke> Myrl-saki: it could be too small, for example
14:58 <merijn> Myrl-saki: Because function pointers are not required to fit in void*?
14:58 <mauke> e.g. 2 byte data pointers, 4 byte function pointers
14:58 <Myrl-saki> Ahh
14:58 mivael joined
14:58 <Myrl-saki> Makes sense.
14:58 LordBrain joined
14:58 <mauke> http://c-faq.com/null/machexamp.html
14:59 <sproingie> usually such platforms have a "far pointer" type
14:59 henriksod joined
14:59 <sproingie> (storage class, whatever)
14:59 <Myrl-saki> x86. :D
14:59 <sproingie> in DOS maybe
14:59 <Myrl-saki> Mhm. 16-bit x86.
15:00 <sproingie> real OS's run in a saner mode
15:00 <Myrl-saki> sproingie: DOS was pretty real for its time. :P
15:01 <sproingie> DOS was a minor BIOS extension ;p
15:01 cschneid_ joined
15:01 <Myrl-saki> mauke: Thanks for the link. That was pretty interesting.
15:01 <Logio> tobiasBora: depends on what sequences you found :)
15:01 zariuq joined
15:01 codesoup joined
15:02 earldouglas joined
15:03 twopoint718 joined
15:03 <geekosaur> if you have a linux kernel with big page support, it uses far pointers internally. nothing to do with "real oses"
15:03 dbmikus_ joined
15:03 <geekosaur> (you're conflating storage type/pointer size with the lack of memory protection)
15:03 asm_ joined
15:03 Trendrrr joined
15:04 bluepixel joined
15:05 <sproingie> yah i guess there was only a brief time in 32-bit land where everything was gloriously uniform
15:05 Guest57256 joined
15:06 rickygee joined
15:07 <twopoint718> What's the current state of deploying stack-ified Haskell applications to Heroku (or similar buildpack-using services)?
15:08 <twopoint718> Is there a preferred solution?
15:09 bluepixel joined
15:10 oisdk joined
15:10 pylbrecht joined
15:10 Gloomy joined
15:11 Trendrrr joined
15:11 ozgura joined
15:12 sepp2k joined
15:12 <sproingie> googling around there do look to be maintained buildpacks using stack
15:12 eliasr joined
15:13 pranitbauva1997 joined
15:18 <twopoint718> sproingie: Yeah, I'm looking at this one: https://github.com/mfine/heroku-buildpack-stack and I was just wondering if anyone had tried it.
15:18 dni joined
15:18 <sproingie> the script looks simple enough
15:19 dm3 joined
15:19 eklavya joined
15:19 buglebudabey joined
15:20 gestone joined
15:20 <twopoint718> Cool, I'll give it a shot
15:20 <twopoint718> sproingie: thanks
15:22 ketil_ joined
15:22 uglyfigurine joined
15:22 maarhart joined
15:23 juanpaucar joined
15:24 oish joined
15:24 conal joined
15:25 Trendrrr joined
15:25 Gurkenglas joined
15:26 rkazak joined
15:26 <Logio> tobiasBora: do you need all the possible orderings of n elements, or just the n-length subsets?
15:27 <heath> https://github.com/juhp/stackage-query
15:27 <tobiasBora> Logio: All the lists of size n containing as elements the elements from the incoming list.
15:29 wroathe joined
15:29 maarhart joined
15:30 phaer left
15:31 psychicist__ joined
15:31 eyck joined
15:33 osa1 joined
15:33 P1RATEZ joined
15:38 jathan joined
15:38 Trendrrr joined
15:38 jutaro joined
15:38 TheInfosphere joined
15:39 _jak joined
15:39 sproingie joined
15:39 urodna joined
15:39 chlong joined
15:40 trism joined
15:41 ErinvanderVeen joined
15:43 tabaqui joined
15:44 Achylles joined
15:47 saussure joined
15:48 buglebudabey joined
15:48 eyck joined
15:49 Trendrrr joined
15:49 RouxTheDay joined
15:50 <buglebudabey> is hmatrix the most efficient matrix library?
15:50 jerbome_ joined
15:50 jmelesky joined
15:51 Lord_of_Life joined
15:51 Lord_of_Life joined
15:53 <lpaste> Logio pasted “Selecting sublists of size n” at http://lpaste.net/355756
15:54 <Logio> tobiasBora: ^
15:54 Durbley joined
15:54 rcschm joined
15:55 augur joined
15:55 <Logio> that's one solution, though not very efficient if n is large
15:56 zacts joined
15:57 <zacts> hi is haskell well-suited for web development?
15:57 <Logio> there is probably a cleverer way to do it by iterating selections but it gets too messy for my brains at this moment
15:57 ph88 joined
15:57 <zacts> when should I use Haskell / Clojure / Elixir?
15:58 <ph88> i have a Vector Unboxed Double with numbers like 1.0 2.0 3.0 .. what function can i use to get the sum per element ?, so 1.0, 3.0, 5,0
15:58 neoo joined
15:58 fakenerd joined
15:58 <ph88> zacts, haskell is statically typed, elixir and clojure dynamically typed .. it's a big difference
15:58 petermw joined
15:58 yellowj joined
15:58 <zacts> ph88: how does this affect web devel?
15:58 <sproingie> zacts: it's extremely suitable, though it does take a little more discipline up front
15:59 <lyxia> ph88: http://hackage.haskell.org/package/vector-
15:59 eazar001 joined
16:00 <zacts> sproingie: ok
16:00 <sproingie> zacts: same as other static typed systems for any app: it takes a different discipline up front (thinking in types), but your debug cycle will be shortened like crazy
16:00 <zacts> oh nice
16:00 <sproingie> also doesn't hurt that haskell has concurrency that gives erlang a run for its money
16:00 <zacts> so Haskell offers this advantage over other systems
16:00 neoo joined
16:00 <zacts> oh cool, so Haskell also has nice concurrency versus even erlang?
16:00 <ph88> lyxia, that computes the sum of all elements .. but i need the sum PER element
16:01 tommd joined
16:01 saussure joined
16:01 <ph88> zacts, with dynamically typed you need to write unit tests for stuff which are already checked by the compiler if statically typed
16:01 <lyxia> ph88: what is a sum per element
16:01 raynold joined
16:01 <sproingie> it has crazy good concurrency, and now there's cloud haskell which makes it distributed like erlang. not as mature in erlang in that last category, but it'll get there
16:02 <ph88> lyxia, when input is 1 2 3 4 output is 1 (1 + 2) (1 + 2 + 3) (1 + 2 + 3 + 4) = 1 3 5 9
16:02 <zacts> oh wow, nice
16:02 <lyxia> ph88: that's a scan
16:02 acertain joined
16:02 <ph88> aha a scan !
16:02 <sproingie> er, as mature *as* erlang
16:02 <lyxia> 1+2+3 = 6 by the way
16:02 <zacts> sproingie: ph88 I'm going to give haskell + web devel a go
16:02 <zacts> I don't have a professional job, so I can just try it out anyway with no worries
16:02 <ph88> lyxia, which scan is best suitable ?
16:02 <zacts> but it is a time investment for me
16:02 neoo joined
16:02 <lyxia> ph88: scanl
16:02 <zacts> so I thought I would ask :-)
16:02 oisdk joined
16:03 <ph88> sproingie, "also doesn't hurt that haskell has concurrency that gives erlang a run for its money" --> can you elaborate ?
16:03 <sproingie> zacts: i'd say start with spock, though possibly pick up scotty too since there may be more tutorials for it
16:03 <zacts> ok
16:03 <lyxia> ph88: scanl starts from the left, scanr starts from the right
16:04 <ph88> zacts, i went with spock .. but i haven't finished it yet
16:04 zv joined
16:04 ContessaTP joined
16:04 <ph88> lyxia, well the new vector be allocated in one go ?
16:04 <sproingie> ph88: haskell's (ok, actually ghc's) thread and i/o scheduler scales like mad. millions of sparks is doable on mid-range hardware
16:04 <lyxia> ph88: postscanl if you don't want the initial accumulator
16:04 <shapr> zacts: I'm using spock at the moment, it's nice.
16:04 <zacts> thanks
16:04 neoo joined
16:04 <zacts> :-)
16:04 <shapr> zacts: but it depends on how much magic you want
16:05 <lyxia> ph88: yes
16:05 <zacts> shapr: semi-define magic. :-P
16:05 <ph88> lyxia, scan with strict accumulator would that help with performance ?
16:05 <shapr> zacts: spock has minimal magic, larger frameworks have much magic where they do everything for you, but that can make the error messages difficult to understand if you don't know what's happening under all the magic.
16:06 <sproingie> i learned about magic the hard way with lift
16:06 neoo joined
16:07 <ph88> shapr, can i ask you some questions about spock later ?
16:07 <shapr> ph88: sure, no guarantees I can answer, I've been out of Haskell webdev for years.
16:07 <shapr> but I'll do what I can!
16:07 <ph88> ok
16:07 <zacts> oh I see
16:07 <zacts> shapr: so spock is like Sinatra, and other frameworks are like Rails
16:07 sleffy joined
16:08 neoo joined
16:08 <ph88> kind of ye
16:08 <sproingie> i'm looking to jump in to haskell web dev myself. gave it a weak stab with snap and yesod way back, but i ended up using spray in scala instead
16:08 <shapr> zacts: roughly, yes but there are still many differences :-)
16:08 <zacts> ok
16:08 kmels joined
16:09 <zacts> Haskell is magic already
16:09 <zacts> like I mean I would probably start with something minimal
16:09 <zacts> because the language itself provides really powerful ways to abstract ideas
16:09 <shapr> I used scotty before, but spock is the spiritual successor, imo
16:09 <shapr> yeah! I agree!
16:09 neoo joined
16:09 afarmer joined
16:09 <lyxia> ph88: hm, it's weird that there is a distinction for unboxed vectors at all.
16:09 <zacts> I'm also interested in doing music composition with Haskell
16:09 Itkovian joined
16:09 <zacts> a la https://overtone.github.io
16:09 <shapr> zacts: ooh, good support for that
16:10 <shapr> zacts: have you seen TidalCycles?
16:10 juanpaucar joined
16:10 <zacts> oh and visual processing
16:10 <zacts> a la https://processing.org
16:10 <lyxia> ph88: I would go with the strict accumulator to be safe
16:10 <zacts> no re: TidalCycles
16:10 <shapr> There are several really fascinating music composition frameworks for Haskell
16:10 <zacts> looks cool
16:10 <shapr> TidalCycles is specifically designed for live performance
16:10 <zacts> nice
16:10 descender joined
16:11 <sproingie> something like Processing with an actually decent language would be nice. i'd love a good spiritual successor to logo that was statically typed
16:11 <shapr> but .. oh, what's the name of Thompson's successor to Hascore?
16:11 <zacts> logo is that turtle language right?
16:11 <shapr> zacts: yup, that's right.
16:11 <zacts> cool
16:11 <zacts> well there is a clojure interface into processing-lang
16:11 <zacts> I think because processing is on the JVM
16:11 <zacts> can GHC interact with the JVM?
16:11 <sproingie> clojure ain't static either. better language than processing's DSL tho
16:12 <zacts> and better than Java
16:12 <sproingie> i dunno at least that is static
16:12 <sproingie> but yeah java isn't the language for a DSL
16:12 <zacts> well I think the processing DSL extends into full java if you want more power
16:12 <zacts> it's like a subset I think
16:13 <zacts> and then if you want more then you just extend that subset into full java, or another JVM language
16:13 <monochrom> No, Haskell doesn't have a JVM story. The irony is that Haskell FFI has reserved a place for it for 17 years.
16:13 <ggVGc> there's frege...
16:13 <zacts> hehe
16:13 <sproingie> haskell has a few JVM stories, not just frege
16:14 sfcg joined
16:14 <zacts> is it theoretically possible to implement in reasonable fashion?
16:14 <james9999> did someone mention gottlieb frege?
16:14 <alx741> and eta...
16:14 <zacts> or would it be totally convoluted?
16:14 <sproingie> the JVM isn't as compelling a platform as it used to be. maybe java 9 will fix that, the deployment story gets a lot better with that
16:14 <ph88> lyxia, i don't understand the difference between prescan, postscan and scan .. but i looked at the samples with (+) at it seems that postscan is what i wanted, and you also recommended that so i choose postscanl' with strict
16:15 <zacts> anyway, thanks. I'll bbl. I'm beginning this haskellbook.com now
16:15 <sproingie> since java9 can bundle a jre into the app, and jigsaw makes that jre not quite so bloated
16:15 <james9999> I recall reading about the jre in a tech book once - Write once, run anywhere!
16:16 <james9999> the bytecode is platform-independent!
16:16 <reactormonk[m]> s/run/debug/
16:16 <lyxia> ph88: the difference is whether to keep elements at the ends.
16:16 <sproingie> WORA, big whoop. the JVM is still very nice tech though.
16:16 mr_sm1th joined
16:16 bennofs joined
16:16 <monochrom> ASCII is also platform-independent. (After EBCDIC fell out of favour.)
16:17 hugo joined
16:17 <ph88> lyxia, if my input vector is of length 5 i would also like an output vector of length 5
16:18 <lyxia> ph88: yes postscanl' does that
16:18 <ph88> :)
16:18 <monochrom> Some Pascal compilers back then also used bytecode (called P-code). I played with one briefly. UCSD Pascal.
16:18 <monochrom> On Apple II, no less.
16:19 armyriad joined
16:19 <hugo> Does anyone have any experience getting mouse input with hscurses?
16:21 <sproingie> jvm bytecode wasn't the new idea so much as the verification stuff. which also didn't turn out well but that had more to do with the deliberate backdoors built into the java standard lib
16:21 <jle`> hm turns out that training ANN's using 'vectors' in ghcjs is pretty slow
16:21 <jle`> i sort of expected it to be so, but i had some hopes
16:21 <jle`> i guess it's time to write ffi wrappers over js linear algebra libraries
16:25 fragamus joined
16:28 eyck joined
16:29 Trendrrr joined
16:32 <buglebudabey> is Float or Double better in practice? if it depends, what does it depend on
16:32 <exarkun> depends on what you're doing with it. ;)
16:32 <buglebudabey> exarkun see second question :P
16:32 <exarkun> yea that's what I was answering
16:33 <buglebudabey> oops, ha
16:33 <buglebudabey> i'm doing matrix operations like page rank
16:33 <exarkun> but, I dunno, it may not really depend. I'm not sure single precision floating point is _worse_ for anything these days.
16:33 <exarkun> You pay an extra memory cost for using double precision.
16:33 <kadoban> Double should be a better default I'd think, especially in haskell where they're both going to take a decent amount of space. (that being usually the only benefit of Float)
16:33 oisdk joined
16:33 <exarkun> But everyone has plenty of memory now.
16:34 mada joined
16:34 FreeBirdLjj joined
16:34 mbuf joined
16:35 <sproingie> use Double, unless you're doing GPU programming
16:35 <sproingie> or just plain need to pack a lot of them and don't need much precision
16:36 <sproingie> otherwise they're going to get upconverted anyway
16:36 pera joined
16:36 dm3 joined
16:36 <buglebudabey> alright
16:36 bencryption joined
16:37 Trendrrr joined
16:40 rkazak joined
16:40 xormor joined
16:45 beanbagula joined
16:47 Noldorin joined
16:47 t7 joined
16:48 geekg_000 joined
16:49 chrissound joined
16:49 acidjnk22 joined
16:50 jutaro joined
16:53 <chrissound> Hello! Are dynamic tags supported well by other panels or is this an xmobar feature?
16:53 eyck joined
16:53 <chrissound> I'm trying to get it to work with tint2, but I'm not too sure how to integrate tint2 with a logHook?
16:54 freusque joined
16:54 ph88 joined
16:55 bigos joined
16:57 buttbutter joined
16:58 Big_G joined
16:59 jerbome_ joined
16:59 twopoint718 joined
16:59 Trendrrr joined
17:00 codygman_ joined
17:00 Cerise joined
17:00 Cerise joined
17:01 caumeslasal joined
17:02 coltfred_ joined
17:03 peterbecich joined
17:04 Elhamer joined
17:05 vgrocha joined
17:06 <chrissound> Ah! XMonad.Actions.DynamicWorkspaces instead of XMonad.Actions.WorkspaceNames. It works! :D
17:07 Trendrrr joined
17:07 gestone joined
17:09 <tobiasBora> Logio: Thank you. I also ended up with this solution: sequence [ possibleValues | i <- [1..n]]
17:09 <tobiasBora> By the way, I've a question:
17:10 <tobiasBora> I've a pure function, that, given an input, gives me an output (whaoooo really ?)
17:10 tzh joined
17:10 fizruk joined
17:10 <tobiasBora> and I'd like to count the number of different output this function gives me
17:10 toblorone joined
17:11 wroathe_ joined
17:11 <tobiasBora> for now I use something like a map on a list of input
17:11 WhereIsMySpoon joined
17:11 <WhereIsMySpoon> How come this doesnt work? https://gist.github.com/Jarob22/23fbed05deba32f87dae4ee6389e455c
17:11 <codygman_> [True, False] ^.. filtered _False -- i expected [False] but got a sizeable type error
17:11 <tobiasBora> and then I do a pattern matching to get only the first occurence
17:11 <codygman_> Eh, bad example. I'm trying to filter a list of products with a prism
17:11 <WhereIsMySpoon> updated it with the error
17:12 <tobiasBora> but here if I'd like to compute everything and sort the output, what would be the more efficient way to proceed ? A map and a sort ?
17:12 SpinTensor joined
17:13 connrs joined
17:13 <koala_man> WhereIsMySpoon: x:xs is a list. [] is a list. [x:xs] is therefore a list in a list. just use (x:xs)
17:14 biglama joined
17:14 <WhereIsMySpoon> oh ffs
17:14 twanvl joined
17:14 <WhereIsMySpoon> hm..still an error
17:14 <WhereIsMySpoon> updated
17:14 oisdk joined
17:15 Trendrrr joined
17:15 <koala_man> WhereIsMySpoon: it's a cons list, so you can do element:list but not list:element
17:15 <WhereIsMySpoon> so do i need to use ++ instead?
17:15 SpinTensor joined
17:15 <koala_man> yes, you can do ++ [x]
17:15 <glguy> codygman_: There's no _False provided by lens, did you write your own?
17:16 <WhereIsMySpoon> yay!
17:16 <WhereIsMySpoon> and i dont need that [x] constraint either
17:17 <WhereIsMySpoon> koala_man: can you explain what you meant by its a cons list and that : wont work?
17:17 jutaro joined
17:18 <glguy> :t (:)
17:18 <lambdabot> a -> [a] -> [a]
17:18 <WhereIsMySpoon> :t (++)
17:18 <lambdabot> [a] -> [a] -> [a]
17:18 <WhereIsMySpoon> ah
17:18 quinor joined
17:18 <WhereIsMySpoon> i see
17:19 <WhereIsMySpoon> cool thanks all
17:19 dni joined
17:19 <koala_man> WhereIsMySpoon: it's a singly linked list if you're familiar, so given the first node there's no immediate way of appending something after the last
17:19 juanpaucar joined
17:19 baldrick joined
17:20 <quinor> hey, do you possibly know any good resources on writing functional language interpreter in haskell? I'm mostly interested in stuff about implementing type inference
17:20 jutaro joined
17:21 conal joined
17:21 <quinor> for now I've got H-M typed lambda calculus with algorithm W and inferring type of recursive lets (especially generalization) was quite rough
17:21 tromp joined
17:22 <sproingie> wasn't there a t-shirt with "What part of [written out algorithm W] don't you understand?"
17:22 Trendrrr joined
17:23 Bassetts joined
17:23 chrisdotcode joined
17:23 ccomb joined
17:24 <quinor> sproingie: the deal is there are some gimmicks if you add recursion
17:24 <quinor> without that it's all fine and simple
17:24 <cocreature> quinor: http://dev.stephendiehl.com/fun/006_hindley_milner.html
17:25 <quinor> cocreature: nothing on recursion and algebraic datatypes, already read that :/
17:25 moongazer joined
17:25 <quinor> thanks though, that's a good one
17:26 ErinvanderVeen joined
17:26 msko joined
17:28 erisco joined
17:28 <codygman_> glguy: nope. New example: [Right 1, Left "a"] ^.. filtered _Right
17:29 <codygman_> > [Right 1, Left "a"] ^.. filtered _Right
17:29 jrn1024 joined
17:29 <lambdabot> error:
17:29 <lambdabot> • Couldn't match type ‘p a’ with ‘[]’
17:29 <lambdabot> Expected type: Getting
17:29 Sonolin joined
17:29 <glguy> codygman_: Have you looked the type of filtered yet?
17:29 tommd joined
17:29 <codygman_> Yes, though it was very ​quickly right before lunch
17:29 <glguy> or the documentation for it?
17:29 amoe joined
17:29 <glguy> I'd recommend going back to that first
17:30 jrn1024 left
17:30 <cocreature> > [Right 1, Left "a"] ^.. traverse . _Right
17:30 <lambdabot> [1]
17:30 <glguy> Until you get more experienced with the lens package, guessing will be tougher
17:30 <cocreature> the important part of the type of filtered is even understandable :)
17:31 SeMas joined
17:31 kaychaks joined
17:32 dcoutts_ joined
17:32 jrn1024 joined
17:32 kaychaks_ joined
17:32 <codygman_> Will go back and reread, thanks glguy
17:33 kaychaks_ joined
17:33 <cocreature> codygman_: the short answer is: filtered expects a predicate "a -> Bool" not a prism
17:33 Itkovian joined
17:34 juanpaucar joined
17:34 kaychaks_ joined
17:34 Trendrrr joined
17:35 juanpaucar joined
17:35 <sproingie> maybe it's my brain operating on a 5 year old level, but my hardest time reading all the greek in papers is not really knowing how to read them aloud
17:35 <exarkun> it makes a difference
17:36 chrissound joined
17:36 <exarkun> if you don't know what they sound like, it's a lot harder to remember them, tell them apart, etc
17:36 <exarkun> it's how human brains work
17:36 <EvanR> sproingie: heh... can you read haskell aloud?
17:36 <exarkun> go memorize the greek alphabet :/
17:36 <sproingie> i end up looking at my greek alphabet printout then stumbling. "gamma implies alpha with type tau therefore ..."
17:36 fizruk joined
17:37 <EvanR> and some professors have weird ways of saying some of them
17:37 bollu joined
17:37 <codygman_> cocreature: thanks as well!
17:39 m0rphism joined
17:40 monadicDuck joined
17:41 thunderrd_ joined
17:41 ErinvanderVeen joined
17:41 <monochrom> Good thing I put "Ω is Greek capital Omega" in my lecture slides.
17:41 <sproingie> anyway it's less the greek letters so much as the connectives, the whole sentence if you will
17:42 <EvanR> ah ohms
17:42 beanbagula joined
17:42 Trendrrr joined
17:42 uglyfigurine joined
17:43 james999 joined
17:43 <dmwit> Perhaps a fun sigbovik paper would be using all the wrong metavariable conventions in an otherwise perfectly conventional paper.
17:43 <sproingie> ξ (xi) is one that throws me. excessive squiggliness.
17:43 <dmwit> Oh, that's not just pronounced "tornado"?
17:43 oisdk joined
17:44 csaurus joined
17:44 <EvanR> ξ zai? ksai?
17:44 <lyxia> depending on the font it looks like an epsilon which hit a wall
17:44 <EvanR> xi isnt really english
17:44 <EvanR> its a roman numeral
17:44 <sproingie> i suspect it's greek :)
17:44 <monochrom> dmwit: Oh w00t! Let h be a group, G be its identity element, e be a homomorphism...
17:44 <sproingie> well romanized greek
17:44 ramsey1 joined
17:45 <sbrg> lyxia: so it's a persian epsilon
17:45 <dmwit> monochrom: Let * \in h and consider *+*2
17:45 <sproingie> i thought "bananas, lenses and barbed wire" was a parody of mathematical notation
17:45 <sproingie> even today i'm not sure
17:46 <paolino> ksee
17:46 <monochrom> But the real disease is mathematicians refusing to use multiple-letter identifiers.
17:46 <wayne> i just wanted to say that i love pandoc.
17:46 gestone joined
17:46 <sproingie> zee i thought. then there's chi, where according to knuth, saying it should make your screen slightly moist
17:46 <monochrom> And that somehow CS people refuse to improve upon it.
17:46 <sproingie> doh, *zeye*
17:47 <dmwit> monochrom: I did that in a draft of a paper once. My coauthors made me change it to avoid confusing people or having to add a sentence saying "we use multiple-letter variable names"...
17:47 <sproingie> monochrom: mathematicians and haskell library developers yes. but types are documentation, right?
17:47 <Tuplanolla> Engineers and economists have adopted multiple-letter variables like FWHM that are impossible to distinguish from products, monochrom.
17:47 eacameron joined
17:48 <sproingie> we should just switch to chinese
17:48 <csaurus> I have a question about doing a list of actions, but stopping after some condition is reached. Would lazy evaluation forgo evaluating calls before the first 'Just' in the following code:
17:48 iAmerikan joined
17:48 <csaurus> foldl (<|>) Nothing [Nothing, Nothing, Just 1, Just 2, Nothing, Just 3]
17:48 <monochrom> Tuplanolla, I am with Dijkstra on this. Multiplication needs a visible operator.
17:48 <csaurus> *calls after the first 'Just'
17:48 <briansteffens> i'm getting a parse error on a file compiled with 'cabal build' but it works with 'ghc'. does cabal build not use ghc internally?
17:48 <dmwit> > foldl (<|>) Nothing [Nothing, Nothing, Just 1, undefined]
17:48 <lambdabot> Just 1
17:49 <dmwit> csaurus: GHC says yes!
17:49 <sproingie> monochrom: i thought that was ×
17:49 <monochrom> Yes.
17:49 <monochrom> So write it out all the time.
17:49 <dmwit> csaurus: Well. The calls will probably still happen. But the arguments won't get forced.
17:49 <csaurus> dmwit: oh yay! thank you! I think this is a pattern I can work with
17:49 <sproingie> monochrom: that'd make high school algebra awful noisy
17:49 <dmwit> > foldl (<|>) Nothing (Nothing:Nothing:Just 1:undefined)
17:49 <lambdabot> *Exception: Prelude.undefined
17:49 <dmwit> csaurus: The above highlights the distinction, I think. Your foldl isn't going to work on an infinite list, e.g.
17:50 Trendrrr joined
17:50 <dmwit> csaurus: (foldr is the canonical fold for lazy languages)
17:50 <dmwit> > foldr (<|>) Nothing (Nothing:Nothing:Just 1:undefined)
17:50 <lambdabot> Just 1
17:50 <briansteffens> nevermind, used 'cabal build -v' to see the command line args to ghc, think i can figure it out
17:50 <csaurus> dmwit: hmm okay - is there a reason foldr is? I always thought that would result in a long change of thunks
17:51 rkazak joined
17:51 <dmwit> csaurus: https://wiki.haskell.org/Foldr_Foldl_Foldl'
17:51 <hexagoxel> briansteffens: default extensions seem the most likely culprit of differences.
17:51 jsgrant_ joined
17:51 Elish joined
17:51 Zaghie joined
17:51 <csaurus> dmwit: Thanks, also is there a more idiomatic way to express what I wrote? The idea of going through a list but stopping early on some condition?
17:52 <dmwit> csaurus: Oh, actually, https://wiki.haskell.org/Fold is probably better.
17:52 <dmwit> :t asum
17:52 <lambdabot> (Alternative f, Foldable t) => t (f a) -> f a
17:52 <monochrom> I will just link you to what Dijkstra wrote: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1300.html
17:52 <dmwit> > asum (Nothing:Nothing:Just 1:undefined)
17:52 <lambdabot> Just 1
17:53 <sproingie> they're both good pages, but the latter is kind of required reading for the former
17:53 <csaurus> > asum (Nothing:Nothing:Just 1: Just 2:undefined)
17:53 <dmwit> csaurus: foldr (or manual recursion) is the canonical way to stop early on some condition when processing a list. But in most cases there is a more specific function that is more idiomatic.
17:53 <lambdabot> Just 1
17:53 Cale joined
17:53 <csaurus> dmwit: okay, thank you! I will do some reading
17:54 Zaghie joined
17:54 rockfordal joined
17:54 <Zaghie> anybody home?
17:55 chlong joined
17:55 <cocreature> Zaghie: just ask your questions directly :)
17:56 <sproingie> the magic of foldr is laziness. if you don't use the second arg, the whole thing short-circuits
17:56 <Tuplanolla> @let wrap a b x = let c = b - a in x - c * floor ((x - a) / c) :: Double -- This thing periodically shifts `x` between `a` and `b`.
17:56 <lambdabot> .L.hs:167:39: error:
17:56 <lambdabot> • No instance for (Integral Double) arising from a use of ‘floor’
17:56 <lambdabot> • In the second argument of ‘(*)’, namely ‘floor ((x - a) / c)’
17:56 <Tuplanolla> (Close enough anyway.)
17:56 <Tuplanolla> How should I define an analogous function for `Word8`?
17:57 Trendrrr joined
17:58 sbrg joined
17:58 sbrg joined
17:58 <csaurus> sproingie: Thanks! that's kind of what I was going for with Maybe and Alternative, better to use foldr though
17:59 <Zaghie> cocreature thanks I'm new to this. could somoene explain what a monad is?
17:59 <dmwit> Tuplanolla: wrap a b x = a+b-x -- ?
17:59 <sproingie> csaurus: these days you can fold over damn near anything, so you might end up using both
17:59 <Zaghie> tutorials tend to be very confusing and/contradictory on Monads
17:59 <sproingie> Zaghie: they're kind of infamous in that way
17:59 <cocreature> Zaghie: do you already understand Functor and Applicative?
18:00 <Tuplanolla> No, dmwit.
18:00 swalladge joined
18:00 <Zaghie> Not really, wanted to start with Monads, should I do those first?
18:00 <Cale> Zaghie: Do you know about data types with parameters?
18:00 <sproingie> monads are simply endotortillas in the category of burritos
18:00 joaj joined
18:00 <Zaghie> yes I know about datatypes with parameters
18:00 <cocreature> Zaghie: yeah, I recommend first learning Functor, then Applicative and then look at Monad
18:00 <dmwit> Tuplanolla: Can you expand that rejection a bit with a reason?
18:00 <Cale> Zaghie: A monad is a data type with a single parameter (i.e. it has kind * -> *) which has a particular interface defined on it.
18:01 <cocreature> Zaghie: do you understand typeclasses?
18:01 <Zaghie> I understand typeclasses
18:01 <Cale> Specifically, if M is our parametric type, we need definitions of:
18:01 <Cale> return :: a -> M a
18:01 <Cale> and
18:01 pranitbauva1997 joined
18:01 <Cale> (>>=) :: M a -> (a -> M b) -> M b
18:01 <dmwit> @let wrap a b x = let c = b - a in x - c * fromInteger (floor ((x - a) / c)) :: Double
18:01 <Cale> which satisfy some properties
18:01 <lambdabot> Defined.
18:01 <sproingie> (not that said capitalization scheme will work in haskell)
18:01 <dmwit> > (wrap 5 10 10, wrap 5 10 5)
18:01 <lambdabot> (5.0,5.0)
18:02 <dmwit> ?let wrap' a b x = a+b-x
18:02 <lambdabot> Defined.
18:02 <dmwit> > (wrap' 5 10 10, wrap' 5 10 5)
18:02 <lambdabot> (5,10)
18:02 <Cale> This pattern shows up a fair amount, when, say M a is supposed to represent some sort of computations whose result will have type a
18:02 <Tuplanolla> The idea is to find the `k` that solves the equation `m == n - a + k * a` with the constraint `a <= m < b`, dmwit.
18:02 <sproingie> for some examples of the pattern: https://philipnilsson.github.io/Badness10k/posts/2017-05-07-escaping-hell-with-monads.html
18:02 <Zaghie> Cale: ok, so we wrap a in M?
18:02 <Cale> Then return v will be the computation which does nothing, but produces v as a result
18:02 <sproingie> it doesn't explain what monads are, but it does explain what (some of them) do
18:03 douglascorrea joined
18:03 <* shapr> hops randomly
18:03 <Zaghie> monads are used to wrap values?
18:03 <monochrom> Zaghie, wrapping is usually a very misleading model.
18:03 <Cale> and x >>= f will be the computation which, when run, will first run x :: M a, obtaining its result v of type a, and then applies f :: a -> M b to decide which action to take next
18:03 <Cale> (and produces the result of that second action as its own)
18:04 <sproingie> it's more used to wrap *types*
18:04 <dmwit> > wrap 5 10 11
18:04 ph88 joined
18:04 <lambdabot> 6.0
18:04 <monochrom> I recommend just following Cale without any presumption or jumping to conclusion.
18:04 rkazak joined
18:04 <Tuplanolla> So for example `fmap (\ n -> f n 7 11) [0 .. 255]` would be `repeat [8, 9, 10, 7]`, dmwit.
18:04 <Tuplanolla> Sorry, `wrap` instead of `f` there.
18:04 sbrg joined
18:04 sbrg joined
18:05 <Cale> Zaghie: There are a lot of specific examples of monads, and you'll understand what the abstraction means best just by picking up examples over time.
18:05 <Zaghie> thanks, ok so it performs f over type a and combines it with b in M as the result? thanks for explaining this Cale
18:05 <sproingie> Zaghie: you got it
18:05 codygman_ joined
18:05 <Cale> Zaghie: You shouldn't usually think of M as "wrapping" something.
18:05 replay joined
18:05 FreeBirdLjj joined
18:05 <dmwit> ?let wrap'' a b x = ((x - a) `mod` (b-a+1)) + a
18:05 <lambdabot> Defined.
18:06 <Cale> It could, but that would be a boring example.
18:06 <dmwit> > map (wrap'' 5 10) [5,6,7,8,9,10,11,12,13]
18:06 <lambdabot> [5,6,7,8,9,10,5,6,7]
18:06 <Zaghie> Cale: haha, what's a more appropriate example?
18:06 <dmwit> Tuplanolla: ?
18:06 <Cale> Zaghie: Consider for example, the type IO, which happens to be a monad
18:06 <Cale> We have getLine :: IO String
18:06 <dmwit> > map (wrap'' 7 11) [0..255]
18:06 <lambdabot> [10,11,7,8,9,10,11,7,8,9,10,11,7,8,9,10,11,7,8,9,10,11,7,8,9,10,11,7,8,9,10,...
18:06 <Cale> Its result will be the string that the user types
18:06 <sproingie> IO is hard to use as an example since there's no looking under the hood unless you want to go explain ST RealWorld
18:06 <Cale> So the result can't be wrapped up in there
18:07 <Cale> sproingie: Well, I could make a simple version of IO
18:07 fryguybob joined
18:07 <Zaghie> true, so how is it handled in that case? or what's the mental model in IO?
18:07 <monochrom> IO is an excellent example because you can't look under the hood.
18:07 <dmwit> Tuplanolla: Oops, off-by-one. =)
18:07 <dmwit> ?let wrap''' a b x = ((x-a) `mod` (b-a)) + a
18:07 <lambdabot> Defined.
18:07 <sproingie> monochrom: no, it implies that all monads are about keeping types in a jail they can't escape from
18:08 <dmwit> > map (wrap''' 7 11) [0..255]
18:08 <lambdabot> [8,9,10,7,8,9,10,7,8,9,10,7,8,9,10,7,8,9,10,7,8,9,10,7,8,9,10,7,8,9,10,7,8,9...
18:08 <sproingie> and that's only true for IO (well ST really)
18:08 geekg_000 joined
18:08 <Cale> One mental model would be something like: data IO a = Done a | GetLine (String -> IO a) | PutLine String (IO a) | ...
18:08 <Cale> and then we'd have getLine = GetLine (\str -> Done str)
18:08 <codygman_> Is there a way to preserve the Prism matched on in: data A { a :: Int }; [A 1] ^.. traverse . _A --gives [(1)] but I'd rather have the type as well.
18:08 chaosmasttter joined
18:08 <mniip> sproingie, how is "an <...> example" related to "all monads"
18:08 <Tuplanolla> > and (zipWith (==) (fmap (\ n -> wrap''' n 7 11) [0 .. 255]) (concat (repeat [8, 9, 10, 7])))
18:08 <lambdabot> False
18:08 Trendrrr joined
18:09 <Cale> and putStrLn s = PutLine s (Done ())
18:09 BlueRavenGT joined
18:09 <Tuplanolla> > and (zipWith (==) (fmap (\ n -> wrap''' n 7 11) [minBound .. maxBound :: Word8]) (concat (repeat [8, 9, 10, 7])))
18:09 <lambdabot> False
18:09 <Tuplanolla> Doesn't seem to hold, dmwit.
18:09 <dmwit> > and (zipWith (==) (fmap (wrap''' 7 11) [0..255]) (concat (repeat [8,9,10,7])))
18:09 <lambdabot> True
18:09 <sproingie> mniip: human nature to fixate on the first example as representative of the whole
18:09 <dmwit> Tuplanolla: My argument order is just different than yours.
18:09 <EvanR> > take 3 $ foldl (flip (:)) [] [1,undefined,3,4,5]
18:09 <mniip> doesn't have to be the first
18:09 <lambdabot> [5,4,3]
18:09 <sproingie> god knows i did, as did many others
18:09 <Tuplanolla> Oh, whoops.
18:09 <Cale> Zaghie: Another example would be a type of parsers:
18:09 wroathe joined
18:09 <dmwit> Tuplanolla: Also: `cycle` is better than `concat . repeat`. ;-)
18:10 mac10688 joined
18:10 <EvanR> > take 3 $ foldl' (flip (:)) [] [1,undefined,3,4,5]
18:10 <lambdabot> [5,4,3]
18:10 unK_ joined
18:10 drewbert joined
18:10 <Cale> With a value of type Parser a being something which knows how to consume the initial portion of a String to produce a result of type a
18:10 <Tuplanolla> Yeah. I forgot the name in hurry, dmwit.
18:10 <dmwit> Tuplanolla: By the way, there is `mod'` if you want a similar implementation for `Double`.
18:10 <Cale> (possibly -- maybe even in multiple ways, if you want backtracking)
18:11 <sproingie> mniip: is why i like to start with Maybe. but i'm drowning out Cale's signal with my kibitzing :)
18:11 connrs joined
18:11 <sproingie> http://www.willamette.edu/~fruehr/haskell/seuss.html
18:11 SkyPatrol_ joined
18:11 <Tuplanolla> I just don't see how your solution works with wrapping, since `x - a` already goes around if `x < a`, dmwit.
18:11 <mniip> that's a terrible parser type
18:11 jameseb joined
18:11 <dmwit> Tuplanolla: mod don't care
18:11 <Zaghie> Cale: ah that makes sense. So Parser a can consume the first, and subsequent parts of a String to return a
18:11 <Cale> sproingie: Well, the misconception I was trying to address was the thought that M t is supposed to "wrap" some value of type t
18:11 <mniip> ok, maybe not terrible but at least it's not perfect
18:12 <Cale> sproingie: So Maybe would perhaps not have done as well at that :)
18:12 <sproingie> mniip: oh FFS it's baby's first parser, it's for an educational lecture
18:12 <Tuplanolla> What if I worked modulo a prime number instead of 256, dmwit?
18:12 <Zaghie> Cale: thank you, it illustrates the point perfectly :)
18:12 <Cale> Zaghie: Yeah, return v will be the parser which consumes none of the input, and produces v as its result
18:13 csaurus left
18:13 <Cale> Zaghie: and x >>= f will be the parser which eats the initial portion of the input with x, obtaining some result(s) v, and then uses f v to parse the remainder of the input
18:13 beanbagula joined
18:13 <dmwit> Tuplanolla: Hm, now I'm curious.
18:13 epsilonhalbe joined
18:14 <dmwit> ?check \(Positive n) -> ((-n) `mod` 7) == fromIntegral (fromInteger (-n) `mod` 7 :: Word8)
18:14 <lambdabot> *** Failed! Falsifiable (after 1 test):
18:14 <lambdabot> Positive {getPositive = 1}
18:14 <Zaghie> oh wow, and a "portion" of the string is a character?
18:14 <dmwit> Tuplanolla: You're right. `x - a` does seem dangerous.
18:14 <Zaghie> or defined by f?
18:14 <dmwit> ?src String
18:14 <lambdabot> type String = [Char]
18:14 <dmwit> Zaghie: ^^
18:14 <Cale> mniip: The Dr Seuss one?
18:15 <Zaghie> thanks dmwit, Cale and everyone else!
18:15 <Cale> mniip: It's great for learning from -- actually, I was half considering launching into a full explanation of how to write that Monad instance...
18:15 nahra joined
18:15 <dmwit> Tuplanolla: Well, you could convert to an Int16 first...
18:16 <Tuplanolla> And when using `Word64`...
18:16 <dmwit> Tuplanolla: (Which should be big enough to faithfully hold the result of a Word8 - Word8, I think.)
18:16 <mniip> Cale, now that I think about it my original argument might have been invalid
18:16 <dmwit> Tuplanolla: Integer. ;-)
18:16 <Zaghie> Cale: that would be awesomne
18:16 <Zaghie> if you want to do that :)
18:16 Trendrrr joined
18:16 <Tuplanolla> Then `Word64#`...
18:16 <EvanR> can foldl get the last element of a list "lazily", i.e. without consuming all the thunks it makes
18:16 <mniip> Cale, the problem with stuff like (\s -> (reverse s, ()))
18:17 rblaze1 joined
18:17 <sproingie> i remember A Gentle Introduction introducing the state monad from first principles, which goes and abbreviates the constructor as ST
18:17 <sproingie> so i went looking into ST and was utterly baffled
18:17 <dmwit> Tuplanolla: Well, you could look into the usual mathematical representation of integers in terms of nats and see if you can abuse it.
18:17 <sproingie> not helped by them being related ideas
18:18 <monochrom> "ADT" will also get you into much trouble.
18:18 <EvanR> > foldl (const id) 5 [0..1000000]
18:18 <lambdabot> 1000000
18:18 <Tuplanolla> There's a trivial recursive implementation, but it's unsatisfying, dmwit.
18:18 <EvanR> ok
18:18 <Tuplanolla> That is, add or subtract `b - a` until done.
18:18 <monochrom> algebraic data type vs abstract data type. Complete bipolar opposites.
18:18 <dmwit> Tuplanolla: namely you introduce `-` as a formal symbol and take the equivalence class under the usual equality, so `a-b = c-d` means `a+d = b+c`.
18:18 <Cale> Also, if you replace String with Text, it's really not so bad at all. I've written at least one parser we're using in production in (more or less) that way.
18:19 <dmwit> Dunno how hard mod is in that representation, though, never thought about it before.
18:19 <dmwit> Probably pretty hard.
18:19 <Tuplanolla> Man, I always get sidetracked into number theory.
18:19 <dmwit> ```(a-b) `mod` (c-0)``` is probably pretty easy, though, so if you believe your mod is going to be positive... =)
18:20 <Cale> Zaghie: okay, perhaps we should hold it in #haskell-overflow just because it's best if the definitions don't scroll away too quickly :)
18:20 <Zaghie> ok, I'll meet you there :)
18:21 dddddd joined
18:21 <dmwit> ?check \a b x -> ((x-a) `mod` (b-a)) == ((x `mod` (b-a)) - (a `mod` (b-a)) `mod` (b-a :: Integer))
18:21 <lambdabot> *** Failed! Exception: 'divide by zero' (after 1 test):
18:21 <lambdabot> 0 0 0
18:21 <dmwit> ?check \(Positive a) (Positive b) (Positive x) -> ((x-a) `mod` (b-a)) == ((x `mod` (b-a)) - (a `mod` (b-a)) `mod` (b-a :: Integer))
18:21 <lambdabot> *** Failed! Exception: 'divide by zero' (after 1 test):
18:21 <lambdabot> Positive {getPositive = 1} Positive {getPositive = 1} Positive {getPositive ...
18:22 <monochrom> sproingie: I am not sure what you mean by "jail of types", but my interpretation is that it's exactly what the monad operations (or rather, what they lack) suggest, so nothing wrong. I have disagreement on "wrap a type", for every time I write "data X a = ..." X wraps a type, but depending on the "..." I might not even have a functor.
18:22 <dmwit> ?check \(Positive a) (Positive x) (Positive m) -> ((x-a) `mod` m) == ((x `mod` m) - (a `mod` m) `mod` (m :: Integer))
18:22 <lambdabot> *** Failed! Falsifiable (after 7 tests and 3 shrinks):
18:22 <lambdabot> Positive {getPositive = 4} Positive {getPositive = 2} Positive {getPositive ...
18:22 baldrick joined
18:23 bvad joined
18:23 <monochrom> To be sure, "jail of types" even when it's right it's putting the focus on the wrong guy. In "IO Int" the most interesting part is the "IO" part not the "Int" part.
18:23 moongazer joined
18:23 <monochrom> Likewise in "[] Int" the most interesting part is the "[]" part.
18:23 Trendrrr joined
18:24 <dmwit> ?check \(Positive a) (Positive x) (Positive m) -> ((x-a) `mod` m) == (((x `mod` m) - (a `mod` m)) `mod` (m :: Integer))
18:24 <lambdabot> +++ OK, passed 100 tests.
18:24 <dmwit> Tuplanolla: So that should help.
18:24 <ph88> when i use Vector Unboxed and i get index out of bounds (101,101) what do those 2 numbers mean ?
18:24 <Tuplanolla> It's for unbounded integers though, dmwit.
18:24 <dmwit> Tuplanolla: Now you just have to check whether ```x `mod` m``` or ```a `mod` m``` is bigger.
18:25 <dmwit> Tuplanolla: Yes, but the fact that it teaches you can be used on bounded, positive integers.
18:25 juanpaucar joined
18:25 <Tuplanolla> Oh, right.
18:25 <wayne> what's it called when you build your own pseudo type system in a type system?
18:25 <wayne> say i'm writing an attribute system for transactions
18:25 <exio4> wayne: masochism?
18:25 <wayne> attributes can be Strings, Ints, DateTime, etc.
18:25 <wayne> hah
18:26 <sproingie> wayne: programming
18:26 <wayne> well, yes, i'd agree
18:26 <wayne> i was wondering if there was a more specific term for it. i've seen it crop up in a variety of large software systems
18:26 <sproingie> well consider almost all programming is an exercise in extending the built-in facilities
18:27 skeuomorf joined
18:27 <wayne> yeah, or even creating new DSLs per program
18:27 <sproingie> complete reinvention i suppose you could call greenspunning
18:27 yellowj joined
18:27 <sproingie> slightly ironic term considering it normally applies to a dynamically typed language
18:28 <cocreature> wayne: I think I’ve heard it called “type universe pattern” or something like that
18:28 <wayne> but this paticular style of implementation involves creating something like a new AttrString type with special abilities
18:28 <monochrom> wayne, user-defined types?
18:28 <wayne> yeah maybe, thanks for the suggestions
18:28 <monochrom> It's a known concept since 1960 or something. See Algol 60.
18:28 <sproingie> "inner platform effect"
18:29 <sproingie> (probably why i equated it with programming. ad hoc inner platforms seems to be all i do now)
18:30 jao joined
18:30 hybrid joined
18:30 <monochrom> Also "abstract data type" if you mean for example "internally it's a string but I'm exposing a limited API".
18:30 wroathe joined
18:31 <sproingie> "abstract" is itself kind of abstract
18:31 <monochrom> and "oh one day I might change the internal implementation while keeping the external promises. I may use a number instead and pull a Goedel trick"
18:31 Trendrrr joined
18:31 isoung joined
18:32 <monochrom> which is also a known concept since 1960. See Algol 60 again.
18:32 <Tuplanolla> @let wrapHarder a b n = let c = b - a in mod (mod n c - mod a c) c + a
18:32 <wayne> an example of usage would be constructing a computation graph with typed nodes. maybe this node takes three Int-output nodes and outputs an Int itself: Node :: AttrInt -> AttrInt -> AttrInt -> AttrInt
18:32 <lambdabot> Defined.
18:32 <sproingie> isn't the collection of operations itself a simple algebraic type?
18:32 <monochrom> To be sure, CLU did abstract types best.
18:32 <james999> In java class they always talked about separating interface from implementation like it was gospel.
18:32 rblaze joined
18:32 joelburget joined
18:32 tefter joined
18:32 <Tuplanolla> > and (zipWith (==) (fmap (wrapHarder 7 12) [minBound .. maxBound :: Word8]) (cycle [10, 11, 7, 8, 9]))
18:33 <lambdabot> False
18:33 <sproingie> it is gospel. java was just not the best preacher of it til generics rolled around.
18:33 <monochrom> sproingie, there are two kinds of "algebra"s. So yes, it is one kind.
18:33 <wayne> you can't just use Int because the function would be setting up a node that does computation, and not running a computation directly
18:34 <Tuplanolla> > and (zipWith (==) (fmap (wrapHarder 7 12) [0 .. 255]) (cycle [10, 11, 7, 8, 9]))
18:34 <lambdabot> True
18:34 yirabbit_ joined
18:34 <Tuplanolla> It still wraps around at some other point, dmwit.
18:36 <Tuplanolla> I need a napkin for this.
18:36 <monochrom> In Haskell, the "algebraic" in "algebraic data type" just means sums and products. (Oh, and then they decided to support exponentiation and recursion too. Now it gets a bit too analytic to be algebraic.)
18:37 <sproingie> exponentiation is ... parameterized type?
18:37 <wayne> monochrom: when you say exponentiation do you mean recursion within a product type?
18:37 coltfred_ joined
18:37 <monochrom> Outside Haskell, "algebraic" often refers to the same sense as "universal algebra". In short it means user-conceived operators and writing equational laws. See for example "algebraic specification".
18:37 <sproingie> i need to re-watch those CT lectures
18:37 acarrico joined
18:38 <monochrom> wayne, it means "Int -> Double" for example. Functions.
18:38 Trendrrr joined
18:38 <monochrom> data X = X1 (Int -> Double) | X2 (Double -> X)
18:38 oisdk_ joined
18:39 zcourts joined
18:39 <monochrom> well this example features both exponential and recursion. If you have only X1, it's expoenentiation.
18:39 <monochrom> And I can't spell.
18:40 <wayne> thanks for clarifying
18:41 <Tuplanolla> Nobody reads beyond exp anyway, monochrom.
18:41 <monochrom> Anyway, sums and products get called "algebraic" because simply "polynomials!"
18:41 <wayne> does that make partial function application the equivalent of log?
18:41 <monochrom> No.
18:41 <shapr> polynameial
18:42 michaelw joined
18:42 <sproingie> polyamourous functions
18:43 <shapr> Is that multiple dispatch?
18:43 <sproingie> heh seems appropriate
18:44 mkoenig joined
18:44 <EvanR> is unsafe the right word for a primitive that if used incorrect can cause bad performance
18:44 <EvanR> or really bad performance
18:44 <EvanR> if not what is
18:45 <monochrom> No no, you get it the other way round.
18:45 <sproingie> considering an actually unsafe implementation might be faster ...
18:45 <monochrom> Yeah :)
18:45 Trendrrr joined
18:45 <EvanR> safeABitTooSafeFoo ?
18:45 <sproingie> if you really want to deprecate it ... maybe just "slow"
18:45 <Tuplanolla> You can call it `slow`, EvanR. There's no need to play word games.
18:45 <monochrom> "unsafe" means it always performs better, but if used incorrectly you break equational reasoning or types or ... those semantics things.
18:46 <EvanR> its not slow, it uses infinite memory but only if you mess up
18:46 <sproingie> sounds like most of haskell to me :)
18:46 <EvanR> right...
18:46 <monochrom> Oh, 50% of safe pure functions do that already.
18:46 <sproingie> thunkedUp
18:47 <monochrom> Consider foldl (+) 0 infinitelist
18:47 <sproingie> makeItThunky
18:47 <Tuplanolla> I nominate the prefix `gluttonous`.
18:47 <EvanR> hrmmm
18:47 <sproingie> we should have prefixes using all seven deadly sins
18:47 <monochrom> So use the prefix "verySafe" :)
18:47 <EvanR> totallyNormalFunctionNothingToSeeHereFoo
18:47 <sproingie> lustfulFoo
18:47 <sproingie> wrathfulBar
18:48 <Tuplanolla> @hoogle lewd
18:48 <lambdabot> No results found
18:48 <Tuplanolla> What a wasted opportunity.
18:48 <sproingie> in EvanR's case, you could call it slothfulFoo
18:49 <barrucadu> Would a function which can break sharing be "envious"?
18:49 <monochrom> narcist :)
18:49 <torstein> One character in a standard bytestring is a Data.Word.Word8, right? How can I check, for example, if the first character of a bytestring is uppercase?
18:50 <monochrom> privatization :)
18:50 <sproingie> barrucadu: i'm a fan of the word "covetous" :)
18:50 <Tuplanolla> What do you mean by character, torstein?
18:50 <sproingie> in fact i've heard "covetous APIs", they want to own everything you pass in to them
18:50 <sproingie> mostly a C++ idiom
18:50 <glguy> Word8 doesn't have a notion of upper case
18:51 geekg_000_ joined
18:51 <torstein> So does everything become lowercase when converting to a standard Bytestring and back to string?
18:51 wroathe joined
18:51 <sproingie> one would hope not
18:51 <monochrom> :)
18:51 <Tuplanolla> In Haskell "char" like the "charred remains of single-byte encoding" is a foreign concept, torstein.
18:52 <monochrom> Will glguy also say "doesn't have lower case either"?
18:52 flatmap13 joined
18:52 <barrucadu> How characters map to bytes is up to the character encoding
18:52 chrissound joined
18:52 <chrissound> How can I get the index of the current workspace?
18:52 <geekosaur> and a huge part of the problem here is everyone assumes that 'a character is a character'
18:52 <barrucadu> If you're using ASCII, one character is one byte. If you're using unicode, that's not true.
18:52 <geekosaur> encodings make that... complicated and sometimes undefined
18:52 <monochrom> Just yesterday we just taught someone how Int8 doesn't have a notion of 253 either.
18:53 jrn1024 left
18:53 <sproingie> and for an encore, went on to prove that black is white and got yourself run over at the next zebra crossing?
18:53 <torstein> I'm working on Stanfords haskell course; they want me to write a parser with bytestrings
18:53 <Taneb> barrucadu, Haskell report says Char represents Unicode characters
18:53 <chrissound> I've tried deriving an instance by `deriving instance Eq (Layout Window)` and then using elemIndex but I get a type error of sorts.
18:53 <geekosaur> chrissound, if that's about xmonad, (1) might be better to ask in #xmonad (2) withWindowSet (W.tag . W.current) (where: import qualified XMonad.StackSet as W)
18:54 <shapr> torstein: sounds like fun
18:54 <chrissound> Ooops sorry I thought I was in #xmonad.
18:54 <barrucadu> Taneb: A Haskell Char is not the same as the abstract concept of a character
18:54 <geekosaur> and you likely want to read the haddock for XMonad.StackSet instead of making assumptions about how things work
18:54 odell joined
18:54 <torstein> Whether I use ASCII or unicode is the same for me; is there anyway to check if a character is upper or lowercase?
18:54 <sproingie> unicode codepoints anyway. "character" is way ambiguous when talking about unicode
18:54 <geekosaur> torstein, you just proved my point
18:55 <sproingie> torstein: isUpper
18:55 <torstein> Then lets say it's ASCII
18:55 cretiq joined
18:55 <Tuplanolla> Nooo! UTF-8 everywhere.
18:55 <Taneb> barrucadu, my point was, there is an encoding that is specified
18:55 Xion__ joined
18:55 <Taneb> torstein, Data.Char.isUpper
18:55 <sproingie> technically you need both isUpper and isLower
18:55 <Taneb> > any isUpper "torstein"
18:55 <lambdabot> False
18:55 <Taneb> > any isUpper "Torstein"
18:55 <lambdabot> True
18:56 <monochrom> torstein, show us where to read the assignment verbatim so we can either tell you what they want or we tell them they are wrong.
18:56 Cale joined
18:56 Itkovian joined
18:56 kirelagin joined
18:56 <torstein> monochrom, http://www.scs.stanford.edu/16wi-cs240h/labs/lab2.html You'll have to look into the source code for the ByteString requirement
18:57 <torstein> isUpper takes a Char, but decomposing a standard ByteString with cons yields a Word8
18:57 <monochrom> Did you see this? "Your parser should support ASCII input files; UTF-8 is fun but not required."
18:57 <sproingie> looks like it doesn't actually require bytestring either, it just recommends it
18:57 <monochrom> It's like merely the 10th line.
18:58 Croniamental joined
18:58 <sproingie> if you're doing unicode, use Text
18:58 <sproingie> (or just plain String if it doesn't have to be fast)
18:58 joaj joined
18:58 flatmap13 joined
18:58 <monochrom> Haha it also has "suggested music"
18:59 <sproingie> flaming lips? could be worse, i suppose.
18:59 <EvanR> torstein: you can convert a Word8 to a Char using an ascii decoder (which may fail)
19:00 <torstein> I think a solution is to assume ASCII; use ByteString.Char8 instead of standard BS, then decomposing with cons yields a Char character instead of a Word8 character
19:00 <EvanR> you can also assume no byte over 127 appear and use ByteString.Char8
19:01 <sproingie> make it work with ascii and unicode will be pretty trivial. polymorphic string types FTW.
19:01 <EvanR> you mean the other way around?
19:01 <sproingie> well it
19:01 <sproingie> well it's totally trivial then
19:01 <EvanR> yes
19:02 odell joined
19:02 wroathe joined
19:02 carlosda1 joined
19:02 <EvanR> assuming ascii is a great way to make your life hell when mr Thévenin calls pissed about his name misspelled
19:02 <sproingie> but still easy enough to switch unless you're doing something really silly
19:03 <EvanR> or mojibked
19:03 <monochrom> sproingie: To a large extent the starter code and more importantly the test cases have ByteString written all over it.
19:03 <exarkun> Extra credit for fixing the test suite.
19:04 <EvanR> make a test suite test suite
19:04 <monochrom> I'm actually OK with "ByteString and it stores UTF-8".
19:04 ahihi joined
19:04 <sproingie> > fix testSuite
19:04 <lambdabot> error:
19:04 <lambdabot> Variable not in scope: testSuite :: a -> a
19:04 <EvanR> or a fix ("test suite "++)
19:04 <monochrom> But last thing you want is live the 1970s pipe dream of "it's just one byte per char".
19:05 <Tuplanolla> Half, even!
19:05 <EvanR> other national encodings use the whole byte
19:05 <sproingie> i'd expect you'd be working with just Strings for the most part, not individual chars
19:05 <EvanR> america was just that alphabetically poor
19:05 cfricke joined
19:05 <sproingie> use the polymorphic string functions and it's just a type change away
19:06 <monochrom> Now, is there any reason parsing INI requires knowing "this is uppercase"?
19:06 juanpaucar joined
19:06 joco42 joined
19:07 oisdk joined
19:07 <torstein> monochrom, No, but converting to lowercase is necessary since most of the INI is supposed to be case insensitive
19:07 <monochrom> Ah I guess you need to treat "Yes" and "yes" as the same thing.
19:08 <EvanR> yeah in my program im trying to figure out how to handle text which case does not matter
19:08 <sproingie> so convert, not test. guessing regexes are out of the question.
19:08 <monochrom> Case conversion is a very lazy way to do this.
19:09 <sproingie> eh, it works out the same
19:09 <EvanR> lazy, is that good or bad
19:09 <sproingie> EvanR: i'll let you know when you actually need the answer
19:09 <EvanR> if the answer is bottom keep it to yourself
19:10 <sproingie> don't worry, i'm not showing my bottom :)
19:10 <monochrom> What you really need is to accept [89 or 121, 69 or 101, 83 or 115]
19:10 osa1 joined
19:10 osa1 joined
19:10 kirelagin joined
19:11 ErinvanderVeen joined
19:12 <sproingie> ah, says don't change the interface of ParseIni.hs ... stuck with Bytestring after all
19:13 dfeuer joined
19:13 kirelagin joined
19:13 bollu joined
19:13 <sproingie> some profs are all right with improving the assignment with the answer, but they might hand it off to a TA who isn't
19:13 <bollu> monochrom: why do you want multiplication to be explicit?
19:13 <monochrom> Then again could do ByteString -> Text -> ByteString and have a party of XYX problems.
19:13 <monochrom> Because Dijkstra said so. No, because it play better with long variable names.
19:14 <bollu> monochrom: do tell?
19:14 <bollu> ah, I understand
19:14 <bollu> xyz is ambiguous
19:14 <bollu> xy * z or x * yz or ...
19:14 phyrex1an joined
19:14 <sproingie> one reason we have programming languages in the first place
19:14 augur joined
19:15 govg joined
19:15 <shapr> sproingie: so we can be explicit about our confusion?
19:15 <monochrom> Dijkstra has great examples like sin(s+i+n) and 3½, 3y, 32.
19:15 <bollu> lol
19:15 <bollu> I see
19:15 <sproingie> 32 == 6, obviously
19:15 <ph88> hey cocreature i was able to speed that calculation up by 60x !!
19:15 <monochrom> The link is http://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1300.html again
19:16 <bollu> monochrom: on the other hand, it would make a lot of things quite large, methinks: eg: ut + 1/2 a t^2 becomes u * t + 1/2 * a * t^2
19:16 <sproingie> it's almost like different notation is useful for different things
19:16 <monochrom> I have actually heard someone made the outrageous rationalization "in 3y, consider 3 means the function (\x -> 3*x)"
19:16 <bollu> sproingie: then you need to keep track of which notation you're using when..
19:17 osa1 joined
19:17 osa1 joined
19:17 <monochrom> People really can use all of their creativity to defend a wrong entrenched convention.
19:17 <bollu> monochrom: not that outrageous :) that's how you can define the scalars acting on a vector space for example
19:17 drewbert joined
19:17 <sproingie> just a humble polynomial would be way cluttered with explicit multiplication
19:18 <ph88> if i do (5 - 2) will ghc optimize this to 3 ? or will it make a thunk on runtime ?
19:18 <sproingie> ghc will fold constants
19:19 Cale joined
19:19 skeuomorf joined
19:20 <sproingie> might need -O to do it, though that one's trivial enough it might do it anyway
19:21 <monochrom> It's best to read the Core.
19:21 <sproingie> wasn't sure if it optimized before or after generating core
19:21 chaosmasttter joined
19:22 <monochrom> Ah, true, read the asm too. :)
19:23 Cerise joined
19:23 Cerise joined
19:23 <monochrom> I usually dump all of Core, Cmm, asm at once. If Core answers my question, cool; else, Core is still a good guide when I try Cmm and asm.
19:24 <cocreature> ph88: nice, how so?
19:24 <monochrom> Especially with all those sat_xyz123abc unique names
19:24 ChaiTRex joined
19:25 <sproingie> numbers being overloaded, even that simple case has some twists to it
19:25 jerbome_ joined
19:27 buttbutter joined
19:27 Wizek_ joined
19:27 darjeeli1 joined
19:27 asjo joined
19:27 <sproingie> SPJ's lecture on Core was really informative. a statically typed IR, how nifty.
19:27 <ph88> cocreature, line 30 https://bpaste.net/show/5ae7ec7d31b9 the important insight was that each part of the formula there is a sliding window over the vector. The index i is only offset by n or n*2 .. then all the values of those 3 windows are summed then (sumA - sumB + sumC) ^ 2 .. but i just precalculated the sum per element with a scan (line 39)
19:28 <cocreature> nice
19:28 <ph88> cocreature, suppose the vector hold numbers 1 to 10, and i want the sum of a window that starts at 3 and ends at 7 i do value[7] - value[3 - 1]
19:29 yqt joined
19:31 merijn joined
19:33 joco42 joined
19:33 <EvanR> sproingie: statically type all the things
19:34 juanpaucar joined
19:34 <sproingie> speaking of types, is there any IDE integration for haskell that can fill in typed holes for you?
19:35 <monochrom> OK, for the sake of scientific reporting: I tried "module G where x :: Num a => a; x = 5 - 2". Core made it "x = fromInteger 5 - fromInteger 2". Cmm and asm didn't improve on it.
19:35 <sproingie> (where emacs is an IDE, yes)
19:35 <EvanR> how could it improve?
19:35 <monochrom> But this is only when I insist polymorphic Num a. If you nail it to Int or Integer or whatever, I'm sure it's 3.
19:35 <ph88> sproingie, what if i first do one = 1 two = 2 and then three = two - one ? will three be constant fold to 3 ?
19:36 <sproingie> i wouldn't have been surprised if it turned into "fromInteger 3", just assuming that even polymorphic numbers exist in a sane world
19:36 <EvanR> the top level number will be lazily evaluated and stay that way at run time
19:36 <sproingie> but you know what they say, assuming makes an ass of u and ming
19:36 <monochrom> actually I only tried -O. Let me now try -O2.
19:36 <EvanR> sproingie: you cant do that...
19:37 <merijn> EvanR: Only if not polymorphic or DMR is enabled
19:37 carlosda1 joined
19:37 <EvanR> DMR?
19:37 <Cale> Dreaded Monomorphism Restriction
19:37 <merijn> EvanR: Dreaded Monomorphism Restriction ;)
19:37 <monochrom> -O2 isn't better.
19:37 <EvanR> right
19:37 <EvanR> well i was talking about not polymorphic
19:37 <EvanR> how does "DMR" apply to that
19:38 <merijn> EvanR: If you leave of the type signature DMR forces it to be not polymorphic
19:38 <merijn> EvanR: By specialising to the first usage of the value
19:38 <sproingie> DMR normally is enabled. i used to hate it, then realized it was basically nagging me to write better signatures
19:38 <EvanR> so it doesnt apply if i set the signature, so i can make it not polymorphic at all
19:38 <merijn> EvanR: If you write an explicit signature DMR never applies, no
19:38 <EvanR> good
19:38 <EvanR> since its top level, id put a signature
19:39 <sproingie> DMR doesn't apply to let-bindings either, right?
19:39 <merijn> EvanR: But even if it did, DMR can only improve things. It stops you from silently making stuff worse
19:39 <EvanR> not sure what that means
19:39 <merijn> sproingie: DMR only applies to top-level "value-like" (i.e. non-function) things without a signature
19:39 <monochrom> DMR applies to let-bindings.
19:39 <merijn> monochrom: Really? I thought it was only to top-level bindings
19:40 <monochrom> I'm going to check again.
19:40 <EvanR> and where clauses
19:40 rkazak joined
19:40 <merijn> EvanR: DMR ensures something is only evaluated once and produces an error when that's not possible.
19:40 <EvanR> got it
19:40 <sproingie> so basically it's "hey dude, your constant isn't"
19:40 <merijn> EvanR: So unless for some bizarre reason you hate efficiency and want to recompute things all the time, DMR either 1) makes stuff better or 2) is a compile error
19:40 <c_wraith> monochrom, beware of interference from MonoLocalBinds, which is automatically enabled by GADTs and a couple other extensions
19:40 cloudhead joined
19:41 <EvanR> merijn: a bizarre reason like, the top level value is infinite
19:41 <monochrom> DMR applies to all bindings, local or global.
19:41 <EvanR> and ive been off and on wanting a way to turn values back into thunks...
19:41 <merijn> sproingie: basically, yes
19:41 <monochrom> You just don't usually feel its effect in local ones, because you explain the momorphism of the local ones by its context.
19:43 <sproingie> i learned ocaml before haskell, i hated the MR in that. haskell's is way less onerous
19:43 <Cale> DMR applies only to pattern bindings which don't have explicit type signatures though
19:43 <Cale> and among those, only the ones whose type is constrained by a type class
19:45 <monochrom> Oh heh OCaml's and SML's are because of the Haskell equivalent of "x :: IORef Int; x = unsafePerformIO (newIORef 0)"
19:45 <Cale> Depending on which extensions you have enabled, your let bindings might be monomorphic for the reason that GHC will turn off the generalisation step altogether though.
19:45 seanparsons joined
19:46 <monochrom> Or rather, "x :: IORef [a]; x = unsafePerformIO (newIORef [])"
19:46 jacereda joined
19:46 <monochrom> from which you can play type tricks.
19:46 <sproingie> haskell, the best imperative language
19:47 <EvanR> i kind of want "the best imperative language"... to see what its like
19:47 rockfordal joined
19:48 kmels joined
19:48 <sproingie> an imperative duck-typed EDSL
19:48 <EvanR> sounds awful
19:49 <sproingie> i should write it. call it "Wrong"
19:49 manek joined
19:49 <EvanR> writing wrongs?
19:49 <sproingie> ya beat me to it :)
19:49 <EvanR> wrong programs
19:49 <sproingie> it's full of wrong
19:49 <monochrom> Hahaha
19:50 <sproingie> stuff it full of every bad idea in programming
19:50 <monochrom> When you create your project, it's "writing wrong". Later when you debug it, it's "righting wrong".
19:51 <sproingie> hell, it worked for PHP
19:51 <manek> Hello guys! :) I need to have an interval tree. I've got a list of NOT overlapping intervals and associated values and I want a structure with fast insert and lookup. I've found several libraries but all seem not touched for a long time. Is there any library that you would personally recommend ? :)
19:52 <monochrom> Oh! Almost thought you need an explanation so you could code it yourself.
19:52 <EvanR> sounds like the intervals are ordered, put them in a Map
19:52 <merijn> sproingie, monochrom: Seems like this link is highly relevant to the discussion: http://colinm.org/language_checklist.html
19:52 <sproingie> was just looking at that yesterday
19:52 <kadoban> manek: Not sure about libraries. But when you have non-overlapping intervals, you can just do that thing where you use a Data.Map and the keys are the left of the interval, and the vaules are a tuple of the right of the interval and the associated value.
19:52 <sproingie> let's see how many boxes we can tick with wronglang :)
19:52 <merijn> EvanR: Naah, that doesn't work, because Map assumes non-overlapping
19:52 <sproingie> "you're using the wrong language"
19:53 bigos joined
19:53 <sproingie> oh man now i actually want to do this
19:53 <manek> kadoban: sure, but the performance is ugly then. I want to search for value in a particular point, so I would need to iterate over everything before that point. In interval trees it could be amortizedto nlogn
19:54 <monochrom> Not just amortized. Worst case lg n.
19:54 <manek> monochrom: yeah, right
19:54 <kadoban> manek: You can look in Data.Map for the greatest key that's less than or equal to a given one in O(lg n) time (and then check the right of that interval and see if it still matches)
19:54 <monochrom> I don't know of a library for this.
19:55 <kadoban> You can also use an IntMap for this I think, it also has lookupLE
19:55 <manek> monochrom: I found these: https://hackage.haskell.org/package/SegmentTree-0.3/docs/Data-SegmentTree.html#t:Interval
19:55 <manek> and
19:55 <manek> https://hackage.haskell.org/package/fingertree-
19:55 <manek> but looking at the source code, it seems not the highest quality and they are not updated for long time
19:56 <manek> kadoban: hmm, interesting, I'll look into it, brb
19:57 <monochrom> Ah, when I said "lg n" I just had "find just one interval" in mind.
19:57 DataComputist joined
19:57 juanpaucar joined
19:57 <monochrom> I think the fingertree one is worth a bet.
19:57 edoput joined
19:58 <manek> kadoban: Ok, that would work, but my specification in the question was not good enough (I just realized it, sorry for that)
19:58 ccomb joined
19:58 <kadoban> manek: Oh, what part is it missing, just out of curiosity?
19:58 <cfricke> Ahoy! Is anyone successfully building/running intero with stack in NixOS? Seem to have some issues with terminfo and its ncurses dependency.
19:58 uglyfigurine joined
19:58 <manek> kadoban, manek : I would love to be able to change some interval in the middle sometimes, so it would be great if these intervals would be relative and update "parents". I dont know however if sometihng like that exist somewhere
19:59 <kadoban> Hmm, not 100% sure what you mean. Something like you have an interval A and then child intervals B and C that modify that? And you want to be able to move the whole bunch to the right by x units or something?
20:00 <EvanR> merijn: thats what manek said
20:00 <EvanR> non ovrelapping
20:00 <manek> kadoban: So I will have interval lengths, not start and end points
20:00 agjacome joined
20:00 <manek> merijn: yeah, right, it will work. I have no overlapping segments here. This are segments of text and they will never overlap
20:00 Itkovian joined
20:01 <kadoban> Sounds kind of interesting, though I'm not sure I'm quite getting the jist.
20:01 <EvanR> ah, not absolutely position intervals
20:01 <manek> kadoban: I've got list of segments and values. Each segment is just a length (assume Word64) and a value. I want to lookup for a specific point and insert new segment in a specific point
20:01 <sproingie> oh like regions. you might want something specialized for this that will handle inserts and deletes gracefully
20:01 augur joined
20:01 <sproingie> yi might have something
20:02 <kadoban> manek: Oh, and it like moves everything else to the right or something?
20:02 <manek> kadoban: right
20:02 <EvanR> theres Sequence
20:02 <manek> kadoban: it just inserts new segment somewhere (like inserting text into a given position)
20:03 <monochrom> Ah, that's different from what I thought.
20:03 <kadoban> Hmm, there should be a good datastructure for that *ponders*
20:03 <EvanR> you can also use Map with Rational keys
20:03 <manek> yeah it looks like it should be handled by something so I thought I would ask here before trying to implement something from scrtch
20:03 <EvanR> to insert something between q1 and q2, use (q1+q2) / 2
20:03 cdg joined
20:04 rblaze joined
20:04 erikd joined
20:04 <manek> EvanR: but then I would not be able to easily lookup for a particular position, right?
20:04 wroathe joined
20:04 <EvanR> i thought there were no positions
20:04 <EvanR> its all relative
20:05 <kadoban> So you need to be able to do uhm ... "insert X units, with associated value V, at point Y" and you need to be able to query what the associated value is an a certain point?
20:05 <manek> EvanR: yeah it's relative, but I want to be able to ask what value was on position "147" and then lookup all relative segments for it.
20:05 <EvanR> now it sounds like a spatial parition
20:05 <EvanR> no it does, since it moves everything
20:05 <EvanR> erhg
20:05 <manek> I need to be able to 1) insert segment in a given fixed position (segment has length and value) and 2) remove given segment 3) lookup for a value in a given fixed position
20:05 buglebudabey joined
20:06 <EvanR> without changin everything to the rights data
20:06 drewbert joined
20:06 <manek> EvanR: If I insert a segment in a position it moves all the later segments to the right with the offset of its length
20:06 <EvanR> conceptually, not lierally right
20:06 <sproingie> looks like Yi uses a fingertree
20:06 <EvanR> since tehy dont have position stored
20:07 <manek> EvanR: these segments are just text fragments, so if you insert a text span in a given char position it "moves" all the later text right
20:07 <kadoban> manek: So it's totally dense, right? Or are there spaces between intervals?
20:07 <manek> kadoban: yep, its totally dense
20:07 <manek> kadoban: its really a Text, or something like a String. whatever, its dense :)
20:08 <manek> EvanR: but these segments are dense and know their lengths so you should be able to ask what was in a fixed position knwoing all the segments lengths
20:08 kirelagin joined
20:09 <kadoban> Something like a fenwick tree almost works, but ... doesn't quite. Hm. That weird RMQ tree thing that competitive programmers use almost works too, but ... kinda doesn't either.
20:09 <monochrom> RMQ does a subtly different thing.
20:09 <monochrom> Or maybe not. :)
20:10 <EvanR> manek: fingertree seems to be the underlying structure for Sequence, which could do this if you do it Char by Char
20:10 Sh4rPEYE joined
20:10 ErinvanderVeen joined
20:10 <buglebudabey> do i have to rebuild my stack project every time i make a minor change or can i run it anyway
20:10 <* Tuplanolla> pokes dmwit.
20:10 <kadoban> monochrom: I think it could be modified to work, but the way I'm thinking of modifying it would have really bad performance in the worst case :-/
20:10 neoo joined
20:10 <manek> EvanR: I don't really want to do uit char by char - these segments would be 50-100 chars long, so there is no point in storying char by char segments :(
20:11 marr joined
20:11 <sproingie> buglebudabey: "stack run" will rebuild if necessary
20:11 <EvanR> the point would be simplicity?
20:11 <buglebudabey> sproingie thank you
20:11 systemfault joined
20:11 <kadoban> You need like, prefix sums with insertion ... hmm.
20:11 <EvanR> manek: alternatively adapt the fingertree structure for your own purposes, fingertree package
20:11 Trendrrr joined
20:11 neoo joined
20:11 <nshepperd> a fingertree would do this, with metric ~ segment length
20:12 <Tuplanolla> @tell dmwit `let (%) = mod in let wrapHardest a b n = let c = b - a in if n < a then (n % c + c - a % c) % c + a else (n - a) % c + a in and (zipWith (==) (fmap (wrapHardest 7 12) [minBound .. maxBound :: Word8]) (cycle [10, 11, 7, 8, 9]))`
20:12 <lambdabot> Consider it noted.
20:12 <buglebudabey> sproingie stack run doesn't seem to be available as a command, could it be it's not added to my path?
20:12 chrissl joined
20:12 <kadoban> Oh right, this could be like an order statistics tree, but instead of "number of elements in here", you store "amount of segment units in here", I guess?
20:12 ziocroc joined
20:13 saussure joined
20:13 Trendrrr joined
20:13 <manek> EvanR, nshepperd : I'm not sure if we are able to define right metric for fingertree, because we need to lookup all the segments to the left to know currents segment position (or cache it somewhere in the parent). I'm not sure if such flexibility would be possible there
20:13 <kadoban> That totally sounds like it'd work
20:13 <manek> I'm asking because I've been never touching fingertrees but thinking about the ones I've found just raised this concern in my head
20:13 <nshepperd> manek: the metric for a subtree is the sum of the lengths of segments in it
20:13 neoo joined
20:14 <nshepperd> you never worry about or store 'absolute' position
20:14 <sproingie> buglebudabey: ah yes, stack install stack-run
20:14 <EvanR> too bad its not absolute or https://hackage.haskell.org/package/fingertree-
20:14 <buglebudabey> sproingie ok, done, now when i run the command it still doesnt work
20:15 saussure joined
20:15 <sproingie> be outside of a stack project when you stack install stack commands
20:15 drewbert joined
20:15 simukis joined
20:15 Silox| joined
20:16 <manek> nshepperd: that sounds like it should work, however, if I'm not wrong, looking at the types here: https://hackage.haskell.org/package/fingertree-
20:16 <manek> nshepperd: you are not allowed to define metrics that "looks over" the underlying elements, are you ?
20:16 neoo joined
20:16 Noldorin joined
20:16 odell joined
20:17 <nshepperd> manek: the metric just has to be a monoid. it is aggregated over the underlying elements automatically
20:17 <nshepperd> measure :: Segment -> v, where v is a Monoid
20:18 neoo joined
20:18 brezel joined
20:18 <manek> nshepperd: oh well, right. So yeah it seems like it would work. So in fact this "v" is just a segment length and I should be able to isnert relative segments etc ? huh that is simpler than I thought if I'm not wrong here!
20:19 <nshepperd> yeah
20:20 ljhms joined
20:20 <manek> nshepperd: and If I understand correctly insertion should be then implemented using `split` ?
20:20 neoo joined
20:20 Trendrrr joined
20:20 Zer000 joined
20:20 <nshepperd> yep
20:21 <manek> nshepperd, EvanR, kadoban, merijn: thank you guys so much for the help!!
20:21 <manek> I'm really thankful for it! thanks again! :)
20:21 <buglebudabey> sproingie got it now, thanks, you were right AND it wasn't on the path
20:21 <kadoban> manek: Good luck, pretty interesting
20:22 <nshepperd> the basic primitive is that you split the sequence into (prefix ++ suffix) with the shortest prefix matching some monotonic predicate
20:22 mmn80 joined
20:22 neoo joined
20:22 xinming_ joined
20:22 <nshepperd> in this case it would be \total_length -> total_length >= where_you_want_to_insert
20:23 <nshepperd> or something like that
20:23 qguv joined
20:23 robertc joined
20:24 dfeuer joined
20:24 <tobiasBora> Hello,
20:25 wroathe joined
20:25 Itkovian joined
20:25 hackebeilchen joined
20:25 <tobiasBora> I don't understand how to use strategy in the Control.Parallel framework
20:25 <tobiasBora> I've a function f
20:25 Durbley joined
20:25 <tobiasBora> a list l
20:26 <tobiasBora> and I would like to compute efficiently "map f l"
20:26 jerbome_ joined
20:26 arpl joined
20:26 maerwald left
20:26 maerwald joined
20:27 Sh4rPEYE joined
20:27 Trendrrr joined
20:28 <lyxia> map f l `using` parList
20:30 eacamero_ joined
20:31 <glguy> that looks like it might have a type error
20:31 chlong joined
20:32 arpl left
20:32 arpl joined
20:33 douglascorrea joined
20:33 <glguy> parMap with the desired element Strategy is probably the most direct
20:33 flatmap13 joined
20:33 <glguy> parMap rnf, for example
20:34 Sonderblade joined
20:34 Durbley joined
20:34 flatmap13 joined
20:35 <tobiasBora> lyxia: oh really strange, thank you! Does it work also with filter?
20:36 sampuka joined
20:36 Trendrrr joined
20:36 <manek> nshepperd, kadoban : by the way, how it is done that Fingertree does not have any Ord constraint on the measurements (I mean the things that need to be monoid). Doesnt it compare them to make the tree?
20:36 tabaqui joined
20:37 pera joined
20:37 <pikajude> no
20:37 <kadoban> I don't actually know fingertrees. I'd have implemented it using something else.
20:37 <shapr> fingertrees are surprisingly simple
20:37 <nshepperd> manek: no, you only need to compare them when you're writing your split predicate
20:38 <kadoban> Yeah, I should really learn them ...
20:38 <manek> nshepperd: oh, thats interesting. I should learn how they work too1
20:38 monty joined
20:40 <dmwit> There's a very readable paper. It's probably linked in the documentation, even.
20:40 <dmwit> confirmed
20:40 <nshepperd> the measure is not really used in the finger tree at all, it is just metadata about the elements that is carried along and cached in each node so that the user can access it for choosing where to split
20:41 iAmerikan joined
20:41 Destol joined
20:41 hackebeilchen joined
20:41 flatmap13 joined
20:41 <manek> dmwit: yeah I see it, I would definitely read it as soon as I grab some free time! But I see that fingertrees could just builld trees based on the number of spns, not their "measurements" and itm akes perfect sense then no to have any Ord defined
20:42 Aruro joined
20:42 <dmwit> Tuplanolla: Glad you got it working. =)
20:43 <Tuplanolla> You can even eliminate the other branch if division is fast, dmwit.
20:43 Flechette joined
20:43 Trendrrr joined
20:44 sync__ joined
20:45 <dmwit> I'm glad you came up with the trick of comparing n and a first (rather than after the mod). I think that's probably clearer syntactically, and maybe faster too.
20:46 <Tuplanolla> The "final final" version is just `wrap a b n = let c = b - a in (n % c + c - a % c) % c + a`.
20:46 <tobiasBora> for parList on filter, should I first apply the map, and then the filter ?
20:46 <Tuplanolla> Now nobody will ever have to derive this again.
20:46 flatmap13 joined
20:47 mjora7 joined
20:47 Sonderblade joined
20:48 chrissound joined
20:49 uglyfigurine joined
20:51 uglyfigurine joined
20:51 uglyfigurine joined
20:52 bennofs joined
20:53 lavalike joined
20:54 <tobiasBora> glguy: I tried P.parMap P.rdeepseq and P.parMap P.rpar, but nothing happened, there is only one thread really active, the others one hardly reach 13% of usage
20:54 <tobiasBora> I use:
20:54 <tobiasBora> filter (==True) ((P.parMap P.rpar (\alphas -> refMatrix == matrixSeveralJ alphas) allAlphaSeq))
20:54 <tobiasBora> where allAlphaSeq = sequence [ possibleAngles | i <- [1..n]]
20:54 Trendrrr joined
20:55 quchen joined
20:56 <nshepperd> are you compiling with -threaded and running with +RTS -N
20:56 Guest40014 joined
20:56 <Zer000> In terms of code style is it better to declare instances of a class where you define the class or where you define your types?
20:57 <nshepperd> you want 'parMap rseq' or 'parMap rdeepseq' here (they're the same for Bool anyway)
20:57 <Itkovian> does any know of a Parser Hostname that checks if a piece of Text is a valid hostname and if so returns it?
20:58 <quchen> Zer000: Both ways are fine.
20:58 <Aruro> Zer000: can be advantage to have all instances in one place
20:58 ChaiTRex joined
21:01 <nshepperd> if they're in the same file I guess it's down to personal style. otherwise it will sometimes be more natural for the place where the type is defined to import the class, or vice versa
21:01 Yuras joined
21:02 edoput joined
21:02 Trendrrr joined
21:04 Cerise joined
21:04 Cerise joined
21:04 <ph88> is it possible to go from Conduit to Vector without going through List first ?
21:05 oab joined
21:06 Achylles joined
21:07 wroathe joined
21:07 Burnout641 joined
21:07 Big_G joined
21:08 umib0zu joined
21:09 conal joined
21:10 buglebudabey joined
21:10 zachk joined
21:10 sproingie joined
21:11 sproingie joined
21:13 rblaze joined
21:16 connrs joined
21:17 sedeki joined
21:17 sepp2k joined
21:18 balor joined
21:18 <c_wraith> I assume you mean efficiently? because it's trivial to do really inefficiently.
21:19 <ph88> c_wraith, yes :D
21:20 gestone joined
21:20 <c_wraith> worst case you could always go with exponential resizing of mutable vectors followed by a freeze. you can probably do better, but that much is at least possible.
21:21 mizu_no_oto joined
21:22 <ph88> what is the allocation strategy for an immutable vector that is growing in size?
21:23 tromp joined
21:23 winter_ joined
21:24 zcourts joined
21:24 <c_wraith> immutable vectors don't grow in size.
21:24 OnkelTem joined
21:25 nomeata joined
21:25 <ph88> well conduit can be streaming
21:25 <ph88> so where do the values go
21:26 <c_wraith> if the conduit is producing vectors, each chunk is independent
21:26 jerbome_ joined
21:26 simukis joined
21:26 <ph88> consume values from stream and return a single immutable vector
21:27 dfeuer joined
21:28 <ph88> https://hackage.haskell.org/package/vector-conduit- ??
21:28 <dmwit> Zer000: I put instances next to types I defined, and next to the class declaration for types from dependencies.
21:28 wroathe joined
21:28 <ph88> there is an M.grow there
21:28 <buglebudabey> if i have a stack project with an image i want to use in my code, where's the best place to keep that, src?
21:29 Itkovian joined
21:29 greeny joined
21:30 <dmwit> buglebudabey: How about `images/` or `resources/`?
21:30 <dmwit> Or do you actually intend to compile the picture? =)
21:31 <buglebudabey> dmwit what i really mean is when i am providing a path, what's it relative to?
21:31 <dmwit> the .cabal file
21:31 <dmwit> or, wait
21:31 <dmwit> When you are providing a path *to what tool*, and *in what way*?
21:32 gestone joined
21:33 <dmwit> The `data-files` clause in your .cabal file is relative to the .cabal file. The path you get from the `Paths_foo` module is also relative to the .cabal file, I think?
21:33 <buglebudabey> dmwit like if i'm reading in a bmp from src/BMPReader.hs should my path be "images/picture.bmp" where images and src are both directories in my main project folder?
21:33 Shatnerz0 joined
21:33 <dmwit> But in reality it's relative to some installed directory that you don't really ever get to know precisely.
21:33 MrWoohoo joined
21:34 <dmwit> buglebudabey: Read the `data-files` section of https://www.haskell.org/cabal/users-guide/developing-packages.html and the linked info on finding those files at runtime.
21:34 <buglebudabey> ok thanks
21:34 <dmwit> I'm not a stack expert but I very strongly suspect the information will be relevant to stack usage as well.
21:35 <codygman_> Is there some function that recursively applies a fold to itself? I'm telling to generate dependencies.
21:35 bjz joined
21:36 <dmwit> :t foldTree -- ?
21:36 <lambdabot> error:
21:36 <lambdabot> • Variable not in scope: foldTree
21:36 <lambdabot> • Perhaps you meant ‘unfoldTree’ (imported from Data.Tree)
21:36 earldouglas left
21:37 <dmwit> foldTree :: (a -> [b] -> b) -> Tree a -> b -- from the documentation
21:37 mjora7 joined
21:38 <codygman_> Yeah, i could probably just store it all as a tree and get children, but I'd still be curious with my original question
21:38 <dmwit> I don't understand your original question.
21:40 chrisdotcode joined
21:40 <codygman_> Perhaps i don't either yet, I'll think on it
21:40 joco42 joined
21:41 <dmwit> :t unfoldTree -- also possible you meant this
21:41 <lambdabot> (b -> (a, [b])) -> b -> Tree a
21:42 Vegitto joined
21:42 <EvanR> hmm as part of the build process, maybe convert the bmp file into source code, then compile it into the binary
21:42 <dmwit> You can combine them to get `hyloTree`. ;-)
21:42 <EvanR> then in some sense your data is an expression
21:43 <dmwit> EvanR: That approach seems to have few advantages and many disadvantages.
21:43 <EvanR> oh?
21:43 joaj joined
21:43 <dmwit> e.g. it makes it much harder to experiment with different textures (you have to rebuild the whole program!).
21:43 <EvanR> well if were talking about dynamic changes to code...
21:44 <EvanR> i would like a better solution than use external image files
21:44 <tobiasBora> nshepperd: Yes, I run it using -threaded -rtsopts -with-rtsopts=-N in the ghc-options of the executable in the cabal file
21:44 freeside joined
21:44 <EvanR> then finally make a final version
21:44 <torstein> Does anyone use Emacs/Spacemacs and know how to get Haddock lookup? There's Hoogle lookup but it only shows function signatures, not function and argument description
21:45 hamishmack joined
21:45 <dmwit> Or, for another example: this prevents you from choosing at runtime what image to use. This rules out "texture packs", and probably badly affects how long it takes your program to start (a big problem with modern games, IMO).
21:45 <tobiasBora> nshepperd: parMap rseq also do not work, 3 threads only reach 12% of CPU, while one 1 100%
21:45 <dmwit> I don't know. I just don't see why it's a good idea.
21:46 darjeeli1 joined
21:46 <EvanR> dmwit: for a single image... distributing a binary vs distributing a binary and an image file...
21:46 <EvanR> the image is really part of the program
21:46 <EvanR> development is a different story
21:47 <dmwit> I don't see why distributing a binary and an image is hard.
21:47 <EvanR> its 2x as many files
21:47 <EvanR> and is easily modified by the end user
21:47 <dmwit> It's one zip file...
21:47 <EvanR> windows?
21:47 <dmwit> Who cares? zip works everywhere.
21:47 <* ski> . o O ( partial evaluation )
21:47 <EvanR> no it doesnt
21:48 <EvanR> it works on windows, on *nix it wont find the image file when you run the program from just anywhere
21:48 <hpc> this is why i only publish software as MIME containers
21:48 <nshepperd> tobiasBora: hm. should be working. are you certain that this map is really the cpu intensive part? could allAlphaSeq be expensive?
21:48 wroathe joined
21:49 <dmwit> EvanR: I think you either give Windows too much credit, or the program author not enough.
21:49 <hpc> dmwit: you've just entered the strange world of packaging
21:49 <tobiasBora> nshepperd: Well, the definition of allAlphaSeq is simple : allAlphaSeq = sequence [ possibleAngles | i <- [1..n]]
21:49 <EvanR> to go the other way with it, id like to be able to distribute all the source code as modifiable modules that runs
21:49 <tobiasBora> so I don't think it's intensive
21:49 Sonderblade joined
21:49 <Tuplanolla> If only you could distribute software as a textual description, which would then read itself...
21:49 <dmwit> hpc: I refuse to believe that shipping a program with an image is not a solved problem.
21:49 <EvanR> Tuplanolla: brilliant
21:50 <hpc> it's very solved
21:50 <hpc> the solution is packaging :P
21:50 <EvanR> dmwit: yes, for lots of resoruces, thers all kinds of installation wizards and framework for it
21:50 <EvanR> package managers, installation scripts
21:50 <dmwit> EvanR: So why are you claiming it's hard???
21:50 <EvanR> downlaoable content
21:50 <* ski> . o O ( `allAlphaSeq = replicateM n possibleAngles' )
21:50 <EvanR> why are you ignoring my criteria for the context?
21:50 <tobiasBora> I tried: P.withStrategy (P.parListChunk 1000)
21:50 <tobiasBora> it's way more efficient :D
21:51 <EvanR> one bmp file
21:51 <tobiasBora> ski: Hum interesting
21:52 <EvanR> i find it silly to set up a zeroconf cross platform platform to facilitate 1 exe and 1 bmp to actually work on the target
21:52 <EvanR> AAA gaming with updates, plugins extensions, whatever is another story
21:52 <nshepperd> tobiasBora: or possibly there is something in the implementation of your mapped operation that is having some shared lock...
21:52 hiratara joined
21:53 <* EvanR> begins thinking about dynamic updating of code modules
21:53 <sproingie> not unusual these days for games to download the rest of their assets on first launch
21:53 <nshepperd> chunked parallel mapping is always good if the operation is cheap, so that you don't spend a ton of time just making sparks
21:53 <tobiasBora> nshepperd: I found the solution using chunk
21:54 <sproingie> even AAA games, though those tend to be of the MMO variety
21:54 <tobiasBora> P.withStrategy (P.parListChunk 1000 P.rdeepseq)
21:54 <nshepperd> tobiasBora: does it have good parallel utilization now?
21:54 <tobiasBora> nshepperd: yes, now all the threads are 98% :D
21:54 <tobiasBora> thank you !
21:55 <nshepperd> ah. so it was just the single threaded overhead in scheduling each cheap element
21:55 <tobiasBora> yes
21:55 <buglebudabey> if i have a game i wrote in haskell is there anyway to make it playable in the browser as is?
21:56 HoierM joined
21:56 aconz2 joined
21:56 epsilonhalbe joined
21:56 tomphp joined
21:57 ixti joined
21:57 ertes joined
21:57 ixti joined
21:57 <sproingie> ghcjs perhaps, but you'd be targeting a very different type of display
21:57 <sproingie> so no, not "as is"
21:58 chrisdotcode joined
21:58 Swizec joined
21:58 exarkun joined
21:59 <nshepperd> on *nix you can bundle your executable and assets into one container with the assets just appended onto the end, and have the program load them whenever. like those self extracting shell scripts
22:00 <tobiasBora> Is there any more efficient version of nub ? Because n^2 to remove duplicate when a sort is in O(n log n) is a bit expensive...
22:00 ixti joined
22:00 zcourts joined
22:00 <sproingie> opengl would be a good bet for a game targeting desktop and browser. ombra might be something you could use, never tried it myself
22:00 iAmerikan joined
22:00 <erisco> tobiasBora, why not use sort, then?
22:00 <tobiasBora> erisco: because I also want the uniqueness property
22:00 <ski> @type map head . group . sort
22:01 <EvanR> tobiasBora: you could do it more efficiently for Ord types... using a Set during a fold
22:01 <lambdabot> Ord b => [b] -> [b]
22:01 <EvanR> or that
22:01 <erisco> tobiasBora, sorry, I thought you had figured out how to solve it with sort already
22:01 jutaro joined
22:02 <EvanR> ski: i wonder whats the complexity of that
22:02 <nshepperd> nubOrd from Data.List.Extra
22:03 <nshepperd> (map head . group . sort) is nice of course but it reorders the list and also isn't productive
22:03 <erisco> you can also just change what it means for two lists to be equal :)
22:03 ixti joined
22:03 saussure joined
22:04 joco42 joined
22:04 <ertes> tobiasBora: if you want uniqueness, why don't you just use Set in the first place?
22:05 <erisco> :t S.toList . S.fromList -- this is another easy one
22:05 <lambdabot> Ord a => [a] -> [a]
22:05 <ertes> > S.fromList [2,5,6,5,1,2,2,8]
22:05 <lambdabot> fromList [1,2,5,6,8]
22:05 <EvanR> a set is not as convenient if you think its a list
22:05 umib0zu joined
22:05 <ertes> then don't think it's a list
22:06 zero_byte joined
22:06 <EvanR> dont think!
22:06 <erisco> just don't
22:06 <maerwald> thought this is #java for a second
22:06 <nshepperd> :t let setNub xs = foldr (\x k seen -> if Set.member x seen then k seen else x : k (Set.insert x seen)) (const []) xs Set.empty in setNub
22:06 <lambdabot> error:
22:06 <lambdabot> Not in scope: ‘Set.member’
22:06 <lambdabot> Perhaps you meant one of these:
22:06 <nshepperd> darn you, lambdabot
22:07 <Tuplanolla> @let import qualified Data.Set as Set
22:07 <lambdabot> Defined.
22:07 flatmap13 joined
22:07 <ertes> nshepperd: S, not Set
22:07 Gloomy joined
22:07 <EvanR> Set seems better
22:08 <Tuplanolla> I dislike single-letter module aliasing.
22:08 <nshepperd> > setNub "hello world"
22:08 <lambdabot> "helo wrd"
22:08 chao-tic joined
22:08 <nshepperd> > setNub [1..]
22:08 <lambdabot> [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,...
22:08 <erisco> doesn't matter if you like it or not because it inevitably causes conflicts
22:08 <tobiasBora> hum... set may also be a good idea, I don't know what's the best
22:08 <tobiasBora> is it possible to do a map from a list to a set :D
22:09 <erisco> this is called Set.fromList
22:09 <nshepperd> of course, maybe you should just be using a Set in the first place!
22:09 wroathe joined
22:09 <ertes> tobiasBora: alternatively just start with a Set to begin with
22:09 codygman_ joined
22:09 <nshepperd> they do have a nice interface
22:09 rickygee joined
22:10 <ertes> tobiasBora: use 'mempty' (the empty set) instead of [], and use 'insert' instead of (:)
22:10 <ertes> > S.insert 2 (S.insert 3 (S.insert 2 mempty))
22:10 <lambdabot> fromList [2,3]
22:10 <tobiasBora> ertes: well I get my input from "replicateM n possibleAngles"
22:10 hybrid joined
22:11 <erisco> > S.singleton 1 <> S.singleton 2
22:11 <lambdabot> fromList [1,2]
22:11 <tobiasBora> so it means that I need to do "fromList $ replicateM ..." and it seems pretty heavy here, since the list representation is way more efficient than the array representation here
22:12 <ertes> tobiasBora: Set will become more efficient as you increase the number of duplicates
22:12 <tobiasBora> ertes: in my input there is no duplicate
22:12 <tobiasBora> in my output I think there are lot's of duplicate
22:12 <ertes> ah
22:13 <ertes> tobiasBora: so you start with a list of unique items and then you transform it in some way that generates duplicates?
22:13 <tobiasBora> yes
22:13 im0nde joined
22:14 <EvanR> you could use a set throughout
22:14 <EvanR> each operation would modify a set, which is auto deduped
22:14 <ertes> tobiasBora: is the transform local enough? i mean: do you only ever look at a single item, or do you need multiple list items to map a single one?
22:15 <tobiasBora> ertes: local map only
22:15 <erisco> I think ertes is shopping in the morphism catalog
22:15 <ertes> tobiasBora: then i suggest that you don't use a list anyway, but use some kind of stream processing… or use a recursive loop instead of replicateM
22:16 <tobiasBora> ertes: I need to use multithreading also,
22:16 <ertes> tobiasBora: transform each item as it comes up and add the result to a set
22:16 <ertes> tobiasBora: that's fine, Set is a monoid =)
22:16 <tobiasBora> that's why recursive loop may be difficult to use
22:16 drewbert joined
22:16 <ertes> "is a monoid" = "i can parallelise this"
22:17 <tobiasBora> ertes: and I keep the input as a list or not ? I'm not sure to see how I can change this replicate code
22:17 <EvanR> a list is a stream processing!
22:17 <EvanR> a list is a monoid that isnt parallizable
22:17 <ertes> tobiasBora: what form of multi-threading do you need? concurrency (to do multiple things at once) or parallelism (to compute faster)?
22:18 <tobiasBora> ertes: parallelism
22:18 sleffy joined
22:18 saussure joined
22:18 <tobiasBora> EvanR: So how would you transform the "replicateM n l" code?
22:18 <ertes> tobiasBora: with effects or pure?
22:18 <nshepperd> the list method with setNub seems fine to me
22:19 <Maxdamantus> Well, the list monoid is parallelisable, but parallelising doesn't necessarily improve performance.
22:19 <tobiasBora> ertes: for now pure. I'm using Control.Parallel.Strategies for my parallelisation
22:20 <nshepperd> maybe revisit the choice if walking down the list to get to the next chunk reaches a *significant* amount of the parallelizable work
22:20 <nshepperd> it sounds like it is currently negligible cost
22:20 <Maxdamantus> It might help if the concatenation tends to be left branching.
22:21 <erisco> concurrency is doing multiple things and parallelism lets you do them at once... just being annoying :)
22:21 <Maxdamantus> (but that's just because left branching concatenation of lists is really inefficient)
22:22 codygman_ joined
22:22 <EvanR> parallelism lets you do things in parallel
22:23 <ertes> tobiasBora: as long as it's pure, using lists is fine, if you make sure that the list is lazy enough
22:23 <EvanR> this terminology stinks, who came up with this, euclid?
22:23 <ertes> tobiasBora: for example if you use replicateM with a state monad, be sure to use a lazy state monad
22:24 <nshepperd> it's parallel because you're doing multiple copies of the same thing in a different place at the same time
22:24 ddere joined
22:24 tromp joined
22:24 <EvanR> contemporaneous
22:25 <Tuplanolla> Just call it blast processing.
22:25 <ertes> tobiasBora: then you can map, then break the list into chunks of a fixed length, 'transpose' it and eagerly convert each sublist individually into a Set… at the end you just take the union of all sublists
22:25 drewbert joined
22:26 <nshepperd> there isn't a word for doing *different* things at the same time in order to make it faster
22:26 <ertes> :t chunksOf
22:26 <lambdabot> Int -> [e] -> [[e]]
22:26 <EvanR> theres pipelining
22:26 <tobiasBora> ertes: Not sure to understand... And example with "replicateM 4 [1,2,3,4,5]"
22:26 <tobiasBora> ?
22:26 <EvanR> but that adds extra connotation
22:27 <ertes> > transpose . chunksOf 3 $ [0..20]
22:27 <lambdabot> [[0,3,6,9,12,15,18],[1,4,7,10,13,16,19],[2,5,8,11,14,17,20]]
22:27 <Tuplanolla> Orthogonalization, nshepperd?
22:27 <ertes> let's say that you do an expensive map before you break it into chunks
22:27 <EvanR> and i didnt think parallel suggested uniformity
22:27 <EvanR> 5k in parallel with 10k
22:27 pera joined
22:28 <ertes> > transpose . chunksOf 3 . map (^100001) $ [(0 :: Word8)..20]
22:28 <lambdabot> [[0,131,0,9,0,15,0],[1,0,7,0,141,0,147],[0,133,0,139,0,17,0]]
22:28 <ertes> tobiasBora: now you have three sublists that you can process in parallel
22:28 <ertes> > parMap rdeepseq S.fromList . transpose . chunksOf 3 . map (^100001) $ [(0 :: Word8)..20]
22:28 <lambdabot> error:
22:28 <lambdabot> • Variable not in scope:
22:28 <lambdabot> parMap :: t0 -> ([()] -> Set.Set ()) -> [[Word8]] -> c
22:29 <ertes> > map S.fromList . transpose . chunksOf 3 . map (^100001) $ [(0 :: Word8)..20]
22:29 <lambdabot> [fromList [0,9,15,131],fromList [0,1,7,141,147],fromList [0,17,133,139]]
22:29 <ertes> just pretend that the final 'map' is actually a parMap
22:29 <tobiasBora> what's the difference between that and P.withStrategy (P.parListChunk 1000 P.rdeepseq) ?
22:30 wroathe joined
22:30 drewbert joined
22:30 <ertes> tobiasBora: the idea is that you never produce the list in memory, but use it in a very lazy way… the 'fromList' is the function that actually forces the computation of the initial 'map'
22:31 fotonzade joined
22:31 hiratara joined
22:31 <ertes> and that one is parallelised very coarsely, ideally by using a chunk length of the number of cores you have
22:31 <tobiasBora> ertes: where do I use fromList ?
22:31 <ertes> see the snippet above
22:32 Nik05 joined
22:32 <tobiasBora> I don't get it
22:32 <tobiasBora> maybe parListChunk use under the hood the same method as you no?
22:32 <tobiasBora> uses*
22:34 <ertes> tobiasBora: it does, but i would expect the explicitly chunking approach to yield better results, because it uses far coarser parallelism
22:34 <ertes> *explicit
22:34 <tobiasBora> I see
22:35 <tobiasBora> and transpose on a list is really efficient ???
22:35 gugah joined
22:35 <ertes> yes
22:36 <ertes> it doesn't really do much other than rearranging the cons cells
22:36 MarioBranco joined
22:36 earldouglas joined
22:36 <ertes> if the original list is lazy, transposition is very cheap
22:36 saussure joined
22:37 afarmer joined
22:37 Levex joined
22:38 Eduard_Munteanu joined
22:39 <tobiasBora> really? ok why not
22:40 <EvanR> @src transpose
22:40 <lambdabot> transpose [] = []
22:40 <lambdabot> transpose ([] : xss) = transpose xss
22:40 <lambdabot> transpose ((x:xs) : xss) = (x : [h | (h:t) <- xss]) : transpose (xs : [ t | (h:t) <- xss])
22:41 <EvanR> such lazy
22:41 <nshepperd> let src = initial_work_items; f = function_that_produces_duplicates; easy_solution = setNub (map f src `using` parListChunk 1000 rseq)
22:42 <nshepperd> if easy_solution is not fast enough, it's because: 1. parListChunk has to jump 1000 elements before getting to the next chunk/spark, and might start too many sparks compared to your number of cpus and 2. setNub is sequential
22:43 DataComputist joined
22:43 mjora7 joined
22:44 <nshepperd> so you can explicitly chunk src sort of like ertes is describing, then apply Set.fromList . map f on each chunk in parallel, then merge the sets later, which should be fast since there are only a small number of sets
22:46 saussure joined
22:47 cables joined
22:48 Sonderblade joined
22:48 CoderPuppy joined
22:51 dan_f joined
22:51 wroathe joined
22:52 <Zer000> can I just point out that on this page https://wiki.haskell.org/Lifting in the first paragraph the type definition of fmap is wrong afaik. It's Functor f => (a -> b) -> (f a -> f b) but should be Functor f => (a -> b) -> f a -> f b
22:52 <hpc> both are the same
22:52 <c_wraith> those are the same.
22:52 <hpc> x -> (y -> z) = x -> y -> z
22:52 <tobiasBora> nshepperd: setNub is defined in a library ?
22:52 <hpc> (x -> y) -> z /= x -> y -> z
22:53 <hpc> this is related to currying
22:53 eacameron joined
22:54 <nshepperd> tobiasBora: it's called Data.List.Extra.nubOrd from package `extra`
22:54 nosefouratyou joined
22:55 skeuomorf joined
22:55 <Zer000> interesting thank you
22:56 Myrl-saki joined
22:58 <hanna> setNub is also in `containers`, where it's called toList . fromList
22:58 tromp joined
22:58 <hanna> from Data.Set
22:59 beanbagula joined
23:01 <dmwit> NB `toList . fromList` does not preserve order. `nub` does.
23:02 <dmwit> Hoogle finds `ordNub` in a few different packages, but none that seems "canonical".
23:02 dfeuer joined
23:03 ketil_ joined
23:03 <ketil_> Anybody use travis-ci? I get an error message from importing containers:
23:03 eacameron joined
23:04 saussure joined
23:04 <ketil_> containers- can't be safely imported! The module itself isn't safe.
23:04 phaji joined
23:04 <ketil_> Anything I can do about this? As far as I can tell, this is just cabal installing containers from hackage.
23:05 <ketil_> ...and it works on my PC, same GHC-version and containers version. Could it be a different cabal-install?
23:05 <dmwit> That sounds like an error associated with the Safe language extension. Do you think it could be enabled for some reason on the CI?
23:06 <dmwit> (Perhaps by a different version of one of the packages that depends on containers?)
23:07 <ketil_> No idea. Also, travis-ci claims ghc 7.10.3, but then it runs ghc --version, which claims 7.4.1. Hmm..
23:07 joco42 joined
23:09 <tobiasBora> nshepperd: Oh ok thank you
23:09 jmcarthur joined
23:09 FreeBirdLjj joined
23:11 twopoint718 joined
23:11 safe joined
23:11 rickygee joined
23:12 <zachk> does this look ok for a randomSelection function from a list: randomSelection :: [a] -> IO a
23:12 <zachk> randomSelection list = do
23:12 <zachk> let len = length list
23:12 <zachk> i <- randomRIO (0,len-1)
23:12 <zachk> return $ list !! i
23:13 saussure joined
23:14 <ski> i suppose so
23:14 <zachk> managed to get an index too large out of it at runtime maybe an empty list or something
23:15 <EvanR> basically randomRIO (0, -1)
23:15 jgertm_ joined
23:15 <byorgey> zachk: you could use http://hackage.haskell.org/package/MonadRandom-0.5.1/docs/Control-Monad-Random-Class.html#v:uniform instead of writing it yourself
23:15 eacameron joined
23:15 <EvanR> something looks fishy there
23:15 <ski> > fst (randomR (0,-1) (mkStdGen 1234)) :: Int
23:15 <lambdabot> 0
23:15 HoierM joined
23:16 <kadoban> For randomR, the docs say "It is unspecified what happens if lo>hi"
23:16 Guest39963 joined
23:16 <kadoban> So, yeah that's a problem.
23:16 <ski> possibly you want to throw an exception in that case ?
23:16 <kadoban> You'd have to throw an exception I suppose, based on that type signature.
23:16 locash joined
23:16 <EvanR> or require a non empty list, or a default value to return in case of empty list
23:16 tromp joined
23:17 Guest99976 joined
23:17 <ski> .. or a failure continuation
23:18 Philonous joined
23:18 <hpc> also "exception" outside of IO pretty much just means "crash"
23:18 <hpc> because they are unpleasant to catch
23:18 <ski> @unmtl ReaderT (IO o) (ContT o IO) a
23:18 <lambdabot> IO o -> (a -> IO o) -> IO o
23:19 eacamero_ joined
23:19 dopey_ joined
23:19 <EvanR> crash early, crash often, right?
23:19 <EvanR> or is that another language
23:19 rickygee joined
23:19 <Eduard_Munteanu> I wonder if the weights must sum up to 1.
23:19 <ski> or "fail fast"
23:20 <EvanR> yeah if the only ways it can fail are fast, thats great
23:20 <Eduard_Munteanu> Erlang?
23:20 <ski> better waste less computing resources
23:21 <* ski> was thinking of Prolog
23:22 <zachk> is there a way to check and see if a Thread from Control.Concurrent is still running?
23:22 <ski> Eduard_Munteanu : for `fromList' ?
23:22 <Eduard_Munteanu> ski, I was asking about 'weighted', I suppose fromList also does.
23:23 lambda-11235 joined
23:23 arpl left
23:23 <ski> Eduard_Munteanu : i suppose they normalize the weights
23:24 <Eduard_Munteanu> Hm, looks like it... uniformMay = fromListMay . map (flip (,) 1) . F.toList
23:27 drewbert joined
23:27 <EvanR> zachk: do you have the threadId ?
23:28 jerbome_ joined
23:28 eacameron joined
23:29 <tobiasBora> Is there any way to quickly provide an efficient ordering if I don't mind which ordering it uses ?
23:29 <zachk> EvanR yea I can get the threadId at creation time via threadId <- forkIO stuff
23:29 <zachk> so how do I see if that threadId is still alive?
23:29 theDon_ joined
23:29 <EvanR> right, here it is
23:29 <EvanR> https://stackoverflow.com/questions/9475392/is-there-a-way-in-haskell-to-query-thread-state-using-threadid-after-a-forkio
23:29 nilof joined
23:29 buglebudabey joined
23:30 <* ski> idly wonders whether this Ramsey categorification makes sense
23:30 TonL joined
23:30 <EvanR> threadStatus :: ThreadId -> IO ThreadStatus
23:30 <EvanR> in GHC.Conc
23:30 beerdrop joined
23:31 <nilof> Is the IO monad's instance of (>>) equivalent to seq with constrained types, or is there some subtle difference between the two?
23:31 <nilof> > :t (>>)
23:31 <lambdabot> <hint>:1:1: error: parse error on input ‘:’
23:31 <ski> not even a subtle difference. a large difference, i'd say
23:31 saussure joined
23:31 markus1209 joined
23:31 <ski> `seq' is about evaluation
23:32 <tobiasBora> Because I'd like to define "Ord (Matrix Mytype)", but I don't want to define a dirty hand-made operator
23:32 <ski> (not even *sequencing* evaluation. there's `pseq' for that)
23:32 <ski> `(>>)' is about sequencing execution
23:32 markus1219 joined
23:32 <ski> evaluation and execution are different things
23:33 wroathe joined
23:33 <ski> @type (>>)
23:33 <lambdabot> Monad m => m a -> m b -> m b
23:33 cyborg-one joined
23:33 <lyxia> tobiasBora: have you tried deriving it
23:33 <dmwit> ?quote sprynge
23:33 <lambdabot> Cale says: Beware of the function [a] -> a. For it may contain trappes and sprynges of great variety and harm.
23:33 <dmwit> Corollary: Beware of the function [a] -> IO a.
23:34 Achylles joined
23:34 codygman_ joined
23:34 <tobiasBora> lyxia: It's possible to derive when Matrix has already been explicited in another lib?
23:34 <dmwit> tobiasBora: `deriving Ord` if that works. Otherwise, no, not really.
23:34 <lyxia> there's still standalone deriving
23:34 <* ski> looks at nilof
23:35 <tobiasBora> dmwit: I tried: "type MatrixCell = M.Matrix Cell deriving Ord" but it does not work
23:35 <tobiasBora> lyxia: what's that ?
23:35 <nilof> Ah, so are there cases where >> does not evaluate its first argument?
23:35 <dmwit> tobiasBora: `{-# LANGUAGE StandaloneDeriving #-}; deriving instance Ord a => Ord (M.Matrix a)`
23:36 Koterpillar joined
23:36 <dmwit> nilof: No. Also, it does much more than evaluate its first argument.
23:36 <dmwit> (In contrast to `seq`, which *only* evaluates its first argument, and sometimes not even that.)
23:37 <dmwit> To wit: ```print 3 `seq` return ()``` doesn't print anything. ```print 3 >> return ()``` does.
23:38 <tobiasBora> dmwit: Can't make a derived instance of ‘Ord (M.Matrix a)’, The data constructors of ‘M.Matrix’ are not all in scope so you cannot derive an instance for it
23:38 <dmwit> tobiasBora: But you will need enough stuff in scope to be able to write the instance yourself. No getting around the module boundaries with this extension. ;-)
23:38 nakal_ joined
23:38 <nilof> ah okay, so seq is quite a lot weaker
23:38 jship joined
23:38 <dmwit> tobiasBora: Oh, dang, you typed just too fast for me to appear prophetic.
23:38 <nilof> while >> is stricter
23:38 <monochrom> Fortunately, there exists an inertial frame that says you're prophetic :)
23:39 <tobiasBora> dmwit: Ahah, maybe you will have another idea to solve this problem, and recover you wizart power?
23:39 <Eduard_Munteanu> nilof, no, (>>) isn't strict at all
23:39 <hpc> "stricter"
23:39 <dmwit> tobiasBora: Yes, write the instance yourself using functions exposed by whatever `M` is.
23:39 <dmwit> tobiasBora: (sorry)
23:39 <hpc> i assume you meant "more specific" ;)
23:39 <EvanR> as in, "boa con"
23:39 <glguy> yeah, there are cases where >> doesn't evaluate its first argument
23:39 <glguy> > undefined >> Proxy -- is the simplest, but there are less degenerate cases
23:39 <lambdabot> Proxy
23:40 <dmwit> glguy: The conversation context explicitly specifies `IO` as the monad of interest.
23:40 <monochrom> For very non-strict >> and >>=, try Control.Monad.State.Lazy. http://lpaste.net/41790/
23:40 <Eduard_Munteanu> Even there, it's kinda conflating evaluation with execution.
23:40 <tobiasBora> dmwit: Hum... So you mean I must copy paste all the stuff defined in the Data.Matrix module in my code?
23:41 louispan joined
23:41 <dmwit> tobiasBora: No, I would not do that.
23:41 saussure joined
23:41 <dmwit> > undefined >> undefined :: Proxy ()
23:41 <lambdabot> Proxy
23:41 <dmwit> neat
23:41 <Eduard_Munteanu> > return undefined >> print "hello"
23:41 <lambdabot> <IO ()>
23:42 <monochrom> Oh! IO. Then consider unsafeInterleaveIO :) http://lpaste.net/77374
23:42 <EvanR> > undefined >> print "hello"
23:42 <dmwit> > (return undefined :: IO ()) `seq` print "hello"
23:42 <lambdabot> <IO ()>
23:42 <lambdabot> <IO ()>
23:42 <Eduard_Munteanu> Hrmpf.
23:42 <dmwit> > undefined :: IO () -- can't tell with this stupid lazy bot ;-)
23:42 <lambdabot> <IO ()>
23:42 <EvanR> :thumbsup:
23:42 <dmwit> > (return undefined :: IO ()) `seq` ()
23:42 <lambdabot> ()
23:43 <dmwit> > (return undefined >> print 3) `seq` ()
23:43 <EvanR> >> in IO is that lazy
23:43 <lambdabot> ()
23:43 <monochrom> main = unsafeInterleaveIO main >> putStrLn "done"
23:43 <Eduard_Munteanu> > (undefined :: IO ()) `seq` ()
23:43 <lambdabot> *Exception: Prelude.undefined
23:44 <Eduard_Munteanu> Heh.
23:44 <EvanR> wtf
23:44 <EvanR> i give up
23:45 <dmwit> tobiasBora: I'd probably write `instance Ord a => Ord (Matrix a) where compare = compare . toLists`.
23:45 <EvanR> lambdabot is playing games with my denotational heart
23:45 <dmwit> (If I didn't care about efficiency or semantics, that is.)
23:46 <dmwit> EvanR: Really? What surprised/confused you?
23:46 <nilof> but if I have something that returns an IO due to side effects and I feed it as the first argument of (>>), I do have a guarentee that it will be executed?
23:46 <monochrom> dmwit: If toLists is lazy enough, I think it is not too bad.
23:46 <EvanR> (undefined :: IO ()) `seq` () is undefined, but undefined :: IO () is not
23:46 davr0s joined
23:47 <monochrom> That's false.
23:47 <glguy> EvanR: How did you determine that (undefined :: IO ()) was not undefined?
23:47 <dmwit> EvanR: because the latter is actually `show (undefined :: IO ())` and the `Show` instance completely ignores its argument.
23:47 <monochrom> I mean the second sentence is false.
23:47 <EvanR> > undefined :: IO ()
23:47 <lambdabot> <IO ()>
23:47 coot____ joined
23:47 <glguy> EvanR: Why do you think that's relevant?
23:47 <EvanR> ah
23:47 <tobiasBora> dmwit: I though to use the lists (even if I didn't know that compare was usable for list), is it also efficient?
23:47 <dmwit> > let ignoreIO _ = "no, lol" in ignoreIO (undefined :: IO ())
23:47 <monochrom> Yeah it's show being non-strict.
23:47 <lambdabot> "no, lol"
23:47 <Eduard_Munteanu> nilof, execution is ordered by (>>), yes
23:47 <monochrom> You almost used const to prove that everything is defined.
23:48 <EvanR> glguy: context being what lambda says, i assume it shows the evaluation of what you asked for
23:48 ContessaTP joined
23:48 <Eduard_Munteanu> EvanR, it's just the show instance for IO stuff
23:48 <EvanR> > undefined :: ()
23:48 <lambdabot> *Exception: Prelude.undefined
23:48 <EvanR> see
23:48 <monochrom> That's ()'s show being strict.
23:48 <EvanR> but now i see thats totally wrong
23:48 Koterpillar joined
23:49 <EvanR> what you see is not what you get
23:49 <monochrom> I do not actually know why the Haskell comittee wanted it, but they did it.
23:49 <dmwit> What you see is one `show` away from what you get. =)
23:49 <EvanR> its like shadows on a cave wall
23:49 <dmwit> All the world's a stage, a `show` in every corner.
23:49 <monochrom> And programmers are supposed to be the people best aware of WYSI not WYG.
23:50 <Eduard_Munteanu> Positivism: What You See *Is*
23:51 <monochrom> That sounds more like tautologism than positivism :)
23:51 <dmwit> I suspect some people have seen things that isn't.
23:51 <nilof> ah, also, I'm wondering, in the case when I write foldr (>>) , will it cause stack overflow with the IO monad? Afaik I'd expect it to overflow for the writer monad?
23:52 drewbert_ joined
23:52 <glguy> I wouldn't expect either of those to be the case
23:52 <monochrom> That depends on a few more variables than that question acknowledges.
23:53 dfeuer joined
23:53 kvda joined
23:53 <monochrom> Consider foldr (>>) undefined (repeat (putStrLn "hello"))
23:53 <monochrom> Runs forever but O(1) space.
23:53 <glguy> > execWriter (foldr (>>) (return ()) (repeat (tell [42])))
23:53 <lambdabot> [42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,...
23:53 jleon joined
23:53 <glguy> That's foldr on an infinite list in Writer
23:53 dan_f joined
23:53 <monochrom> And yeah, Writer depends on whether you use execWrite or evalWriter
23:54 wroathe joined
23:54 <monochrom> So, more variables than the question is aware of.
23:54 <monochrom> http://www.vex.net/~trebla/humour/tautologies.html #5
23:55 <monochrom> Oh I still need to add the picture I took the other day for #0.
23:55 <hpc> if you want to be really obnoxious, you can answer the question as asked with "it will never overflow because you haven't posited anything that evaluates it"
23:55 <monochrom> The picture is of a sign posted outside a pub. It said "Tuesday is like Monday, but different. =)"
23:55 <monochrom> haha hpc wins.
23:55 <glguy> nilof: foldl is more likely to have trouble with IO
23:56 <thang1> glguy: is that because it's not strict? Would foldl' work fine?
23:56 <wayne> hey if i want to write a language runtime in haskell, are there any libraries that give me low-level memory management facilities?
23:56 <glguy> I'd expect foldl' to have a similar amount of trouble
23:56 <monochrom> foldl is too strict, foldl' even worse
23:57 <wayne> the memory for the program itself is pretty hands-off, but maybe there's a library that will let me manage blocks in the heap maybe?
23:57 <monochrom> foldl is strict on the input list (so infinite list will cause trouble) and foldl' on top of that is strict on one more thing and it's a complete disaster.
23:57 <wayne> a memory monad wouldn't be the worst thing
23:57 <hpc> monochrom: there's actually a kernel of truth in there too, that evaluation never happens unmotivated (and in fact neither does execution)
23:57 obadz joined
23:57 <hpc> IO is a data structure! :D
23:57 <Eduard_Munteanu> wayne, you can allocate memory for a Ptr and manage it yourself.
23:58 <Eduard_Munteanu> Heap in a heap.
23:58 <monochrom> Yeah! const () (undefined `seq` undefined `seq` undefined `seq` foldl' seq undefined undefined) is not going to bottom out despite all the seqs in the world you put there.
23:58 <EvanR> wayne: theres the FFI which includes such vagaries as "malloc"
23:58 <EvanR> careful not to segfault
23:59 saussure joined
23:59 eacameron joined
23:59 <wayne> Eduard_Munteanu: that's the approach i was going to try...but i was wondering if there were any popular libraries that would provide some higher-level functionality than casting/alloc/dealloc
23:59 <EvanR> you can also use a better data structure
23:59 <wayne> i want to stay away from FFIs if possible
23:59 <EvanR> IntMap to represent memory
23:59 omilu joined
23:59 <EvanR> or a TotalMap Int