<    March 2017    >
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31
00:00 <Welkin> jle`: what's the square root of the sun?
00:00 <scope> this is still not working and giving me a type mismatch error again sqrt(realToFrac((x1 - y1)^2 + (x2 - y2)^2))
00:01 hiratara joined
00:01 <Koterpillar> scope: while you're at it, what's x1 - y1?
00:01 Shatnerz joined
00:01 <glguy> scope: It's hard to guess what you're doing wrong
00:01 <jle`> scope: you still haven't pasted the error
00:01 theDon_ joined
00:01 <MarcelineVQ> use your paste, that way you can include the error and people don't have to ask what your type signature is with that line otherwise
00:01 lambda-11235 joined
00:01 <glguy> you have to show us errors and actual code you're using to generate the errors
00:01 <jle`> the error is the first thing we asked for heh, and it the single most useful thing for helping you
00:02 <scope> can't copy it directly from cmd
00:02 coot joined
00:02 <jle`> hm...maybe screenshot?
00:02 <scope> one sec
00:02 <glguy> scope: Then figure out how to fix your computer so you can copy text and then come back and we can help
00:02 dolio joined
00:02 louispan joined
00:02 <jle`> i'm not just joking, heh, if we had seen an error from the beginning then the answer would have been extremely easy and fast :)
00:03 <jle`> that's how much of a difference it makes :3
00:03 <scope> http://i.imgur.com/ifGElwZ.png
00:04 <scope> and the code http://lpaste.net/4367931914116399104
00:04 <Koterpillar> scope: right-click CMD window and select "Select" and then "Copy" to copy.
00:04 <scope> right clicking does nothing
00:04 <jle`> so the problem is that the function's type and the type signature don't match. which one do you want to fix?
00:04 Netwolf joined
00:05 <jle`> do you want to fix the type signature to match the function, or the function to match the type signature?
00:05 <scope> I can't change the function stub, only what comes after the =
00:05 Netwolf left
00:05 <jle`> so you can't change the type signature?
00:05 <scope> yes
00:05 <jle`> then the problem is that 'x1 :: a', but it wants a 'b'
00:05 <jle`> so you can use realToFrac to convert x1 from an 'a' to a 'b'
00:05 Fairy joined
00:06 <scope> but that's what I've done
00:06 <scope> sqrt(realToFrac((x1 - x2)^2 + (y1 - y2)^2))
00:06 <jle`> the eerror isn't from sqDistance
00:06 <jle`> the error you gave us is from distance
00:06 <glguy> scope: It looks like the problem is you didn't save your file
00:06 <scope> holy fuck
00:06 <scope> I'm an idiot
00:06 <scope> guys I apologize
00:06 <jle`> sqDistance should probably be ok
00:06 <glguy> ah, that
00:06 <jle`> no problem :)
00:06 <jle`> see, the error helps :D
00:06 <scope> ok loaded fine
00:06 <scope> wow
00:07 <scope> I had typed the sqrt function under a separate function I haven't completed yet
00:07 <scope> thanks guys
00:08 <jle`> glad everything worked out :)
00:08 <scope> Me too haha I've been banging my head against my keyboard for the last hour
00:08 <scope> haskell is confusing for someone that only knows OOP languages
00:09 <geekosaur> btw, you should probably stop that habit of removing the spaces between a function and its parameters
00:10 <geekosaur> it happens to work like languages you are used to as long as there is only one parameter
00:10 <geekosaur> > div 5 3
00:10 <lambdabot> 1
00:10 <scope> yeah exactly, that's what I've been reading in LYAH geekosaur
00:10 DarkPlayer1 joined
00:10 <scope> throwing me off
00:11 tromp joined
00:11 ahri joined
00:12 systadmin joined
00:15 <Welkin> a bridge?
00:17 Ayey_ joined
00:19 plutoniix joined
00:19 Levex joined
00:21 oisdk joined
00:23 plugin joined
00:23 Levex joined
00:23 <tmciver> Hey folks. I'm working on a toy project to implement a simple blockchain and I thought using Hashable for hashing a block seemed like a good solution but I'm wondering what the hashing algorithm is or if it's even the same across instances. Looked a bit at the instance for Bytestring; it ultimately calls a C function "c_hashCString" but I don't know what that does. I don't suppose I can choose a hashing
00:23 <tmciver> algorithm, can I?
00:23 <tmciver> Or perhaps using Hashable isn't a good solution here if I want to be able to parameterize the algorithm used.
00:24 <peddie> @hackage hashabler
00:24 <lambdabot> http://hackage.haskell.org/package/hashabler
00:25 <tmciver> peddie: Thanks! that looks promising.
00:25 nakal joined
00:26 ystael joined
00:26 systadmin joined
00:28 systadmin joined
00:29 ClaudiusMaximus joined
00:30 takle joined
00:31 subttle joined
00:31 Jinixt joined
00:35 <michalrus> What’s the best way to unapply newtype? Say, I have `newtype LastName = LastName Text`. How to get this Text better than `let (LastName t) = ln in t`? Or how do I get uppercased LastName? (And what if it wasn’t string in case someone suggests IsString!)
00:35 sdrodge joined
00:35 andyhuzhill joined
00:36 ajhager joined
00:36 gugah joined
00:36 <Boomerang> newtype LastName = LastName { getLastName :: Text }
00:36 <michalrus> Boomerang: yeah, but then I’m getting conflicts like this one:
00:36 <michalrus> newtype A = A { toText :: Text } ; newtype B = B { toText :: Text }
00:36 <michalrus> xs = [ A "1", A "2", A "3" ]
00:36 <michalrus> ys = toText <$> xs
00:36 <michalrus> Ambiguous toText…
00:37 <michalrus> (With DuplicateRecordFields, that is.)
00:37 <Koterpillar> michalrus: use fromA and fromB instead
00:37 tromp joined
00:37 <Koterpillar> newtype A = A { fromA :: Text }
00:37 <Koterpillar> sometimes unA or runA are used
00:38 <michalrus> Even if the name isn’t A, but something from the depths of *business* like SchemaConfigurationListVisitorErrorListener?
00:38 <michalrus> fromSchemaConfigurationListVisitorErrorListener?
00:39 sz0 joined
00:39 <Koterpillar> SchemaConfigurationListVisitorErrorListener is awful by itself anyway
00:39 <Koterpillar> but, yes
00:39 <* michalrus> nods
00:39 <michalrus> Oookay. :)
00:39 <michalrus> Thanks!
00:40 mizu_no_oto joined
00:40 oisdk joined
00:41 <Boomerang> michalrus: if you really need a uniform getText you could create a GetText type class with a getText function and have instance of that class for all your newtypes A, B, C... I don't know if this is a good pattern for large prjects though
00:42 <michalrus> That crossed my mind, too… But so verbose. :’
00:42 <Boomerang> It's not too bad
00:42 <Koterpillar> not at usage site
00:43 <Boomerang> class GetText a where getText :: a -> Text
00:43 Fairy joined
00:43 <Boomerang> instance GetText A where getText = fromA
00:43 <michalrus> instance GetText A where getText a = let (A t) = a in t
00:43 <michalrus> :p
00:44 <michalrus> Hmmm.
00:44 <michalrus> instance GetText A where getText (A t) = t
00:44 <michalrus> I dunno. :’(
00:46 gcross_ joined
00:46 <michalrus> I wonder if there is enough information available for a compiler plugin to implement `unnewtype` or `mapnewtype`
00:46 <michalrus> toUpper `mapnewtype` (A "xyz") == A "XYZ"
00:46 takle joined
00:46 Destol joined
00:46 Rotaerk joined
00:47 <michalrus> Interesting that nobody needed it. I’m clearly doing something wrong here. =)
00:47 eacameron joined
00:47 <Boomerang> michalrus: you could derive Functor for your newtype
00:47 <michalrus> But it’d need to be * -> *, right?
00:47 <michalrus> A Text is just *
00:47 <Koterpillar> you can use Generic
00:48 <michalrus> I’ll read about that one, then! Thank you. (:
00:48 <Koterpillar> but if you have so many newtypes with the same shape and you want to use them the same way, why are they different?
00:48 <geekosaur> michalrus, there's also a standalone package (newtype) and stuff in lens (Iso iirc?)
00:49 <michalrus> Koterpillar: good point, I don’t know. I just wanted to toUpper one of them and probably went too far in my imagination…
00:49 <michalrus> geekosaur: I’ll check them out, too, thank you!
00:49 nighty- joined
00:50 samgd joined
00:50 markus1189 joined
00:50 markus1199 joined
00:51 subttle joined
00:52 <geekosaur> oh, also: if you want to distinguish Foo Int from Int in the type system, but still do math on it, consider GeneralizedNewtypeDeriving and deriving (Num)
00:52 <geekosaur> etc.
00:53 plugin joined
00:53 <michalrus> Yes, I want exactly that! :) :) Thank you!
00:53 <geekosaur> which indeed makes the compiler do the wrapping/unwrapping for you
00:53 <dopey_> hey yalls, network programming question. im using the Warp library to run a small proxy and I'm wondering if it's possible to access the socket currently handling the request from the request handler (router in Warp terminology i believe).
00:54 louispan joined
00:54 <dopey_> with access to the socket I would be able to query the user of the process making the request, which is my ultimate goal.
00:55 <Koterpillar> that's assuming the user is on the same machine?
00:55 <dopey_> correct. this is local so I'm sure of that part
00:56 crobbins joined
00:57 fizbin joined
00:57 <scope> another question for you all: I have some functions that find the distance between two points and the closer pair (coordinate-wise) between two pairs of points. I'm now trying to find the closest pair of points from a list of points. I'm having trouble figuring out how to do this.
00:59 theDon_ joined
00:59 Rotaerk_ joined
01:01 mudri joined
01:01 wtetzner joined
01:04 JoshS joined
01:05 justan0theruser joined
01:07 <pacak> scope: minimumBy blah $ do
01:07 <pacak> p1 <- points
01:07 <pacak> p2 <- points
01:07 <pacak> guard $ p1 /= p2
01:07 <pacak> return (p1, p2)
01:07 subttle joined
01:08 <mudri> Hi. I'm trying to make a type class instance where the type has a number k in it, and the instance needs k at the value level.
01:08 Durbley joined
01:08 <lpaste_> mudri pasted “No title” at http://lpaste.net/353619
01:09 <mudri> ^ this is the obvious thing I wrote, but k is not in scope for the ⟨take k⟩ expressions.
01:10 <robertkennedy> https://www.4clojure.com/problem/106
01:10 <mudri> I'm not really sure what else to try. I'm familiar with normal dependent types, but not the Haskell variety.
01:10 mmachenry joined
01:11 <robertkennedy> Traveling from 1 -> 4137 I get 1.5 ms for answer, 5 ms for a version that saves the path. Does that seem orders of magnitude high?
01:12 ajhager joined
01:12 gugah joined
01:14 <geekosaur> mudri, I think you want KnownNat?
01:14 <MarcelineVQ> robertkennedy: are you doing this in haskell? is there a goal ms?
01:14 <geekosaur> (ghc doesn't actually have dependent types as such. you have some limited ability to reflect between types and values.)
01:15 <mudri> geekosaur: I'll take a look...
01:15 <mudri> (And where do I recognise you from?)
01:16 <MarcelineVQ> mudri: this talk about the current state of depdendent types in ghc was quite interesting, though I'm not sure how appicable to your problem
01:16 <MarcelineVQ> *this talk https://www.youtube.com/watch?v=P4Io2CRpwyg
01:16 <geekosaur> #xmonad, probably :)
01:16 <mudri> Oh yeah, that was just the other day.
01:18 {emptyset} joined
01:18 Stanley00 joined
01:19 xkapastel joined
01:22 systadmin joined
01:22 cdg joined
01:23 <robertkennedy> MarcelineVQ: yeah, we have an fp club at my work. Speed is the goal
01:23 Welkin joined
01:24 andyhuzhill joined
01:25 dbmikus joined
01:25 Xlaech joined
01:25 ajhager joined
01:25 MP2E joined
01:26 FreeBirdLjj joined
01:26 Levex joined
01:27 oisdk_ joined
01:29 <kadoban> robertkennedy: What are you doing, BFS?
01:31 <kadoban> robertkennedy: Hmm ... what's the input sizes and time limits on these things, I guess it doesn't tell you?
01:36 cdg joined
01:36 ramzifu joined
01:37 mizu_no_oto_work joined
01:37 sanett joined
01:38 <robertkennedy> I'm doing a fold on `F IntSet IntSet` (visited, new). But it doesn't allow for much parallelism. Sparse adjacency matrices seem better, but youd want an unbounded matrix space
01:39 eacameron joined
01:39 oisdk joined
01:39 doomlord joined
01:39 jshjsh joined
01:40 Ayey_ joined
01:40 <robertkennedy> No one at my company has got `123456 -> 234567`. Indeed, I have the quickest solution so far.
01:40 dsantiago joined
01:41 chindy joined
01:41 subttle joined
01:42 levex_ joined
01:42 Rodya_ joined
01:43 eacameron joined
01:43 halogenandtoast joined
01:45 cschneid_ joined
01:49 <halogenandtoast> join #ur
01:49 <halogenandtoast> sorry :(
01:50 <centril> Cale: If IO wasn't transparent, we could possibly also do: Comonad IO (unless it is represented as a state monad in which case you still cant)
01:50 <centril> or: unsafePerformIO :P
01:51 <edwardk> centril: IO or OI as a comonad is unsound given the presence of strength in our language
01:51 <centril> edwardk: it was a "joke! ;)
01:52 systemfault joined
01:52 <edwardk> i mention it because it has been raised "seriously" before http://citeseerx.ist.psu.edu/viewdoc/download?doi=
01:52 <centril> oh :P
01:52 <edwardk> and i want to be clear that it gives a problem =)
01:53 <centril> edwardk: could IO possibly be a WriterT RealWorld a instead of StateT RealWorld a ?
01:53 anuxivm left
01:53 FreeBirdLjj joined
01:53 <edwardk> WriterT is kind of a damn mess, i presume you want to be able to pass and listen? what is the monoid?
01:54 <edwardk> if you don't want pass/listen and just want tell, then how do you readLine?
01:54 <Welkin> I thought Writer could only append, not modify?
01:54 <edwardk> :t Control.Monad.Writer.pass
01:54 <lambdabot> MonadWriter w m => m (a, w -> w) -> m a
01:54 <edwardk> :t Control.Monad.Writer.listen
01:54 <lambdabot> MonadWriter w m => m a -> m (a, w)
01:54 <geekosaur> append is a modification, just a restricted one
01:54 <edwardk> those kinda play hell with it
01:54 <edwardk> as they are partially "handlers"
01:55 <centril> if not, since StateT s a is not a comonad, it makes sense that IO cant be comonad
01:55 <centril> edwardk: the monoid is "here be dragons"
01:56 <edwardk> StateT s a is not a comonad, but it arises by composing the two halves of an adjunction that happens to live in hask (, s) -| (->) s to get s -> (a, s)
01:56 <edwardk> if you compose them the other way you get (s -> a, s)
01:56 <edwardk> which is the store comonad
01:56 <edwardk> (# RealWorld# -> a, RealWorld #) doesn't make sense as such though
01:56 rkazak_ joined
01:57 <edwardk> er (# State# RealWorld -> a, State# RealWorld #)
01:57 <centril> edwardk: im pulling a Fermat: "i have a proof" in the margins
01:58 paulsh94 joined
01:58 marsam joined
01:59 <centril> edwardk: damn, category is really awesome for pulling new concepts out like "magic"
01:59 <centril> I clearly need to learn it much better
02:03 <robertkennedy> :t (# 3 , True #)
02:03 <lambdabot> Num t => (# t, Bool #)
02:04 jshjsh joined
02:05 louispan joined
02:08 robertkennedy joined
02:10 peterbecich joined
02:12 andyhuzhill joined
02:13 tswett_to_go joined
02:16 k0m joined
02:17 <vaibhavsagar> is there a trick to getting stack to build an executable with debugging symbols?
02:17 ystael joined
02:18 infinity0 joined
02:18 Rizy joined
02:21 infinity0 joined
02:21 <edwardk> is hackage down?
02:22 subttle joined
02:24 infinity0 joined
02:25 brynedwardz joined
02:25 <Rotaerk_> website at least doesn't look down to me
02:27 infinity0 joined
02:28 <pacak> edwardk: works for me
02:28 robkennedy joined
02:29 pera joined
02:29 infinity0 joined
02:30 sanett joined
02:31 sdrodge joined
02:31 Ayey_ joined
02:31 gugah joined
02:32 infinity0 joined
02:35 infinity0 joined
02:37 <lpaste_> tswett pasted “pkg-config could not be found” at http://lpaste.net/353621
02:37 vwker joined
02:38 <tswett_to_go> Hi everyone. I'm trying to run the test suite for haskell-cpython under Windows, and I'm getting an error message. See the lpaste link above.
02:38 <geekosaur> pkg-config has to come from your system package manager
02:38 <geekosaur> on Windows, that may be a tall order...
02:38 <tswett_to_go> Yup.
02:39 <geekosaur> although, you should presumably have some kind of mingw/msys/cygwin around
02:39 <geekosaur> since I think it's required for ghc on windows
02:40 <tswett_to_go> Unsurprisingly, pkg-config isn't in the Windows Store. :)
02:40 <tswett_to_go> I saw some Stack Exchange answer saying that one popular way to get pkg-config is to just install GTK+.
02:40 <geekosaur> I think that way lies pain
02:41 <tswett_to_go> And the GTK+ website said you could use msys2 to install it, but didn't explain how.
02:41 <tswett_to_go> So I looked at another Stack Exchange answer which said to run such-and-such pacman commands. And I successfully installed *something*.
02:41 <geekosaur> pkg-config is roughly the C/C++ equivalent of ghc-pkg. programs have to register their libraries with it.
02:41 <tswett_to_go> But whatever it was, it didn't seem to provide pkg-config.
02:41 <geekosaur> if you are using libraries that are not from msys2 or whatever, they will not know about or use pkg-confgig
02:42 <tswett_to_go> Makes sense.
02:42 <geekosaur> are you running frm cmd.exe, or from powershell, or from an msys2 shell?
02:42 <tswett_to_go> I'm running cabal from cmd.exe.
02:42 <geekosaur> you should probably be using the latter (msys2 programs can run from cmd.exe but it takes a bit of fiddling)
02:43 cdg joined
02:43 theorbtwo joined
02:43 <tswett_to_go> I'll give it a shot.
02:43 mizu_no_oto joined
02:44 <tswett_to_go> "bash: cabal: command not found" Right... that's not hard to get around.
02:44 wagle joined
02:44 <tswett_to_go> "cabal.exe: The program 'ghc' version >=6.4 is required but it could not be found."
02:44 <tswett_to_go> I don't like the way this is going. :D
02:45 <geekosaur> likely need to add the haskell platform bin path to your bash $PATH
02:45 <geekosaur> C:\Program Files\Haskell Platform\8.0.2\bin\ but I don't recall how msys2 bash wants you to say that
02:46 <geekosaur> (probably won;t work as a windows path)
02:46 Rizy joined
02:46 Scip joined
02:46 sanett joined
02:46 <lpaste_> tswett revised “pkg-config could not be found”: “pkg-config could not be found” at http://lpaste.net/353621
02:46 <tswett_to_go> I got the pkg-config could not be found error again.
02:47 <tswett_to_go> I'm kind of relieved. :D
02:47 zchn joined
02:49 wtetzner joined
02:51 k0m joined
02:51 <tswett_to_go> http://stackoverflow.com/a/25605631 "A alternative without glib dependency is pkg-config-lite. Extract pkg-config.exe from the archive and put it in your path."
02:51 <tswett_to_go> Sounds easy enough.
02:55 <k0m> set chat.*
02:56 <edwardk> haddock: internal error: Ix{Int}.index: Index (1280) out of range ((0,437)) -- has anyone encountered this one before?
02:57 meff` joined
02:58 kshukla joined
02:59 <kshukla> Can I have a data definition inside a let expression?
02:59 AustinTasseltine joined
02:59 byorgey joined
02:59 danharaj joined
03:00 <Koterpillar> AFAIK no
03:00 <geekosaur> no
03:00 Jeanne-Kamikaze joined
03:00 <pacak> kshukla: Nope.
03:00 <kshukla> ... and in a where clause?
03:00 <geekosaur> no
03:00 <pacak> And nope.
03:00 <edwardk> kshukla: no to both
03:00 hucksy joined
03:00 <kshukla> thanks
03:00 <edwardk> well, technically inside the module Foo where ... is inside a where clause ;)
03:01 sanitypassing joined
03:01 portu joined
03:01 <tswett_to_go> module Foo where rownum <= 100;
03:02 gfixler joined
03:02 shafox joined
03:02 dbmikus joined
03:03 <tswett_to_go> Anyway, looks like cabal was pacified by installing pkg-config-lite. I don't think pkg-config-lite actually *works* the way cabal wants it to.
03:03 <tswett_to_go> But cabal doesn't seem to actually care that it doesn't work. :)
03:06 eacameron joined
03:07 hotdog joined
03:08 Ayey_ joined
03:08 dbmikus joined
03:08 <tswett_to_go> "cabal: The pkg-config package 'python-3.5' is required but it could not be found." Yeah... I was kind of afraid of that.
03:08 doomlord joined
03:09 <tswett_to_go> This is while running it in an environment where running "python" gives you Python 3.5.2.
03:09 skeuomorf joined
03:09 <tswett_to_go> Which is supposedly the exact version of Python that this version of haskell-cpython expects.
03:09 <Koterpillar> tswett_to_go: well, that's possible even without Windows in the mix, because you can have the binaries but not headers
03:10 <tswett_to_go> Koterpillar: ah, right. If this were Linux, I'd have to install the -devel packages, right?
03:10 <Koterpillar> tswett_to_go: e.g. on a Debian system you'd install python-dev to get pkg-config... yes
03:10 <tswett_to_go> Yup.
03:11 stvc1 joined
03:13 <tswett_to_go> Looks like I have them. They're in C:\Users\tanne\Anaconda3\envs\keras-tf\include.
03:13 <tswett_to_go> At least, that's where I have *one* set. :)
03:13 <tswett_to_go> I've got another set in C:\Users\tanne\Anaconda3\pkgs\python-3.5.2-0\include...
03:14 <tswett_to_go> Something I haven't tried is actually running the real Python 3.5.2 Windows installer.
03:14 systadmin joined
03:14 fabianhu_ joined
03:15 andyhuzhill joined
03:16 <tswett_to_go> No... I *have* run the real Python 3.5.2 Windows installer. That put the include files in C:\Users\tanne\AppData\Local\Programs\Python\Python35\include.
03:16 mmachenry joined
03:17 <geekosaur> tswett_to_go, as I said earlier: Windows native programs do not know about or use pkg-config
03:17 augur joined
03:17 <tswett_to_go> Oh right... you said they have to register somehow?
03:18 <geekosaur> The libraries may well be there, but the Haskell package you are trying to install told cbal to use pkg-config to find the libraries. pkg-config does not know where to find libraries for a Python installation that did not register its libraries with pkg-config, because it is a native Windows package
03:18 <tswett_to_go> Right, right.
03:18 xtreak joined
03:18 <geekosaur> pkg-config is a unix thing, not a windows thing. msys2 has it but that's because msys2 pretends to be unix
03:20 <geekosaur> but msys2 pkg-config only knows about msys2 libraries that register with it
03:21 cdg joined
03:21 cschneid_ joined
03:21 <Koterpillar> is there python for msys2?
03:23 <tswett_to_go> I wonder if haskell-cpython is even capable of using Python out of %PATH%, then, because I've been using Anaconda, and it uses %PATH% to tell the shell which python to use.
03:23 louispan joined
03:23 <Koterpillar> python on %PATH% is a binary
03:24 <Koterpillar> so the answer is no
03:24 <Koterpillar> because it needs python the library
03:24 <tswett_to_go> Ohhh. Yeah, I should have thought of that.
03:24 <Koterpillar> s/binary/executable/
03:25 <tswett_to_go> I find myself yearning for the familiar comfort of the .NET Framework, where the only difference between an EXE and a DLL is that you can double-click an EXE and it does something.
03:27 variable joined
03:27 <tswett_to_go> This is making me wonder if there's some better interoperability solution out there.
03:27 xplat joined
03:28 <tswett_to_go> Maybe there's some Python library I can use to expose a module as a web service, and then a Haskell library that will call that web service.
03:28 <tswett_to_go> I just have to use Windows Communication Foundation to... uh...
03:28 <tswett_to_go> I've really been using .NET too much. :)
03:28 aarvar joined
03:28 hexagoxel joined
03:29 <Koterpillar> tswett_to_go: reverse engineer multiprocessing or celery?
03:30 <tswett_to_go> Hmmm. A benefit of a network-based solution is that I'd be able to do the Haskell part under Linux.
03:31 <Koterpillar> I'd definitely look into celery protocol
03:32 <Koterpillar> (IDK what random parts fall off Python on Windows, though)
03:32 k0m joined
03:33 Welkin joined
03:33 xplat joined
03:34 sellout- joined
03:36 skeuomorf joined
03:37 sanett joined
03:38 a3Dman joined
03:38 ali_bush joined
03:40 halogenandtoast joined
03:41 <platz> anyone use concurrent-output? curious how the stm-in-anger approach works out
03:42 eacameron joined
03:43 jsgrant- joined
03:43 enitiz joined
03:44 Rodya_ joined
03:46 exferenceBot joined
03:50 raycoll joined
03:51 subttle joined
03:51 hexagoxel joined
03:53 louispan joined
03:55 zcourts joined
03:57 zargoertzel joined
03:58 dbmikus joined
03:58 armyriad joined
04:00 DarkPlayer2 joined
04:01 safe joined
04:02 cyborg-one joined
04:02 shayan_ joined
04:03 <tswett_to_go> I'm going to give SOAP a shot. That's Definitely Not a Bad Idea At All.
04:03 Big_G joined
04:03 benl23 joined
04:03 tripped joined
04:04 doodlehaus joined
04:05 kody joined
04:06 <tswett_to_go> I'm gonna hit the sack. Night, everyone.
04:12 tromp joined
04:15 systadmin joined
04:21 gryle joined
04:22 justanotheruser joined
04:24 <jle`> is there any way to double up on type family dependencies
04:24 <jle`> type Fam a b = c | c -> a, c -> b ?
04:32 Xanather joined
04:33 <MarcelineVQ> type familiy Fam a b = c | c -> a b maybe
04:33 aarvar joined
04:34 tomboy64 joined
04:39 sanett joined
04:41 connrs joined
04:44 sanett joined
04:44 <halogenandtoast> MarcelineVQ: really... https://github.com/MarcelineVQ/marcelinevq.github.io/blob/master/index.html#L1
04:45 xtreak joined
04:45 Rodya_ joined
04:45 louispan joined
04:47 <halogenandtoast> I want to rewrite my personal website at some point in Haskell
04:47 rkazak joined
04:48 <halogenandtoast> it sucks at the moment as I'm just using ghost as a blogging platform (and I don't love JavaScript).
04:48 <halogenandtoast> Considering using Hakyll
04:48 pwnz0r joined
04:49 <tippenei1> ^ would recommend
04:50 <tippenein> there are plenty of good examples around and the documentation is sufficient
04:50 ali_bush joined
04:50 ali_bush joined
04:52 dbmikus joined
04:53 _deepfire joined
04:53 andyhuzhill joined
04:56 permagreen joined
04:58 <jle`> halogenandtoast: fwiw my blog is in hakyll + purescript
04:58 arawack joined
05:01 thunderrd joined
05:02 <halogenandtoast> jle` link?
05:04 <jle`> http://blog.jle.im
05:04 <jle`> i even wrote a post about the transition/rewrite if you're interested
05:05 <jle`> but to be fair, i rewrote it from scotty, another haskell library lol
05:06 hexagoxel joined
05:06 <halogenandtoast> jle`: Looks nice, I'll check it out
05:08 mexisme2 joined
05:09 andyhuzhill joined
05:11 roboguy` joined
05:13 ptvirgo joined
05:13 lithie joined
05:16 verement joined
05:17 Apocalisp joined
05:20 dni joined
05:21 sidei joined
05:23 takuan joined
05:23 <MarcelineVQ> halogenandtoast: what :>
05:26 happy0 joined
05:26 <halogenandtoast> MarcelineVQ: I was expecting something useful/interesting, was dissappointed.
05:27 <MarcelineVQ> oh no I don't make useful things, I'd have to get payed if I did that
05:27 roboguy` joined
05:31 takle joined
05:32 <MarcelineVQ> hopefully there's something interesting around there though :>
05:34 louispan joined
05:35 zariuq joined
05:36 mexisme joined
05:38 mbuf joined
05:40 takle joined
05:43 systemfault joined
05:43 Swizec joined
05:44 systadmin joined
05:44 athan joined
05:45 vlatkoB joined
05:45 <halogenandtoast> MarcelineVQ: I stopped investigating at that point
05:46 Rodya_ joined
05:46 dbmikus joined
05:47 zargoertzel joined
05:50 cur8or joined
05:52 ali_bush joined
05:56 Gurkenglas joined
05:57 dni joined
05:58 zar joined
05:59 doomlord joined
06:00 zariuq joined
06:01 osa1 joined
06:01 osa1 joined
06:04 CoconutCrab joined
06:05 sanett joined
06:07 dec0n joined
06:07 mexisme2 joined
06:08 Rizy joined
06:10 harfangk joined
06:10 raichoo joined
06:11 Hafydd joined
06:11 Hafydd joined
06:14 sanett joined
06:21 BartAdv joined
06:23 sanett joined
06:24 CurryWurst joined
06:25 louispan joined
06:29 sanett joined
06:32 spacedog82 joined
06:34 blueonyx joined
06:34 danvet joined
06:35 eacameron joined
06:35 nemorichard joined
06:35 nemorichard left
06:39 Rizy joined
06:41 dbmikus joined
06:41 tromp joined
06:41 connrs joined
06:46 edsko joined
06:46 sanett joined
06:46 dbmikus joined
06:47 Rodya_ joined
06:48 ubsan_ joined
06:51 valdyn joined
06:51 Ayey_ joined
06:52 xtreak joined
06:52 meandi_2 joined
06:53 ThomasLocke joined
06:53 ThomasLocke joined
06:54 zargoertzel joined
06:55 doomlord joined
06:56 djellemah joined
06:56 sanett joined
06:56 t0by joined
06:56 dni joined
06:57 connrs joined
06:59 sanett joined
07:02 <grayhatter> https://gist.github.com/7dde0485f1e951feb1c1b8381d3ee03b
07:02 kritzcreek_ joined
07:02 <grayhatter> any idea what I'm doing wrong?
07:02 robertkennedy joined
07:03 <grayhatter> I have no idea why it's returning (String, String, (String, String, String))
07:03 ragepandemic joined
07:04 <osa1> grayhatter: get rid of `return`
07:04 <grayhatter> I thought I tried that
07:05 <grayhatter> oh, I did, but now I'm getting a diffirent error, and I read the line numbers wrong -_- thanks osa1
07:08 zariuq joined
07:08 hexagoxel joined
07:08 vlatkoB_ joined
07:08 hdeshev joined
07:09 sword865 joined
07:09 Rizy joined
07:10 quchen joined
07:12 MindlessDrone joined
07:14 AleXoundOS joined
07:14 ragepandemic joined
07:15 schjetne joined
07:16 jhrcek joined
07:16 connrs joined
07:20 sanett joined
07:20 ali_bush joined
07:20 ali_bush joined
07:21 cschneid_ joined
07:24 Ayey_ joined
07:24 Ayey_ joined
07:27 igniting joined
07:31 Yuras joined
07:31 cyphase left
07:32 ali_bush joined
07:32 xall joined
07:32 eazar001 joined
07:33 emily1 joined
07:36 SlashLife joined
07:36 dbmikus joined
07:39 pleax joined
07:41 zeroed joined
07:42 hexagoxel joined
07:44 Ayey_ joined
07:46 <quchen> Anyone else using Atom, and did the recent Linter upgrade break your Haskell support as well? Is there a quick fix until the downstream packages adapt?
07:46 systadmin joined
07:47 raichoo joined
07:49 Sose joined
07:51 ali_bush joined
07:51 ali_bush joined
07:52 CurryWurst joined
07:52 JagaJaga joined
07:52 CurryWurst joined
07:53 ydl joined
07:55 wei2912 joined
07:56 eacameron joined
07:56 takle joined
07:57 tomphp joined
08:04 xtreak joined
08:05 ericsagnes joined
08:05 guiben joined
08:05 mattyw joined
08:10 Beetny joined
08:14 yqt joined
08:15 uncertainty joined
08:15 albertid joined
08:16 takle joined
08:18 ali_bush joined
08:20 sanett joined
08:20 raichoo joined
08:21 magneticduck joined
08:22 sidei joined
08:23 oish joined
08:25 bjz joined
08:28 Sampuka joined
08:28 hexagoxel joined
08:29 systadmin joined
08:31 dbmikus joined
08:32 vydd joined
08:32 vydd joined
08:36 dbmikus joined
08:37 curious_corn joined
08:39 xtreak joined
08:39 ysangkok joined
08:40 <ysangkok> how is it possible that I get "Could not deduce (HasInfixDecls QName ds0) from the context ..." but ds0 does not appear in the context?
08:40 <ezyang> the goal doesn't necessarily come from context
08:41 hamishmack joined
08:41 merijn joined
08:42 tromp joined
08:43 Einwq joined
08:43 thc202 joined
08:49 medicijnman joined
08:51 connrs joined
08:52 mgu joined
08:53 biglama joined
08:53 grafa joined
08:57 bennofs joined
08:59 fweth joined
08:59 doodlehaus joined
09:04 louispan joined
09:05 FreeBirdLjj joined
09:05 doomlord joined
09:07 howdoi joined
09:07 benl23 joined
09:07 andyhuzhill joined
09:07 rgr joined
09:08 ramzifu joined
09:08 dcoutts joined
09:08 dcoutts joined
09:09 k0ral joined
09:10 takle joined
09:11 shane joined
09:12 marfoldi joined
09:12 forgottenone joined
09:16 upvjjo joined
09:19 tomphp joined
09:19 <shane> Can anyone suggest a good module for CSV parsing?
09:20 <merijn> I mostly hear cassava for CSV, but I've never used it
09:21 tippenein joined
09:21 <shane> Thanks
09:22 tomboy64 joined
09:22 <ysangkok> if the goal doesn't come from the context, how can I learn where the goal comes from? i presume that i could fix the error by manually requiring the ds0 to an instance of the type class, but if it doesn't appear in the context, where could it be?
09:22 discrttm joined
09:23 dcoutts_ joined
09:23 <ysangkok> here is the error http://lpaste.net/353629
09:24 tomboy64 joined
09:24 <ysangkok> and here is the code https://github.com/ysangkok/programatica/blob/master/src/programatica/tools/base/tstModules.hs#L92
09:24 dec0n joined
09:25 bezirg joined
09:26 shane left
09:26 dbmikus joined
09:26 tv1 joined
09:27 marr joined
09:27 balor joined
09:28 sanett joined
09:30 Yuras joined
09:30 oish joined
09:31 dbmikus joined
09:31 ali_bush joined
09:31 ali_bush joined
09:32 xtreak joined
09:33 <k0ral> Hello
09:34 <ysangkok> i wonder if there is a way to defer my error to runtime. changing the definition to say, "if it is an instance of this type class, do this, other wise runtime error"
09:34 MarioBranco joined
09:35 <ezyang> -fdefer-type-errors?
09:35 <k0ral> after reading https://elvishjerricco.github.io/2016/09/17/abstracting-async-concurrently.html , I'm eager to learn how to apply this trick in practice to add concurrency to my free-monad-based program; is there a code example somewhere ?
09:36 tomboy64 joined
09:36 <k0ral> I've always wanted to use async but never could as this requires a `MonadBaseControl IO` instance and FreeT isn't
09:36 <ysangkok> ezyang: ooh thank you
09:38 plugin joined
09:38 Yuras joined
09:38 MarioBranco joined
09:38 sanett joined
09:43 tromp joined
09:43 comerijn joined
09:44 <Xnuk> Is there a function like Control.Concurrent.Async.race but does not throw an exception when the second returns successful result?
09:45 xtreak joined
09:45 <jle`> ysangkok: "if it is an instance of this type class then do this otherwise runtime error" isn't really possible in haskell
09:46 forgottenone joined
09:46 <comerijn> jle`: Actually it is
09:46 bjz joined
09:46 <jle`> :o
09:46 <quchen> Xnuk: You mean one that does not cancel the slower thread?
09:46 <comerijn> jle`: Observe this magnificent hack: https://github.com/mikeizbicki/ifcxt
09:47 <jle`> this is horrifying
09:47 <Xnuk> quchen: yes if the first fails
09:47 forgottenone joined
09:48 <Xnuk> If the fast one is successful, cancels the slower one
09:50 forgottenone joined
09:50 tomboy64 joined
09:50 <merijn> Xnuk: Well, yes, that's kinda the point of 'race'
09:50 shane joined
09:52 shurick joined
09:52 Lord_of_Life joined
09:55 <Xnuk> but `race (threadDelay (1 * sec) >> fail "foo") (threadDelay (5 * sec) >> return True)` fails
09:55 <Xnuk> where sec = 1000000
09:58 <Xnuk> I want it returns `True` or `Right True` or `Just $ Right True` or something else contains True
09:59 zero_byte joined
10:00 _sg joined
10:01 <merijn> Wrap the individual actions in an exception handler before calling race?
10:04 <mauke> the most horrible part of ifcxt is that it's not called ifctx
10:04 <Xnuk> merijn: making both returns successful result?
10:05 <merijn> mauke: or ifctxt
10:05 ziyourenxiang joined
10:06 forgottenone joined
10:07 phaji joined
10:07 forgottenone joined
10:08 ali_bush joined
10:08 ali_bush joined
10:09 gregman_ joined
10:11 locallycompact joined
10:11 forgottenone joined
10:11 jaspervdj joined
10:12 sphinxo joined
10:16 dmiles joined
10:18 MarioBranco_2 joined
10:19 biglama joined
10:21 dbmikus joined
10:22 eacameron joined
10:22 Ade joined
10:26 <quchen> Xnuk: You could use »a <- async (...); b <- async (...); result <- join (race (wait a) (wait b))«, would that work?
10:27 <quchen> Or does wait cancel its async if it is canceled?
10:27 codenirvana joined
10:27 <merijn> quchen: I would assume so
10:28 ub joined
10:29 bollu joined
10:29 ali_bush joined
10:29 ali_bush joined
10:29 codenirvana left
10:29 <Xnuk> :t join
10:30 <lambdabot> Monad m => m (m a) -> m a
10:30 pleax joined
10:31 <Xnuk> fmap join $ race (wait a) (wait b) ?
10:31 MarioBranco joined
10:33 plugin joined
10:34 augur joined
10:35 freusque joined
10:36 Fairy joined
10:36 locallycompact joined
10:39 louispan joined
10:40 pleax joined
10:40 <quchen> fmap join = join
10:41 <quchen> (One of the Monad laws)
10:44 Sose joined
10:45 <Xnuk> but `race` is `IO (Either a b)`
10:45 yellowj joined
10:45 <Xnuk> > join $ Right (Just 4)
10:45 <lambdabot> error:
10:45 <lambdabot> • Couldn't match type ‘Maybe’ with ‘Either a1’
10:45 <lambdabot> Expected type: Either a1 (Either a1 a)
10:46 augur joined
10:49 Rodya_ joined
10:50 ali_bush joined
10:50 ali_bush joined
10:51 eatman joined
10:53 bollu joined
10:55 doomlord joined
10:56 FullyFunctional joined
10:57 sidei joined
10:58 thi_ joined
10:58 <int-e> Xnuk: using Async primitives, something like http://lpaste.net/3720874479425945600 should work. (warning though, that code is completely untested, I didn't even try to load it)
10:59 freusque joined
11:00 ali_bush joined
11:00 ali_bush joined
11:01 augur joined
11:02 Snircle joined
11:03 mattyw_ joined
11:04 magthe joined
11:04 Apocalisp joined
11:06 fizbin joined
11:07 FreeBirdLjj joined
11:08 forgottenone joined
11:09 dbmikus joined
11:09 Rizy joined
11:10 <Xnuk> int-e: works well, thanks
11:12 FreeBirdLjj joined
11:12 ali_bush joined
11:13 sst joined
11:14 Sampuka joined
11:16 Apocalis_ joined
11:23 schjetne joined
11:23 silver joined
11:23 plugin joined
11:24 <sanett> Hey folks I'm having a a really hard time understanding lambda calculus.
11:24 <Cale> Hello!
11:25 <Cale> Anything I can help with?
11:25 <sanett> I now have an expression λz.(n z)(m z) (λx.x), how do I deal with lambda x and lambda x in this expression?
11:25 <sanett> lambda z and lambda x*
11:25 <Cale> I don't think there's anything to reduce there
11:26 <Cale> Unless you intended to have more parens...
11:26 <sanett> oh so that's the end of it?
11:26 <Cale> If it was (\z. n z (m z)) (\x. x) then you'd have something to do.
11:27 <Cale> But generally by convention, lambdas scope as far to the right as possible
11:27 <sanett> oh perfect because now I don't know if there's a parenthesis around n and z
11:28 <Cale> ah, and the other common convention is that application associates to the left
11:28 <Cale> So, f x y z means ((f x) y) z
11:28 <Cale> and n z (m z) and (n z) (m z) means the same thing
11:28 plugin joined
11:28 <Cale> mean*
11:29 <sanett> so how are (\z. n z (m z)) (\x. x) and λz.(n z)(m z) (λx.x) different?
11:29 louispan joined
11:30 fendor joined
11:30 <Cale> The latter means \z. (((n z) (m z)) (\x. x))
11:31 <sanett> ah right lambda goes as far right as possible
11:31 <sanett> no I actually meant (\z. n z (m z)) (\x. x)
11:31 coot joined
11:31 JeanCarloMachado joined
11:32 lukaramu joined
11:33 <Cale> Well, those are identical now :)
11:33 <Cale> If I understand you
11:34 freusque joined
11:34 fotonzade joined
11:34 <Cale> (\z. n z (m z)) (\x. x) = n (\x. x) (m (\x . x))
11:35 <sanett> right... so I keep this thing (\x.x)
11:35 <Cale> and then you can't go any further without knowing n or m
11:35 <sanett> right...
11:35 <sanett> thanks a lot Cale
11:35 <Cale> No problem
11:37 Xanather joined
11:37 dmiles joined
11:38 Rizy joined
11:40 voglerr joined
11:42 unK_ joined
11:43 petermw joined
11:44 logicmoo joined
11:45 HoierM_ joined
11:46 sanett joined
11:49 fizbin joined
11:50 Rodya_ joined
11:51 petermw joined
11:52 amit_r joined
11:52 Thra11 joined
11:54 Schoolmeister joined
11:56 danza joined
11:56 dennisvennink joined
12:01 <quchen> ezyang: Congratulations! :-)
12:01 <quchen> Just heard about your defense
12:03 hexagoxel joined
12:03 Rizy joined
12:05 shane joined
12:08 mda1 joined
12:09 prophile joined
12:09 mattyw joined
12:10 <tabaqui1> I'm trying to make stack package
12:10 alexbiehl joined
12:11 coot joined
12:11 <tabaqui1> it contains library and executable module depended on it
12:11 <tabaqui1> in two separate folders
12:11 Aland joined
12:12 <tabaqui1> I've added my-lib in .cabal dependencies section
12:12 <tabaqui1> and stack build it first
12:12 sidei joined
12:12 <tabaqui1> and writes a message in .stack-work/log/my-lib.log
12:12 <tabaqui1> that package installed in .stack-work/install/...
12:13 <tabaqui1> but there is not library and I get compile error while building my-exec
12:13 <tabaqui1> what am I doing wrong?
12:13 <tabaqui1> library marked as extra-dep in stack.yaml
12:19 cschneid_ joined
12:20 sanett joined
12:20 Thra11 joined
12:21 mmhat joined
12:22 slomo joined
12:23 bariscant joined
12:23 <maerwald> I forgot how the {..} feature was called, anyone?
12:23 <maerwald> and it's not a particularly good google search term
12:24 mmhat_ joined
12:25 fendor joined
12:25 <liste> maerwald: RecordWildCards ?
12:25 <liste> maerwald: or NamedFieldPuns
12:25 <liste> maerwald: https://ocharles.org.uk/blog/posts/2014-12-04-record-wildcards.html
12:25 <Tuplanolla> How about `RecordPuns`?
12:25 <ocharles> it's RecordWildCards
12:27 <suppi> too wild for me
12:27 sdothum joined
12:28 uncertainty joined
12:31 <tabaqui1> ah, yeah, I've forgot to add actual modules in exposed-modules
12:32 lep-delete joined
12:33 tromp joined
12:36 pavonia joined
12:36 kshukla joined
12:36 sanett joined
12:38 sidei joined
12:39 coltfred joined
12:39 <shane> Are there any features in attoparsec that are not present in parsec?
12:41 <Clint> automatic backtracking?
12:41 <shane> I see...and does attoparsec still have a significant speed advantage?
12:41 yellowj joined
12:41 Schoolmeister joined
12:42 sanett_ joined
12:44 kody joined
12:47 AustinTasseltine joined
12:47 doodlehaus joined
12:50 Thra11 joined
12:50 ogrady joined
12:51 Rodya_ joined
12:52 montanha_ joined
12:53 fizbin joined
12:54 montanha_ left
12:55 mfukar joined
12:55 bjz joined
12:56 eacameron joined
13:00 forgottenone joined
13:00 a3Dman joined
13:00 md208 joined
13:01 <md208> hello. what is difference between 'stack' and 'haskell-stack' packages? Sorry if it's obvious, but i am
13:01 <md208> kinda newbie
13:01 <md208> I am using Manjaro.
13:02 netheranthem joined
13:03 ompaul joined
13:05 <coot> hello, anybody knows an example of a PureScript project running client side tests in karma?
13:05 eschnett joined
13:06 <codedmart> My project is getting big enough that compilation times are getting noticable. Reading around I foung this as ghc-options `--ghc-options="-O0 -j +RTS -A128m -n2m -RTS"` to reduce compilation times. Are these safe options to use? What am I gaining or sacrificing by using them?
13:06 uncertainty joined
13:06 cdg joined
13:06 sanett joined
13:06 tromp joined
13:07 <merijn> codedmart: Looks like it disables optimisation, enables parallelism and increases GHCs memory so it's GCing less
13:07 <codedmart> merijn: When you word it like that it only the disable optimizations sounds negative.
13:07 <merijn> codedmart: Yeah
13:08 <merijn> codedmart: Personally I have a "development" set of flags and a "final compilation"
13:08 <merijn> Where I use the "dev" ones only for typechecking/errors/warnings while coding
13:08 <codedmart> So I could disable optimizations in development then not for production.
13:08 <merijn> In which case the secret "moar speed" setting would be "-O0 -fno-code"
13:09 <merijn> which skips optimisations/code generation and only type checks
13:09 <merijn> If you use, like, ghc-mod/hdevtools you can configure those to use those flags to be faster
13:10 <codedmart> Ah interesting. What do you use the final?
13:10 <codedmart> Does it vary
13:10 <codedmart> I need to learn the options better.
13:10 <codedmart> And do you just use those as cabal flags?
13:10 nikivi joined
13:11 <merijn> codedmart: I use hdevtools, so I specify those options in hdevtools
13:11 <merijn> codedmart: The GHC manual is rather elaborate and explains most flags and somehow mostly escapes people's notice :p
13:11 <codedmart> :) reading is hard.
13:11 <codedmart> Thanks for your help.
13:12 _deepfire joined
13:13 jmelesky joined
13:13 plugin joined
13:14 earldouglas joined
13:15 coot_ joined
13:16 Gurkenglas joined
13:17 wlemuel joined
13:18 shafox joined
13:20 dbmikus joined
13:20 magneticduck joined
13:20 Thra11 joined
13:21 sujeet joined
13:23 bjz_ joined
13:25 eacameron joined
13:26 halogenandtoast joined
13:27 fryguybob joined
13:27 Rodya_ joined
13:28 eSVG joined
13:29 mizu_no_oto_work joined
13:31 uncertainty joined
13:31 cpennington joined
13:32 mmachenry joined
13:32 ystael joined
13:33 chlong joined
13:34 lukaramu_ joined
13:37 kshukla joined
13:37 kshukla joined
13:38 detrumi joined
13:39 mizu_no_oto_work joined
13:39 sanett joined
13:41 Anon1123097123 joined
13:42 <lpaste_> foobar pasted “first 4 digs of las” at http://lpaste.net/353633
13:43 <Anon1123097123> #hackthissite
13:43 <Anon1123097123> ./join hackthissite
13:43 oisdk joined
13:43 Anon1123097123 left
13:46 oisdk joined
13:47 <kshukla> http://lpaste.net/353633 : something funny is happening. `(las 5)` gives 312211 (as expected),`firstNDigs 4 (las 5)` gives 3122 (as expected), but if I change the definition of `las` to `firstNDigs 4 (nextLas (las (n-1)))` I get 3112 (wrong).
13:48 <kshukla> http://lpaste.net/353633 : something funny is happening. `(las 5)` gives 312211 (as expected),`firstNDigs 4 (las 5)` gives 3122 (as expected), but if I change the definition of `las` to `firstNDigs 4 (nextLas (las (n-1)))` I get 3112 (wrong).
13:50 sidei joined
13:50 <kshukla> Basically, firstNDigs and las work fine. But when I modify las to apply firstNDigs on its return value, I get wrong results.
13:51 Thra11 joined
13:51 PSoBI joined
13:52 kusti85 joined
13:52 `^_^v joined
13:55 Levex joined
13:55 sepp2k joined
13:55 locallycompact joined
13:56 cdg_ joined
13:59 oish joined
14:00 Levex joined
14:00 BartAdv joined
14:00 harfangk joined
14:01 carlomagno joined
14:03 bjz joined
14:04 <codedmart> @merijn Do you use stack?
14:04 <lambdabot> Unknown command, try @list
14:04 sanett joined
14:04 <merijn> codedmart: Nope
14:05 <codedmart> OK, having issues with hdevtools
14:05 <merijn> the one on hackage used to be a bit outdated, not working with recent GHC. Mine is installed from github, I think. Not sure if someone took the hackage project over
14:06 <merijn> oh, looks like wat updated in december, so I guess someone took over maintenance
14:08 sellout- joined
14:09 t0by joined
14:10 eacameron joined
14:10 <merijn> codedmart: One common issue I can imagine is that hdevtools uses ghc-the-library to do it's things, so if a stack project uses a different GHC than what hdevtools is built against it might fail
14:10 <codedmart> It has something to do with --package-db
14:11 sanett joined
14:15 mson joined
14:16 dsh joined
14:16 TechnoTony joined
14:18 dawehner joined
14:20 jcarpenter2 joined
14:20 tromp joined
14:20 Fairy joined
14:21 Thra11 joined
14:21 fabianhu joined
14:22 oish joined
14:25 <ertes> is there an effectful version of (%%=) in lens?
14:25 cdg joined
14:26 BusFactor1 joined
14:27 robkennedy joined
14:27 <ertes> i would use 'zoom', but the lenses in pipes-parse/pipes-bytestring are improper, so i'm a bit worried about repeating effects
14:30 cyborg-one joined
14:31 <ertes> although it should actually be safe… 'zoom' only uses the lens once
14:31 <mutsig> what's the purpose of the "--| some comment" - comments in haskell source codes? In contrast to just "-- some comment" or "{- some comment -}"
14:31 jcarpenter2 left
14:31 <ertes> mutsig: it's haddock's comment syntax
14:31 <ertes> its purpose is automated generation of documentation
14:32 <ertes> mutsig: https://www.haskell.org/haddock/doc/html/index.html
14:32 sektor_ joined
14:32 <mutsig> oh, I see. Thanks ertes
14:33 <Tuplanolla> Without the space it's an operator, mutsig.
14:33 carlosdagos joined
14:33 <Tuplanolla> > let x --| y = x * y + x / y in 42 --| 13
14:33 <lambdabot> 549.2307692307693
14:33 crobbins joined
14:35 al-damiri joined
14:37 jsgrant- joined
14:38 mettekou joined
14:38 sword865 joined
14:38 Boomerang joined
14:39 sdrodge joined
14:39 ziocroc joined
14:40 pera joined
14:40 <orion> Are the objects within Hask Sets?
14:40 coltfred joined
14:42 plugin joined
14:42 Cthalupa joined
14:43 Rodya__ joined
14:44 coot joined
14:45 fotonzade joined
14:45 Elish joined
14:45 wraithm joined
14:47 <eschnett> i believe the objects in Hask are types, which are isomorphic to sets (of the possible values of these types, including “undefined”)
14:47 sanett joined
14:48 jsgrant joined
14:48 cdg joined
14:49 cschneid_ joined
14:50 maxwell joined
14:50 Guest_ joined
14:50 maxwell left
14:50 maxwell joined
14:51 <orion> And are morphisms functions?
14:51 <orion> Like, f :: Int -> Int
14:51 Thra11 joined
14:53 bodisiw joined
14:53 zero_byte joined
14:54 honeymead joined
14:55 bennofs joined
14:55 <NickHu> Yeah
14:55 <NickHu> Hask isn't quite what you think it is though
14:56 rekahsoft joined
14:56 _sg joined
14:56 <NickHu> It's not exactly a category of Haskell types as objects and functions as morphisms
14:56 <NickHu> Because you have undefined
14:56 <NickHu> Which doesn't correspond to anything
14:56 uglyfigurine joined
14:57 Luke joined
14:57 PennyNeko joined
14:58 <ski> NickHu : i don't follow ..
14:58 <mmachenry> NickHu, ski, By undefined we mean bottom, right?
14:58 albertus1 joined
14:58 <NickHu> Yeah
14:59 <NickHu> undefined :: a
14:59 <mmachenry> Yes, that undefined but also all other things that are in bottom that aren't undefined.
14:59 <ski> it's more like the category of pointed sets, than the category of sets, if you account for partiality
14:59 doodlehaus joined
15:00 dawehner joined
15:00 <ski> (however, then there's partially defined values which aren't `_|_', but which aren't fully defined either .. so it's a bit more complex than the category of pointed sets)
15:01 kshukla joined
15:02 <ski> in the category of pointed sets, an object is a pair of a set, and a value (a point) in it
15:02 <NickHu> mmachenry: That's true, yea
15:02 uncertainty joined
15:03 <ski> and a morphism from one such pair `<A,bot_A>' to another `<B,bot_B>' is a function from `A' to `B', that maps `bot_A' to `bot_B'
15:03 JoshS joined
15:03 <NickHu> Ehh, you could do it that way, but all the literature I've ever seen about Hask is the way I described, and people just conveniently don't consider bottoms
15:04 <ski> we can think of this as a partial function from `A' to `B', where the values of `A' where the function isn't defined are all mapped to `bot_B' (denoting `undefined'), and where we require `bot_A' to also map there, to not get any more "wiggly room" in how we choose what a partial function does
15:05 <ski> in effect, you add a "bottom" element to every set, and by this procedure your partial functions now turn into total functions on these extended (pointed) sets
15:05 <* ski> isn't talking about `Hask' atm, fwiw
15:05 Cthalupa joined
15:06 <Xnuk> > "🤔"
15:06 <lambdabot> <hint>:1:2: error:
15:06 <lambdabot> lexical error in string/character literal at character '\129300'
15:06 <Xnuk> 🤔
15:07 dawehner_ joined
15:07 <NickHu> ski: I see
15:07 <Prutheus> jaspervdj: are you here?
15:07 <ski> if we want to be able to model partially undefined values, and non-strict functions, then look into "domain theory" (denotational semantics)
15:07 <NickHu> mm
15:07 <Prutheus> jaspervdj: I've send you a mail a week ago you havent answered yet
15:08 sphinxo joined
15:08 <ski> where there is stilla bottom element of every domain, but now there's also an ordering, e.g. `(_|_,2)' is less defined that `(3,2)'
15:09 <ski> and morphisms have to be "monotonic", preserve information. if it maps a partially defined value to some output. then it can't map a *more* defined value to an output having *less* information
15:09 <ski> can't retract information about the output that you've already computed, as more information about the input comes in
15:10 <ski> if a function maps `(_|_,2)' to `5', then it can't map `(3,2)' to `_|_'
15:11 doodleha_ joined
15:11 <ski> there's also limits being brought into the sequence
15:13 <ski> if you have an increasing sequence `_|_',`2 : _|_',`2 : 3 : _|_',`2 : 3 : 5 : _|_',... (increasing in the definedness sense, not necessarily, in this case, in some natural ordering on the elements of the lists here)
15:13 <ski> and you will eventually compute a defined value for any element of the list
15:14 <ski> iow you have a computation that (ideally speaking) computes an infinite list
15:14 <NickHu> I see; that's pretty cool
15:14 <ski> then if you apply a function to it, iow you apply a function to all the above finite approximations of the finite list
15:15 <ski> then the sequence of values that you get from applying the function to each finite approximation .. this sequence will also converge
15:15 spacedog82 joined
15:15 <ski> and you can do stuff along this lines to describe how recursion (e.g. `fix') works
15:16 <ski> (er, finite approximaitons of the infinite list)
15:16 uncertainty joined
15:16 theelous3 joined
15:17 guampa joined
15:18 <centril> I need to make Maybe an instance of MonadError () Maybe ... will this cause an orphan instance given that neither data type and class is defined by me ?
15:18 staafl joined
15:19 yogsotot_ joined
15:20 Rodenbach joined
15:21 oisdk joined
15:21 Guest_ joined
15:21 <cocreature> centril: yep
15:22 Thra11 joined
15:22 <centril> cocreature: crap :(
15:22 danharaj joined
15:22 marsam joined
15:22 <centril> i dont get why Maybe is not an instance of MonadError () Maybe tho... it should be...
15:22 <cocreature> centril: if you don’t want the orphan instance, your only choice is a newtype
15:22 Ayey_ joined
15:23 <centril> cocreature: Right - I'll go with Either () a instead then, since it is already MonadError () (Either ())
15:24 <cocreature> centril: if you are working on an executable or a non-public library, orphan instances are also not really a problem
15:24 dunx joined
15:24 <centril> cocreature: it is intended to be part of a public executable that has a public library forit
15:25 <centril> Either () a is fine i guess
15:25 <centril> not that much diff
15:25 <cocreature> centril: if it’s part of the executable that’s still not a problem because you can’t depend on it. if it’s part of the public library then you should probably avoid it
15:25 <centril> cocreature: part of lib
15:25 <centril> cocreature: I guess I could nag the maintainers of mtl / transformers to fix this ;)
15:26 mettekou joined
15:27 rkazak joined
15:28 <cocreature> yep :)
15:29 wraithm joined
15:30 trism joined
15:31 sphinxo joined
15:31 marsam joined
15:31 MrcRjs joined
15:32 Fairy joined
15:32 eschnett joined
15:32 Levex joined
15:33 codesoup joined
15:34 MP2E joined
15:35 marsam joined
15:36 tomboy64 joined
15:37 conal joined
15:38 sn34k joined
15:38 <nak> can someone explain this { :: } syntax here newtype EitherT e m a = EitherT { runEitherT :: m (Either e a) }
15:38 <nak> what should i be looking up for that ?
15:39 <mauke> records
15:39 <geekosaur> record syntax
15:39 <glguy> nak: Haskell Report section 3.15 : Datatypes with Field Labels
15:39 sn34k joined
15:39 <nitrix> nak: <record constructor> { <field label> :: <type of field> }
15:39 <mauke> https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-490003.15
15:40 DataComputist1 joined
15:40 <nak> interesting......
15:40 <nak> it creates a new function for each record field ?
15:40 <nak> :t runEitherT
15:40 <lambdabot> error:
15:40 <lambdabot> • Variable not in scope: runEitherT
15:40 <lambdabot> • Perhaps you meant ‘runWriterT’ (imported from Control.Monad.Writer)
15:40 <nak> PHOOEY
15:40 <Sornaensis> :t runStateT
15:40 <lambdabot> StateT s m a -> s -> m (a, s)
15:40 <nak> i will guess tho:
15:41 <Sornaensis> @src runStateT
15:41 <lambdabot> Source not found. That's something I cannot allow to happen.
15:41 <nak> runEitherT :: Either e m a -> Either e a
15:41 qpykxs joined
15:41 <nak> is that right ?
15:41 thc202 joined
15:41 <glguy> nak: No, you dropped a 'T'
15:41 <glguy> and an 'm'
15:41 <nak> let's try again
15:42 <nak> runEitherT :: EitherT e m a -> m (Either e a)
15:42 <codedmart> I am struggling with lenses a bit. I want to use putObject from amazonka but use poaACL to modify the acl field? https://www.stackage.org/haddock/nightly-2017-03-03/amazonka-s3-1.4.5/Network-AWS-S3-PutObject.html#v:putObject
15:42 <codedmart> Not sure the proper syntax. Never used lenses before.
15:43 <nak> so intuitively, runEitherT just unwraps an EitherT and gives us the underlying monad ?
15:43 Scip joined
15:43 freusque joined
15:43 Yuras joined
15:44 simukis__ joined
15:45 machinedgod joined
15:45 <mauke> codedmart: me neither, but 'set poACL x (putObject ...)' maybe? /me closes eyes and prepares for type errors
15:46 Noldorin joined
15:46 <nak> so in order to wrap a monad in EitherT we must EitherT { runEitherT = mypatheticmonad }
15:46 <nak> ?
15:46 <glguy> nak: It's uncommon to use record syntax to construct an EitherT. You can just write: EitherT yourThing
15:46 <nitrix> nak: You have to wrap an `Either e a` in the monad you're transforming.
15:47 wraithm_ joined
15:47 <mauke> that's not what a "monad" is, btw
15:47 <codedmart> mauke: Ah I had it backwards. I was trying `putObject .. <&> set poACL ..`
15:47 <codedmart> Thanks!
15:47 <mauke> isn't <&> the fmap one?
15:47 <nitrix> @unmtl EitherT String IO Int -- nah
15:47 <lambdabot> EitherT String IO Int
15:47 <nitrix> *nak
15:47 <mauke> :t (<&>)
15:47 <lambdabot> Functor f => f a -> (a -> b) -> f b
15:48 <mauke> :t (&)
15:48 <lambdabot> a -> (a -> b) -> b
15:48 dfeuer joined
15:48 <mauke> codedmart: looks like & would work
15:48 henriksod joined
15:48 <nitrix> Why's lambdabot struggling here?
15:48 <nitrix> @unmtl EitherT String IO Int
15:48 <lambdabot> EitherT String IO Int
15:48 <* nitrix> scratches head
15:48 <nak> glguy: interesting. so if i don't specify the field names for record syntax, the field values will be assigned in order of their definition ?
15:48 <mauke> EitherT isn't mtl
15:48 <glguy> @unmtl ErrorT String IO Int
15:48 <lambdabot> IO (Either String Int)
15:48 serendependy joined
15:49 <nak> glguy: eg data Foo = Foo { bar :: String } deriving (Show) -- Foo "hello" == Foo { bar = "hello" }
15:49 <codedmart> mauke: Just `&` and not `<&>`? `&` doesn't seem to work, but I will play with it some more. Thanks!
15:49 <mauke> @let data SomeRecord = MkRecord { field_1 :: String, field_2 :: Int } deriving (Eq, Ord, Read, Show)
15:49 <lambdabot> Defined.
15:50 <mauke> > MkRecord "hello" 42
15:50 <lambdabot> MkRecord {field_1 = "hello", field_2 = 42}
15:50 MarioBranco joined
15:50 <nak> FANCIFUL
15:50 <mauke> > MkRecord "hello" 42 == MkRecord { field_2 = 42, field_1 = "hello" }
15:50 <lambdabot> True
15:50 <nak> mauke: a+ demonstration, thank you
15:52 Thra11 joined
15:52 boombanana joined
15:52 <mauke> > ("x", "codedmart") & set _1 42
15:53 <lambdabot> (42,"codedmart")
15:53 <Sornaensis> :t set
15:53 <lambdabot> ASetter s t a b -> b -> s -> t
15:53 <Sornaensis> lenses are magic
15:53 <Sornaensis> look at all that black magic, wtf
15:53 <mauke> lenses are s t a b b y
15:53 raichoo joined
15:53 <mauke> set's type is easy, though
15:53 <Sornaensis> :t _1
15:54 <lambdabot> (Field1 s t a b, Functor f) => (a -> f b) -> s -> f t
15:54 <int-e> don't put lenses in your eyes... wait.
15:54 Schoolmeister joined
15:54 halogenandtoast joined
15:54 <mauke> set takes a field descriptor, a new (field) value, and a record
15:54 <codedmart> mauke: Thanks, I must have had a different syntax error. I appreciate it.
15:54 <mauke> and it returns a record the the field has that new value
15:55 <mauke> & is backwards $
15:57 fosskers joined
15:59 Ayey_ joined
16:01 <* nak> is not ready for lenses
16:02 <ocharles> I wish we had |> and <| instead of & and $ :(
16:02 <mutsig> Can lenses be used on newtypes? Not that I see a reason, just curious.
16:03 <ocharles> mutsig: they certainly can
16:03 <Cale> ocharles: I kinda just wish we didn't have &
16:03 <ocharles> And _Wrapped is a batteries-included lens (at least with the `lens` library)
16:03 <Tuplanolla> I sometimes wish we had no operators at all.
16:03 thunderrd joined
16:03 <ocharles> Cale: I've come to really like forward application for some things
16:03 wraithm joined
16:04 <Cale> There are a few places where it's idiomatic already, but mostly it just bothers me when anyone uses it
16:04 <ocharles> I think we need both forward and backward, because I think things come out more readable if you're at least consistent in your order of composition
16:05 <ocharles> there's so much code that use >>= and ., information flows all over the place like that
16:08 urodna joined
16:08 mfukar joined
16:10 <Cale> ocharles: I rarely actually use (>>=) directly.
16:10 <Cale> It's (=<<) or do-notation
16:11 conal joined
16:11 Vzox01 joined
16:11 sellout- joined
16:12 Guest_ joined
16:12 <dolio> I feel like <&> is nicer in a lot more situations than &.
16:12 <dolio> But I think some people disagree with me.
16:13 dennisvennink joined
16:14 sdothum joined
16:17 <robkennedy> Does >=> offer performance improvements? Or will ghc just replace >>= with >=> when it can?
16:17 <Cale> No
16:17 mada joined
16:17 <Cale> If anything, it potentially harms performance very slightly, but that won't usually happen because it should inline
16:18 <ocharles> Cale: good! I wish my colleagues were as good as you :p
16:19 <ocharles> I've finally stopped them importing Control.Arrow and using &&& everywhere though
16:19 <robkennedy> It seems like >=> would inline much easier than >>=. But I suppose that's been solved probably
16:20 <Cale> Just checking one of our projects... in the backend which is about 9100 lines of Haskell, there are 3 occurrences of >>= two of which are followed by a \case and the other of which, well, I don't hate it, but should probably be a do-block anyway
16:20 oisdk joined
16:20 jathan joined
16:20 alx741 joined
16:21 <ocharles> 203 occurrences here, in 31k lines of Haskell
16:21 <Cale> In the frontend, which is about 18000 lines of code, there's 12 occurrences, three of which are followed by \case, and the rest of which are all things I should probably stamp out
16:21 <ocharles> and wtf, since when did we have 31k lines
16:21 <Cale> (I'm using sloccount to count)
16:21 <ocharles> cloc here
16:21 Sonolin joined
16:23 <Cale> altmappend (cn ^? _ConversationId_Direct >>= SP.other i) (cn ^? _ConversationId_Sidebar . _1 >>= exclusiveOther i) -- whoever wrote this needs talking to
16:23 <Cale> :D
16:23 <ocharles> haha
16:23 robotroll joined
16:23 <ocharles> let me see what gems I can dig up
16:23 <ocharles> join $ readMay . uncurry (<>) . (T.toUpper . T.take 1 &&& T.toLower . T.drop 1) . head <$> M.lookup k
16:24 <ocharles> god damnit team.. stahp. wat r u doing.
16:24 <ocharles> This pattern shows up so often I can actually quickly understand this, but so many times I've had to manually inline the definitions of &&& and `.` just to see what the hell is going on
16:25 <Cale> The (.)'s don't bother me at all, and the (&&&) I'm okay with
16:25 <* ocharles> hisses
16:25 <Cale> It's the head that worries me
16:25 <ocharles> that too
16:25 <bennofs> ocharles: I'd have to look up the precendence of &&& vs (.)
16:25 <Cale> and the join isn't so wonderful there
16:26 fabianhu joined
16:26 <bennofs> that line is just too long
16:26 <bennofs> it would be fine if some of the subexpressions were given names I think
16:26 <ocharles> basically there's nothing ok with it
16:26 <ocharles> we're on the same page then ;)
16:26 <Cale> It's basically titlecasing something
16:26 <bennofs> o.o why does it use join
16:26 <bennofs> and not just =<<
16:26 <Cale> I don't know that the rest is about
16:26 <MarcelineVQ> also whether lookup or readMay fails isn't known ye?
16:27 <ocharles> bennofs: lookup can fail and readMay can fail
16:27 <Cale> toTitle :: Text -> Text O(n) Convert a string to title case, using simple case conversion. Subject to fusion.
16:28 <Cale> Well, that'll do every word
16:28 <Cale> which you might not want
16:28 <bennofs> what, how does this code even compile. The <$> is using the (->) r instance, right?
16:29 <Cale> > uncurry (<>) . (T.toUpper . T.take 1 &&& T.toLower . T.drop 1) $ "hello"
16:29 <jaspervdj> Prutheus: Yeah sorry -- I'll check if I have time to go through it tomorrow. Been busy with work and zurihac stuff.
16:29 <lambdabot> mueval-core: Time limit exceeded
16:29 <Cale> ...
16:29 <Cale> > uncurry (<>) . (T.toUpper . T.take 1 &&& T.toLower . T.drop 1) $ "hello"
16:29 <lambdabot> error:
16:29 <lambdabot> Not in scope: ‘T.toUpper’
16:29 <lambdabot> No module named ‘T’ is imported.error:
16:29 <Cale> ah, we don't have Data.Text
16:30 <bennofs> @let import qualified Data.Text as T
16:30 <lambdabot> Defined.
16:30 danza joined
16:30 <Cale> > uncurry (<>) . (T.toUpper . T.take 1 &&& T.toLower . T.drop 1) $ "hello"
16:30 <lambdabot> error:
16:30 <lambdabot> • Couldn't match type ‘T.Text’ with ‘[Char]’
16:30 <lambdabot> Expected type: [Char] -> (T.Text, T.Text)
16:30 <Cale> > uncurry (<>) . (T.toUpper . T.take 1 &&& T.toLower . T.drop 1) . T.pack $ "hello"
16:30 <lambdabot> "Hello"
16:30 <bennofs> yeah that makes sense so far
16:30 <bennofs> :t readMay
16:30 <lambdabot> error: Variable not in scope: readMay
16:30 <bennofs> @hoogle readMay
16:30 <Cale> oh jeez
16:31 <lambdabot> Safe readMay :: Read a => String -> Maybe a
16:31 <lambdabot> BasicPrelude readMay :: Read a => Text -> Maybe a
16:31 <lambdabot> ClassyPrelude readMay :: (Element c ~ Char, MonoFoldable c, Read a) => c -> Maybe a
16:31 <Cale> is this like, turning true into True and then reading it?
16:31 <ocharles> bennofs: there might have been something else important on the next line, I was just providing an example of the horrors deep in some of the legacy code
16:31 <ocharles> I wouldn't put it past it
16:31 wraithm joined
16:31 <bennofs> Cale: looks like it
16:31 <ocharles> Let me go and actually open this file :p
16:31 <Cale> That's pretty questionable
16:31 <bennofs> ocharles: oh, yes. But one could have just written it with =<< instead of join $ f <$> bla
16:31 <ocharles> https://www.irccloud.com/pastebin/zbDmq7nr/
16:32 NeverDie joined
16:32 <Profpatsch> Cale: I very often user >>= \case
16:32 <Cale> Probably just needs some lambdas
16:32 <Profpatsch> I thank thaw
16:32 <ocharles> It's for query parsing in URLs, so yes, it looks like it does parse true to True and false to False
16:32 <Profpatsch> I love that idiom
16:32 <Cale> Yeah, >>= \case is one of the only places where I actually like >>=
16:32 <bennofs> Cale: what do you use instead of >>=? do notation or =<< ?
16:32 <Cale> bennofs: Yes
16:33 <ocharles> :)
16:33 <Cale> and the occasional <=<
16:33 <bennofs> ocharles: i would replace uncurry (<>) by foldOf both #lensforlife :D
16:33 <Cale> pls
16:33 <Cale> There's nothing worse than abuse of lens
16:34 <Tuplanolla> How about abuse of children?
16:34 <bennofs> is this an abuse ? foldOf both is pretty clear to me
16:34 <Cale> Tuplanolla: hmm, uniplate also can get pretty crazy
16:35 <Cale> http://hackage.haskell.org/package/uniplate-1.6.12/docs/Data-Generics-Uniplate.html#v:children
16:35 <Tuplanolla> Yes.
16:35 HarveyPwca joined
16:36 <ocharles> uniplate is already an abuse with it's horrific orphan instance modules
16:36 <bennofs> :t T.splitAt
16:36 <lambdabot> Int -> T.Text -> (T.Text, T.Text)
16:36 <bennofs> > T.splitAt 0 ""
16:36 <lambdabot> error:
16:36 <lambdabot> • Couldn't match expected type ‘T.Text’ with actual type ‘[Char]’
16:36 <lambdabot> • In the second argument of ‘T.splitAt’, namely ‘""’
16:36 <bennofs> > T.splitAt 1 ""
16:36 <lambdabot> error:
16:36 <lambdabot> • Couldn't match expected type ‘T.Text’ with actual type ‘[Char]’
16:36 <lambdabot> • In the second argument of ‘T.splitAt’, namely ‘""’
16:36 <bennofs> > T.splitAt 1 (T.pack "")
16:36 <lambdabot> ("","")
16:37 <bennofs> :t foldOf both . over _1 T.toUpper . T.splitAt 1
16:37 <lambdabot> T.Text -> T.Text
16:38 <ocharles> or just over _head T.toUpper
16:38 <bennofs> ocharles: does that work for Text?
16:38 <ocharles> if it doesn't it should
16:38 <bennofs> :t over _head
16:38 <lambdabot> Cons t t a a => (a -> a) -> t -> t
16:38 <ocharles> Cons Text Text Char Char
16:38 <ocharles> should work fine
16:38 <ocharles> (that instance exists)
16:38 <bennofs> ocharles: you'd need to use Data.Char.toUpper and not Text.toUpper then though
16:39 <ocharles> we have some stupid overloaded monofoldable toUpper thing in scope
16:46 <grayhatter> is there a list of infix operators?
16:46 <grayhatter> eg, where I referenec <$>, $, <>, <*>
16:48 <geekosaur> no, because it depends on what linraries you use
16:48 <MarcelineVQ> I used to use http://stackoverflow.com/questions/7746894/are-there-pronounceable-names-for-common-haskell-operators a lot, it's not exactly reference since it's just names though
16:48 <Gurkenglas> hayoo successfully searches for them
16:48 <geekosaur> *libraries
16:49 <Gurkenglas> http://hayoo.fh-wedel.de/?query=%3C%24%3E
16:49 <geekosaur> infix ops are not wired into the language like they are in java or c++
16:50 <merijn> geekosaur: Well, to be fair, he only asked about a lot common operators from base, and I assume someone made a reference for those somewhere
16:50 <geekosaur> probably, but even those change :)
16:50 <MarcelineVQ> also relevant, but just names, https://wiki.haskell.org/Pronunciation
16:51 <geekosaur> of those four, three are fairly recent
16:51 dan_f joined
16:52 <merijn> geekosaur: Applicative is from like 2004, no? Not sure you can still call that recent
16:52 <merijn> geekosaur: That's 13 years ago >.>
16:52 <geekosaur> there's quite a few references out there that were never updated from haskell98 though
16:53 NeverDie_ joined
16:53 Rodya_ joined
16:54 obadz joined
16:56 cdidd joined
16:56 <tippenein> what is an IO (Either String a) -> IO a
16:57 amit_r joined
16:57 <ocharles> I'm starting to think these days that I don't want named operators for infix operators, but what I actually want is a function that's a monoid homomorphism from the free monoid generated by the operand types to the result of the operator. Does mean that the operator and domain needs to be a monoid though
16:57 <nak> how is "newtype" different from "type" ?
16:57 <nak> or "data"
16:57 <grayhatter> ocharles> ....
16:57 <nak> ugh
16:57 <ocharles> but then you get sum :: [a] -> a, and :: [Bool] -> Bool, or :: [Bool] -> Bool, etc. It's kinda lispy
16:57 <grayhatter> I know some of these words
16:58 Einwq joined
16:58 <mutsig> nak: newtype can be used to make class instances, which isn't true for types
16:58 osa1 joined
16:58 <ocharles> grayhatter: Well, (+) :: Int -> Int -> Int. 0 + a = a, a + 0 = a, a + (b + c) = (a + b) + c. Hey look, that's everything we need to know that (Int, 0, +) is a monoid! So I'd argue rather than having "plus :: Int -> Int -> Int", I'd rather have "plus :: [Int] -> Int"
16:59 <geekosaur> nak: "type" is exactly a type alias. "newtype" tells the typechecker to pretend that the type is distinct from what it "wraps", but doesn't literally wrap it.
16:59 plugin joined
16:59 <mutsig> As I see it, newtypes are a lightweight version of a "data"-type with only 1 constructor.
16:59 mt joined
16:59 mohsen_ joined
16:59 <geekosaur> so the main use for newtype is to allow different typeclass instances, althouygh it's sometimes just to keep you from combining two notional Int-s that should be kept distinct (think things like age and quantity)
17:00 <hexagoxel> nak: https://github.com/quchen/articles/blob/master/fbut.md#data-newtype-type
17:00 <nak> mutsig geekosaur i guess i just keep reading... if anyone pretends learning haskell is easy tho, that's really unfair
17:00 <nak> hexagoxel: thank you
17:01 <geekosaur> I found getting used to laziness much harder than this... but I came in with a fair amount of experience already
17:01 <mutsig> nak: almost every part of haskell is simple but abstract, and simple and abstract things can be hard to learn.
17:01 <mutsig> i.e. simple /= easy
17:02 <robkennedy> Any XML package suggestions? I tried Xeno but it failed with no debugging
17:02 <robkennedy> I'm just consuming XML
17:03 Xanather joined
17:03 <Cale> I was somewhat already prepared for laziness, as when I really got going learning Haskell (back around 2001 or so), I had just finished writing an IRC bot as what amounted to a really long bash pipeline.
17:03 <Cale> (with netcat at one end, and a fifo tying the knot)
17:03 jchia joined
17:04 Swizec joined
17:04 LnL joined
17:05 fabianhu joined
17:05 <geekosaur> robkennedy, my only suggestion is that a lot of stuff uses HXT... don't go down that rabbit hole, there are better ways now
17:05 Swizec joined
17:05 <cocreature> robkennedy: I like xml-conduit
17:05 <nak> Cale: is that referring to my comment ?
17:06 <robkennedy> Ty I had just started hxt
17:06 <Cale> nak: Moreso geekosaur's
17:06 lc_ joined
17:06 <nak> Cale: ok that makes more sense
17:07 erisco joined
17:07 <geekosaur> re laziness, spreadsheets helped me more there, fwiw.
17:07 <geekosaur> because "laziness" is really demand driven evaluation, and spreadsheets do that by default
17:08 <ocharles> robkennedy: I've had luck with xml-conduit in the past
17:08 <Cale> Yeah, I'd used spreadsheets as well, but I'd never had a spreadsheet that was involved enough that I had to worry about what order it was being evaluated in.
17:08 mda1 joined
17:08 Ayey_ joined
17:09 <ocharles> Cale: do you still have the source to that bot?
17:09 <Cale> Probably not... I think it would have been on the hard drive that really died.
17:10 <Cale> I have a bunch of stuff that's on a hard drive I merely don't have in any machine, and which I should rescue though.
17:10 <ocharles> just thought it could be interesting to see that fairly atypical approach to writing a bot :)
17:12 vlatkoB joined
17:12 <dminuoso> This may sound like a really silly question, but when you do fmap (+1) (Just 1) -> does this imply that Just is a functor or how is it know how fmap is applied to Just?
17:12 <Cale> Maybe is a functor
17:12 <nak> is anyone interested in entertaining me with a discussion about EitherT (and perhaps monad transformers in general) ?
17:12 oisdk joined
17:12 <Cale> dminuoso: As for how it selects the implementation of fmap based on the type, that's just what type classes do
17:13 <Cale> There's an instance:
17:13 <Cale> instance Functor Maybe where
17:13 <Cale> fmap f Nothing = Nothing
17:13 <Cale> fmap f (Just x) = Just (f x)
17:13 Guest_ joined
17:13 <dminuoso> and.. fmap func (Just val) = Just (func val)
17:13 <dminuoso> yeah
17:13 Rainb joined
17:13 <erisco> once upon a time there was EitherT. EitherT had a hard time making friends with the other transformers because of his indecisiveness.
17:14 <nak> erisco: ^_^
17:14 padre_angolano joined
17:15 coot joined
17:16 AndreasK joined
17:16 <nak> if i have someMonad of someEither (m e), i am under the impression i can use EitherT M (where M is the type of m) to make it easier to work with the nested monads
17:16 <nak> my first question: is this understanding correct
17:16 <dolio> Cale: By the way, do you know if there's some `coend -| ??? -| end` characterization? The obvious thing to try doesn't really work, because dinatural transformations don't compose in general.
17:17 <erisco> :t EitherT
17:17 <lambdabot> error:
17:17 <lambdabot> • Data constructor not in scope: EitherT
17:17 <lambdabot> • Perhaps you meant variable ‘either’ (imported from Data.Either)
17:17 aarvar joined
17:17 <dolio> And extranatural transformations don't even make sense to compose, really.
17:17 <erisco> EitherT :: m (Either a b) -> EitherT a m b
17:17 <ski> @kind ExceptT
17:17 <lambdabot> * -> (* -> *) -> * -> *
17:18 <erisco> so the understanding is, if you have a Monad full of Either, you can lift this to EitherT
17:18 <nak> erisco: ok so EitherT is a wrapper for our Monad containing our Either
17:19 <nak> yes ok cool
17:19 <ski> nak : if `M' has kind `* -> *', then it can't be the type of a value
17:19 <Cale> dolio: No idea.
17:19 kshukla left
17:19 Netwolf_ joined
17:20 ragepandemic joined
17:20 vydd joined
17:20 vydd joined
17:20 <nak> erisco: so i have some function f that gives me an (m e) -- would the first step to working with that be (EitherT . f) in order to put (m e) into the EitherT wrapper ?
17:21 tromp joined
17:21 <erisco> what is e? it has to unify with m (Either a b)
17:21 <nak> e is a Left or Right
17:22 <nak> an "instance of Either" is the way my brain is thinking about it
17:22 <nak> but that's probably wrong
17:22 <* ski> isn't sure whether nak's `e' is a value or a type
17:22 intx left
17:22 <erisco> I don't understand because Left and Right are constructors, so m Left or m Right don't make any sense presuming m is a type var for a Monad
17:23 oish joined
17:23 <nak> i mean like Foo (Left a) or Foo (Right b)
17:23 <erisco> okay, and so Foo is a constructor?
17:24 Rodya_ joined
17:24 <nak> yea
17:24 <erisco> what is the type of Foo (Left a) given a :: t ?
17:24 <nak> uh...
17:25 <nak> FooType (Either e a) ??
17:25 <erisco> lets start with the type of Foo, what is that?
17:25 <mutsig> nak: How does your data-type declaration look like? "data FooType = Foo a" or "data FooType a = Foo a"
17:25 <* ski> would like to see a more concrete example nak would like help with
17:26 <erisco> I'd let you hand-wave but I think that is missing exactly what we want to talk about
17:26 <Cale> dolio: http://math.stackexchange.com/questions/709838/does-the-coend-have-a-right-adjoint
17:27 plugin joined
17:27 <nak> ok let's make FooType "Maybe" in this example - i'm just trying to talk about a monadic value of another monadic value
17:27 <nak> Just (Left a), Just (Right b)
17:28 <nak> so type of Maybe (Either e a), rigtht ?
17:28 jchia joined
17:28 <Cale> nak: Usually it's not worth focusing too hard on the fact that some type is a monad.
17:28 mstruebing joined
17:28 <erisco> if a :: e and b :: a, yes
17:28 <ski> assuming `a :: e' or `b :: a', yes
17:28 <nak> ah, Just (Left e), Just (Right a)
17:28 <nak> ok ^_^
17:29 <ski> then `e :: e' respectively `a :: a' :)
17:29 <Cale> I mean, there are cases where you will need to know that, and of course, if you want to write something that works with an arbitrary monad, that's all you get to assume, but usually there will be many other operations around
17:29 <ski> (value variables and type variables living in different name spaces)
17:29 <nak> yeah lots of overwhelming things !
17:29 <erisco> so now EitherT (Just (Left a)) :: EitherT e Maybe a
17:29 igniting joined
17:30 _deepfire joined
17:30 replay joined
17:30 <nak> and EitherT (Just (Right a)) :: EitherT e Maybe a
17:31 <nak> yes ?
17:31 <erisco> if a :: a, yes
17:31 tag joined
17:32 <nak> v_v
17:32 <nak> i guess i don't understand
17:32 plugin joined
17:33 SpinTensor joined
17:33 mson joined
17:33 <erisco> you said something correct but you don't understand? are we in the Chinese room? :P
17:33 <nak> well i was not certain with my guess !
17:34 oisdk joined
17:34 <erisco> you just follow the types
17:34 <erisco> you know the type of EitherT and the type of Just (Left a)
17:34 <erisco> and you know the rule for the type of application
17:35 <erisco> i.e. f :: a -> b, x :: a ---> f x :: b
17:35 <ski> (unfortunately, imho, the data constructor is here called the same as the type constructor. which can muddle up things in your mind, if you're not clear on the distinction to begin with)
17:35 <nak> ski only partially clear on it
17:36 <erisco> ah, well if you are not clear on values versus types we need to start there
17:36 fotonzade joined
17:36 sanitypassing joined
17:36 <erisco> EitherT (Just (Left a)) :: EitherT e Maybe a what is the EitherT on the left versus the EitherT on the right?
17:37 <nak> EitherT on the left is a data constructor
17:37 <erisco> yes, and what is EitherT on the right?
17:38 <nak> EitherT is a type constructor on the right, binding m :: Maybe in EitherT e m a
17:38 <* nak> crosses fingers
17:38 <* nak> waits in anticipation
17:38 <erisco> yes, and so in general the names on the left of :: are in a different namespace than names on the right of ::
17:39 wildlander joined
17:39 <erisco> and by "in general" I mean "always"
17:39 mmachenry joined
17:39 <nak> mm wakarimashita
17:39 <okeuday_bak> hackage.haskell.org user account creation requires manual approval, right?
17:39 <erisco> so seeing things of the same name on both sides never says they are the same thing, in fact they are always different
17:39 <halogenandtoast> nak: 本当に
17:39 <erisco> this is why in Haskell we're allowed to give data constructors the same name as type constructors
17:39 wildlander joined
17:39 <erisco> whereas in other languages, such as Idris, we cannot
17:39 <nak> ok erisco so some data constructors and some type constructors can have the same name ?
17:40 <erisco> yes, because they are different name spaces
17:40 <erisco> the EitherT on the right of :: can never refer to the data constructor, because that is always on the left
17:40 <nak> halogenandtoast: my jp is like level zero... sumimasen :(
17:40 <erisco> and vice versa
17:41 <nak> erisco: ok that's already a huge point of confusion cleared up
17:41 <nak> re: type/data constructors can have the same name
17:41 <nak> so: data Person = Person { name :: String }
17:41 <nak> gives us a Person TYPE and a Person DATA constructor
17:41 <nak> there is no type *constructor* here tho
17:41 <nak> just a type
17:42 <erisco> well I am not sure what the official definition of type constructor is, but sure
17:42 <nak> mm
17:42 <nak> ok
17:42 <erisco> Nothing is a data constructor but takes no arguments
17:42 <erisco> so similarly, Person is a type constructor
17:42 <erisco> but maybe the official terminology does not have this similarity, I don't know
17:42 <* nak> nods
17:42 <erisco> it is a minor pedantic point
17:42 <Cale> You can tell something is a type or data constructor because it will start with an uppercase letter
17:43 <dolio> Except type aliases/families ruin that.
17:43 <Cale> ah, right
17:43 fridim_ joined
17:43 <Cale> That's actually really unfortunate
17:43 <dolio> Yeah.
17:43 <nak> rip
17:43 mmn80 joined
17:44 <nak> ok so we have some function f :: Maybe (Either e a)
17:44 <nak> erisco: and now we wanna do something cool with it
17:44 <nak> like i dunno, map over the inner either
17:44 castlelore joined
17:44 castlelore joined
17:44 <erisco> well that is not a function, but go on
17:44 <nak> ah sorry,
17:44 <nak> let me get that straight
17:45 <nak> f :: Int -> Maybe (Either String Int)
17:45 Luke_ joined
17:46 fridim_ joined
17:46 Netwolf_ left
17:46 <nak> possible values might look like Just (Left "no way") or Just (Right 5) or Nothing
17:46 <nak> do those fit ?
17:46 Netwolf joined
17:46 <erisco> no, because neither of those have a function type
17:46 <nak> i meant return values of the function
17:46 kadoban joined
17:47 <Cale> sure
17:47 <erisco> still no, because those are Either (Either a b) (Either c d)
17:47 <Cale> er, what?
17:47 <* erisco> was hit on the head
17:47 <erisco> I kept reading "Just" as "Right" oO
17:47 sphinxo joined
17:48 <* nak> waits for the dust to settle
17:48 Vzox01 joined
17:48 <erisco> yes it looks fine nak
17:48 <nak> mm ok
17:49 sssilver joined
17:51 Swizec joined
17:51 conal joined
17:52 raynold joined
17:52 JagaJaga joined
17:52 <nak> so if we want a monad that can behave both as Maybe and as Either, we might reach for EitherT to compose both behaviours in one
17:53 <ski> the monad would be `EitherT String Maybe' in this case
17:53 <nak> like data MaybeEither e a = EitherT e (Maybe a)
17:53 <ski> (`Either' is not a monad, but `Either e', for any type `e', is)
17:54 <ski> you're missing a data constructor, but sure
17:54 <nak> ah ok that makes more sense
17:54 <nak> mmm ok let me try to fix
17:54 <nak> data MaybeEither e a = MaybeEither EitherT e (Maybe a)
17:54 <ski> (or perhaps you wanted a type synonym instead ?)
17:54 wraithm joined
17:55 <dminuoso> Cale: Well it's certainly interesting, something must be inherently different about this. But I guess I should stop thinking about Haskell in terms of other common object oriented languages.
17:55 <nak> (unsure, but basics are preferred at the moment. i'm such a scrub noob)
17:55 <* ski> is a fan of naming the data constructor by prefixing `Mk' to the type constructor, in case there's only a single one, and no better name suggests itself
17:56 <ski> `data' (and `newtype') defines a new type (the type constructor you invent, applies to any type parameters)
17:56 <davean> dminuoso: Almost everything is inherantly different, Haskell isn't an object oriented language, and there a few things people think have similarities but they're also different then any "objects" I've ever come across
17:56 <ski> `type' just gives a synonym name to an existing type
17:57 freechips joined
17:57 fnurglewitz joined
17:57 <nak> ok but the declaration i have above is OK, ski ?
17:57 <ski> it is
17:57 <davean> dminuoso: Almost nothing from OO languages really applies
17:57 <nak> (i'm ok with learning the nuances of data/type/newtype later)
17:57 <erisco> I don't like when I have to use a Mk* name... I am thinking of using Mc* instead because that is what I think of
17:58 <* ski> smiles
17:58 <ski> @src String
17:58 <lambdabot> type String = [Char]
17:58 <ski> @type words
17:58 <lambdabot> String -> [String]
17:58 <ski> means the same thing as
17:58 <ski> [Char] -> [[Char]]
17:58 <erisco> and somehow find an excuse for McDouble :: Double
17:58 <nak> lol
17:58 <ski> `String' is just a shorthand (or what you want to call it) for `[Char]'
17:59 <dolio> If you want to follow Double's naming convention, you should postfix a # on the constructor name.
17:59 <dolio> Although I think it's D#, not Double#.
17:59 <ski> you gain no extra checking by using a type synonym
17:59 <Cale> dminuoso: If you're going to relate type classes to anything in Java, the closest thing would be interfaces.
17:59 raichoo joined
18:00 <monochrom> Corollary: F# is a subset of Haskell. :)
18:00 <nak> ok so given my new MaybeEither type, can i work with my values (eg) Just (Right 5) more easily ?
18:00 <Cale> dminuoso: But there's an important difference: with type classes, the information about how the operations are implemented travels separately from the values, which allows things like this:
18:00 conal joined
18:00 <Cale> :t read
18:00 <lambdabot> Read a => String -> a
18:00 <ski> nak : the opposite. you have to peel away the extra data constructor layer, to "get to" the actual information-bearing content
18:01 <Cale> Here, for any type a which is an instance of the type class Read, the function will take a String, and produce a result of type a
18:01 <monochrom> erisco: I like Mk, but I don't mind Mc.
18:01 <monochrom> newtype Cont r a = McCont{unCont :: (a -> r) -> r}
18:01 <ystael> Mc in the sense of "son of"?
18:01 <monochrom> Also do you have a preference on what to rename unCont to?
18:02 <ski> nak : sorry, i just noticed the pair of brackets in your declaration should go
18:02 <Cale> (well, there are also lots of other differences, but that's a start :)
18:02 <Cale> dminuoso: Monad is hard to capture in settings without proper type classes because of the type of return:
18:02 <Cale> :t return
18:02 <lambdabot> Monad m => a -> m a
18:02 <erisco> I am alright with that one so I haven't made a joke for it ;)
18:02 <ski> nak : .. however, library operations that are polymorphic in a monad (like `mapM_', e.g.) will apply to this new monad `EitherT e Maybe' (or to `MaybeEither e m', if you make that an instance of `Monad' as well), in a *useful* way
18:02 <Cale> It's polymorphic again in the type of the result of the function.
18:03 <* ski> . o O ( `sunCont' )
18:04 connrs joined
18:04 subttle joined
18:05 <monochrom> ski, I have a personal preference I haven't said. I want the constructor and the selector to have the same prefix length. So, whereas I add two letters to the constructor, I also want to just add two letters to the selector.
18:07 jchia joined
18:07 <monochrom> erisco: Actually, what would you think of putting the Mk after? ContMk?
18:08 <erisco> I actually like that more
18:08 <monochrom> I just thought up another one. ContOf. How about that one?
18:08 <erisco> makes it easier to read an expression when the significant part is first
18:08 pwnz0r joined
18:09 <erisco> that is better yet :)
18:09 <erisco> one I have been using is "Form"
18:10 <monochrom> I am now thinking of the pair ContOf and deCont. Because "ContOf (\k -> k 1)" is "I make a Cont out of the following...", and "deCont xxx" is "I strip away the Cont wrapper"
18:10 <erisco> because that is a common phrase: "forms a monoid"
18:11 <erisco> but you can also say "a monoid consisting of"
18:12 magneticduck joined
18:12 <monochrom> Now I'm splitting hair between "un" and "de"...
18:12 <erisco> "of" is shorter and makes for a good suffix, which is superior to a prefix imo because it is less significant
18:12 {emptyset} joined
18:12 conal joined
18:13 <erisco> though "of" could be argued for the type as well
18:13 <erisco> EitherOf Int String
18:13 <monochrom> Yeah, it is inspired by "newtype Double = D# ...", except the "#" suffix is better reserved for primitives. But the suffixing idea is good.
18:14 <erisco> ContOf Int String
18:14 osa1 joined
18:14 osa1 joined
18:15 <Tuplanolla> Would that prefix eventually lead to `deCreate` or `deStroy`?
18:15 scope joined
18:16 mcafee joined
18:16 <monochrom> Oh w00t! Rationalization of ContOf: In SML you write "datatype Shape = Square of Double | Rectangle of ..."
18:16 <dolio> deLaMancha
18:17 <scope> Hey guys, I have some code to paste and a noobie question
18:17 <geekosaur> @paste it and ask
18:17 <lambdabot> Haskell pastebin: http://lpaste.net/
18:17 <geekosaur> you don;t have to ask to ask here
18:17 <erisco> if you have a non-nullary type constructor then maybe consider the suffix "On"
18:17 machinedgod joined
18:17 <monochrom> I don't have a Stroy type or a Create type. I don't know what "stroy" is, and "create" is better a function name than a type name.
18:17 <scope> I'm trying to figure out how to do the closestPair function at the bottom, and having a really hard time working through the logic http://lpaste.net/493703887925018624
18:17 <scope> I'm extremely new to haskell and don't fully understand syntax
18:18 <erisco> when you are working in a dependent system I don't think it is necessarily a bad idea to easily distinguish type and data constructors with suffixes
18:18 <erisco> a Hungarian notation
18:19 <erisco> because you have things "on a domain"
18:19 <scope> I'm assuming I need to use the closerPair function.
18:19 <erisco> and you have elements "of a domain"
18:19 ubsan_ joined
18:20 <erisco> so newtype ContOn r a = ContOf { deCont :: (a -> r) -> r }
18:20 curious_corn joined
18:20 <scope> I was trying to do something along the lines of this but the syntax is all kinds of messed up (closerPair(p1,p2) p1 <- pairsFromPoints(points), p2 <- pairsFromPoints(points), p1 /= p2)
18:22 animated_ joined
18:22 <erisco> it wouldn't have to be used everywhere, but just for the circumstances where you'd otherwise have the data and type constructors have the same name
18:22 <scope> So I have a function that gives me every possible pair of points, and I need to find the two points that are the closest together coordinate-wise
18:23 <monochrom> erisco: Yeah, good idea.
18:23 oisdk joined
18:24 mizu_no_oto_work joined
18:25 ompaul joined
18:25 <erisco> scope, okay, I sort of see what your thinking is
18:25 fotonzade joined
18:26 <erisco> scope, you're trying to express "forall points p1, p2 in pairsFromPoints points where p1 ≠ p2, closerPair p1 p2"
18:26 <erisco> which doesn't really make much sense but is in the ballpark
18:26 mizu_no_oto joined
18:26 <scope> right, so closerPair takes two pairs of points and finds which of those two pairs is the closer together
18:26 <erisco> it makes sense up to the proposition closerPair p1 p2
18:26 <scope> so I need to iterate through the list of all pairs and find the two closest
18:27 <erisco> okay, let me start with a simpler example
18:27 <erisco> say I have a list of numbers [5,2,7,3] and I want to find the smallest one, how can I do that?
18:27 <scope> minimum
18:27 <scope> I was trying to do something with minimumBy but I don't understand it
18:28 <erisco> okay, what did your attempt with minimumBy look like?
18:28 guampa joined
18:28 <scope> I'll paste it one sec
18:28 <scope> http://lpaste.net/4702265186482913280
18:28 <monochrom> minimumBy would make closerPair useless and make you write a comparator for Pairs instead.
18:29 <scope> sqDistance takes in two points
18:29 <monochrom> And the biggest pain is that the comparator pretty much duplicates closerPair's algorithm.
18:29 <scope> so that doesn't really work
18:29 <scope> gotcha, so I guess I just don't really know how to go about using closerPair
18:29 <monochrom> If you already have closerPair, you're better off using recursion for closestPair and using closerPair as a helper.
18:29 <erisco> well, I know there is another way to do this monochrom, I just don't know if busting out a fold is the right thing
18:30 <scope> I was debating using recursion, but like I said I'm a huge noob when it comes to Haskell
18:30 <monochrom> But we don't have to bust out fold. We can write our own recursion.
18:30 <erisco> well I am not going to compete for ways to solve the problem, I don't care :P
18:31 conal joined
18:31 <erisco> what method fancies you scope?
18:31 <scope> I'm pretty sure I need to first create the list of all pairs, then use closerPair within closestPair
18:31 <scope> I think recursion would probably work
18:31 `^_^v joined
18:31 subttle joined
18:31 conal joined
18:32 <erisco> okay cool, we'll do the recursive solution with closerPair and then if you're interested we can also do the minimumBy and fold solutions for comparison
18:32 <monochrom> You already have pairsFromPoints.
18:32 <scope> monochrom right, I just don't know how to use that within closestPair
18:32 <scope> but sure I just want to understand how to get this function to work
18:32 <erisco> what does your attempt at the recursive solution look like?
18:33 <scope> I honestly haven't tried yet, I've been fighting with other solutions
18:33 <monochrom> closestPair points onepair = let allpairs = pairsFromPoints in ...
18:33 hiThisIsMe joined
18:33 <monochrom> err
18:33 <monochrom> closestPair points onepair = let allpairs = pairsFromPoints points in ...
18:33 pkoshy joined
18:33 <erisco> okay, so for recursion we want to write a definition for each case
18:33 <monochrom> err, wrong number of parameters
18:34 <monochrom> closestPair points = let allpairs = pairsFromPoints points in ...
18:34 <erisco> closestPair :: [Point a] -> Pair a so we're taking a list of points
18:34 <erisco> are you going to do this monochrom? I'll step out
18:34 <monochrom> No, I have to go.
18:35 <scope> thanks anyways mono
18:35 <erisco> okay, and I have maybe 15 min
18:35 <scope> that's fine as lone as I can get a start
18:35 tag joined
18:35 <erisco> so what are the cases of list?
18:35 <scope> so with mono's answer, what would come after the "in"? closestPair points = let allpairs = pairsFromPoints points in ...
18:35 marsam joined
18:36 <scope> what do you mean?
18:36 <erisco> okay, similar example, say I want to define length for lists
18:36 <erisco> then my cases are empty list, i.e. [], and cons, i.e. (x:xs)
18:36 <erisco> length [] = 0; length (x:xs) = 1 + length xs
18:36 <erisco> this is what a recursive definition looks like
18:37 <erisco> there is some base case and some recursive case (or many of each)
18:37 <erisco> what is the base case for closestPair?
18:37 Levex joined
18:37 <scope> I would guess null if there aren't any points in the list?
18:37 <erisco> or the "stopping case" or "stopping condition" or whatever you want to call it
18:38 <erisco> Haskell doesn't have null
18:38 `^_^v joined
18:38 <scope> when it reaches the end of the list rather
18:38 <erisco> but that is a good thought, what if the list is empty
18:38 <erisco> well if the list is empty we cannot return a Pair a, can we, because we have no pairs
18:38 <erisco> so there are two things we can do
18:38 <erisco> option 1 is to accept that closestPair is a partial function
18:39 <scope> I'm treating it as a partial function
18:39 <erisco> option 2 is to change the type, so perhaps closestPair :: [Point a] -> Maybe (Pair a)
18:39 <erisco> or closestPair :: NonEmpty (Point a) -> Pair a
18:39 <erisco> okay, so we're going to be partial
18:39 <ski> monochrom : *nod*
18:39 cur8or joined
18:39 <erisco> then we will just ignore the case where the list is empty
18:39 <scope> right
18:39 Kreest__ joined
18:40 <erisco> the effect of this is that evaluating on an empty list will give us bottom, which is the null of Haskell, if there was one
18:40 <erisco> we still need a base case though, so what is that
18:40 <dolio> It's not null, though.
18:40 wraithm joined
18:40 <erisco> it is absolutely not and don't let me confuse you into thinking it is :P
18:41 <scope> I guess when it reaches the last pair returned by pairsFromPoints
18:41 <scope> not sure how to put that into the right words
18:41 <erisco> a list of one element, or a singleton list
18:41 <erisco> what is the pattern for that?
18:41 dennisvennink joined
18:42 <scope> do you have my code open somewhere or should I paste again?
18:42 <erisco> I have it open
18:42 <scope> Man like I said I'm so new to this. I came from entirely OOP languages
18:42 <erisco> I'll make life a bit easier and change the type like this scope http://lpaste.net/353644
18:43 <scope> I can't change the types, have to deal with them as they are
18:43 <erisco> so we're operating on a list of pairs, not a list of points
18:43 <erisco> well okay, I made an edit
18:44 <erisco> if we define closestPair', then closestPair = closestPair' . pairsFromPoints
18:44 <scope> do you know what mono was going for with his partial solution? what he was doing interests me
18:44 <erisco> if he was thinking of recursion then I am doing the same thing
18:44 <scope> Ok
18:45 pie__ joined
18:45 <monochrom> yeah
18:45 <erisco> he might have juggled things a bit differently but it will be the same concept
18:45 JagaJaga joined
18:45 <erisco> the pattern for a list of one element is (x:[]) or [x]
18:45 <scope> right that much makes sense
18:45 <erisco> so closestPair' [x] = ? fill in the blank
18:46 peterbecich joined
18:46 <scope> x?
18:46 <erisco> looks good
18:47 pwnz0r joined
18:47 <erisco> so we have, for example, closestPair' [Pair (1,2) (3,4)] = Pair (1,2) (3,4)
18:47 levex_ joined
18:47 <erisco> now we need the recursive case, any ideas what that should be?
18:47 averagehat___ joined
18:47 Unhammer joined
18:47 <scope> not a clue, I've never been great with recursion and its a bit harder for me with haskell
18:48 <erisco> okay, so we're trying to span all lists
18:48 <erisco> except the empty one
18:48 <erisco> so we have covered a list of one element
18:48 <erisco> if we also cover a list with two or more elements, we'll have covered all non-empty lists
18:48 skeuomorf joined
18:48 <erisco> the pattern for this is (p1:p2:ps)
18:49 <erisco> so we have closestPair' (p1:p2:ps) = ? what is the blank here?
18:50 <srhb> cd
18:50 <srhb> woops
18:50 <* erisco> prints the help text for cd
18:50 IRCFrEAK joined
18:50 <scope> lol
18:50 <scope> erisco I'm not sure.
18:50 <srhb> erisco: That's not what no argument cd does!
18:50 <erisco> this is why I am not a sys admin
18:50 <srhb> :-)
18:51 <erisco> scope, okay, well we can start with closerPair p1 p2, yes?
18:51 ij left
18:51 <scope> sure
18:51 ali_bush joined
18:51 marsam joined
18:51 IRCFrEAK joined
18:51 <erisco> alright, so we find the closer of these two pairs and we still have the rest of the list left
18:51 <scope> right
18:51 <erisco> so our question now is: what is the closest pair out of closerPair p1 p2, and the rest of the list, right?
18:52 <scope> Yes.
18:52 <erisco> how can we solve that?
18:52 <scope> p1:p2:ps like what you were saying before?
18:52 nycs joined
18:52 <pkoshy> Why are there so many people in this channel? In terms of users in language related channels, it is second only to python at the moment. I didn't really expect that
18:52 mattyw joined
18:52 <erisco> well (p1:p2:ps) is a pattern
18:53 <erisco> if we write p1:p2:ps on the right of the = then this just rebuilds the list we started with
18:53 <scope> so we just want ps then?
18:53 <pkoshy> Is haskell having some kind of renaissance or something?
18:53 <erisco> but we don't want that list, because we've just reduced it by finding the closer of p1 and p2
18:53 <erisco> well, what about closerPair p1 p2?
18:53 <erisco> if we just use ps then we're forgetting the closer of p1 and p2, and one of those may actually be the minimum
18:53 <Cale> pkoshy: #haskell has been one of the largest channels on freenode for several years now
18:54 <erisco> scope, let me spark your imagination a bit and suggest closerPair p1 p2 : ps
18:54 <erisco> what can we do with this list?
18:54 <pkoshy> Cale: had no idea...I'm impressed I guess? It has been of interest to me personally but is it used much in industry?
18:54 shayan_ joined
18:55 <erisco> note that that is (closerPair p1 p2) : ps
18:55 <Cale> pkoshy: Well, we use it where I work, at least. :)
18:55 <erisco> if we make that list, we want to find the closest pair in that list, yes? do we have a function which can do that?
18:55 <scope> closerPair?
18:55 supki joined
18:55 <pkoshy> Cale: Interesting - thank you for the info
18:55 <Cale> pkoshy: It's used somewhat in industry -- could probably stand to be more popular.
18:56 <frontendloader> pkoshy: people like me are hoping to one day understand what a Monad is
18:56 <erisco> scope, I am thinking of a function f so we can write f (closerPair p1 p2 : ps)
18:56 <pkoshy> heh
18:56 <frontendloader> beyond "simply a monoid in the category of endofunctors"
18:56 <geekosaur> pkoshy, for one example: there's a fair amount of direct and indirect interest from Javascript programmers, because Haskell's do notation turns out to be a good way to write callback-based programming without explicitly writing callbacks all over the place
18:56 <Cale> The company I'm working for, Obsidian Systems, makes web applications for various clients, and we use Haskell both for the frontend (compiled to Javascript using GHCJS) and for the backend (using Snap)
18:56 <erisco> scope, remember closerPair p1 p2 : ps :: [Pair a]
18:57 <pkoshy> geekosaur: Interesting. Good to know
18:57 <scope> I'm struggling so hard to follow, sorry erisco
18:57 <scope> I know this must be frustrating for you
18:57 <Cale> We also compile our frontends for iOS and Android using GHC's ARM support.
18:57 <geekosaur> so there are haskell to javascript compilers, and various Javascript derivatives that are inspired by Haskell
18:57 <erisco> yeah I am going a bit quick because my time is limited ^.^
18:57 <erisco> no it is not frustrating
18:57 IRCFReAK joined
18:57 <ggVGc> pkoshy: there is one notable use of haskell in "industry" and it's the entire anti-spam system of facebook. They rewrote it because of performance issues of the earlier one, and to be able to create a type safe DSL for non-programmers to use for making the spam rules
18:58 <ggVGc> and it's been a huge success for them
18:58 <erisco> let me describe what I want to do with this algorithm
18:58 <ggVGc> they also contributed some much needed improvements to GHC while doing it
18:58 <erisco> I have a list of points, say it is [p1,p2,p3,p4,...]
18:58 <Cale> (Rather nice that you can have one piece of code which gets compiled to Javascript and also to native code)
18:58 <ggVGc> because it turned out haskell was not completely ready for large scale use like that, until they fixed it
18:58 bennofs joined
18:58 <ggVGc> pkoshy: https://www.youtube.com/watch?v=sl2zo7tzrO8
18:58 <ggVGc> that's a very good talk
18:58 <scope> erisco right
18:58 <erisco> what if I found the minimum of the first two elements? of p1 and p2, call it px
18:59 <pkoshy> All very interesting info - thanks everyone. I honestly had no idea it was used
18:59 <erisco> well then I know that the minimum of the whole list must be found in [px,p3,p4,...]
18:59 <erisco> so by doing this I have just made the list smaller
18:59 <erisco> and I can keep doing this, by now finding the minimum of px and p3, call it py
18:59 <erisco> now I have [py,p4,...]
18:59 <erisco> and I can keep going until the list has only one element (our base case)
19:00 <scope> Right, see I understand that. Putting it into code is what is slowing me down
19:00 wtetzner joined
19:00 <erisco> so, because I have to go, what I would write is closestPair' (p1:p2:ps) = closestPair' (closerPair p1 p2 : ps)
19:00 twanvl joined
19:01 <scope> alright I'll give it a shot, thanks for your help!
19:01 <erisco> run through a few examples using equational reasoning and see what happens
19:01 <Cale> pkoshy: I can honestly say I'd never want to go back to building web applications any other way. Sharing data types and common logic between the frontend and backend, ensuring that for example, you never have issues with JSON encoding mismatches is so nice.
19:01 <erisco> good luck and talk to you later :) if you figure this out and want we can later go over the minimumBy and fold solutions
19:02 <pkoshy> Cale: I've heard good things about clojure/clojurescript that I think fits into that problem space
19:02 <pkoshy> Cale: Someone at my former company swears by it
19:02 <Cale> Nevermind the fact that we're using a really nice functional reactive programming system (reflex-dom) in our frontends which makes it really easy to do live-updating stuff everywhere, and generally makes GUI programming pretty fun.
19:03 animated_ joined
19:03 <Cale> (I actually enjoy frontend work more than backend most of the time now! CSS is still annoying though.)
19:04 livingbeef joined
19:04 rodarmor joined
19:04 IRCFReAK joined
19:04 <dopey_> anyone know of a haskell http server that has an interface to the underlying socket during request handling?
19:05 <livingbeef> How do I run ghci in noninteractive mode?
19:05 Levex joined
19:05 conal joined
19:06 <livingbeef> nevermind, it's not really a problem
19:06 <cocreature> livingbeef: just run ghc instead of ghci?
19:06 curious_corn joined
19:07 <cocreature> livingbeef: if you want something that interprets instead of compiling your code first and the running it use "runhaskell"
19:07 <Cale> dopey_: Well, what kind of interface do you need?
19:07 <Cale> I think most of them provide *some* kind of interface ;)
19:07 IRCFReAK joined
19:07 nak left
19:09 <livingbeef> cocreature: that doesn't work for naked espressions at top level. Bug I can live with promts, I guess.
19:09 <livingbeef> *but
19:09 mohsen_ joined
19:10 <cocreature> livingbeef: iirc you can make ghci run a script and then exit
19:10 <cocreature> ghc -e ':script filename'
19:10 <dopey_> cale: pretty much I just want access to the socket (https://hackage.haskell.org/package/network- during request handling. I'm using Warp right now, and I *don't think* I have access to the socket from the "router"
19:11 <Cale> hmm
19:11 <Cale> Snap has a way
19:11 <Cale> Let me have a look
19:11 <dopey_> cheers. taking a look now too
19:12 <Cale> hmm, Warp has a way to specify which Socket it will use...
19:12 <livingbeef> cocreature: I guess runhaskell is the only option then, if I want to interpret text at hand. But I'll have to wrap it in main...
19:13 <cocreature> livingbeef: how does ghc -e not do what you want?
19:13 <cocreature> dopey_: you got me interested. what do you need this for?
19:13 Levex joined
19:13 <livingbeef> Then I'd have to create files and such, which is not ideal. But it's not a big deal.
19:13 conal joined
19:14 <dopey_> cale: right, but I think that's just when you start the server, no? after that I assume it assigns a new socket to each request
19:14 <cocreature> livingbeef: no you don’t. I thought you had a file. you can just run something like 'ghc -e "1 + 1"'
19:14 <geekosaur> livingbeef, you want a programmatic interface to interpretation? Look at the hint package
19:14 <geekosaur> note however that this is a separate interpreter not connected to your program, that is, changes made there do not affect your running program
19:14 IRCFReAK joined
19:14 <dopey_> cocreature: id like to be able to use the socket to do another layer of verification as to the source process making the request. basically getting the user id of the originating process
19:15 <dopey_> cocreature: i know that the process is local (or should be)
19:15 wraithm joined
19:16 <cocreature> dopey_: for security purposes?
19:16 conal joined
19:16 <dopey_> cocreature: yep
19:18 <cocreature> dopey_: cool, thanks for the explanation :)
19:19 IRCFReAK joined
19:19 <dopey_> cocreature: np. i want to get it working first and then explore the security merits, e.g. whether it can be spoofed
19:20 doodlehaus joined
19:21 IRCFReAK joined
19:22 <Jinxit> i seem to remember there being a good blog series on Free and how it can be used to make a DSL, does anyone happen to know which one i'm talking about?
19:23 tromp joined
19:25 Levex joined
19:25 ragepandemic joined
19:25 louispan joined
19:26 connrs joined
19:27 cyborg-one joined
19:27 louispan joined
19:27 IRCFReAK joined
19:27 oisdk joined
19:30 chaosmasttter joined
19:35 albertus1 joined
19:37 peterbecich joined
19:38 sepp2k joined
19:38 Wizek_ joined
19:41 peterbecich joined
19:41 IRCFReAK joined
19:42 oberstein joined
19:43 dmwit_ joined
19:43 peterbecich joined
19:44 IRCFReAK joined
19:44 doodlehaus joined
19:45 eschnett joined
19:45 Levex joined
19:45 IRCFReAK joined
19:47 lerax joined
19:48 luis joined
19:49 peterbecich joined
19:51 Rodya_ joined
19:51 IRCFReAK joined
19:52 peterbecich joined
19:53 MarioBranco joined
19:54 jsgrant_ joined
19:54 forgottenone joined
19:55 Levex joined
19:57 mda1 joined
19:58 dawehner joined
19:58 forgottenone joined
20:00 curious_corn joined
20:01 <jle`> ezyang: congrats! :)
20:01 <jle`> 🎉
20:02 mmachenry joined
20:02 conal joined
20:03 petervaro joined
20:04 oisdk joined
20:04 danvet joined
20:05 alx741 joined
20:05 IRCFReAK joined
20:05 acarrico joined
20:07 IRCFReAK joined
20:09 IRCFReAK joined
20:09 forgottenone joined
20:10 <ezyang> jle`: THanks :)
20:11 amit_r joined
20:11 <AWizzArd> I tried to write a Lens that would return me the nth element of a tree. The view works, and returns me the correct element. The over operation however does not return the whole tree, with that element changed. But instead it only returns me also the (now possibly changed) nth element.
20:12 <AWizzArd> Is there anything useful one can suggest me, without seeing the code?
20:12 IRCFReAK left
20:13 NeverDie_ joined
20:13 ramzifu joined
20:14 thc202 joined
20:14 <Cale> What is the type of the thing that you wrote?
20:14 <Cale> AWizzArd: ^^
20:14 Prutheus joined
20:15 IRCFReAK joined
20:15 <AWizzArd> Cale: nthElement :: (Functor f) => Int -> (Program -> f Program) -> Program -> f Program
20:15 IRCFReAK left
20:15 <Cale> ahh, harder to tell what's wrong because it's all Program
20:16 <AWizzArd> Yes, I guess there is not much anyone could tell me.
20:16 <AWizzArd> I was hoping that this is a kind of a „typical” mistake of Haskell/Lens beginners.
20:17 <Cale> I'm guessing that you just didn't make the function put everything back together correctly
20:17 <Cale> So, nthElement n f p
20:17 mettekou joined
20:17 <AWizzArd> Cale: yes, it’s correct. I was just writing the non-lens version of it. And tried to lensify it.
20:17 <Cale> is supposed to take apart p somehow, finding the nth element
20:17 <Cale> (whatever that is)
20:17 <Cale> and then apply f to it
20:17 mszczygiel joined
20:18 <Cale> and then put the rest of the structure back on surrounding that
20:18 marcopullo joined
20:18 <AWizzArd> I can easily write a function that traverses my tree/Program depth-first.
20:18 <Cale> Oh, also, if you can write the view and set
20:18 Tourist joined
20:18 Tourist joined
20:18 <Cale> there's a function you can use to make the lens
20:18 <Cale> :t lens
20:18 <lambdabot> Functor f => (s -> a) -> (s -> b -> t) -> (a -> f b) -> s -> f t
20:18 AKifer_ joined
20:18 cdg joined
20:18 <AWizzArd> Didn’t use that. I tried it first the more complicated way, via Functor.
20:19 <Cale> Here's an example of a lens:
20:20 <Cale> > let scnd f (x,y) = (\y' -> (x,y')) <$> f y in over scnd (+1) (10,20)
20:20 <lambdabot> (10,21)
20:21 <scope> Hey guys, I'm trying to create a list in an if then else by doing this http://lpaste.net/8165899308453855232
20:21 <Cale> So, the pattern to note is that the argument to <$> here is kind of like our original pair (x,y), only with a hole in it
20:21 <scope> what's wrong with my syntax?
20:21 <Cale> That is, the first argument is
20:21 ramzifu joined
20:21 <AWizzArd> Okay thanks, I will study this example.
20:21 owiecc joined
20:21 <Cale> and the second argument to <$> is just the function applied to the thing which was in that hole
20:22 <mauke> scope: it looks like you're trying to use statements or something
20:22 <mauke> scope: haskell doesn't have those. the syntax is 'if <expr> then <expr> else <expr>'
20:22 <AWizzArd> Cale: and what is this „in”?
20:22 <Cale> scope: several things
20:22 conal joined
20:22 <Cale> AWizzArd: let <declarations> in <expr>
20:22 <scope> welp
20:22 <mauke> AWizzArd: 'let <definitions> in <expr>' defines local variables for use in one expression
20:23 <AWizzArd> Aah, _this_ in. Okay.
20:23 <scope> ok thanks
20:23 <Cale> scope: Okay, so first of all, line up the 'then' and 'else' just to be safe
20:23 <Cale> secondly, perhaps you want a let
20:23 <scope> super new to Haskell so apologies for the terrible formatting/syntax
20:24 <scope> I tried to use a let but that told me it needed to be in a do block?
20:24 <Cale> but... I don't really understand what line 5 is supposed to be
20:24 <mauke> 'let' needs to be followed by 'in' normally
20:24 <Cale> > let x = 5 in x * x
20:24 <lambdabot> 25
20:24 <mauke> exceptions are 'do' blocks and list comprehensions
20:24 <Cale> scope: What is the context of this code?
20:24 al-damiri joined
20:25 <Cale> scope: Is this part of a function declaration?
20:25 <scope> one sec I'll paste the rest
20:25 <Cale> scope: Why define allDirections to be [] and then write allDirections ++ ..., rather than just writing [] ++ ...
20:25 unit73e joined
20:26 <Cale> scope: and of course, appending an empty list isn't going to change much :)
20:26 <Cale> scope: In Haskell, if something is equal to something else, it means you can substitute one for the other, just like in algebra
20:26 <scope> lpaste is frozen for me, won't load
20:27 <Cale> seems to load for me
20:27 Levex joined
20:27 <Cale> lpaste.net, right?
20:27 <scope> here's the context http://lpaste.net/1955896736157270016
20:27 <mauke> what's allDirections?
20:28 <scope> the list of all of the results from lineSide
20:28 <scope> to be used later
20:28 <Cale> scope: Nope...
20:28 <Cale> scope: Well, you might want it to be
20:28 <Cale> scope: But in that case, you should define it to be such a list
20:28 <scope> it needs to be, as I need to check whether all of the results of lineSide are either <= 0 or >= 0
20:28 <Cale> okay
20:28 IRCFReAK joined
20:29 <mauke> it looks like you're trying to call a function on each element of a list
20:29 <* mauke> is now known as Clippy
20:29 <Cale> So, which parameters should we supply to lineSide?
20:29 <scope> a point from the points list, and edge
20:29 <scope> both coming from isHullEdge
20:29 <Cale> scope: for each of the points?
20:29 <scope> yes
20:29 <Cale> Perhaps we should use a list comprehension, just for fun. We could also use map
20:30 <scope> I barely have any grasp on haskell as I'm sure you can tell lol
20:30 <Cale> [lineSide edge point | point <- points]
20:30 Levex joined
20:30 <mauke> scope: do you know any other programming languages?
20:30 <mauke> (my guess: yes)
20:30 <scope> Yes, all OOP though
20:30 <mauke> which ones?
20:30 <scope> C, C++, Java, some Ruby
20:31 <Cale> scope: So this will be the list which you wanted. Now what do you want to do with that list?
20:31 <scope> check that all of the values are either <= 0 or >= 0
20:31 <Cale> ah, okay
20:32 <Cale> So, perhaps a let will be appropriate
20:32 <scope> so are you saying set allDirections to [lineSide edge point | point <- points]?
20:32 forgottenone joined
20:32 <Cale> let allDirections = [lineSide edge point | point <- points]
20:32 <scope> ok
20:32 <Cale> in all (<= 0) allDirections || all (>= 0) allDirections
20:33 <scope> wow well that compiled
20:33 <scope> let me test to make sure it's working somewhat
20:34 IRCFReAK joined
20:34 <scope> wow, thank you very much Cale
20:34 Confusius joined
20:34 <scope> passes my tests
20:34 <Cale> cool
20:34 MP2E joined
20:34 <scope> I was making it much more complicated than I needed to
20:35 <Cale> You can also write
20:35 <Cale> allDirections = map (lineSide edge) points
20:35 <Cale> if you prefer
20:35 <scope> See that seems even easier, what exactly is happening there with the map?
20:35 <Cale> map :: (a -> b) -> [a] -> [b]
20:36 <Cale> is a function which, given a function, and a list of values to apply it to
20:36 <Cale> applies the function to all the values and gives a list of the results
20:36 aarvar joined
20:36 <Cale> map f [] = []
20:36 <Cale> map f (x:xs) = f x : map f xs
20:36 IRCFReAK joined
20:36 <scope> syntax for haskell still looks very alien to me
20:36 <scope> need to do more reading on it
20:37 <Cale> So that breaks the problem of defining map down into two cases: every list is either the empty list []
20:38 <Cale> or it's a nonempty list with some first element (say x) and some tail (say xs)
20:38 <scope> so another quick question, in "let allDirections = [lineSide edge point | point <- points]" what would the english equivalent of the pipe operator be?
20:38 <Cale> which we can write (x : xs)
20:38 <Cale> "where"
20:38 <scope> that's what I assumed, ok
20:38 <Cale> Or "such that"
20:38 <mauke> are you familiar with math notation for sets?
20:38 <scope> somewhat
20:38 <Cale> and "<-" can be read as "is selected from"
20:38 IRCFReAK joined
20:39 <mauke> { lineSide(edge, point) | point ∈ points }
20:39 <scope> ahhh ok, this IRC is helping me learn Haskell much easier than I would have otherwise
20:39 curious_corn joined
20:39 <Cale> > [(x,y) | x <- [1,2,3], y <- [4,5]]
20:39 <lambdabot> [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
20:39 <Cale> > [(x,y) | x <- [1,2,3], y <- [4,5], even (x + y)]
20:39 <lambdabot> [(1,5),(2,4),(3,5)]
20:39 <scope> You guys have been extremely helpful. But alright that makes sense Cale/mauke
20:40 <mauke> > [ show x ++ " is even" | x <- [1 .. 10], even x ]
20:40 <lambdabot> ["2 is even","4 is even","6 is even","8 is even","10 is even"]
20:40 <Cale> > [(x,y,z) | x <- [1..20], y <- [x..20], z <- [y..20], x^2 + y^2 == z^2]
20:40 <lambdabot> [(3,4,5),(5,12,13),(6,8,10),(8,15,17),(9,12,15),(12,16,20)]
20:40 <mauke> heh
20:40 subttle joined
20:40 <mauke> that might not be the most efficient way to brute force that
20:41 <Cale> Iterating over the choices of z is a bit foolish :)
20:42 IRCFReAK joined
20:42 <scope> hey if it works I'm happy
20:42 <scope> still learning
20:42 <Confusius> Quit
20:42 <scope> hahaha
20:42 <scope> tempting
20:42 <mauke> /quit
20:42 <scope> :q
20:43 <Cale> :wq
20:43 <mauke> :x > :wq
20:43 <Cale> scope: It's good to get to know how to manipulate lists early, because lists are effectively our loops.
20:43 k0ral joined
20:43 <scope> Cale: yeah I'm starting to realize that. Haskell isn't like any language I've ever used before, really difficult to wrap my brain around and rewire it
20:43 <Cale> Just as a loop either might not occur (because its precondition isn't met), or consists of an iteration followed by another loop, a list is either empty, or consists of an element followed by another list.
20:44 forgottenone joined
20:44 <scope> that much I understand
20:44 <Tuplanolla> Trees are also everywhere.
20:44 <Cale> But the effect on the code is sort of like everything has been turned inside out
20:45 <scope> Cale: kind of like my brain trying to learn Haskell
20:45 <Cale> Instead of having the index set up on the outside, and having all this code inside of the loop body
20:45 mizu_no_oto joined
20:45 <Cale> The list you're iterating over is sort of at the "innermost" position usually, and you're applying functions to that to transform it
20:46 <Cale> (which might or might not get you more lists)
20:46 acarrico joined
20:47 IRCFReAK joined
20:47 graygray joined
20:47 <Cale> Which ultimately ends up being a bit more modular, because, well, you can cleanly separate a problem of generating things to be iterated over from the problem of processing them.
20:47 <Cale> (with some special thanks to lazy evaluation)
20:48 bjz joined
20:48 <scope> everything about this language is pushing my thought process to its limits, I think it's just because I'm not used to it yet.
20:48 <Cale> Yeah
20:48 djfo joined
20:48 <scope> Thanks for you help Cale.
20:48 <Cale> When I started learning Haskell back around 2001 or so, it took me a couple months to feel like I could do anything useful
20:49 <Cale> and about a year to be "comfortable" for some definition of that word
20:49 <scope> Well I've only been doing it for about two weeks ha
20:49 <graygray> Can someone explain why when year = "2007", if (cast year :: Maybe Int) /= Nothing returns false
20:49 <mauke> because "2007" is not an Int
20:49 <scope> It seems incredibly powerful/elegant for what it is though.
20:49 <mauke> it's a String
20:50 <monochrom> What is the type of "cast"? And what does the doc say?
20:50 ragepandemic joined
20:50 <geekosaur> graygray, cast there is not a C cast
20:50 Jackneill joined
20:50 <cocreature> :t cast
20:50 <lambdabot> (Typeable b, Typeable a) => a -> Maybe b
20:50 <mauke> the other answer is: cast doesn't convert anything
20:50 <mauke> it's just a runtime type check, basically
20:50 allenj12 joined
20:50 <Cale> cast will only produce Just x in the case that the types a and b are the same
20:51 bariscant joined
20:51 <allenj12> if you wanted to make a list in haskell without using ADT's such as (defn cons [h t] #(if % h t)) what would the type signature of that function be? since it is a recursive type?
20:51 <Cale> (The advantage it buys you is that sometimes you don't know that a and b are the same type even though they might be)
20:52 takle joined
20:52 Jackneill joined
20:52 <graygray> so if i did cast read("2007"),1 would that return 2007?
20:52 <mauke> allenj12: uh, what?
20:52 <monochrom> Yes, but then you would also screw "cast".
20:53 <mauke> > cast read("2007"),1
20:53 <lambdabot> <hint>:1:18: error: parse error on input ‘,’
20:53 <graygray> monochrom: how so?
20:53 hackebeilchen joined
20:53 <Cale> > cast (read "2007" :: Integer) :: Maybe Integer
20:53 <lambdabot> Just 2007
20:53 <Cale> > cast (read "2007" :: Integer) :: Maybe String
20:53 <lambdabot> Nothing
20:53 <Cale> > cast (read "2007" :: Int) :: Maybe Integer
20:53 <lambdabot> Nothing
20:54 <monochrom> Because you already have the number. Why would you jump through more hoops to get it again?
20:54 <Cale> They have to match *exactly*
20:54 <allenj12> mauke: so if i wanted to make a list but only using functions, no ADT's. cons h t = \b -> if b the h else t . Where t would be another cons, what would the type signature for cons look like
20:54 <mauke> that's not a list
20:54 marcopullo joined
20:54 <Cale> allenj12: The branches of that if expression don't appear to have matching types
20:54 <mauke> :t let cons h t = \b -> if b then h else t in cons
20:54 <lambdabot> t -> t -> Bool -> t
20:55 <monochrom> "I am using my desktop to ssh to the same desktop to IRC" You could, but why would you.
20:55 <Cale> If your intention is that this get used to build up lists, anyway
20:55 <mauke> you've defined a pair
20:55 <Cale> yeah
20:55 <graygray> monochrom: I was taking in an input and wanted to make sure it was maybe an Int so was using cast to see if I got anything returned
20:55 <mauke> .oO( homo-pair? )
20:55 <allenj12> Cale: https://aphyr.com/posts/340-acing-the-technical-interview
20:55 <Cale> a pair of values of the same type
20:55 <allenj12> i want to do that but in haskell
20:55 <monochrom> Have you answered my question about what cast's doc says?
20:55 <mauke> graygray: input is always a string
20:55 <centril> is there anything like (\f ts -> join <$> traverse f ts) in lens or anywhere else on hackage ?
20:55 <monochrom> Does the doc even say anything remotely close to your goal?
20:56 danvet joined
20:56 gawen joined
20:56 <centril> doesn't have to be join tho, other candidates: concat
20:56 <allenj12> Cale: my problem is the type signature is recursive so i have no idea how to even start writing the function
20:56 IRCFReAK joined
20:56 <Cale> allenj12: I guess if we defined a type which was inclusive enough to begin with such that it could contain both functions and whatever type of elements you want in your "lists", then you could do something similar
20:57 <Cale> allenj12: They're abusing the fact that whatever lisp that is is untyped though
20:57 <allenj12> Cale: i know, its also clojure. but it should be possible in haskell?
20:57 <Cale> Well, you can Church encode a list
20:57 ziocroc joined
20:57 <allenj12> Cale: this is purely for excersice, nothing practical
20:57 <graygray> mauke: yeah but when I read Input and store in an Int it causes runtime errors if Input doesn't cast so I was checking using cast before storing it
20:58 fabianhu_ joined
20:58 <Cale> > let myList = (\nil cons -> cons 1 (cons 2 (cons 3 nil))) in myList 0 (+)
20:58 <lambdabot> 6
20:58 <mauke> graygray: I don't know why you keep talking about casts. this has nothing to do with casting
20:58 <graygray> doesn't it?
20:58 Guest_ joined
20:59 <mauke> ... no?
20:59 <monochrom> For the 4th time, you should read the doc.
20:59 <graygray> I did read the doc
20:59 <monochrom> And then if it's still unclear to you, we can talk.
20:59 <mauke> it has to do with 'read' erroring out when given something it doesn't like
20:59 <mauke> wrapping cast around an error achieves nothing
20:59 <monochrom> OK, so what did it say and how did you deduce that it's relevant?
20:59 <Cale> Use readMay if you want to handle a parse failure
21:00 <Cale> (or reads)
21:00 <Cale> :t readMay
21:00 <lambdabot> error: Variable not in scope: readMay
21:00 <monochrom> it's readMaybe
21:00 <Cale> ah
21:00 <monochrom> in Text.Read
21:00 Rodya_ joined
21:00 <Cale> :t readMaybe
21:00 <lambdabot> error: Variable not in scope: readMaybe
21:00 <monochrom> "readMay" is a pig latin thing.
21:00 <Cale> haha
21:00 <Cale> @let import Text.Read
21:00 IRCFReAK joined
21:00 <Cale> :t readMaybe
21:00 <lambdabot> Defined.
21:00 <Cale> lambdabot running a little slow today
21:01 <lambdabot> error: Variable not in scope: readMaybe
21:01 <mauke> @hoogle readMay
21:01 <lambdabot> Plugin `hoogle' failed with: <<timeout>>
21:01 carlosdagos joined
21:01 <Cale> I think readMay is from Safe
21:01 <monochrom> OK, no answer. Point proved, problem solved.
21:02 <Cale> But yeah, readMaybe is in base, use that :)
21:02 <graygray> I was just trying out readMaybe
21:03 conal joined
21:03 <Cale> .oO(IPv6 is great for ban effectiveness...)
21:04 pwnz0r joined
21:05 conal_ joined
21:05 preyalone joined
21:07 dawehner joined
21:08 tromp joined
21:09 mizu_no_oto joined
21:09 Shatnerz0 joined
21:13 forgottenone joined
21:13 oisdk joined
21:15 flebron joined
21:16 jomg joined
21:16 uglyfigurine joined
21:16 thefox joined
21:17 ph88^ joined
21:17 mizu_no_oto joined
21:19 texasmynsted joined
21:22 <AWizzArd> carlosdagos: are you here?
21:22 tag joined
21:23 ystael joined
21:23 <ph88^> hi guys
21:23 <ph88^> ghc advice me to use Rank2Types, i never used it before, should i use it? I get the notice with this code https://bpaste.net/show/503bbab9fe6f
21:25 <glguy> ph88^: That's a trivial use of RankNTypes, doesn't hurt anything. If you want to avoid the extension change to: eotTerminal :: (Generic a, Applicative f) => eot -> LensLike' f eot a
21:29 mexisme joined
21:29 oisdk joined
21:30 Rainb joined
21:31 mettekou joined
21:32 mizu_no_oto joined
21:33 <mmaruseacph2> can anyone help me understand why this behavior happens? http://lpaste.net/353653
21:33 ragepandemic joined
21:33 mettekou joined
21:35 mettekou joined
21:35 beaky joined
21:35 pie____ joined
21:36 <Cale> If you use thaw rather than unsafeThaw, you'll get the result you wany
21:36 <Cale> want*
21:36 cpup joined
21:36 <mmaruseacph2> yes, but I want the unsafe everywhere
21:37 mda1 joined
21:38 mettekou joined
21:38 <Cale> It's only safe to unsafeThaw a vector if you do not use the immutable one ever again after that point.
21:39 <mmaruseacph2> even if I freeze it after the modify?
21:39 <Cale> Right.
21:39 Shatnerz0 joined
21:39 <mmaruseacph2> cool, thanks
21:39 <Cale> My guess is that it has to do with replicate
21:39 plugin joined
21:40 <scope> Hey so I have duplicate points coming out of this function, for instance the list it returns might have points ((1,4), (5,7)) and ((5,7), (1,4)). How can I prevent this?
21:40 <scope> http://lpaste.net/7363021821769154560
21:41 <mmaruseacph2> it is because of replicate, if I pass a V.fromList [VU.fromList [0, 0], VU.fromList [0, 0]] instead it works
21:41 <Cale> scope: (x:xs) <- tails points, y <- xs
21:42 <scope> ahh that makes sense
21:42 <scope> ty
21:42 bollu joined
21:42 mizu_no_oto joined
21:43 bollu joined
21:43 bollu joined
21:45 replay_ joined
21:45 <scope> Cale I tried your solution but I get **Exception: tail empty list while testing
21:46 <Cale> tails, not tail
21:46 <scope> changed to tails and get a shitload more errors
21:46 <Cale> > tails [1,2,3,4,5]
21:46 <lambdabot> [[1,2,3,4,5],[2,3,4,5],[3,4,5],[4,5],[5],[]]
21:47 <scope> works without tails though
21:47 <Cale> > [(x,y) | (x:xs) <- tails [1,2,3,4,5], y <- xs]
21:47 <lambdabot> [(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)]
21:47 <scope> [(x,y) | x <- tails points, y <- points, isHullEdge points (x,y), x /= y]
21:47 <Cale> that's not what I wrote...
21:47 <glguy> scope: You still have to show actual code and errors
21:47 <scope> oh wow
21:47 <scope> I see what you're saying
21:47 <glguy> we can't guess what the typos are
21:48 <scope> glguy I literally just pasted the line
21:48 <scope> cale knows what's happening
21:49 curious_corn joined
21:49 marsam joined
21:49 <scope> I missed the (x:xs) Cale, works now, thanks
21:50 <Cale> Do you understand how it works?
21:50 <Cale> We're picking a nonempty tail of the list of points
21:50 <Cale> and then the first element of that tail is our first selected point
21:51 <Cale> and we pick the second point from the remainder of that tail
21:51 <Cale> so the second point is necessarily one that came later in the original list
21:52 hiratara joined
21:53 kazagistar joined
21:53 Lord_of_Life joined
21:53 dawehner joined
21:55 ubsan_ joined
21:56 <scope> Hey sorry Cale, yes I do understand how it works
21:56 reu joined
21:56 augur joined
21:57 nyuszika7h joined
21:57 augur_ joined
22:00 <ph88^> glguy, yeah that worked really nice .. but now i get some errors that i'm not sure what to do about them. I think it's best to first fix the bottom one and then the ones higher up https://bpaste.net/show/0977056f3a1f
22:01 <laudiacay> /b 2
22:01 <mauke> 2 /b or not 2 /b
22:02 <ph88^> glguy, from which timezone are you ?
22:02 <glguy> ph88^: It looks like you forgot the 'eot' typed parameter
22:02 <glguy> eotTerminal f (Left fields) = becomes eotTerminal _eot f (Left fields) =
22:02 Rodya_ joined
22:02 plugin joined
22:02 <mauke> @time glguy
22:03 <ph88^> glguy, yeah i know that, but i'm not sure what i'm suppose to do with that _eot parameter
22:03 <glguy> mauke: I elected not to implement CTCP responses this time around
22:03 <mauke> heh
22:03 erisco joined
22:03 <glguy> I'm on PST/PDT -8/-7
22:04 <ph88^> oh nice afternoon
22:04 <ph88^> let me think about that eot for a bit
22:05 <erisco> scope, how's your breath?
22:05 <scope> I haven't quite gotten the one we were working on earlier to work right
22:05 <scope> I've made progress on other functions though with some help
22:05 ystael joined
22:05 <erisco> hm, well lets take a look
22:06 <scope> I do have a question for you though, how can I prevent duplicates in this list comprehension? [fst(x,y) | x <- points, y <- points, isHullEdge points (x,y)]
22:06 <erisco> I gave every line needed
22:06 jeltsch joined
22:06 <erisco> okay, well first fst (x, y) reduces to x, so may as well just write that
22:07 <erisco> now, do you mean prevent duplicates or just remove them afterwards?
22:08 <erisco> if you mean prevent then there is a problem, because you necessarily have a duplicate x for every y
22:08 <scope> problem is the context, I need to send a pair of points to isHullEdge
22:08 <erisco> if you just want to remove duplicates afterwards then use nub
22:08 <scope> here one sec
22:08 <scope> http://lpaste.net/1086680722216845312
22:09 <scope> edge is a pair of points
22:10 <scope> I might be able to skip using isHullEdge and just use convexHullEdges
22:10 <erisco> are we looking at line 11 then?
22:10 <scope> trying to fix line 16
22:10 <scope> line 11 works as intended
22:11 <erisco> interestingly the Graham Scan is the first thing I wrote in Haskell ^.^
22:11 <erisco> it was horrendous
22:12 <scope> tell me about it haha
22:12 <mauke> horrendomorphism
22:12 <erisco> okay, so we want all the points on the hull, got it
22:13 <erisco> and our test for knowing if a point is on the hull is if it forms a line segment (with any other point) that is on the hull
22:13 <scope> right
22:13 {emptyset} joined
22:14 <erisco> okay, so, you have a function convexHullEdges which finds all the edges that form the hull
22:14 fDev2179 joined
22:14 <erisco> all the points then can be found with these edges, yes? (the implication is backwards here, but I think it is still okay)
22:14 <scope> Yes, this is true.
22:15 replay joined
22:15 <scope> But they're wrapped up in the form ((x,y), (x,y))
22:15 <erisco> okay, so if we take this list of edges and project out the two points that make them we'll end up with a list of list of points, yes?
22:15 <erisco> or a list of tuples of points, but lets say we make it a list of lists
22:15 <scope> Right, having trouble figuring out how to do this
22:15 <lambdabot> Local time for glguy is manual response?
22:15 <erisco> okay, what is the definition of Edge?
22:16 <scope> Two points
22:16 <scope> type Edge a = (Point a, Point a)
22:16 <erisco> okay, I meant exactly. So it is an alias
22:16 <scope> yes
22:16 <erisco> :t fst
22:16 <lambdabot> (a, b) -> a
22:16 MP2E joined
22:16 <erisco> :t snd
22:16 <lambdabot> (a, b) -> b
22:16 <erisco> do you see now how we can get the points out?
22:16 <scope> I think I get what you're saying.
22:16 <scope> give me a minute to play around
22:18 <scope> something along the lines of this? I know this isn't quite correct [x | x <- fst(convexHullEdges(points))]
22:18 <erisco> not everything has to be a list comprehension, you know ;)
22:19 <erisco> [x | x <- xs] is just xs
22:19 <scope> what exactly do you mean?
22:19 <AWizzArd> When I get a Non-exhaustive pattern error message in ghci, is there then a way to see the actual arguments with which my FN was called?
22:20 <erisco> well you write everything as a list comprehension and that's okay but there are other options
22:20 <scope> how would you suggest doing it? I understand what you're saying but I can't picture the code
22:20 scottj joined
22:20 <erisco> it may help to think outside the box of list comprehensions
22:20 <bollu> :t map
22:20 <lambdabot> (a -> b) -> [a] -> [b]
22:20 <scope> are you saying like xs <- fst(convexHullEdges(points))?
22:20 <bollu> > map (+ 1) [1..10] == [x + 1 | x <- [1..10]]
22:21 <lambdabot> mueval-core: Time limit exceeded
22:21 <erisco> okay, so, convexHullEdges points :: [Edge a]
22:21 <bollu> what?
22:21 <erisco> right?
22:21 <scope> right
22:21 <erisco> now, we want to take this list of edges and end up with a list of list of points
22:21 <erisco> i.e. we want to take the points out of each edge and make a list
22:22 <erisco> so, we can do that latter part with \(x, y) -> [x, y]
22:22 <scope> what does the \ do?
22:22 <erisco> okay lets not use that
22:23 <erisco> lets say pointsOfEdge :: Edge a -> [Point a]; pointsOfEdge (x, y) = [x, y]
22:23 <scope> do we need to make the tuple into a list or can I just take the first element of the tuple?
22:23 <ph88^> glguy, what i don't get about this code https://bpaste.net/show/4ec41c1fcae7 before i had eot -> P.Doc (line 6) and 2 arguments where enough (line 23) .. and now i have also just 1 arrow (line 41) but i suddenly require 3 arguments (line 58) .. what's going on ?
22:23 <scope> Think I'm misunderstanding what we're trying to do here
22:24 <erisco> ah, heh, well I think you are using a clever insight about how the edges form the hull
22:24 nilof joined
22:24 <erisco> let me frame the algorithm then
22:24 <mauke> the \ thing is for functions. \ PARAMETERS -> BODY
22:24 <erisco> we get a list of points, call it ps, and from this we find the edges that form the convex call, call it es = convexHullEdges ps
22:25 bollu joined
22:25 <erisco> form the convex hull*
22:25 <erisco> now we want all the points on the convex hull and we have a list of the edges of the convex hull
22:25 <erisco> does it make sense up to here scope?
22:25 <scope> somewhat
22:26 <erisco> we should be 100% up to this point so what is unsure?
22:26 robertkennedy joined
22:26 <scope> it's just how it's coded, I understand the logic
22:27 <erisco> well I am just describing the idea, not the code, at the moment, so are we good up to that point?
22:27 <scope> ah, yes. But we shouldn't need to call the list of points ps, as it's already defined as "points" correct?
22:28 <erisco> "we get a list of points, call it points, ..." that just didn't sound clear to me :P
22:28 <scope> it's a parameter for convexHullPoints haha, that just threw me off
22:28 <scope> continue on
22:28 <erisco> okay, so we know all the points on the hull can be found in the edges that form the hull
22:29 <lyxia> How can I know what options stack calls ghc with?
22:29 <scope> correct
22:29 <erisco> so our objective is to get all the points out of the edges, and we have our answer
22:29 <erisco> does that rough idea make sense?
22:29 <scope> absolutely
22:29 <erisco> okay, so the first thing I did was figure out how to get the points out of an edge
22:30 <MarcelineVQ> lyxia: it'll be in -v with a line like Run process:
22:30 <scope> I'm just trying to come up with the code for it, when you say it doesn't need to be a list comprehension that confuses me though, as that's how I've been doing most things
22:30 <erisco> now, I happen to know a little further ahead, so I know we'll want to put them in a list, I am just saving a bit of backtracking for us
22:30 <scope> so I can't just do [es <- convexHullEdges points] can I?
22:30 <erisco> it *can* be a list comprehension, I am just suggesting that you try other things
22:30 <scope> gotcha
22:30 <erisco> we'll use a list comprehension
22:31 <scope> I mean if you think it's better to do it another way I'll do my best to make sense of it
22:31 hiratara joined
22:31 <scope> I'm just not used to what you're suggesting but I'm willing to learn
22:31 <erisco> well I don't want to confuse more than necessary
22:31 <erisco> it is just that list comprehensions are a combination of simpler pieces and it might help to know them individually
22:31 curious_corn joined
22:32 <scope> fair enough, keep going with your suggestion
22:32 <scope> I'll try to keep up
22:32 <erisco> okay, so I made a new function called pointsOfEdge which takes the points out of an edge and puts them in a list
22:32 <erisco> did that function make sense to you?
22:32 <scope> Yes
22:33 <erisco> we'll do this without a list comprehension first then and I'll show you how it connects to a list comprehension after
22:33 <erisco> now we have es :: [Edge a] and pointsOfEdge :: Edge a -> [Point a] and we desire ps' :: [Point a]
22:33 <erisco> ps' is our desired list of hull points
22:34 <scope> now what does the ' notation mean?
22:34 <erisco> bollu gave us the function to stick es and pointsOfEdge together in the way we want
22:34 <erisco> it is just another character
22:34 <scope> alright
22:34 <erisco> Haskell lets you use it for identifiers
22:34 <scope> gotcha
22:34 <erisco> so I am using it like you might mathematically for the "after"
22:34 <erisco> we start with ps and want to get to ps'
22:35 <erisco> :t map
22:35 <lambdabot> (a -> b) -> [a] -> [b]
22:36 <erisco> so lets look at this type carefully, as we should do first when trying to understand anything in Haskell
22:36 Mon_Ouie joined
22:36 <erisco> map takes a function a -> b, and a list [a], and gives us back a list [b]
22:36 <erisco> can you intuit what map does?
22:36 <monochrom> Oh bollu is around! bollu: http://www.vex.net/~trebla/haskell/cont.xhtml
22:36 Yuras joined
22:36 <scope> puts things into a list based on a function's result?
22:36 <scope> something like that?
22:37 <erisco> that's close to it
22:37 <AWizzArd> Is there a way, in ghci, to automatically place a break in the moment I get a Non-exhausting pattern error? So that I can see the args with which the function was called.
22:37 <erisco> the function takes a's, where does it get the a's from?
22:37 <bollu> monochrom: thanks!
22:37 <scope> not sure to be honest
22:38 <erisco> okay lets use concrete types
22:38 <erisco> map :: (Int -> Char) -> [Int] -> [Char]
22:38 Dagnabit joined
22:38 <erisco> where does it take the Ints from?
22:38 <scope> is it a parameter for map?
22:39 <erisco> maybe my question is more obtuse than I realise
22:39 <erisco> > map f [a,b,c]
22:39 <scope> you mean the first Int right?
22:39 <lambdabot> mueval-core: Time limit exceeded
22:39 <erisco> lambdabot get your shit together man
22:39 <scope> hahaha
22:39 <erisco> okay, well it should have told us this:
22:39 <erisco> [f a, f b, f c]
22:39 <scope> so map applies a function to a list
22:40 gugah joined
22:40 <scope> I think I see where you're going with this. Are you suggesting using map with pointsOfEdge to create the new list?
22:40 bollu joined
22:40 <erisco> yes, that is exactly it
22:40 <scope> so that the tuples are no longer tuples?
22:40 <erisco> mhm
22:40 <scope> Ok makes sense
22:40 <erisco> now like I said, I know a step ahead of this, so we'll get to why we don't want tuples in a minute
22:41 <bollu> anyone know what's up with lambdabot?
22:41 <erisco> map :: (a -> b) -> [a] -> [b] and so what is the type of map pointsOfEdge ?
22:41 mettekou joined
22:41 <scope> a list?
22:41 <erisco> tell me exactly
22:41 <scope> uhhhhh
22:42 djfo left
22:42 <scope> a list of the points on the edge?
22:42 <erisco> map :: (a -> b) -> [a] -> [b] and pointsOfEdge :: Edge a -> [Point a]
22:42 subttle joined
22:42 <erisco> so what is map pointsOfEdge :: ?
22:42 <bollu> erisco: may want to change "a" to "p" or something :)
22:42 <scope> the points that make up the convex hull? maybe I'm not following
22:42 <erisco> curse you hygiene!
22:43 <erisco> well I am looking for a type
22:43 <erisco> tell me a type, like Int, or Maybe String, or something like that
22:43 <kazagistar> Its slightly less confusing if you use different letters, yeah. Like (a -> b) -> [a] -> [b]  and  pointsOfEdge :: Edge e -> [Point p]
22:43 <erisco> well it cannot be e and p, but we can say pointsOfEdge :: Edge c -> [Point c] or something
22:43 <scope> I'm struggling here, doesn't help that chat keeps moving
22:44 <kazagistar> oh, right
22:44 <erisco> I don't think we're at the stage of being confused about the variable hygiene
22:44 <bollu> scope: OK. think of this as a game of "matching"
22:44 <erisco> lets start simpler, since we really need to develop a basic sense of types to program in Haskell
22:44 <scope> before that, what was the type you were looking for?
22:44 <scope> it may click when you say it
22:44 <erisco> I will tell you that (+1) :: Int -> Int, and I will tell you x :: Int
22:45 <erisco> what is the type of (+1) x then?
22:45 louispan joined
22:45 <lyxia> Tuplanolla: I don't see my options in -v, even though I can see them taking effect...
22:45 <scope> Int...?
22:45 <erisco> yes
22:45 <erisco> now I will tell you f :: a -> b and x :: a, so what is the type of f x ?
22:45 <scope> a
22:45 <erisco> try again
22:45 <Tuplanolla> What are we discussing, lyxia?
22:46 <bollu> scope: why a?
22:46 <scope> b rather
22:46 <erisco> does that make sense?
22:46 <scope> well f changes a to b, is that right?
22:46 <erisco> yes, f is a function from a to b
22:47 <bollu> scope: also remember, these are _types_
22:47 <erisco> so if we give it an a, then we will get a b
22:47 <scope> right
22:47 Eduard_Munteanu joined
22:47 <erisco> okay, now say f :: a -> b and x :: Int, what is the type of f x ?
22:47 <scope> whatever b is
22:48 <lyxia> Tuplanolla: I want to know why stack is optimizing my builds, and more generally how it's calling ghc
22:48 <scope> wait
22:48 <Tuplanolla> Okay, lyxia. I don't use Stack though.
22:48 <erisco> scope, Int and "a" look different, are you sure that is okay?
22:49 <scope> is this a trick question? lol
22:49 <erisco> well I can't know everything you've already learned so I am not sure
22:49 <erisco> I presume you know "a" is a type variable, whereas "Int" is a type
22:49 conal joined
22:49 <scope> well how can f x even work if f doesn't take an Int
22:50 Apocalisp joined
22:50 hiWorld joined
22:50 <erisco> okay, good, this is really important to know
22:50 <scope> I legitimately thought that was a trick question lol
22:50 srhb joined
22:50 <erisco> types in Haskell can be polymorphic, meaning they may have variables in them
22:51 <erisco> f :: a -> b is polymorphic. we can choose "a" or "b" to be any type
22:51 <erisco> "a" and "b" are type variables
22:51 <erisco> just like if I have an equation y = 3*x + 4 I can choose x to be any number
22:51 <erisco> in types we can choose variables to be any type
22:51 <MarcelineVQ> lyxia: Looks like I was wrong, I also don't see options in full debug output, or find them in build logs
22:52 <erisco> so, if f :: a -> b, it is also the case that f :: Int -> b
22:52 <erisco> because we can choose a = Int
22:52 <glguy> ph88^: You changed the type of eotTerminal from one that needed 1 parameter to one that needed 3
22:52 <scope> ah alright
22:52 <erisco> why do we choose a = Int? well because x :: Int and we need to match them up
22:52 <erisco> this process of instantiating variables to match types is called unification, and is something Haskell does for us
22:52 <maerwald> it's like duck typing, but during compile time! (lol)
22:53 <Lazersmoke> (and completely safe)
22:53 <erisco> but we need to know how it works so we can write type correct programs
22:53 <scope> I've noticed that you don't need to explicitly call something an int or whatever
22:53 <scope> meaning I could do name = 5 or name = "myname"
22:53 <Lazersmoke> the compiler is pretty good at inferring what the type *should* be from the context
22:53 <scope> so I understand that much
22:53 <hiWorld> haskell assigns typing at compile time, so it only appears to the user as if it's duck typed
22:53 <bollu> scope: so, f :: a -> b is "actually" f :: forall a, forall b, a -> b
22:53 <erisco> okay, so, armed with this knowledge, can you figure out the type of map pointsOfEdge ?
22:53 <MarcelineVQ> lyxia: if Cabal optomizes by default though that's likely why stack would be, it seems to use Cabal on the configure step
22:54 __main__ joined
22:54 <erisco> right
22:54 <erisco> it is, in words, "forall types a, forall types b, f has the type a -> b"
22:54 <Lazersmoke> worth noting that `forall a b. a -> b` is actually a nonsense type because it would have to be a function that works for every single possible type
22:54 <scope> :t map
22:54 <lambdabot> (a -> b) -> [a] -> [b]
22:55 <erisco> right, f is actually unsafeCoerce, which is bad, but we were just using it for an example
22:55 <scope> so the type would be a function?
22:55 <bollu> scope: I have a question for you. Consider g :: forall a. a -> a. Can you implement such a "g" for me?
22:55 <scope> specifically pointsOfEdge?
22:55 <erisco> yes
22:56 <lyxia> MarcelineVQ: Thanks, that seems to be it.
22:56 <scope> bollu I understand the logic but don't think I understand how the syntax would look
22:56 chenyu joined
22:57 <bollu> scope: tell me the logic then :)
22:57 <bollu> can I not have cyclic data declarations?
22:57 theelous3 joined
22:57 <erisco> bollu, is that a separate question?
22:57 <bollu> erisco: yeah that's to the channel
22:57 <erisco> cyclic as in mutual?
22:57 <scope> so erisco, you're saying for convexHullPoints points = [map pointsOfEdge (convexHullEdges)] or something of the sort
22:58 <bollu> A is a sum type which uses X in one of the branches. X is a product type that always uses A
22:58 <scope> I know there's more to it
22:58 <bollu> so it's not wrong to create this
22:58 <bollu> to imagine such a type that is
22:58 <bollu> but the compiler doesn't let me do this
22:58 <erisco> bollu, maybe write out your attempt and I can get a better idea
22:58 lp joined
22:59 __main__ joined
22:59 <erisco> scope, not quite, no, so I just wanted you to figure out the type at this point
22:59 <erisco> to program in Haskell what you really want to do is follow the types
22:59 <erisco> they're like the walls, they tell you things
22:59 <erisco> you see you have type A and you want type B and that informs you of what needs to happen
23:00 <scope> right
23:00 <erisco> so if we know the type of map pointsOfEdge it is going to become clear as to how we finish the definition
23:00 <Lazersmoke> Sometimes you can figure out what something does from the types alone
23:00 <bollu> erisco: http://lpaste.net/7092124185572409344#line142. ExprNodeLet uses Binding. Binding uses Lambda. Lambda uses ExprNode
23:00 medicijnman left
23:01 <erisco> and what is the compiler error?
23:01 <scope> well the type is pointsOfEdge, which returns a list
23:01 <glguy> bollu: The problem is that you used TH between the two
23:01 Schoolmeister joined
23:01 <erisco> pointsOfEdge is not a type
23:01 <glguy> bollu: specifically makePrisms, doing that segments your module
23:01 <bollu> glguy: what? :O
23:02 <erisco> in Haskell there are types and there are values, and they never mix
23:02 <bollu> glguy: I have never heard of this, why does this happen?
23:02 <glguy> bollu: move all the data type declarations above your splicing in of the Prisms
23:02 <erisco> we write x :: t which means "the value x has the type t"
23:02 <bollu> OK
23:02 <scope> well wouldn't the type be the return type of pointsofedge?
23:02 <erisco> so values are always on the left and types always on the right of ::
23:02 <Lazersmoke> yeah that makes sense. TH probably stopped reading the file before it got to the definition of ExprNode
23:02 <erisco> pointsOfEdge is a function, so it is on the left of ::, it is a value
23:02 <erisco> tell me the type of pointsOfEdge
23:02 <scope> [Point a]
23:03 <erisco> nope, go back to when I defined pointsOfEdge
23:03 <glguy> bollu: It does that so that you can use things from TH as you define them to make new things, but the things you are using need to be finished being defined before you can use them , so it processes the module in chunks
23:03 <scope> it takes an edge and returns the points in that edge
23:03 <bollu> glguy: I see
23:03 <scope> pointsOfEdge :: Edge a -> [Point a]
23:03 <bollu> glguy: and why are the chunks not fused up?
23:04 <erisco> when I ask for a type I always mean something like String, or Int, or a formal thing like this
23:04 <glguy> bollu: so that you can use the thing syou just defined with TH below the TH
23:04 <erisco> okay, so tell me in words what pointsOfEdge :: Edge a -> [Point a] is. don't tell me what the function does, just tell me what that notation means
23:04 <erisco> and if you don't know that is okay, we'll go through it
23:05 <erisco> I'm not sure how much you know and don't know so I am taking some guesses when I direct these questions
23:05 <scope> pointsOfEdge changes an edge to a list of points, I don't know what you mean, is that not what the notation means?
23:05 <erisco> okay, that is part of it
23:05 <bollu> glguy: I'm still not sure as to why the chunks are not fused together once the spilicing has finished?
23:06 <erisco> you can word it differently, but it is something like this: "pointsOfEdge has the type function from Edge a to [Point a]"
23:06 <scope> right, I understand that
23:06 <glguy> bollu: It's discussed in the GHC user's guide. I'd start there. There's a chicken/egg problem if you want to be able to inspect parts of the module while you're defining the module
23:06 systemfault joined
23:06 <erisco> so x :: t means "x has the type t", and a -> b means "function from a to b"
23:06 <scope> right
23:06 <Lazersmoke> GHC is frustratingly linear; you can't compile mutually recursive modules without {-# SOURCE #-} and hs-boot, and TH splices break things. I wish GHC treated every top-level definition as its own module and allowed mutual recursion
23:07 <Lazersmoke> that would make me cohappy
23:07 <erisco> okay, good, so when you say "the type is pointsOfEdge" do you see why that doesn't work?
23:07 <bollu> ah OK
23:07 <bollu> glguy: much appreciated
23:07 <bollu> glguy: what do I need to look for?
23:08 <scope> Okay so I get why pointsOfEdge won't give me what I need, it only takes a single edge rather than all of them
23:08 <glguy> Template Haskell
23:08 <scope> meaning I'll only get the points on a single edge
23:08 <erisco> no, it doesn't work because pointsOfEdge is not a type :P
23:08 <scope> but map takes a function???
23:08 <bollu> this is perhaps offtopic, but is there some sort of haskell meetup in zurich every week or some such?
23:08 <erisco> you cannot say "the type is x" when x isn't a type because that is a nonsense statement
23:08 <Lazersmoke> a "function" is different from a "function type"
23:08 <scope> ah but yes I understand that
23:08 <scope> pointsOfEdge is a function
23:09 <scope> I misunderstood you
23:09 <erisco> yes maybe we are being unclear when I say "function", as Lazersmoke points out
23:09 <Lazersmoke> yeah map takes a function, and the function you are giving it is pointsOfEdge
23:09 <scope> Lazersmoke exactly
23:09 <scope> I get that haha
23:09 tromp joined
23:09 coltfred joined
23:10 <erisco> id x = x this is a function definition, it defines the value called id
23:10 <erisco> so I will say "id is a function"
23:10 <erisco> id also has a type, this type is a -> a
23:10 halogenandtoast joined
23:10 <erisco> so I should have more clearly said "a -> a" is the type of functions from a to a
23:10 <Lazersmoke> :t id
23:10 <lambdabot> a -> a
23:11 <scope> so I can't send convexHullEdges(points) to pointsOfEdge because convexHullEdges returns a list, whereas pointOfEdge doesn't take a list
23:11 <Lazersmoke> exactly
23:11 <erisco> the key phrase being "type of functions", which -> constructs
23:11 <Lazersmoke> that's where map comes in. It takes a function and "upgrades" it to work on each element of a list individually
23:11 <Lazersmoke> :t map
23:11 dni joined
23:12 <lambdabot> (a -> b) -> [a] -> [b]
23:12 <erisco> that's right, if the types don't match then it is a no-go
23:12 <erisco> but map pointsOfEdge will work, I just wanted you to figure out the type of this
23:12 <erisco> if you know what type it has it will help us finish the definition
23:12 <scope> this still doesn't quite work though convexHullPoints points = map pointsOfEdge (convexHullEdges(points))
23:12 <Lazersmoke> that type is the same as "(a -> b) -> ([a] -> [b])" btw
23:12 Prutheus joined
23:12 <erisco> right, well, humour me and find the type :P
23:13 <bollu> Lazersmoke: I think you should wait till you bring in currying and associativity of (->) and all that
23:13 <Lazersmoke> yeah probably
23:13 <erisco> you can take some intuitive guesses at this point but it will be so much easier if you just learn how to understand the types
23:13 <scope> the type of that whole expression or something in particular?
23:13 takle joined
23:14 <Lazersmoke> what is the type of convexHullEdges? "[Point a] -> [Edge a]"?
23:14 <erisco> then you don't just be taking stabs, you'll be making careful, well-timed attacks ;)
23:14 <erisco> Lazersmoke, http://lpaste.net/1086680722216845312
23:14 <Lazersmoke> ah ty
23:14 <scope> convexHullEdges is a function
23:14 <scope> lol
23:14 <scope> but it returns a list of points
23:14 <erisco> it is a function, yes, and that is the type (ignoring the context)
23:15 <scope> AH
23:15 <erisco> so here is the task
23:15 <erisco> map :: (a -> b) -> [a] -> [b] and pointsOfEdge :: Edge c -> [Point c]
23:15 <erisco> so you just need to find the a and b such that a -> b is the same as Edge c -> [Point c]
23:15 <erisco> then you can find the type of map pointsOfEdge
23:16 mexisme joined
23:17 <scope> dammit
23:18 rekahsoft joined
23:18 <scope> put this into english for me and I think I could understand map :: (a -> b) -> [a] -> [b]
23:18 <bollu> scope: what part are you finding trouble with? the entire type, or some part of it, or..?
23:18 <scope> I'm just struggling to take in so much information at once I think
23:19 <erisco> "map has the type of a function from a -> b to a function from [a] to [b]
23:19 <erisco> "
23:19 <erisco> if the two ->'s are confusing you we can discuss that
23:19 <scope> yeah just a bit
23:19 <erisco> actually I'll let bollu tell you because he knows
23:19 <Lazersmoke> you can put parentheses like this if it helps: "(a -> b) -> ([a] -> [b])"
23:19 meandi joined
23:20 <Tuplanolla> :t uncurry map -- Alternatively you can view it like this, scope.
23:20 <lambdabot> (a -> b, [a]) -> [b]
23:20 lambda-11235 joined
23:20 marcopullo joined
23:20 Raddamu joined
23:20 <Tuplanolla> :t uncurry id -- It is one kind of a generalization of this, scope.
23:20 <lambdabot> (b -> c, b) -> c
23:21 <bollu> scope: OK, let's talk about a -> b -> c v/s a -> (b -> c)
23:21 <bollu> scope: consider this
23:21 <bollu> :t (+) :: Int -> Int -> Int
23:21 <lambdabot> Int -> Int -> Int
23:22 BlueRavenGT joined
23:22 <bollu> what does (+) do? it takes 2 integers and returns another one, corect?
23:22 <bollu> > 1 + 2
23:22 <lambdabot> 3
23:22 <bollu> now, that's _one_ way to look at it
23:22 <bollu> the other way is like this
23:22 __monty__ joined
23:22 <bollu> > ((+) 1) 3
23:22 <Raddamu> 6 + 4
23:22 pwnz0r joined
23:22 <bollu> Raddamu: ?
23:22 <lambdabot> mueval-core: Time limit exceeded
23:22 <lambdabot> mueval: ExitFailure 1
23:23 <bollu> why is lambdabot failing :(
23:23 <geekosaur> because whatever it's hosted on is overloiaded
23:23 <erisco> I think a cicada is stuck in the CPU fan
23:23 <Lazersmoke> RIP lambdabot, you will live on forever in our hearts, if not in our IRC
23:23 <geekosaur> stick stuff in the cloud, occasionally end up with a cloudburst :p
23:23 <bollu> geekosaur: I had never realised how much I rely on lambdabot to explain things :P
23:23 <Tuplanolla> Clouds are subject to weather.
23:24 <scope> so erisco, map pointsOfEdge
23:24 <bollu> https://www.youtube.com/watch?v=AnxrJiS5uKU
23:24 <Lazersmoke> (map :: (a -> b) -> [a] -> [b]) (pointsOfEdge :: Edge a -> [Point a])
23:24 <bollu> scope: the other way of looking at (+) is as follows: (+) is a function that takes an integer, and returns another _function_ which takes an integer and returns a value
23:25 <scope> bollu I think you're confusing me more
23:25 <bollu> scope: in the sense, let f = (+) 1
23:25 <bollu> scope: OK
23:25 <scope> I'm literally just trying to figure out the type of map pointsOfEdge
23:25 <scope> which I think should be a list
23:25 <chaosmasttter> why do you think that?
23:25 <bollu> scope: answer this question first: how many parameters does map have?
23:26 <scope> one, a tuple
23:26 tenohk joined
23:26 <erisco> <erisco> so you just need to find the a and b such that a -> b is the same as Edge c -> [Point c]
23:26 <Lazersmoke> scope: You just need to match up "Edge a -> [Point a]" with the "a -> b" in map
23:26 louispan joined
23:26 <erisco> can you do that scope? I narrowed the problem for you
23:26 <bollu> :t map
23:26 <lambdabot> (a -> b) -> [a] -> [b]
23:26 pawn joined
23:26 <* erisco> is glad we still have map and not just fmap
23:27 <bollu> scope: why do you think map takes 1 parameter? (a tuple)
23:27 <bollu> erisco: lol
23:27 <bollu> > fmap @ []
23:27 <pawn> How does haskell do multiple statements in a function?
23:27 <lambdabot> error:
23:27 <lambdabot> Pattern syntax in expression context: fmap@[]
23:27 <lambdabot> Did you mean to enable TypeApplications?
23:27 <pawn> Cause isn't there only one return and stuff?
23:27 <bollu> pawn: you don't? you literally have only expressions
23:27 <geekosaur> pawn, haskell doesn't do statements
23:27 bjz joined
23:27 <erisco> doesn't "do" statements, heh
23:27 <bollu> pawn: "return" is just a function
23:27 <geekosaur> do notation pretends to, but it's actually an expression
23:27 <bollu> :t return
23:27 <lambdabot> Monad m => a -> m a
23:28 <scope> I misunderstood your question, I meant pointsOfEdge takes one parameter being a tuple
23:28 <scope> map takes a function and a list correct?
23:28 <erisco> yes
23:28 <bollu> scope: yes
23:28 <geekosaur> pawn, and that is in a sense your answer: instead of statements, we use sequences of functions
23:28 <geekosaur> @undo do a; b; c
23:28 <lambdabot> a >> b >> c
23:28 <bollu> scope: now, in the call "map pointsOfEdge", how many parameters are we passing?
23:28 <pawn> So, how would you do the equivalent of this in javascript: (x) => { dosomething(x); return 23; }?
23:28 <Lazersmoke> scope: in order to figure out the type of "map pointsOfEdge", you need to figure out what a and b are in the type of map
23:29 <scope> just one, but I've tried map pointsOfEdge (convexHullEdges(points))
23:29 <bollu> pawn: it depends on what dosomething(x) does.
23:29 <geekosaur> pawn, that depends on the type of doSomething
23:29 <scope> which should satisfy both requirements
23:29 <Lazersmoke> pawn: haskell functions are pure, they only return a value, and don't do side effects
23:29 <bollu> scope: step back for a second
23:29 <geekosaur> hm, why did I camelify that...
23:29 <bollu> scope: let's say I have a function that takes two parameters, but I give it only 1. is this legal haskell?
23:29 <scope> No, and I realize that
23:29 <erisco> pawn, you can get a quick answer but if you want to understand how Haskell approaches this differently then you'll need to learn Haskell
23:30 <scope> map pointsOfEdge isn't valid
23:30 <bollu> scope: it _is_ legal haskell :D
23:30 <scope> what
23:30 <scope> my life is a lie
23:30 <erisco> pawn, so the long answer is a few weeks or months of practice
23:30 <bollu> scope: yes :)
23:30 raddamu2 joined
23:30 <pawn> Eeek
23:30 <bollu> scope: OK, so to understand this, I want to go back to (+)
23:30 <bollu> scope: we think (+) has two parameters correct?
23:30 <scope> I don't even know what that is
23:30 <scope> that's why I thought you were confusing me more
23:30 <bollu> scope: that's just the operator + for addition
23:30 <Lazersmoke> (+) is just +, like 1 + 2
23:30 <scope> oh
23:30 <geekosaur> it's the + operator, presented as a prefix function instead of an infix operator
23:31 <Lazersmoke> you put it in parentheses and you can call it like "(+) 1 2"
23:31 <scope> oh ok
23:31 <bollu> > (+) 1 2
23:31 <lambdabot> 3
23:31 <bollu> plz work lambdabot
23:31 <bollu> yes
23:31 <bollu> OK
23:31 <scope> lol
23:31 <carlosdagos> lol
23:31 <bollu> OK, so, now, we think of (+) as a function with two parameters?
23:31 <erisco> pawn, if "doSomething" is a side effect then there is IO and ST as common solutions, and so it might look like \x -> doSomething x >> return 23
23:31 <scope> yes
23:32 <Lazersmoke> lambdabot, our lord and savior, has returned. all praise his holy presence
23:32 <erisco> pawn, but some of those side effects we just do differently, such as having state
23:32 <bollu> however, we can think of (+) as a function that takes _1_ parameter, and _returns a function_ which takes another parameter and then does the (+). Actions speak louder, let me demonstate
23:32 <erisco> pawn, we prefer a type called State which lets us save and retrieve a value
23:32 <erisco> pawn, and it would look similarly
23:32 <bollu> > let inc = (+) 1 in (inc 2, inc 3)
23:32 <* ski> . o O ( s/his/her/ )
23:32 <lambdabot> (3,4)
23:32 locallycompact joined
23:32 <scope> ok I see what happened there
23:32 <scope> added one to 2 and one to 3
23:32 <erisco> pawn, another answer is that in Haskell we don't have a lot of functions that look like that
23:33 <Lazersmoke> pawn, how experienced are you with Haskell?
23:33 <bollu> right? so I can pass fewer parameters than needed, and haskell will go "oh cool, now I know what the first k parameters are, give me the rest of them and I will evaluate them!"
23:33 <bollu> scope: do you follow this
23:33 eiriksfa joined
23:33 <scope> yes
23:33 <Lazersmoke> scope: what is the type of inc, if the type of (+) is "Int -> Int -> Int"?
23:33 <bollu> scope: OK, so now
23:34 <bollu> scope: the type of (+) is actually
23:34 <bollu> (+) :: Int -> (Int -> Int) === take an integer, return a *function* that takes an integer and returns an integer
23:34 <bollu> scope: does this make sense?
23:34 <scope> yes
23:34 <bollu> scope: a -> (b -> c) == take a, return a function from b to c, remember?
23:34 <bollu> scope: OK
23:35 <bollu> scope: now, traditionally, we have (->) associate rightward. So, a -> b -> c -> d is *by convention* read as a -> (b -> (c -> d))
23:36 <bollu> scope: which means, a function that takes a and (returns a function that takes b and returns (a function that takes c and returns d)))
23:36 <bollu> scope: this makes sense too?
23:36 <scope> so, take a, return a function that returns a function from c to d
23:36 skorgon joined
23:36 <scope> right
23:36 <bollu> so when I write a -> b -> c, I actually mean a -> (b -> c)
23:36 <scope> ok
23:37 <bollu> this is fundamentally different from (a -> b) -> c
23:37 <pawn> Lazersmoke: Not so experienced at all
23:37 <tenohk> hi all. I'm trying to create a main function such that > main = putStrLn $ printAndReturn "foo" < prints "foo" twice, but cannot wrap my head around how to implement such a printAndReturn function.
23:37 <bollu> a -> (b -> c) = take a , return function from b to c. (a -> b) -> c = take a function from a to b, return c
23:37 <pawn> I'm just wondering how haskell does do more than one thing in a function if it only does expressions?
23:37 <bollu> does that make sense too?
23:37 <scope> yes
23:37 <bollu> so now
23:37 <bollu> consider
23:37 <bollu> map :: (a -> b) -> [a] -> [b]
23:37 <bollu> (what was the other thing?)
23:37 <scope> pointsOfEdge :: Edge a -> [Point a]
23:37 <scope> ?
23:38 <ski> tenohk : can't be done like that. can be done if you change `$' to `=<<'
23:38 <erisco> pawn, the secret is in what "do a thing" means
23:38 <bollu> right, yeah
23:38 <bollu> so what will map pointsOfEdge be?
23:38 <tenohk> thanks @ski ill check that out
23:38 <bollu> "map pointsOfEdge" is legal haskell
23:38 <bollu> as we discovered
23:38 <erisco> pawn, x * 2 + 1 I do two things here in this expression, right? I multiply by 2 and add 1
23:38 <bollu> so now, I want you to tell me the tye
23:38 <halogenandtoast> :t (=<<)
23:38 <bollu> type*
23:38 <lambdabot> Monad m => (a -> m b) -> m a -> m b
23:38 <ski> tenohk : in this case, `(=<<) :: (a -> IO b) -> IO a -> IO b'
23:38 <bollu> pawn: It really depends on what you mean by "do things
23:38 <bollu> "
23:38 inferno-cop joined
23:38 <pawn> I see
23:38 <tenohk> haha damn i feel so retarded. thanks
23:39 <Lazersmoke> pawn: "doing more than one thing" means doing one thing, and then doing another thing, correct?
23:39 <scope> a list of lists? tenohk I feel retarded too
23:39 <bollu> scope: don't guess
23:39 <bollu> scope: think of this as pattern matching in your head
23:39 <pawn> Lazersmoke: Yes
23:39 <bollu> map :: (a -> b) -> [a] -> [b]
23:39 <ski> tenohk : `putStrLn' takes a `String', so in `putStrLn $ printAndReturn "foo"', `printAndReturn "foo"' must compute to a simple `String'. it can't do any I/O
23:39 <bollu> map :: (a -> b) -> [a] -> [b]
23:39 <bollu> pointsOfEdge :: Edge c -> [Point c]
23:40 <Lazersmoke> pawn: so in Haskell, we have the function (>>) which takes two arguments: the first thing to do, and the second thing to do
23:40 <pawn> Lazersmoke: I'm trying to figure out how you go from the functionName { block } way of thinking where { block } can be { statement. statement. statement...} to the haskell way
23:40 <bollu> map pointsOfEdge :: ?
23:40 <scope> fuck
23:40 <bollu> scope: ?
23:40 <tenohk> thanks ski
23:40 <ski> tenohk : in `putStrLn =<< printAndReturn "foo"', however, `printAndReturn "foo"' will have type `IO String', which is very different. this is a "recipe" for doing some I/O and ending up with a `String' (possibly a different one each time you follow the recipe, each time you execute the action)
23:40 <scope> I don't know why I can't wrap my head around this
23:40 <bollu> scope: OK, step back
23:40 <halogenandtoast> scope: Just do variable substitution
23:40 <erisco> pawn, like I said, that is a question of learning Haskell
23:40 <bollu> scope: what is the type of (+)?
23:41 <Lazersmoke> pawn: and it smooshes them together into a new "thing to do" that does the first thing, then the second thing
23:41 <erisco> pawn, if I asked you "how do you solve a problem so it looks like statement1; statement2; statement3; ..." you'd tell me to learn procedural programming
23:41 <Lazersmoke> pawn: there is special syntax that lets you write that in a pretty way
23:41 <scope> a function
23:41 <bollu> scope: yes, but what is the type?
23:41 <scope> Int
23:41 <bollu> scope: is it?
23:41 <bollu> scope: so (+) is a number?
23:41 <erisco> pawn, so similarly your question is big
23:41 <ski> tenohk : so then `putStrLn =<< printAndReturn "foo"' will "add" the action of printing out this computed `String', after the recipe of `printAndReturn "foo"' -- iow, extending the recipe into a larger recipe. and because we define `main' to be this recipe, when the Haskell program is run, it'll start following the recipe
23:41 <pawn> I understand that erisco, however, I'm interested in the FP way
23:41 <scope> no it isn't but
23:42 <Lazersmoke> pawn: most of your programming is not actually doing side effects, but computing a value of some kind
23:42 robkennedy joined
23:42 <halogenandtoast> scope: don't confuse "return type" with type
23:42 <bollu> scope: but?
23:42 <erisco> pawn, now you can look at simpler systems such as Lambda Calculus if you want a taste, but that alone is not practical programming so it may be difficult to connect
23:42 <scope> I don't understand what you mean, a function isn't a type
23:42 <bollu> scope: a function *has* a type
23:42 <bollu> scope: everything has a type :)
23:42 <bollu> scope: I am asking you what type + has
23:42 <erisco> so I'd direct you to introductory texts on Haskell
23:42 <scope> num?
23:42 <ski> tenohk : just *evaluating* the "recipe", the action, will not perform any I/O whatsoever. it will only determine *what* to (possibly) later do. actually doing it (*executing* it), only happens as a result of being made part of the `main' action
23:42 <ski> tenohk : does that make sense ?
23:42 <erisco> I heard people poo-pooing LYAH and RWH so I don't know what the new hotness is
23:43 <bollu> scope: what other languages do you know?
23:43 <orion> erisco: haskellbook.com
23:43 <scope> C, C++, Java and some Ruby
23:43 <erisco> either of those are probably still reasonable
23:43 <monochrom> I can see how "the type of this function" is an alien concept for, say, C programmers.
23:43 <erisco> okay, go to there and start reading! we're here for your questions
23:43 <halogenandtoast> scope: For a function a type is defined by what types it can take, and what type it returns
23:43 <bollu> scope: OK, so, if I wrote this: int add(int a, int b) { return a + b; } and I asked you "what is the type of add" what would your answer be?
23:43 <Lazersmoke> pawn: don't listen to the haters, LYAH is the best book ever written http://learnyouahaskell.com/chapters
23:43 <scope> int
23:43 <monochrom> :)
23:44 <bollu> scope: wait what?
23:44 <carlosdagos> Lazersmoke: *claps*
23:44 <scope> I fail at life
23:44 Ayey_ joined
23:44 <tenohk> yes. I'm just starting get into the idea of monads, this helped a lot. it's part of a greater effort, I'll see if i can pull it off now
23:44 <halogenandtoast> bollu: in oops when we talk about type, it's the return type
23:44 <bollu> scope: have you used function pointers in C?
23:44 <halogenandtoast> that oops what auto correct for oop...
23:44 <scope> Yes
23:44 <bollu> scope: for callbacks and stuff?
23:44 <scope> not very good with them
23:44 <bollu> scope: OK, so what is the signature of the function pointer for add?
23:45 <bollu> scope: because that will be the type of the *function* called add (since in a function pointer, we hold the type of function itself)
23:45 <ski> @quote /bin/ls
23:45 <lambdabot> shachaf says: getLine :: IO String contains a String in the same way that /bin/ls contains a list of files
23:45 <ski> tenohk ^
23:45 <scope> I mean I've used them but don't fully understand
23:45 <bollu> scope: hm, OK
23:45 <halogenandtoast> int (*add)(int, int)
23:45 <bollu> scope: uh, how much of a math background do you have?
23:46 <scope> my brain is also mush at the moment and I'm half asleep, so I'm sure that's not helping
23:46 <tenohk> im trying to create a sort of Maybe type such that whenever a function returns a Nothing, some IO action is performed
23:46 <erisco> maybe sleep and a new day is the best way to continue
23:46 <scope> not much
23:46 <scope> I've taken calc
23:46 <scope> so you tell me, what is the type of add?
23:46 <ski> tenohk : sounds doable
23:47 <bollu> scope: add :: (int , int) -> int
23:47 <scope> maybe when you say it I'll immediately understand and feel like an idiot
23:47 meba joined
23:47 <bollu> scope: takes two integers, returns an integer
23:47 <scope> see that's where I'm getting confused
23:47 <bollu> OK, tell me
23:47 <bollu> what is confusing
23:47 <scope> I've been thinking of types as int, double, char etc.
23:47 <bollu> scope: yes
23:47 <halogenandtoast> those are
23:47 <tenohk> im trying to create a sort of Maybe type such that whenever a function returns a Nothing, some IO action is performed
23:48 <tenohk> ups sorry
23:48 <erisco> Haskell ups the game and gives us more complicated types
23:48 <scope> never thought too much of types of functions, I just know what they take in and return
23:48 <bollu> scope: in mathematics, do we not define the domain and codomain of a function?
23:48 <halogenandtoast> scope: That is what a function is though
23:48 <halogenandtoast> it takes something in, it's "domain"
23:48 <halogenandtoast> and returns something, it's "codomain"
23:48 tromp joined
23:49 <bollu> scope: have you seen the whole f: R -> R or g : C -> C in calculus
23:49 <bollu> ?
23:49 <scope> man I haven't thought about calc since high school
23:49 <Lazersmoke> scope: a function's type *is* what it takes and what it returns (with an arrow in between)
23:49 <ph88^> glguy, i mean in the new type i only see 1 arrow, so i don't understand why it needs 3 parameters
23:49 <scope> see that's where the confusion came from lazersmoke
23:49 <orion> In category theory, if I have two morphisms f and g from any object a --> Bool, f _ = True, g _ = False, are f and g endomorphic, monomorphic, both, or neither?
23:49 tag joined
23:49 <scope> that's why every time I was asked "what's the type of this function?" I'm just like, "but it's a function..."
23:50 <scope> I never thought of it that way
23:50 <bollu> scope: I see
23:50 JagaJaga joined
23:50 fDev2179 left
23:50 <halogenandtoast> scope: but we need a way to distinguish between what functions take in and return
23:50 <halogenandtoast> so we can pass the around
23:50 <erisco> I will show you the world... a whole new world!
23:50 <scope> I just think of that as parameters and return types lol
23:50 <inferno-cop> scope: Haskell is different from C/C++ in that functions are also objects. A function is just another kind of "thing", like double, char etc.
23:50 <bollu> orion: doesn't endo only make sense in a monoid?
23:50 <halogenandtoast> scope: You need to realize that if you want to turn functions into parameters themselves
23:50 <halogenandtoast> their type signature matter
23:51 <orion> bollu: No idea. I'm just getting in to category theory.
23:51 <halogenandtoast> so you encode the type signature in the type
23:51 <scope> so can we go back to the map pointsOfEdge and try to clear that up?
23:51 <chaosmasttter> orion: you probably mean epi not endo
23:51 <halogenandtoast> a function that is (String -> Int) can not be passed as a parameter to something that wants (Int -> String)
23:51 <ski> orion : endomorphic iff `a' is `Bool'. monomorphic iff `a' is a subsingleton
23:51 <Lazersmoke> and the idea that functions are just normal "things" is called "first class functions"
23:51 <erisco> well I am not sure you've graduated from bollu's school of function types yet
23:52 <scope> lol
23:52 <erisco> you need to find the a and b such that a -> b is the same as Edge c -> [Point c]
23:52 <Lazersmoke> scope: see how "a -> b" matches "(Edge a) -> ([Point a])"?
23:52 <bollu> ski: don't endomorphisms need to form a ring?
23:52 <scope> yes lazer
23:52 <Lazersmoke> like how they have the same "shape"
23:52 <Lazersmoke> so what does a and b match with then?
23:52 <scope> oh wait
23:52 <halogenandtoast> :t map
23:52 <ski> bollu : just a monoid
23:52 <lambdabot> (a -> b) -> [a] -> [b]
23:52 <scope> so the [] is what is throwing it off?
23:52 <halogenandtoast> now do replacement
23:52 <orion> bollu: What "things" can I apply the label "monoid" to?
23:52 <scope> around [point a]
23:53 <Lazersmoke> [Something] just means a List of Something
23:53 <bollu> orion: have a binary operator, call it (<>), which has an identity element
23:53 <erisco> throwing what off? stay on target scope
23:53 <inferno-cop> scope: Just as you can have a variable that contains a Double, you can have a variable that contains a (Double -> Int). It just so happens that an object of type (Double -> Int) is a function that you can call with a Double to get an Int
23:53 <scope> right, but b isn't [b]
23:53 <erisco> or you'll miss the port hole and Darth Vader will win
23:53 <ski> Lazersmoke : the type of lists with elements of type `Something'
23:53 <orion> bollu: How does the concept of an operator translate in to CT?
23:53 <erisco> okay, lets do this step by step even furthe
23:53 <erisco> r
23:54 <erisco> we can match the -> with the other ->, right?
23:54 <Lazersmoke> yeah my bad; what I said only applies to types, not values
23:54 <scope> yes
23:54 Shatnerz joined
23:54 <erisco> so now we have to find the "a" that matches Edge c, what is that?
23:54 <orion> bollu: Does it only make sense to talk about "operators" in the categories of Set and Hask?
23:54 <scope> Edge? I literally don't understand
23:54 <ski> orion : depends on what you mean by "operators" ..
23:54 <erisco> okay, the types are a -> b and Edge c -> [Point c]
23:54 <orion> ski: bollu used the word "binary operator".
23:54 <orion> words
23:54 <erisco> "a", "b", and "c" are all type variables, meaning we can substitute *any* type for them
23:55 <erisco> we need a -> b to look like Edge c -> [Point c]
23:55 <scope> right, so why can't edge c just go where a is?
23:55 <halogenandtoast> scope it can
23:55 <erisco> yes, that is exactly it lol
23:55 <scope> what the fuck
23:55 <erisco> a = Edge c
23:55 Ayey_ joined
23:55 <erisco> now, what is b?
23:55 <halogenandtoast> so now you have Edge c -> b
23:55 <scope> Point c
23:55 <Lazersmoke> :t map
23:55 <halogenandtoast> no
23:55 <lambdabot> (a -> b) -> [a] -> [b]
23:55 Welkin joined
23:55 <erisco> Edge c -> Point c doesn't look like Edge c -> [Point c]
23:55 <halogenandtoast> b is not Point c
23:55 <scope> [point c]
23:55 <erisco> so try a different b
23:56 <Lazersmoke> b is "[Point c]", not "Point c"
23:56 <bollu> orion: endo-anything means that the domain and codomain are same
23:56 <halogenandtoast> yes [Point c]
23:56 <bollu> orion: so you can have endo-arrows
23:56 <erisco> okay! progress! :)
23:56 <bollu> Hom(X, X)
23:56 <scope> damn you guys are pickier than a compiler
23:56 <scope> hahaha
23:56 <bollu> scope: GHC is pickier than us :)
23:56 <erisco> so, a = Edge c and b = [Point c], so what is the type of map pointsOfEdge ?
23:56 <bollu> orion: you can have "endofunctors"
23:56 <ski> orion : if you have a category with categorical products, you can consider "multiple argument" morphisms, as morphisms whose domain object is a categorical product of a bunch of objects. like `(+) : Integer * Integer >---> Integer', e.g. .. or `between : Integer * Integer * Integer >---> Bool'
23:56 <scope> true that lol
23:56 bjz_ joined
23:56 <Welkin> pricklier
23:57 <Tuplanolla> Endorsement, bollu?
23:57 <bollu> Tuplanolla: :)
23:57 <Lazersmoke> scope: http://imgur.com/KZOJEaR
23:57 <scope> (Edge c -> [Point c] -> [Edge a] -> [[Point c]]
23:57 <halogenandtoast> yes!
23:57 <bollu> scope: Ithink you dropped a ")" somewhere
23:57 <allenj12> ok, so i looked up some church encoding to make a list. cons :: a -> b -> (Bool, (a, b))
23:57 <allenj12> cons h t = (False, (h, t))
23:57 <allenj12>
23:57 <scope> happens
23:57 <bollu> halogenandtoast: not yet ;) almost there
23:57 <erisco> well you missed a paren
23:57 <bollu> scope: where should the ")" go?
23:57 <halogenandtoast> yeah I missed the dropped )
23:57 <Lazersmoke> that's exactly right, scope :D
23:57 <ski> orion : in some cases you want to consider another "product" than categorical product, though ..
23:57 <allenj12> but how does this type? b should b (bool -> (a,b) but (True,True) contradicts that
23:58 <Lazersmoke> well almost
23:58 <erisco> and that is not the type of map pointsOfEdge, but that is on the way
23:58 <scope> (Edge c -> [Point c])
23:58 <bollu> ski: oh god, the tensoring and day convolution and all that craziness comes into picture now doesn't it? :D
23:58 <erisco> what you have is the type of map
23:58 <Welkin> lol day convolution
23:58 <* ski> smiles
23:58 <halogenandtoast> erisco: it was progress though
23:58 <scope> Edge a rather
23:58 <Welkin> that always reminds me of Chiat Day, the marketing company that makes the ads for apple
23:58 takle joined
23:58 <erisco> so map :: (Edge c -> [Point c]) -> [Edge a] -> [[Point c]] and pointsOfEdge :: Edge c -> [Point c] and so what is map pointsOfEdge?
23:58 <halogenandtoast> figuring out the next step is hard
23:58 <erisco> yes, we're going forward
23:58 <bollu> ski: I want to know where day convolution is actually used in math
23:59 <halogenandtoast> for some reason or another
23:59 <Lazersmoke> scope: map :: (Edge c -> [Point c]) -> [Edge a] -> [[Point c]]
23:59 <allenj12> i think i will make an lpaste so its clearer to read
23:59 takle joined
23:59 <ski> allenj12 : .. i don't think that would be called a church encoding. and i think you need dependent types, to statically type that