<    April 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
00:00 nick123 joined
00:01 alx741_ joined
00:02 alienbot joined
00:03 parolang joined
00:03 moth joined
00:04 darlan joined
00:06 gcross_ joined
00:06 plutoniix joined
00:06 <Jinxit> glguy: how would you do it with fundeps? they're still somewhat arcane to me
00:06 beanbagula joined
00:06 <glguy> class Walkable t i | t -> i where walk :: Walker i a -> t -> t
00:07 path[l] joined
00:08 alienbot joined
00:08 gmhafiz_ joined
00:08 IanKelling joined
00:10 acidjnk22 joined
00:12 biglambda joined
00:12 vektorweg11 joined
00:13 deech` joined
00:15 acidjnk22 joined
00:15 mda1 joined
00:17 futuristic joined
00:17 cp__ joined
00:23 Lord_of_Life joined
00:24 <robkennedy> Is there a version of `fold` for associative folds, which spawns multiple folds throughout the list? I might be describing a magic function
00:24 <joe9> utcToMillis :: UTCTime -> Integer ; utcToMillis = numerator . toRational . (* 1000) . utcTimeToPOSIXSeconds
00:24 exferenceBot joined
00:24 <joe9> is my function. I am definitely doing something wrong as I keep getting different values here.
00:24 <glguy> You don't want to use numerator
00:25 <joe9> I think it is the pico seconds that are messing the calculation
00:25 <joe9> glguy: What do you recommend using, please?
00:25 beanbagula joined
00:25 <joe9> when I just give a number of milliseconds, it works fine.
00:25 <joe9> but, if the time has some pico seconds in there, it messes up.
00:25 <c_wraith> robkennedy, foldMap can do that, depending on the specific Foldable instance in use. it will use that approach for a tree, but not for a list. (lists are inherently linear)
00:26 <joe9> I need UTCTime -> milliseconds as Integer
00:26 Rodya_ joined
00:27 roconnor joined
00:27 mekeor joined
00:28 <robkennedy> Ty c_wraith
00:29 <DrMentats> sorry, I was away for a bit
00:29 <DrMentats> so if I understand this right
00:29 <DrMentats> in name :: proxy t -> String
00:29 <DrMentats> proxy stands for a type constructor, basically?
00:30 <Koterpillar> yes
00:30 <Koterpillar> _any_ type constructor with one argument
00:30 <c_wraith> DrMentats, in fact, it stands for *any* type constructor
00:30 <glguy> proxy is any type with the correct kind
00:30 <Koterpillar> :k Maybe
00:30 <glguy> it doesn't have to be a type constructor
00:30 <lambdabot> * -> *
00:30 <DrMentats> that's really nice actually
00:30 ebzzry joined
00:30 <Koterpillar> glguy: isn't anything of that kind a type constructor?
00:30 <glguy> no
00:31 <c_wraith> how can you possibly use a type family there?
00:31 <glguy> Type constructors are the capitalized names introduces by data, newtype, type, etc at the type level
00:31 <glguy> proxy can be 'Either Int'
00:31 <c_wraith> Oh, you are counting partially applied type constructors
00:31 <glguy> or it can be a type variable you have in scope
00:32 <c_wraith> it does have to be generative. ie, not a type family
00:32 <glguy> type variables can't be instatiated with unsaturated type families
00:32 andyhuzhill joined
00:32 <glguy> so proxy won't be one of those
00:35 filterfish joined
00:36 featherlessbiped joined
00:37 vektorweg1 joined
00:38 carlosda1 joined
00:39 filterfish_ joined
00:40 <glguy> it also can't be the type constructor Int (as another counter example)
00:41 <Koterpillar> OK, thanks for clarifying my definition of a type constructor
00:43 <joe9> glguy, would you recommend properFraction. this seems to work: +utcToMillis = fst . properFraction . (* 1000) . utcTimeToPOSIXSeconds
00:44 <glguy> joe9: how about just 'floor' ?
00:44 <joe9> if it works, sure. Thanks. glguy.
00:44 moth joined
00:45 jgt3 joined
00:45 steeze joined
00:45 <joe9> glguy: it worked . Thanks.
00:46 beanbagula joined
00:48 anuxivm left
00:50 vektorweg1 joined
00:50 <joe9> glguy: How do I convert an integer to the DiffTime? fromInteger does not seem to do the correct thing. http://codepad.org/KXIbiFQU is what I am trying to do. I am writing a quickcheck instance to test the above code. I want to ensure that the time is in millisecond precision and not below.
00:50 ebzzry joined
00:51 Tourist joined
00:51 Tourist joined
00:52 bhiliyam joined
00:52 castlelore joined
00:52 castlelore joined
00:52 yellowj joined
00:53 Welkin joined
00:53 <pacak> joe9: picosecondsToDiffTime and diffTimeToPicoseconds
00:53 bschwb joined
00:54 Stanley00 joined
00:55 robertkennedy joined
00:55 <joe9> pacak: Thanks.
00:56 dan_f joined
00:56 nomicflux joined
00:56 ryxai joined
00:56 vaibhavsagar joined
00:58 <joe9> pacak: you would need to convert UTC to DiffTime, correct? The DiffTime in the UTC is only for this day, correct?
00:59 <pacak> UTCTime - specific time stamp DiffTime - relative between two timestamps
01:00 <joe9> pacak: ok, Thanks.
01:00 <pacak> I think there's some epoch UTCTime you can use
01:01 nick123 joined
01:04 Swizec joined
01:04 <joe9> pacak, got it. figured it out, I think.
01:04 SpaceGazebo3 joined
01:05 eacameron joined
01:07 halogenandtoast joined
01:07 Wizek joined
01:09 <halogenandtoast> Morning everyone
01:10 Destol joined
01:14 benl23 joined
01:14 asmyers joined
01:15 <nshepperd> glguy: 'type' doesn't define a type constructor does it?
01:15 TheInfosphere joined
01:17 <glguy> nshepperd: it does
01:18 <nshepperd> you're saying that a 'type constructor' is literally just any type with a capitalized name?
01:20 pera joined
01:20 <ezyang> Man, we should really have overloaded case
01:20 paul0 joined
01:20 bsima joined
01:21 <glguy> nshepperd: there are type constructors and type variables
01:22 <bsima> is there a function IO [a] -> IO () that prints all the a's?
01:22 <glguy> type variables are the lower cased ones, type constructors are uppercased and with extension can be operator symbols
01:22 Tourist joined
01:22 Tourist joined
01:22 <Koterpillar> bsima: with a Show a constraint, traverse print
01:24 beanbagula joined
01:24 ystael joined
01:24 leat joined
01:25 <halogenandtoast> If I have a list of lists [[1,2,3],[4,5,6],[7,8,9]] and a list of 2-tuples containing Ints [(1,1),(2,2)] can I use a lens (traversal?) to get a list of Maybe Ints corresponding to the positions [Just 5, Just 9] ?
01:26 <Welkin> what is the point of the Maybe?
01:27 <halogenandtoast> Welkin: that list of tuples could have invalid values
01:27 <halogenandtoast> [(10, 10)] should result in [Nothing]
01:27 <Welkin> just throw them out then
01:28 <nshepperd> halogenandtoast: I don't think you can make one traversal that does that. has the same problem as combining lenses - with [(1,1),(1,1)] you would break the laws
01:28 <halogenandtoast> Welkin: this sounds like a tangential problem unless doing so makes my initial problem easier somehow.
01:29 <nshepperd> halogenandtoast: but if you have a function that can turn a (Int,Int) into the right lens, you can just map that over your list of positions
01:29 <halogenandtoast> nshepperd: sure I could write that myLens (x, y) = ix x . ix y; I assume
01:29 <halogenandtoast> I'll try it out
01:30 <Welkin> a list seems like the wrong data structure
01:30 <Welkin> what are you trying to do with it?
01:30 <Welkin> Why not use a Map?
01:30 <nshepperd> \xxs positions -> map (\(i,j) -> xxs ^? (ix i . ix j)) positions
01:30 <nshepperd> somethn like that
01:30 <Welkin> you can use tuple keys
01:31 <halogenandtoast> Welkin: Given a list of neighboring positions, I want to count how many in my nested structure are flagged
01:31 <halogenandtoast> the positions and nested structure are independent.
01:31 {emptyset} joined
01:31 <Welkin> even still, a list is not right if you want to reference them by index
01:31 <Welkin> use an array
01:32 <Welkin> or array of arrays
01:33 sharkbabyxiang joined
01:33 <halogenandtoast> Welkin: I haven't yet used Array in Haskell, I'll check it out.
01:33 <Welkin> there is Array and Vector
01:33 <Welkin> Array is more flexible for how you index it
01:33 <halogenandtoast> and Sequences it seems
01:33 <Welkin> you can use whatever you want, including tuples
01:33 <Welkin> Sequence is my favorite
01:33 <Welkin> List is almost never the right data structure
01:34 <Welkin> it's more of a control structure, like for creating a "loop"
01:34 <halogenandtoast> Welkin: Yeah I'm reading that, I think that's a powerful observation I hadn't yet made.
01:35 robkennedy joined
01:36 <halogenandtoast> thanks nshepperd and Welkin
01:36 <halogenandtoast> Time to do a major refactoring
01:36 cross joined
01:37 QRealm joined
01:42 path[l] joined
01:44 sword865 joined
01:45 splanch joined
01:47 hexfive joined
01:48 Goplat joined
01:48 Supersonic112_ joined
01:53 bhiliyam joined
01:54 <bsima> thanks Koterpillar, mapM_ ended up working for me
01:54 <bsima> plus do-notation (which I've been trying to avoid, but oh well)
01:54 <Koterpillar> :t traverse print
01:54 <lambdabot> (Show a, Traversable t) => t a -> IO (t ())
01:55 <Koterpillar> :t traverse_ print
01:55 <lambdabot> (Show a, Foldable t) => t a -> IO ()
01:55 <bsima> yeah, the error was "No instance of Traversable" or something like that
01:56 <Koterpillar> lists are
01:56 <Koterpillar> what did you end up with?
01:56 <bsima> I've got a list of records
01:57 codesoup joined
01:57 <bsima> mapM_ print myList
01:57 <Koterpillar> :t mapM_
01:57 <lambdabot> (Monad m, Foldable t) => (a -> m b) -> t a -> m ()
01:57 <Koterpillar> :t traverse_
01:57 <lambdabot> (Applicative f, Foldable t) => (a -> f b) -> t a -> f ()
01:57 <bsima> ah, so they are basically the same
01:58 serendependy joined
01:58 urodna joined
02:00 beanbagula joined
02:00 hucksy joined
02:02 darjeeling_ joined
02:02 ertes joined
02:06 adolby joined
02:06 sellout- joined
02:06 safe joined
02:06 exferenceBot joined
02:10 brynedwards joined
02:11 hexagoxel joined
02:13 dolio joined
02:13 Qommand0r joined
02:14 darlan joined
02:15 SCHAPiE joined
02:19 jsgrant joined
02:20 <lpaste> DrMentats pasted “GADTs Are Fun” at http://lpaste.net/354525
02:20 <joe9> http://dpaste.com/3CYNA05 is my code . I figure there is a way to used Data.Fixed.Pico instead of Integer when converting to and from UTCTime to picoseconds. any suggestions on how , please?
02:20 <Koterpillar> DrMentats: do you want Typeable and/or Generic?
02:21 Argue_ joined
02:22 thang1 joined
02:22 <thang1> summmer of haskell 2017 looks awesome
02:22 <DrMentats> well, what I wanted originally was a way to pass types around as values but while still being able to use them as instances
02:22 vaibhavsagar joined
02:22 burtons joined
02:23 <thang1> DrMentats: why? (jumped into the middle of that and I have no context)
02:24 <DrMentats> I hadn't described the problem yet actually, but what I'm making is an interpreter for a dynamic language, and there is a data type that represents arbitrary haskell values wrapped in Dynamic
02:24 Orion3k joined
02:24 infinity0 joined
02:24 <DrMentats> but I also wanted to pass some information around, such as type names, so I could say things like "got an int where a string was expected"
02:25 takle joined
02:26 <thang1> Have you looked at how GHC's error reporting tells you what type it wanted and what type it got?
02:26 lpsmith joined
02:26 systemfault joined
02:27 <DrMentats> well, the GADT approach seems to work great, and is also extensible, which is perfect for my needs
02:28 infinity0 joined
02:29 Rodya_ joined
02:30 sanitypassing joined
02:30 mekeor joined
02:30 <thang1> Ooh, also
02:30 infinity0 joined
02:31 WarmCookie joined
02:31 takle joined
02:31 <WarmCookie> Hi guys, can I create a sum type that also uses existantial quantification?
02:31 robertkennedy joined
02:32 <thang1> have you seen this paper, DrMentats? https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/trees-that-grow.pdf
02:32 sleffy joined
02:32 <Zemyla> WarmCookie: You may need to use GADts for htat.
02:32 j2j joined
02:32 dreco joined
02:32 raycoll joined
02:33 <DrMentats> I definitely will read it
02:33 infinity0 joined
02:34 <WarmCookie> Also, is this legal or can I make it legal easily?
02:34 <WarmCookie> data Ui = exists c. Ui { uiUpdate :: Event -> Game c Result, uiRender :: Renderer c () }
02:34 SimpleL joined
02:36 <thang1> (The paper paper goes over a syntax tree that can be extended to add new constructors and new fields to existing constructors fairly easily)
02:36 infinity0 joined
02:37 juhp joined
02:38 eacameron joined
02:38 nomicflux joined
02:39 <thang1> Dumb question, why do you name it Ui instead of UI, WarmCookie?
02:39 infinity0 joined
02:39 <DrMentats> it may be a little too academic for a humble hacker like me, but I'll see if I can make sense of it
02:40 <thang1> The actual idea behind it is actually relatively simple. They talk about things as fully general as possible (of course), but starting with section 3 is the explanation for what their solution is. The paper itself also is a literate haskell file so you can run all of the code in it and try it out
02:40 carlosda1 joined
02:41 <DrMentats> oh I think I see it now
02:41 <DrMentats> so the general gist is that you can extend the tree without having to change its internals?
02:42 <DrMentats> because if that's it then I really am interested
02:42 <thang1> Much of the paper is actually revolving around taking the very simple idea and hiding much of the implementation so that it doesn't feel any more cumbersome. Yeah that's the idea behind it
02:43 <WarmCookie> Zemyla: Worth checking, thanks.
02:44 <thang1> Midele of page 5 is how they write the extensible version of the data type. It's relatively simple to see the changes they made, which is why I like it so much
02:45 <DrMentats> so you fancy this kind of thing too? compilers and the such?
02:45 <thang1> top of page 6 shows the "undecorated" version of the tree. Most of the rest of the paper details ways to hide away the added complexity and added typing that the extensible solution requires
02:45 <DrMentats> it's been a favorite subject of mine in programming for the longest time
02:46 a3Dman joined
02:46 <thang1> I love Haskell in general. Functional languages, etc. Not so much compilers, but they're also super neat. I'm more into data structures, algorithms, how things are written and how to write programs that generate programs as well.
02:46 <thang1> I have a feeling I'd really like writing compilers and languages since I come up with toy ideas all the time; I've never gotten around to it yet, though. I'm still only on chapter 11 of the haskel from first principles book
02:48 <DrMentats> I usually just caught glimpses of this kind of thing, before coming to haskell
02:48 <DrMentats> now it seems to me that this is all it's about
02:48 <thang1> lol funny how that works
02:49 teggi joined
02:49 takle joined
02:49 <thang1> before haskell I was fine writing imperative code. Now that I've taken a well designed C++/OOP intro-ish course series at my University and used Java/C++ for "semi real" stuff and am finally getting into how to actually think in Haskell... I'm really enjoying it all
02:50 <thang1> It's pretty neat to actually understand most of what's on the subreddit now. Before it was "oh cool, *save link*, I'm sure I'll understand that in a year or three"
02:50 <thang1> Now, what's your dynamic language like?
02:50 <thang1> I'm curious :)
02:51 <DrMentats> I hate to admit it, but I used to be scared of monads. When I heard about Haskell, I just though "well, you can't have side effects in it? what's it good for then?"
02:51 <DrMentats> little did I know
02:52 <thang1> hah that actually was just relevant today outside of programming
02:52 <thang1> in my quantum computing class at uni, we were going over quantum gates and measurement
02:53 <thang1> In quantum computing, you have to delay measurement until the very end of the computation, so the question was "is it still as powerful as classical computing?" and my immediate response was "of course. Function transformations are a valid way to program in pure languages with referential transparency"
02:53 <thang1> took a few of the imperative people a bit to catch on though
02:54 <DrMentats> heh I can imagine that
02:54 <DrMentats> speaking of how great Haskell is
02:54 <DrMentats> http://lpaste.net/354526
02:54 bhiliyam joined
02:54 <DrMentats> I still can barely believe that this works AND is type safe
02:55 <DrMentats> if I had used a traditional data type for TypeInfo, I couldn't guarantee that Magic contains the type it describes
02:55 meandi_2 joined
02:56 <thang1> I swear, type systems are magic in haskell sometimes
02:56 cables joined
02:56 <lordcirth> DrMentats, it looks interesting but I don't really understand it
02:56 <lordcirth> I'm a beginner
02:56 <thang1> I just type a bunch of shit out. Hit save and think "this probably won't work; it's literally the first thing that came to mind..." and it typechecks
02:56 <thang1> then I'm like "huh... neat... did that work?" (and it does). Great feeling
02:56 <DrMentats> lol exactly
02:56 <lordcirth> DrMentats, you have a typeclass that lets you print the name of the type, is that it?
02:57 {emptyset} joined
02:57 <DrMentats> yes, any type can be an instance of TypeInfo if it can be named
02:57 <thang1> Yeah, he's writing a dynamic language and wants error messages that are useful
02:58 <Welkin> just add static types
02:58 <DrMentats> this uses GADTs, which is an extension of haskell, so you're not likely to see it every day
02:58 tinkyholloway joined
02:58 <Welkin> like javascript's flow
02:58 <DrMentats> I might, eventually
02:59 <DrMentats> but the language is more aimed at quick scripting, so I don't want to make it too strict
02:59 <thang1> You mean, too useful? :p
02:59 <DrMentats> lol
02:59 takle joined
02:59 <DrMentats> I'm a big ruby fan, I'll have you know
03:00 <DrMentats> anyway, you asked about the language before
03:00 <thang1> I'm a lisp fan :D
03:00 <thang1> dem macros <3
03:00 <DrMentats> I'll put it on my github once I refactor it a bit, code is really ugly right now
03:00 <DrMentats> oh I love lisp too
03:00 <thang1> nice!
03:01 <DrMentats> I'd like to support macros, I just don't know how to implement them lol
03:01 <thang1> I need to learn Lisp... One thing at a time, though. I'm taking 4 classes (full time) and don't want to kill myself
03:01 <thang1> DrMentats: If your language is homiconic, it's much easier
03:02 <DrMentats> that's true, but it's just
03:02 <DrMentats> have you seen any homoiconic languages beside lisp?
03:02 <thang1> Then it's a simple matter of text expansion, is it not?
03:02 <DrMentats> there might not exist others at all lol
03:02 <Sornaensis> prolog
03:03 nick123 joined
03:03 <thang1> http://wiki.c2.com/?HomoiconicLanguages
03:03 <DrMentats> prolog huh? I had no idea
03:03 <Sornaensis> prolog programs are prolog terms
03:03 chlong joined
03:03 chlong_ joined
03:03 <thang1> which makes sense considering that predicate calculus itself is built inductively
03:03 <Sornaensis> it's a neat concept
03:04 thunderrd joined
03:04 <DrMentats> either way, afaik, lisp macros go much beyond simpe text substitution
03:05 <DrMentats> there's the whole evaluation phase thing
03:05 <thang1> https://en.wikipedia.org/wiki/Rebol Rebol is a multi paradigm homoiconic language as well
03:06 plutoniix joined
03:06 <DrMentats> I'm deeply inspired by Rebol, too bad it's very slow to parse, since semantics change based on function arity and you can only detect this at runtime (for a dynamic language)
03:06 xtreak joined
03:07 plutoniix joined
03:07 <thang1> http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html and more than you ever wanted to know about lisp macros is here
03:08 <DrMentats> I think it depends a lot on whether we're talking about common lisp or scheme though
03:09 crobbins joined
03:09 jgt3 joined
03:10 <DrMentats> Racket's (a scheme) macros are lexically scoped, for example
03:10 <thang1> Really? That's neat
03:10 takle joined
03:10 <DrMentats> yeah, they really focus on macro hygiene there
03:11 <thang1> Now I'm curious as to whether or not Clojure macros can be typechecked...
03:12 <DrMentats> I wonder if Rebol could be typechecked to make it possible to parse it ahead of time
03:12 <DrMentats> which understandably would make it less flexible though
03:12 <DrMentats> speaking of languages that are parsed during run time, I believe Tcl is the ultimate one
03:13 <thang1> Is that the language that has zero difference between runtime, compile time, and evaluation?
03:13 <DrMentats> everything is a string lol
03:13 <thang1> (even lisp has a tiny difference)
03:13 <thang1> lol that would do it
03:14 <DrMentats> you need to use a function to do arithmetics, which is basically a fully fledged parser
03:14 <DrMentats> you don't even know if you got the syntax right until the program is already running
03:16 harfangk joined
03:16 fkurkowski joined
03:16 <DrMentats> anyway, sorry for going off-topic. lordcirth, if you have any more questions about my code, I would be happy to explain, even though I'm a bit of a beginner myself.
03:17 dan_f joined
03:18 dpepsilon joined
03:18 dpepsilon joined
03:18 takle joined
03:18 jgt3 joined
03:18 <parolang> Wow funny you guys are talking about Prolog while I was reading about it
03:19 <thang1> what were you reading?
03:19 xtreak joined
03:19 felixsch_ joined
03:19 turnage joined
03:21 <joe9> what is the function to do Integer -> Data.Fixed.Pico?
03:21 <Sornaensis> @hoogle Integer -> Data.Fixed.Pico
03:21 <lambdabot> No results found
03:21 <Sornaensis> :(
03:21 <thang1> ? are you trying to use an integer in a function that uses *.Pico?
03:22 <thang1> FromInteger is probably what you want, in that case?
03:23 <Sornaensis> :t fromInteger
03:23 <lambdabot> Num a => Integer -> a
03:23 <joe9> http://codepad.org/2YAnRnJj I am doing this. but want only second precision
03:23 <joe9> I can use arbitrarySizedIntegral but cannot figure out how to go from Integer to pico
03:24 <geekosaur> it has a Num instance, so fromInteger
03:24 <thang1> Well, as a side note, why do you care about less precision vs more precision? There are no performance concerns Haskell the same way there are in C-style languages
03:24 <thang1> But yeah, fromInteger can be thought of as a "cast" into any type that derives from Num
03:26 <joe9> thang1: I am parsing it out to a file and reading back in and the data is in second format. If I go for more precision the tests are failing.
03:26 BlueRavenGT joined
03:28 <parolang> thang1: http://stackoverflow.com/questions/8297574/difference-between-logic-programming-and-functional-programming
03:28 <joe9> newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord is not exposed in Data.Time.Clock.Internal. How do you build up the NominalDiffTime?
03:28 <joe9> I have a pico value but the constructor is not exposed.
03:29 <DrMentats> if the tests pass with less precision but fail with more, then I might suggest that you change the tests instead of the data itself
03:29 codesoup joined
03:29 contextfree joined
03:29 jgt3 joined
03:29 <joe9> DrMentats: That is what I am doing . trying to get a better or more suitable Arbitrary instance
03:30 <DrMentats> ah, I see, forgive my misunderstanding
03:30 Rodya_ joined
03:31 tathougies joined
03:31 sanitypassing joined
03:32 <joe9> geekosaur: would you mind helping, please? I want to build a NominalDiffTime but the constructor does not seem to be exposed. http://codepad.org/aAPWCVTL
03:33 <joe9> Is there a better time package? this seems bad.
03:35 takle joined
03:35 nshepperd joined
03:35 otto_s_ joined
03:36 xtreak joined
03:36 <geekosaur> I see NominalDiffTime having Enum and Num instances. I also see in the documentation "Conversion functions will treat it as seconds."
03:38 <joe9> when there is a Num instance, does that mean I can just do x = (100 :: Uni) where x :: POSIXTime?
03:38 <joe9> geekosaur: POSIXTime is a type synonym for NominalDiffTime
03:38 <joe9> I cannot figure out how to do x :: NominalDiffTime when I have the value that belongs in that newtype.
03:38 <joe9> geekosaur: Does that make sense?
03:39 <geekosaur> Num instance means fromInteger will work. Enum instance means toEnum will work
03:39 <joe9> http://codepad.org/NIkJBXMV
03:39 <joe9> geekosaur: it is a hidden module in the package ‘time-1.6.0.1@time-1.6.0.1’
03:39 <DrMentats> maybe you can generate two UTCTimes instead and then get the difference between them?
03:39 <joe9> when I try to load Data.Time.Clock.UTC
03:39 <thang1> parolang: thanks! Looks interesting
03:40 <thang1> Have you read up on anything about the programming language Curry?
03:40 <geekosaur> that means you are yusing cabal repl or stack ghci and did not declare the time package as a dependency
03:40 <geekosaur> ...or maybe you did so but with an older version that lacks those, but I doubt that
03:41 carlosda1 joined
03:41 <joe9> geekosaur: :m +Data.Time.Clock works fine.
03:41 <joe9> geekosaur: I will follow your advice and use UTCTime's instead.
03:41 <geekosaur> in any case I am looking at Data.Time.Clock not Data.Time.Clock.UTC
03:42 <geekosaur> in fact I see no such public module in time-1.6.0.1. what led you to try to use it?
03:42 takle joined
03:42 <joe9> but, the constructor of NominalDiffTime is defined in the UTC file and it does not seem to be exported.
03:42 <geekosaur> maybe there's a reason for that
03:42 <joe9> makes sense.
03:43 <joe9> Thanks.
03:43 <geekosaur> do you normally source dive to look for constructors to use instead of sticking to the documented public interface?
03:43 <geekosaur> I mean, I'm just looking at the haddock for Data.Time.Clock. I'm not sure why you need help with that.
03:44 mzf joined
03:44 <joe9> geekosaur: I was going by what the info of ghci suggested.
03:45 Jesin joined
03:45 <geekosaur> you need to be careful with that, yes, it will happily lead you to internals you probably shouldn't poke at directly. Doublecheck against the haddock.
03:45 <thang1> GHCI is fameously simultaneously incredibly useful and incredibly useless
03:45 <parolang> thang1: I've been reading about it too. Interesting.
03:46 <thang1> My professor fall quarter for discrete structures is one of the main guys who's been working on Curry
03:46 <geekosaur> ghci has only limited ways to control what it shows you; normally it drills as deep as it can. but it has no way to know whether a module is part of the exposed interface or not
03:46 <thang1> I'm hoping to pick his brain about it because that language fascinates the fuck out of me
03:46 xall joined
03:46 <parolang> yep
03:47 vlatkoB joined
03:48 revprez_atlanta joined
03:48 <parolang> Maybe they key is to think in terms of relations rather than (mathematical) functions.
03:48 halogenandtoast joined
03:49 <parolang> Thats why logic programming seems so weird.
03:52 <parolang> A function is only half of a relation :)
03:52 <thang1> For logical languages you think in terms of logical predicates
03:53 takle joined
03:53 <parolang> Predicate = Relation roughly
03:54 vite joined
03:54 bhiliyam joined
03:57 splanch joined
03:57 <DrMentats> well, I'm getting sleepy. it was nice talking to you all. see you guys tomorrow!
03:57 <thang1> see ya
03:57 <parolang> night
03:58 <thang1> ironically I found the lowest answer on the stack overflow page to be the most enlightening
03:58 IndigoTiger joined
03:59 Sose_ joined
03:59 cschneid_ joined
04:00 takle joined
04:01 dreco joined
04:02 ali_bush_ joined
04:04 hamishmack joined
04:04 ali_bush joined
04:04 ali_bush joined
04:05 flatmap13 joined
04:08 harrismai joined
04:10 <joe9> is the quickcheck arbitrary strict? arbitrary = ModifiedJulianDay <$> (elements [40587 .. ]) hangs the system
04:13 raycoll joined
04:14 takle joined
04:14 chenshen joined
04:15 iqubic joined
04:15 raycoll joined
04:16 splanch joined
04:16 <iqubic> Is there a suitable data type for x y co-ordinate points?
04:17 flatmap13 joined
04:18 sanitypa1 joined
04:18 <MarcelineVQ> joe9: the way elements is written needs to know the size of the list in order to pick one randomly
04:18 <joe9> Data.V2?
04:18 <MarcelineVQ> and length on an infinite list is a bad time
04:18 <joe9> oh, ok. Thanks. any recommendations on how I can tell Quickcheck to take any number greater than a particular number?
04:19 <joe9> I can hardcode the max value, but, it would be ideal to let quick check pick what it likes.
04:19 <iqubic> joe9: Where can I find a link to Data.V2?
04:20 <MarcelineVQ> I'm sorry I don't really understand the question, what does it mean for quickcheck to take a number?
04:20 wagle joined
04:20 <joe9> MarcelineVQ: do not worry. I think I figured it out. Sorry for the bother.
04:20 <MarcelineVQ> np
04:20 <joe9> i think diagrams uses points quite a bit
04:22 <MarcelineVQ> did you mean Linear.V2? if so then https://hackage.haskell.org/package/linear-1.20.5/docs/Linear-V2.html
04:22 raycoll joined
04:23 <joe9> MarcelineVQ: I notice something similar with this too: instance Arbitrary Text where arbitrary = suchThat arbitrary (T.all ((/=) '\0'))
04:23 <joe9> I want to generate text elements that do not have null in them. q
04:23 <joe9> quick check hangs when I use that arbitrary instance.
04:24 <joe9> Yes, Linear.V2
04:24 raycoll joined
04:25 juhp joined
04:26 insitu joined
04:26 <iqubic> Is Linear.V2 the best library for dealing with 2-d points?
04:28 raycoll joined
04:30 parolang left
04:30 <MarcelineVQ> joe9: hmm well consider which arbitrary you're passing to suchThat
04:31 Rodya_ joined
04:31 mazeinmaze_ joined
04:31 eklavya joined
04:32 _sras_ joined
04:32 raycoll joined
04:32 <joe9> oh, yeah. good point. MarcelineVQ
04:33 <_sras_> I want to the hash of the currently checkout commit to a file, before a stack build. Is there any way to include this step in the `stack build` command itself so that it won't be missed?
04:34 <_sras_> srry. I mean, I want to write the hash of the currently checked out commit to a file...
04:35 <MarcelineVQ> Yes, but it's likely easier to write a shell script or makefile or something and use that to build with
04:35 takle joined
04:36 <MarcelineVQ> Depends on where your strengths are is what I mean by that. You can customize Setup.hs to do pretty much anything
04:37 raycoll joined
04:37 <joe9> MarcelineVQ: any suggestions on how to go about building an arbitrary without null values for Text, please? most of the quickcheck functions such as bounded, etc. are for integers.
04:37 <joe9> s/integers/numbers/
04:38 <MarcelineVQ> I probably wouldn't, I'd use a full normal arbitrary for Text and modify that when I need a specific kind of Gen
04:38 insitu joined
04:38 <iqubic> Is Linear.V2 the best library for dealing with 2-d points?
04:40 wroathe joined
04:41 <MarcelineVQ> joe9: iow I wouldn't try to customize the instance, at least not without a newtype wrapper. I'd use a normal one like you'd find in https://hackage.haskell.org/package/quickcheck-instances and then use something like suchThat on it where it to be more specific
04:41 beanbagula joined
04:42 carlosda1 joined
04:42 raycoll joined
04:42 thunderrd joined
04:43 <MarcelineVQ> iqubic: no idea, if people don't answer you btw it's usually that people don't know or people that do know aren't around
04:45 raycoll joined
04:47 feynhat joined
04:47 hybrid joined
04:49 <joe9> MarcelineVQ: Thanks. good idea.
04:49 <iqubic> I'll look aroujnd.
04:49 <joe9> iqubic: I think it was when I was checking out Diagrams. and Diagrams uses it extensively (I think)
04:49 wroathe joined
04:50 <MarcelineVQ> iqubic: possibly a good lead is to look at programs likely to deal with 2d things and see what they dso
04:50 <halogenandtoast> So this reddit post intrigues me a little: https://www.reddit.com/r/haskell/comments/64ui11/reasons_i_dislike_type_synonyms/
04:50 raycoll joined
04:50 <halogenandtoast> I was using a couple of type synonyms and I wonder if they fall into the same pitfalls (if those are actually pitfalls)
04:50 <halogenandtoast> I had the following type Dimensions = (Int, Int) and type Position = (Int, Int)
04:50 <halogenandtoast> should these be ADTs instead?
04:51 <halogenandtoast> err newtype Dimensions = Dimensions Int Int for example
04:51 <MarcelineVQ> often​ I start with 'type' like that and move them to data or newtype as the program forms
04:51 xall joined
04:52 <MarcelineVQ> Mostly to be more descriptive when things are still forming, foo :: Width -> Height -> Waffle is nicer than Int -> Int -> (Int,Int)
04:52 <MarcelineVQ> for someone's opinion of nicer :>
04:53 Xanather joined
04:53 osa1 joined
04:53 osa1 joined
04:53 <halogenandtoast> MarcelineVQ: yeah I was trying to get to the point where you could understand functions from the type signature fairly easily
04:54 andyhuzhill joined
04:55 raycoll joined
04:55 fizruk joined
04:55 bhiliyam joined
04:56 pzuck joined
04:58 Swizec joined
04:58 <cocreature> MarcelineVQ: personally I mostly stopped using type synonyms and use newtypes/adts instead
04:59 <cocreature> having the compiler yell at me when I mix things up is really helpful :)
05:00 <cocreature> halogenandtoast: also you probably also want the fields of Dimensions and Position to be strict in most cases so that’s another reason to go for ADTs instead of type synonyms
05:00 wroathe joined
05:00 takle joined
05:00 <halogenandtoast> cocreature: what do you mean by strict?
05:01 <cocreature> halogenandtoast: data Position = Position !Int !Int
05:01 raycoll joined
05:02 <halogenandtoast> What does that do?
05:02 beanbagula joined
05:03 <halogenandtoast> is it just more efficient in regards to the heap?
05:03 raycoll joined
05:04 <iqubic> What's ADT?
05:04 <halogenandtoast> iqubic: I'm 99% certain I used it incorrectly there but I meant Algebraic Data Type
05:04 nick123 joined
05:05 <cocreature> halogenandtoast: when you apply a data constructor each argument with a strictness annotation, i.e. !, is evaluated to whnf.
05:05 <cocreature> algebraic data type is correct
05:05 <iqubic> What's Weak Head Normal Form???
05:06 <halogenandtoast> iqubic: I sort of have the same question, but mine is, what benefit does having something evaluate to whnf have?
05:06 <cocreature> iqubic: https://stackoverflow.com/questions/6872898/haskell-what-is-weak-head-normal-form
05:06 <cocreature> halogenandtoast: it avoids space leaks
05:07 dreco joined
05:07 <cocreature> halogenandtoast: let’s say we have a function "(Int, Int) -> (Int, Int) -> (Int, Int)" that does elementwise addition
05:07 <halogenandtoast> so f (1, 2) (3, 4) = (4, 6)
05:07 <cocreature> now you are given a list [(Int, Int)] and since you know about space leaks you think it might be a good idea to use foldl' here
05:08 <halogenandtoast> "and since you know about space leaks" big assumption there :p
05:08 andyhuzhill joined
05:08 <halogenandtoast> but let's roll with it.
05:08 <cocreature> halogenandtoast: oh sorry, let me go back
05:08 <cocreature> halogenandtoast: so do you know why implementing "sum = foldl (+) 0" can cause problems?
05:09 dec0n joined
05:09 <cocreature> specifically why it doesn’t run in constant memory
05:09 caumeslasal joined
05:10 darlan joined
05:10 <halogenandtoast> because it can't reduce?
05:10 wroathe joined
05:10 <halogenandtoast> or the reduction happens rightmost
05:10 <halogenandtoast> not that it can't
05:10 raycoll joined
05:11 <halogenandtoast> 0 + (1 + (2 + 3))) vs (((0 + 1) + 2) + 3)
05:11 <cocreature> so if we run "foldl' (+) 0 [1,2,3]" we end up with a thunk representing (((0+1)+2)+3)
05:11 <halogenandtoast> @define thunk
05:11 <lambdabot> Parse failed: TemplateHaskell language extension is not enabled. Please add ...
05:11 <cocreature> but that’s not what we want! we want to force the evaluation of the accumulator at each step
05:12 <cocreature> a thunk is a value that still needs to be evaluated
05:12 <halogenandtoast> 理解
05:12 <cocreature> so what we are looking for is first add 0+1, force the evaluation so we get 1, then add 2, force the evaluation so we get 3, …
05:12 <halogenandtoast> okay
05:12 moet joined
05:13 <cocreature> that’s what foldl' gives us
05:13 <moet> how does STM interact with IO?
05:13 <moet> i don't think IO actions can be undone in a transaction which fails...
05:14 <moet> you generally don't want IO actions to be retried if a transaction is retried...
05:14 <cocreature> moet: that’s why you can’t embed IO actions in STM :)
05:14 jgt3 joined
05:15 raycoll joined
05:16 <moet> cocreature: what.. hrm.. i haven't finished rewriting a file to use STM, but i'm pretty sure the part that does liftIO in STM is typechecking
05:16 <cocreature> moet: STM is not an instance of MonadIO so you can’t use liftIO
05:17 filterfish joined
05:17 <iqubic> Alright what does seq do?
05:18 Mysterious_Light joined
05:18 <moet> cocreature: hmm.. maybe there's a later typechecker pass which will find that.. thanks for clarifying!
05:19 <monochrom> There is only unsafeIOToSTM if you want to risk it, but it is still not made liftIO.
05:20 raycoll joined
05:20 wroathe joined
05:21 <monochrom> The official bridge between STM and IO are only atomically and newTVarIO. And they are a one-way street.
05:21 Kuros joined
05:21 <iqubic> So, what does seq do? Is it useful?
05:21 lithie joined
05:21 jgt3 joined
05:22 <opqdonut> iqubic: it allows you to influence evaluation order and strictness
05:22 xall joined
05:22 <opqdonut> iqubic: it's very useful, but it's a bit of a hack
05:22 JoshS joined
05:23 edvorg joined
05:23 <opqdonut> often instead of explicit seq one uses BangPatterns or strict data
05:24 <iqubic> So, how does one use seq?
05:24 <pacak> :t seq
05:24 <lambdabot> a -> b -> b
05:24 frangor joined
05:24 <iqubic> That's not too helpful.
05:24 <opqdonut> well as a toy example "strictAnd x y = y `seq` (x && y)"
05:25 <pacak> You pass whatever you want to evaluate as a and whatever you want to return - as b
05:25 <cocreature> "seq a b" evaluates to "b" but before returning it will also evaluate "a"
05:25 raycoll joined
05:25 serendependy joined
05:25 <iqubic> What the heck???
05:25 <opqdonut> now "strictAnd False undefined" is an error, unlike "False && undefined" which is False
05:25 beanbagula joined
05:25 <pacak> :t const
05:25 <lambdabot> a -> b -> a
05:25 <pacak> > const () undefined
05:25 <halogenandtoast> cocreature: so I'm not sure how what you said related to doing Dimensions !Int !int
05:25 <lambdabot> ()
05:26 <pacak> > seq undefined ()
05:26 <lambdabot> *Exception: Prelude.undefined
05:26 <pacak> Something like that
05:26 <opqdonut> for a real use of seq, consider:
05:26 <opqdonut> @src foldl'
05:26 <lambdabot> foldl' f a [] = a
05:26 <lambdabot> foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs
05:26 <opqdonut> the strict foldl
05:26 <halogenandtoast> I'd assume with my limited knowledge that an Int would already be in normal form
05:26 <glguy> (1 + 2) :: Int
05:26 <cocreature> halogenandtoast: that ensures that you can’t build up thunks inside of the fields of Dimensions: whenever you apply the Dimensions constructors, the arguments will be evaluated first
05:26 <pacak> halogenandtoast: Nope.
05:26 <pacak> > const (1 + undefined) ()
05:27 <lambdabot> *Exception: Prelude.undefined
05:27 <pacak> > const () (1 + undefined)
05:27 <lambdabot> ()
05:27 <cocreature> pacak: that’s Integer :)
05:27 takle joined
05:27 <pacak> > const () ((1 :: Int) + undefined)
05:27 <lambdabot> ()
05:27 <pacak> > seq ((1 :: Int) + undefined) ()
05:27 <cocreature> halogenandtoast: for Int whnf and nf is the same but an Int can still be unevaluated
05:27 <lambdabot> *Exception: Prelude.undefined
05:28 <halogenandtoast> cocreature: I see
05:28 <moet> ah, there it is
05:28 <halogenandtoast> I now understand the effect, but not the side-effects.
05:28 insitu joined
05:28 <moet> i guess i was still in the 'in scope' pass.. it wasn't checking typeclass contexts
05:28 <moet> thanks cocreature
05:28 <halogenandtoast> Would I want to make all types like that strict?
05:29 <cocreature> halogenandtoast: definitely not. e.g. if [] was defined like that you couldn’t have infinite lists
05:29 DataComputist joined
05:29 <cocreature> usually it makes sense to make “small” fields strict. so things like Bool, Int, …
05:29 <cocreature> but be lazy especially when it comes to recursive data types
05:30 <iqubic> Yeah. You don't want a strict list.
05:30 wroathe joined
05:32 piyush-kurur joined
05:33 raycoll joined
05:35 danvet joined
05:37 piyush-kurur joined
05:38 splanch joined
05:39 govg joined
05:40 <monochrom> I wouldn't call seq a hack where BangPatterns and StrictData aren't. They are equivalent. So either all of them are hacks or none of them are.
05:41 <halogenandtoast> cocreature: thanks for the explanation.
05:42 Xanather_ joined
05:42 <halogenandtoast> It's seems like a neat part of Haskell I haven't tinkered with yet.
05:42 carlosda1 joined
05:43 _paul0 joined
05:45 <opqdonut> monochrom: agreed, they're equivalent. maybe hack was the wrong word... necessary evil? practical but impure?
05:46 raycoll joined
05:46 Swizec joined
05:49 tomboy64 joined
05:49 fakenerd joined
05:49 <monochrom> They can be hacks. John Hughes invented seq to reduce laziness so when you think that laziness uses more memory than necessary you can kill it. And it has the non-ideal consequence of bursting the denotational dream of bottom = \_ -> bottom
05:50 <opqdonut> indeed
05:50 Mutter joined
05:50 ryantrinkle joined
05:51 wroathe joined
05:53 benl23 joined
05:53 dustmote joined
05:53 doomlord joined
05:54 fakenerd joined
05:54 ThomasLocke joined
05:54 ThomasLocke joined
05:54 Argue__ joined
05:55 <thang1> A nice way to think of whether or not to be strict vs lazy is "lazy in the spine, strict in the leaves"
05:55 <thang1> or, to expand on those definitions slightly, the organization and evaluation of the STRUCTURE of the data type should be lazy as possible
05:55 <thang1> However, the organization and evaluation of the CONTENT of the data type should be strict as possible
05:56 nick123 joined
05:56 <thang1> When you do 1 + 1 you don't want to wait, you want a 2 the second you type 1 + 1
05:56 bhiliyam joined
05:56 eacameron joined
05:56 <thang1> But when you define a list [1..] you don't actually care about the list yet, you're just saying "this data structure has a structure of a list that counts from 1 up to infinity" and that's all you care about
05:57 Shatnerz0 joined
05:57 <monochrom> Unless and until one person's content is another person's structure. For example Map Int (Map Tree (InfiniteList Bool))
05:58 raycoll joined
05:59 <thang1> Which is why it's a rule of thumb and not a biblical rule ;)
05:59 andyhuzhill joined
05:59 <thang1> But still, why would you do that anyway...?
05:59 julienchurch joined
05:59 <ongy> monochrom: is that actually a problem? afaik that would only evaluate the outer constructor? So probably the root node
06:00 <monochrom> Sure, I wouldn't go that far. But Map Int (InfiniteList Double) is already pretty plausible and proves the point.
06:00 <ongy> oh I parsed that one wrong, but same thing, afaik that's Cons 1 <thunk>
06:00 <thang1> Fair :)
06:00 <monochrom> In other words Map Int [Double] could be when you want Data.Map.Lazy again.
06:01 zeroed joined
06:01 zeroed joined
06:01 <thang1> Isn't map strict, though? Iirc, it forces evaluation
06:01 <monochrom> It forces its spine and the keys.
06:01 <ongy> and there's Data.Map.Strict
06:01 <thang1> Right, so in your above example you'd try to apply int to an infinite list of doubles and everything would break
06:01 wroathe joined
06:02 <monochrom> (More accurately, it forces the keys as much as to perform Ord operations.)
06:02 <thang1> (if I got that right)
06:02 xtreak joined
06:02 revprez_atlanta joined
06:03 takle joined
06:03 xinming_ joined
06:04 <monochrom> ongy: Yes, due to the definition of [], if you use Data.Map.Strict on Map Int [Double], it is not all that strict anyway. But imagine one day tibbe gets drunk and inflict Data.Map.DeepSeq on us.
06:05 ner0x652 joined
06:05 ogrady joined
06:06 raichoo joined
06:06 raycoll joined
06:07 caumeslasal joined
06:08 <thang1> Hmm...
06:08 <monochrom> Debate topic: Should it be Control.DeepSeq or should it be Data.DeepSeq? :)
06:09 <mniip> Seq.Deep
06:09 <Koterpillar> monochrom: careful, with some thinking you can put everything in Data.
06:09 <mniip> Koterpillar, -> ?
06:09 <glguy> Data.Control.Monad?
06:09 <monochrom> Naw, no one would propose "Data.IO".
06:09 Sam___ joined
06:10 <Koterpillar> glguy: Data.Monad, using Free or something :P
06:10 <monochrom> Not to mention possible trademark infringement to Data I/O, a company.
06:10 <glguy> what about Data.IO?
06:10 <kadoban> Heh, the whole Data/Control split is kind of obsolete and weird anyway, isn't it?
06:10 <thang1> Data.Control.Monad.IO
06:10 raycoll joined
06:10 <glguy> we already have Data.Data
06:11 <glguy> what could we put in Control.Control?
06:11 <monochrom> I don't know yet, but good idea for next April 1st. :)
06:11 <thang1> higher dimensional control abstractions!
06:11 wroathe joined
06:11 <thang1> I'm thinking Logic related stuff
06:11 quchen joined
06:12 <monochrom> How about Control.Control contains generic derivation tools for deriving Functor, Applicative, Monad, DeepSeq, and Arrow?
06:12 <thang1> "is your life out of control? Use the Control library! Are your Controllers out of Control? Control them with Control.Control!"
06:12 <glguy> Pest.Control
06:13 <glguy> helps with bug elimination
06:13 <thang1> pffh this isn't OOP
06:13 <thang1> it's Control.Pest
06:13 eacameron joined
06:13 <monochrom> haha
06:13 <Koterpillar> Control.Self?
06:14 <thang1> (error: module imports Control.Netflix which imports Control.Self)
06:14 <thang1> (fucked the wording up slightly but hopefully the gist is gotten)
06:14 raycoll joined
06:16 hurkan joined
06:17 Guest16115 joined
06:17 <thang1> "If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor, and when was the last time you needed one?" -- Tom Cargil
06:18 LuckyRawApe joined
06:18 jhrcek joined
06:18 zeroed joined
06:18 etehtsea joined
06:19 je5finger joined
06:19 mszczygiel joined
06:20 <monochrom> GHC unifies data and control under closure. So maybe we should just create and use the Closure prefix. Closure.List, Closure.Monad
06:20 <jle`> Data.IO makes sense, cause IO is data
06:20 <mauke> "pure virtual" and "abstract" mean the same thing. "protected" and "private" contradict each other. "virtual" is listed twice.
06:21 takle joined
06:21 eacameron joined
06:21 wroathe joined
06:23 andyhuzhill joined
06:25 benl23 joined
06:25 insitu joined
06:25 <thang1> mauke: http://stackoverflow.com/questions/3618760/c-protected-abstract-virtual-base-pure-virtual-private-destructor
06:26 <mauke> oh, the first part qualifies "base"
06:26 <mauke> ok then
06:27 andyhuzhill1 joined
06:27 <thang1> I mean, it's written in a purposely obtuse way and the actual code is basically useless, but it's /possible/
06:28 <mauke> but also useless
06:28 takle joined
06:29 <mauke> you might as well ask "what is a constant volatile register variable-length array?" in C
06:29 gmhafiz_ joined
06:29 fakenerd joined
06:30 <thang1> hah, true. Sure, you can do it, but why the fuck do you even want to
06:30 azahi joined
06:30 <thang1> This is my favorite example of practical-yet-fucked-up C++: http://duramecho.com/ComputerInformation/WhyHowCppConst.html
06:30 eatman joined
06:31 <mauke> there are non-obvious uses for 'const volatile' but the real joke is the 'register' array
06:31 systemfault joined
06:31 <mauke> 'register' prevents taking the address of a variable so with "register int a[5];" you can't access the elements
06:32 wroathe joined
06:32 <thang1> ahh got it.
06:32 systemfault joined
06:32 <thang1> Knew there was a reason I've never heard about the register keyword
06:33 <thang1> (I love how, in C++, you can declare something const int*const Method3(const int*const&)const and then inside the method write mutable and /still/ change it)
06:33 systemfault joined
06:34 Rodya_ joined
06:34 SimpleL joined
06:34 eklavya joined
06:34 <thang1> or by using const_cast willy nilly
06:35 <mauke> "... but requires the every use of the variable in the called routine altered like that and the calling routine also altered to pass a pointer to the variable. It is rather cumbersome." <- it's also explicit at the call site. you know that f(&x) may change x but f(x) won't
06:35 <mauke> some people consider that an advantage
06:35 <ongy> mauke: what if it's void f(int &x), then callsite will have a harder time to see it :) (but I think C++ isn't terribly on topic)
06:36 <mauke> thang1: mutable is just a shortcut. you can get the same effect by using a pointer
06:38 <quchen> q
06:38 <thang1> True. I forget that raw pointers bypass so many things
06:38 takle joined
06:38 fizruk joined
06:38 <monochrom> My heart has a soft spot for f(int &x) because my heart has a soft spot for Pascal (and Algol) and Pascal has f(var x : Integer)
06:39 <mauke> also, putting const on a function's return type is silly
06:39 <thang1> Now that I've successfully derailed a bunch of fp nerds... *cough* I'm off to bed. I'm still pretty sick and need to go to the DEQ tomorrow to get my car tags renewed
06:40 bollu joined
06:40 <quchen> mauke is fairly easy to derail, just say anything about C and he will correct you
06:41 <ongy> C is the captial letter of c
06:41 <monochrom> @quote monochrom faster.than
06:41 <lambdabot> monochrom says: einstein's theory implies that haskell cannot be faster than c
06:41 <quchen> I wish I knew as much about Haskell as he about C :-)
06:42 wroathe joined
06:42 <thang1> haaa, funny
06:42 <thang1> Also, I wish I knew as much about C as he about C :p
06:42 <thang1> There's a sort of beauty to looking insanity in the eye and somehow staying mostly sane
06:43 carlosda1 joined
06:43 <mauke> "an object or variable which has been declared ‘const’ can be converted to changeable by use of ‘const_cast’" <- I'm pretty sure that's not true
06:43 <mauke> in that trying to modify a const object is UB
06:43 <thang1> http://en.cppreference.com/w/cpp/language/const_cast
06:44 <mauke> const_cast is like unsafeCoerce
06:44 fizruk joined
06:44 <thang1> (I can't grok most of that, but this is what hte standard has to say about it)
06:44 <mauke> it's for when you know it's actually mutable but you can't convince the type system
06:44 <johnw> mauke: except all that it can do is cast away constness
06:45 <mauke> yes
06:45 <mauke> (and volatile)
06:45 <joe9> anyone tried curry? any first impressions that you could share? like it or hate it?
06:45 <thang1> (of the systems languages, though, Rust is the one I'm looking forward to learning the most, and I suppose I shall learn C++ too if I have to)
06:45 jgertm joined
06:45 <mauke> I've recently started reading The C++ Programming Language
06:46 <thang1> joe9: my professor from fall quarter is one of the designers of the language
06:46 <thang1> I've yet to try it, though. I'm going to take a crack at it sometime after finishing "haskell from first principles"
06:47 julienchurch joined
06:47 <joe9> thang1: cool, is it an improvement over dependent typed languages?
06:47 nick_h joined
06:48 <thang1> I wouldn't say improvement, I would say "alternative"
06:48 <thang1> Dependent types are a way of meshing together and blurring the lines between types and values
06:48 <thang1> (cue cannonical example of type-safe length vector)
06:49 <joe9> have you tried refinement types (liquid haskell)?
06:49 <thang1> This allows the compiler to act as a basic proof assistant to a greater extent than in a language like vanilla Haskell
06:49 <thang1> (no I haven't. It sounds cool, though)
06:49 <quchen> Dependent types don’t »blur« the lines, they simply don’t have the lines
06:49 <quchen> Like Haskell does not »blur« the lines between Bool and Int
06:51 guiben joined
06:51 takuan joined
06:52 wroathe joined
06:52 <thang1> You're correct. I still sort of find it useful to think of it as a line blurring because dependent types are types that are dependent on values of the function. So the values and types become much more tightly bound together in the thinking and reasoning about a program
06:52 takle joined
06:52 Sose_ joined
06:53 noan_ joined
06:53 sujeet` joined
06:53 tput- joined
06:53 <thang1> Whereas traditional Haskell has the types and the values very separate. Your values have types but the types are purely a way to ensure program safety and sketch out data flow. No concept of proofs, depndency, quantifiers, and so on
06:53 delYsid`` joined
06:54 <thang1> Probably not the best way to think about them, but it's what I've got for now until I get more mature in functional programming :)
06:55 adraenwan_ joined
06:55 nick123_ joined
06:55 <thang1> Anyway, joe9, one of the main uses of dependent types can be thought of as (roughly) a sort of "constraint checking".
06:55 pleiosaur joined
06:55 jrslepak joined
06:55 mgaare joined
06:55 threshold joined
06:55 sajith joined
06:55 Frans-Willem joined
06:56 threshold joined
06:56 stvc joined
06:56 blackdog joined
06:56 oherrala joined
06:56 <thang1> To use the length vector as an example. A vector of length n + vector of length m = vector of length n+m. That sort of function is using dependent types to declare constraints on what the acceptable values and inputs are beyond merely the "type"
06:56 wting joined
06:56 cdidd joined
06:56 free_beard joined
06:56 tgeeky joined
06:56 n__dles joined
06:56 guios joined
06:56 abrar joined
06:56 thallada joined
06:56 Ke joined
06:56 Ke joined
06:56 xcin joined
06:56 Logio joined
06:56 machinedgod joined
06:56 <thang1> Logical functional programming also allows you to do that sort of constraint programming
06:56 aegray joined
06:56 tero- joined
06:56 tjt joined
06:56 <quchen> What usually gets me when thinking this way is when types and kinds are also »blurred«.
06:56 monochrom joined
06:56 weinzwang joined
06:57 exio4 joined
06:57 owickstrom joined
06:57 joeyh joined
06:57 alexbiehl joined
06:57 angseus joined
06:57 kofdog joined
06:57 bhiliyam joined
06:57 <quchen> And then I try to find a value of kind Int, or have a 1 that I’d like to have type Set, and so on.
06:57 osfameron joined
06:57 mitchty joined
06:57 gsingh93 joined
06:57 tobiasBora joined
06:57 JPohlmann joined
06:57 JPohlmann joined
06:57 <thang1> Consider a function that yields the last element of a list.
06:57 <joe9> I am thinking of Curry vs LH for my next learning step.
06:57 nikivi joined
06:57 gspia joined
06:57 brisbin joined
06:57 kgadek joined
06:57 fairfieldt joined
06:57 ongy joined
06:57 tv joined
06:57 tv joined
06:57 alphor joined
06:57 <thang1> In Curry, this is a valid solution: last xs | ys++[e] =:= xs = e where ys,e free
06:58 catern joined
06:58 <thang1> Narrowing (finding a solution that works in the solution space of any possible solution) is then used to "solve" the function
06:58 hegge joined
06:58 boxofdeath joined
06:58 vishesh joined
06:58 CuriousErnestBro joined
06:59 <thang1> You can also define it, validly, in Curry like so: last (ys++[e]) = e
06:59 <nshepperd> with TypeInType, types *are* kinds, right?
06:59 BartAdv joined
06:59 ThomasLocke joined
06:59 <thang1> quchen: that's a good point. I haven't gotten to the point where I really get types vs kinds yet, so I haven't run into that tripping me up yet
06:59 <nshepperd> Nothing :: Maybe t can be a value, or a type
06:59 opqdonut joined
07:00 aarvar joined
07:00 <quchen> thang1: values have types, types have kinds, kinds have sorts, and the named hierarchy ends here.
07:00 ninjazoete joined
07:00 <thang1> ahh right, thanks.
07:00 iross joined
07:00 <thang1> I keep forgetting some of the most profound concepts in haskell are really just stupidly simple
07:01 bgamari joined
07:01 mrd joined
07:01 AtnNn joined
07:01 <quchen> The naming of the hierarchy using 3 synonyms is probably not the best scheme ;-)
07:01 lokydor joined
07:01 `0660 joined
07:01 Saizan joined
07:01 <thang1> Eh, worse ones have been used before :p
07:02 bsmt joined
07:02 ClaudiusMaximus joined
07:02 <thang1> joe9: To be perfectly honest. I would suggest LH over Curry
07:02 wroathe joined
07:02 biglambda joined
07:03 <thang1> Curry doesn't have a whole lot of really good beginner documentation on it. People say that Haskell is a research programming language but Curry is /really/ a research programming language.
07:03 <quchen> In Agda for example, you have true : Bool, Bool : Set, Set : Set1, Set1 : Set2, …
07:03 indi_ joined
07:03 <quchen> So Set roughly corresponds to Haskell’s types, Set1 is like kinds, and so on.
07:03 <thang1> ಠ_ಠ
07:03 fizruk joined
07:03 <thang1> But /why/
07:04 <quchen> Because why not!
07:04 indi_ joined
07:04 <thang1> Can you just keep going on up to SetN? Or does it stop at 2?
07:04 <quchen> It goes up to eleven
07:04 <thang1> https://jeltsch.wordpress.com/2013/04/27/a-taste-of-curry/
07:04 <quchen> thang1: Okay, not really. It goes up all the way.
07:04 <nshepperd> it goes on until you get tired
07:05 <thang1> okay. I wasn't sure if that was a spinal tap reference or not
07:05 <quchen> The index is there to avoid having »Set : Set«, which is Russell’s Paradox in type theory.
07:05 <quchen> It was. :-)
07:05 <thang1> Even if it was actually how that worked, I /still/ wouldn't be sure if that was a spinal tap reference or not... :p
07:05 <thang1> programmers are nerdy
07:06 <quchen> Here is a function that gives you a type that has a value iff the list has an element: IsEmpty : [a] -> Set; IsEmpty [] = Void; IsEmpty _ = ()
07:06 <thang1> Makes sense. I guess if I was going to allow for an infinite chain of type hierarchies, I'd name it some generic thing and then an index...
07:06 <nshepperd> it might go up to eleven! kind of hard to imagine needing an element of Set11 that isn't Set10 though
07:07 <quchen> Usually, you use sets of level α, β, and (max α β).
07:07 <quchen> :-)
07:07 <quchen> Lists in Haskell can contain only homogeneous values of types of kind *, for example.
07:08 <rjeli> the good ol scala way
07:08 <rjeli> Tuple23
07:08 benl23 joined
07:08 <quchen> In a dependently typed language, you can have homogeneous lists of values of any type. And Set is a type, so it’s perfectly reasonable to have a list containing [Bool, Int].
07:08 <quchen> In Haskell we can do this as well, using promoted data types.
07:08 <thang1> Really? That's cool
07:08 <quchen> The type-level list would be written '[Int, Bool].
07:09 <quchen> Well, it’s with GHC extensions, so strictly speaking it’s not *Haskell*.
07:09 <thang1> Most modern haskell is written with a small army of extensions, anyway :p
07:09 rcschm joined
07:10 <quchen> Hm, I’m not so sure about that. Most extensions I use are syntactic ones.
07:10 <quchen> I certainly don’t use type families all over the place.
07:10 takle joined
07:11 <thang1> I suppose the extension use is less pervasive than it appears to be. To me, it seems like a ton of code I see in places have at least 2-3 pragmas in most files
07:11 <thang1> I've seen more than 5 fairly often as well
07:11 <quchen> Yes, but not all of them are heavyweights like TypeInType or UndecidableInstances :-)
07:12 <quchen> BangPatterns for example
07:12 <quchen> LambdaCase, PackageImports
07:12 <quchen> RankNTypes
07:12 <thang1> True. Syntactic niceities definitely make up the majority of stuff I would use
07:12 wroathe joined
07:12 <thang1> (who doesn't love writing less code, anyway?)
07:13 <thang1> I've become a fan of writing obscenely terse code. But not for the sake of terseness; rather, for the sake of elegance of idea expression
07:13 qvqidv joined
07:13 <quchen> Just be careful not to make it too elegant :-)
07:14 <rjeli> i think optimizing for grokkability is elegant
07:14 <rjeli> which isnt always terse
07:14 <thang1> If it's too elegant, it turns into pure haskell which is only meant to be written once and then admired from afar; a perfect diamond which one will nevefr understand
07:14 <thang1> (/s)
07:14 albertid joined
07:15 yellowj joined
07:16 <quchen> When prototyping, I usually have crappy 20-line diamonds with comments and crappy names and TODOs, decorated with a simple type signature.
07:16 <quchen> And then the cooking begins :-)
07:16 <rjeli> would it be possible to use Curry for business logic
07:16 <rjeli> or is it for constrained domains
07:16 vlatkoB joined
07:17 mstruebing joined
07:17 ventonegro joined
07:18 dan_f joined
07:18 rightfold joined
07:18 <thang1> You should have full power over business logic with Curry
07:18 <thang1> (https://jeltsch.wordpress.com/2013/04/27/a-taste-of-curry/ see this for a neat toy example)
07:18 raichoo joined
07:19 <rightfold> I asked someone about zipping optics some time ago here, I think I found it: https://pursuit.purescript.org/packages/purescript-profunctor-lenses/3.1.0/docs/Data.Lens.Grate#v:zipWithOf
07:20 greymalkin joined
07:20 jgertm- joined
07:21 valkyr2e joined
07:22 baldrick joined
07:22 wroathe joined
07:23 julienchurch joined
07:23 jeltsch joined
07:24 insitu joined
07:24 <thang1> rjeli: https://www.cs.princeton.edu/courses/archive/spring17/cos333/knuth-mcilroy.pdf
07:25 <thang1> My favorite example for elegance and grokkability
07:25 eklavya joined
07:25 justanotheruser joined
07:30 takle joined
07:31 feynhat joined
07:33 wroathe joined
07:34 Rodya_ joined
07:36 bollu joined
07:36 kadoban joined
07:38 insitu joined
07:39 thc202 joined
07:39 selthas joined
07:39 peterbecich joined
07:40 takle joined
07:41 henriksod joined
07:41 beanbagula joined
07:41 cur8or joined
07:41 Guest28734 joined
07:42 <Guest28734> how is functional programming these days
07:42 <rightfold> Guest28734: that's a very broad question
07:42 sibi joined
07:43 <kadoban> Guest28734: Pretty functional
07:43 fermi_ joined
07:43 <Guest28734> ok. how is haskell
07:43 <rightfold> It's fun
07:44 <halogenandtoast> It changed my life.
07:44 <halogenandtoast> I went from being bored to being slightly less bored.
07:44 carlosda1 joined
07:45 <thang1> I learned how to write a factorial function in 2 lines of code /s
07:45 <thang1> (fuck I got distracted again) g'night for real
07:46 Itkovian joined
07:46 <rightfold> The time originally spent debugging is now spent learning
07:47 <quchen> thang1: \n -> product [1..n]?
07:47 rbocquet joined
07:47 <halogenandtoast> quchen: that's one line of code :p
07:47 <quchen> Add newlines as desired
07:48 <rightfold> Put "memoize $" on the line before it
07:49 nemesit|znc joined
07:49 <halogenandtoast> I'm assuming thang1 meant fac 1 = 1; fac n = n * fac (n - 1); but that would be a partial function
07:49 srbaker_ joined
07:50 raichoo joined
07:50 <rightfold> Actually would be total if n :: Int
07:50 <halogenandtoast> well I guess it's not partial
07:50 <halogenandtoast> rightfold: yeah I derped too quickly
07:50 <rightfold> Wrap on underflow :P
07:51 <quchen> If your stack has that many frames you can even use it
07:51 <quchen> > maxBound :: Word64
07:51 <lambdabot> 18446744073709551615
07:51 <rightfold> It's sometime I wanted for some time
07:51 <rightfold> Detecting base cases that don't consider negative inputs
07:51 <rightfold> It's a common mistake
07:52 <lpaste> halogenandtoast pasted “ParseMove.hs” at http://lpaste.net/354529
07:52 <halogenandtoast> Any suggestions on how to make that less redundant? ^^
07:52 <halogenandtoast> a `where` wouldn't be shared right?
07:53 <rightfold> halogenandtoast: it wouldn't but you can use case
07:53 wroathe joined
07:53 <halogenandtoast> ah right
07:53 <rightfold> Or lambdacase even if you're into that
07:53 <halogenandtoast> rightfold: Only on the weekends.
07:53 <rightfold> Alternatively you can do
07:53 <quchen> Or you could drop the leading »f« before using your function
07:53 <Guest28734> could u use functional programming to build a rocket
07:54 <rightfold> Just . (if take 2 str == "f " then Flag else Reveal) $ …
07:54 <rightfold> Or something like that
07:54 beanbagula joined
07:54 <rightfold> Guest28734: I think the hardware is a bigger problem
07:55 <halogenandtoast> > putStrLn "=>"
07:55 <lambdabot> <IO ()>
07:55 <halogenandtoast> there rocket ^^
07:55 <Guest28734> haha
07:55 <rightfold> FP can even help you with the hardware
07:55 vydd joined
07:55 vydd joined
07:56 <rightfold> Look up cλash
07:56 dhil joined
07:57 <halogenandtoast> iirc old IBM chips had some problem, and they used FP afterwards to better test them to prevent errors.
07:57 jdt joined
07:57 <Guest28734> halogenandtoast: putStrLn isn't exactly functional though
07:57 <halogenandtoast> Guest28734: is it a function?
07:57 <rightfold> There's no reason a discipline of referential transparency couldn't get you to the Moon
07:57 <halogenandtoast> Then is passes the litmus test.
07:57 <halogenandtoast> s/is/it/
07:57 <quchen> putStrLn is exactly functional.
07:57 <Guest28734> it causes output to be displayed i mean
07:57 <halogenandtoast> Guest28734: it does not
07:58 <rightfold> putStrLn is a function that returns the same IO () when you give it the same String
07:58 bhiliyam joined
07:58 <halogenandtoast> the result of putStrLn is compiler dependent
07:58 takle joined
07:58 <quchen> It results in a primitive operation that, when used by the right runtime, might instruct it to print something.
07:58 <rightfold> Calling putStrLn returns a IO () value
07:58 <rightfold> That's all it does
07:58 <Guest28734> hmm
07:58 <rightfold> If you discard the IO (), and run the executable, nothing is printed
07:58 <halogenandtoast> Guest28734: WELCOME TO MY WORLD MWUH HA HA HA HA
07:58 <quchen> > let foo = putStrLn 5 in foo `seq` ()
07:58 <lambdabot> error:
07:58 <lambdabot> • No instance for (Num String) arising from the literal ‘5’
07:58 <lambdabot> • In the first argument of ‘putStrLn’, namely ‘5’
07:59 <quchen> > let foo = putStrLn "hello" in foo `seq` ()
07:59 <lambdabot> ()
07:59 <Guest28734> shove it into /dev/null
07:59 <quchen> putStrLn is evaluated, yet does not print anything.
07:59 kazagistar joined
07:59 Salih joined
08:00 <halogenandtoast> iirc the intermediate representation doesn't even have the IO part anymore.
08:00 cschneid_ joined
08:00 <halogenandtoast> s/intermediate/compiled/
08:00 bertschneider joined
08:00 <halogenandtoast> somewhere in my words is what I'm trying to say.
08:00 <rightfold> If you're familiar with C# then IO T is analogous to Action<T> except there's no way to invoke it
08:01 blocky joined
08:01 <rightfold> Action<T> putStrLn(string s) is pure
08:01 <bollu> I think I only actually understood IO once I wrote a monadic DSL
08:01 zar joined
08:02 <quchen> I only understood IO once I understood the STG, which is what the GHC runtime runs
08:02 <quchen> Luckily, it’s not terribly complicated :-)
08:02 <halogenandtoast> I **think** I understood IO once I read: https://wiki.haskell.org/IO_inside
08:03 wroathe joined
08:03 <bollu> quchen: :) alternatively, I wrote a template instantiation machine interpreter, which is way simpler than STG but still lazy. Really made laziness click
08:03 <quchen> halogenandtoast: The key insight is that GHC compiles Haskell to something with fixed evaluation order. And that you can run perfectly well with side-effects, so you can put in proper IO. (All safety is out the window at this stage anyway.)
08:04 <bollu> quchen: inspired by STGi xD http://github.com/bollu/timi
08:04 fizbin joined
08:04 <quchen> bollu: Cool!
08:04 <halogenandtoast> quchen: Ah very true.
08:04 fermi_ joined
08:05 juhp joined
08:05 <quchen> Unspecified evaluation order is just a compiler convenience so GHC can rearrange the code to its liking
08:06 yellowj joined
08:06 mattyw joined
08:06 oisdk joined
08:06 <quchen> halogenandtoast: Much like you have a primitive function +# to add two ints, you have a primitive function print# (not sure what the actual name is) that prints something when forced
08:07 armyriad joined
08:08 Swizec joined
08:08 <quchen> Well, it’s not that simple (because of buffering and what not), but conceptually that’s it
08:08 SimpleL joined
08:08 freusque joined
08:09 ggVGc joined
08:10 oisdk joined
08:11 acidjnk22 joined
08:11 jdt joined
08:12 albel727 joined
08:12 twanvl joined
08:12 splanch joined
08:13 wroathe joined
08:14 <rightfold> Takes a handle actually
08:14 <quchen> putStrLn does a lot of things under the hood. One of them is printing things character-wise ;-)
08:14 <quchen> Well, handle them character-wise, at least. But that’s because of String.
08:16 lep-delete joined
08:17 Guest91238 joined
08:17 takle joined
08:17 kfish joined
08:18 beanbagula joined
08:18 <Guest91238> sure you could use a functional language to build a rocket but it wouldn't fly. running time too slow ahahhaa
08:18 Beetny joined
08:18 <rightfold> Buffering, encoding, probably newline stuff, locale stuff maybe
08:18 <Guest91238> u like?
08:20 fizbin joined
08:21 <rightfold> Wouldn't call it a pinnacle of SRP
08:23 filterfish joined
08:23 fotonzade joined
08:24 wroathe joined
08:24 <Cale> Guest91238: Given the budget for those things, you might want to use a functional language to write a one-shot compiler for the control system on one of those things though, so that you can do a bunch of additional verification.
08:26 <Cale> Guest91238: One of the things Haskell has been used for in industry has been this kind of metaprogramming approach to building realtime control systems (for hybrid hydraulic vehicles) that are timed correctly without need for a RTOS.
08:27 <rightfold> With linear types you can get referential transparency and mutations at the same time
08:27 <rightfold> With no runtime overhead of any kind
08:28 <Cale> Well, the idea here isn't to be writing Haskell or other functional code which will run directly on the embedded devices, but rather to use a Haskell program to generate the machine code for them.
08:28 freusque joined
08:28 sigmundv_ joined
08:29 silentcontrib joined
08:29 <quchen> The downside of linear types is that you then have linear types.
08:29 <Cale> haha
08:29 <Cale> yeah
08:29 <rightfold> I've been playing with affine types lately
08:29 <rightfold> It's super rad
08:29 <Guest91238> hmm very clever
08:30 <Guest91238> shove it into /dev/null
08:30 <quchen> Linear types are interesting, but fairly restrictive for everyday programming
08:30 <bollu> what are affine types?
08:30 <ventonegro> http://ivorylang.org/
08:30 <bollu> quchen: rust diasgrees :]
08:31 <Cale> Rust is fairly restrictive for everyday programming
08:31 <quchen> I disagree that rust disagrees.
08:31 <rightfold> bollu: handwavy, they're like linear types but with an "at most once" restriction instead of "exactly once"
08:31 takle joined
08:31 <bollu> quchen: oh?
08:31 bweston92 joined
08:31 <quchen> rightfold: That’s not really handwavy, that’s pretty much the definition :-)
08:31 <bollu> Cale: I don't feel that way having written a decent amount of Rust
08:31 <rightfold> So you can throw the cake in the garbage instead of being forced to eat it
08:31 <bollu> rightfold: where are you using this? and in which language?
08:31 <rightfold> But if you do eat it, you can't have it too
08:32 <Cale> bollu: I do my everyday programming in Haskell though, so I'm probably spoiled.
08:33 <quchen> I don’t think Rust is simple to use. I think it has a good reason for this though, since the problems its type system tries to solve are fairly hard to solve.
08:33 <rightfold> Needs some getting used to
08:33 <quchen> Sure. So did Haskell.
08:33 <rightfold> You have to decide when writing the data type how you're gonna use it
08:33 <rightfold> For example I'm writing a compiler in Rust
08:34 <rightfold> The AST is a recursive type, so I need some form of indirection or its size would be infinite
08:34 wroathe joined
08:34 xtreak joined
08:34 <rightfold> I need to decide what indirection I want, before I can use it. Unique ownership pointer, shared ownership pointer, non-owning pointer?
08:35 <rightfold> Went with non-owning because I'll use an arena to allocate the AST nodes
08:35 <bollu> rightfold: yes, but Rust has the correct types to encapsulate those
08:35 <bollu> rightfold: eg. Rc
08:35 <rightfold> But now I can't easily switch to some other scheme anymore
08:35 Rodya_ joined
08:35 <rightfold> I abstracted the recursion into a different type (a la recursion schemes) so the sum type is still decoupled
08:36 hdeshev joined
08:36 xtreak joined
08:36 mekeor joined
08:37 <bollu> Cale: I'm liking C++11 onwards tbh
08:37 marr joined
08:38 <Philonous> Is there an ETA for pi-types? 8.2 doesn't have them yet, AFAICS
08:38 ragepandemic joined
08:38 <Iceland_jack> a few years Philonous
08:38 <Philonous> _Years_? That's disappointing :(
08:38 yoyo_ joined
08:38 <Iceland_jack> Take a look at https://typesandkinds.wordpress.com/2016/07/24/dependent-types-in-haskell-progress-report/
08:39 <Iceland_jack> Good things come to those who wait
08:39 <Philonous> Thanks, reading
08:39 <Iceland_jack> (kind of)
08:39 johnw joined
08:39 indi_ joined
08:40 <Philonous> Is that Richard Eisenberg's page? It doesn't say
08:40 <Iceland_jack> Yeah it is
08:40 <quchen> Pi types in Haskell? Is that planned?
08:40 <Philonous> Yes
08:41 doomlord joined
08:41 <quchen> Woah
08:41 <Philonous> You can sort-of have them already
08:41 <Iceland_jack> Philonous: If you want a nice bedtime read, Richard's thesis is also out
08:41 meandi joined
08:41 <Philonous> Neat!
08:41 <Iceland_jack> http://cs.brynmawr.edu/~rae/papers/2016/thesis/eisenberg-thesis.pdf
08:41 <quchen> Richard’s thesis?! I thought he’s been a researcher for ages
08:41 <quchen> Like post-postdoc levle
08:42 locallycompact joined
08:42 balor joined
08:42 <Philonous> No, he's been working on -XTypeInType for his thesis
08:42 <rightfold> *In*
08:43 <Iceland_jack> For those interested, Richard also has a draft about CONSTRAINED type families
08:43 <Iceland_jack> (and CLOSED type classes)
08:43 <Iceland_jack> http://cs.brynmawr.edu/~rae/papers/2017/partiality/partiality.pdf
08:43 <Iceland_jack> Very interesting
08:43 <Philonous> Man, if we take sway his PhD, will he do more amazing work to get it back? :>
08:43 <Philonous> away*
08:43 <Iceland_jack> haha
08:44 wroathe joined
08:44 <Iceland_jack> "Almost got it Richard" *dangles tantalising carrot*
08:44 hdeshev1 joined
08:44 carlosda1 joined
08:46 <rightfold> Yummy, raw carrot
08:46 <Iceland_jack> I found the parts on "matchability" from his thesis very interesting
08:46 cschneid_ joined
08:46 yxadyx joined
08:47 <Iceland_jack> It's also a genuinely good overview of GHC features
08:49 <Philonous> And thus the ever-growing list grows yet again.
08:49 hdeshev joined
08:49 soLucien joined
08:51 hdeshev2 joined
08:51 hdeshev1 joined
08:52 mmn80 joined
08:52 gregman_ joined
08:53 hdeshev3 joined
08:53 jgertm joined
08:53 takle joined
08:54 sanett joined
08:55 wroathe joined
08:55 <bollu> is there another exposition on recursion schemes other than the original paper? I find the notation confusing, especially because he packages up everything inside Mu
08:56 <bollu> like, does that style of thinking actually make it intuitive?
08:56 baldrick joined
08:57 oish joined
08:57 hdeshev joined
08:57 daniel-s joined
08:58 bhiliyam joined
09:04 Luna521 joined
09:04 wroathe joined
09:05 jaspervdj joined
09:06 chenshen joined
09:06 Mysterious_Light joined
09:11 Unhammer joined
09:11 fizruk joined
09:14 Aidan[m] joined
09:14 Luna521 joined
09:15 Sigyn joined
09:16 joncol joined
09:16 <joncol> exit
09:16 joncol left
09:18 ub joined
09:18 eacameron joined
09:18 <rightfold> bollu: the recursion is removed from the type
09:18 <rightfold> Now you need something else to add the recursion again
09:18 <rightfold> Mu is one of the things that can do that
09:18 <rightfold> Another useful one is Cofree
09:19 reactormonk[m] joined
09:19 wictory[m] joined
09:19 bb010g joined
09:19 closures999[m] joined
09:19 alaradia[m] joined
09:19 Naughtmare[m] joined
09:19 NickHu joined
09:19 davidar_ joined
09:19 davidar joined
09:19 riaqn joined
09:19 roadrunner168[m] joined
09:19 herzmeister[m] joined
09:19 karroffel joined
09:19 nick2000 joined
09:19 jyp[m] joined
09:19 M-BostonEnginerd joined
09:19 kaichao[m] joined
09:19 curry[m] joined
09:19 seequ_ joined
09:19 m4lvin[m] joined
09:19 elwan7[m] joined
09:19 travisr joined
09:19 monomon[m] joined
09:19 unclechu joined
09:19 <rightfold> This is because the structure of Mu is known to the recursion schemes
09:19 jmnoz[m] joined
09:19 sudoreboot[m] joined
09:19 miviotros[m] joined
09:19 zaphar_ps[m] joined
09:19 korayal[m] joined
09:19 M-Illandan joined
09:19 Magnap joined
09:19 M-berdario joined
09:19 MatrixTraveler[m joined
09:19 sirius[m] joined
09:19 hendrik[m] joined
09:19 M-schmittlauch joined
09:19 hiq[m] joined
09:19 M-Quora joined
09:19 corintho[m] joined
09:19 rdesfo[m] joined
09:19 srenatus[m] joined
09:19 tfc[m] joined
09:19 bobjason[m] joined
09:19 M-krsiehl joined
09:19 TylerCecil[m] joined
09:19 FederalRick[m] joined
09:19 ptek[m] joined
09:19 jacqueline[m] joined
09:19 cbHXBY1D[m] joined
09:19 hakan[m] joined
09:19 iffsid[m] joined
09:19 Soif[m] joined
09:19 colton[m] joined
09:19 tester668[m] joined
09:19 wr3n[m] joined
09:19 ProofTechnique[m joined
09:19 noraesae joined
09:19 tomkerk[m] joined
09:19 rfabbri[m] joined
09:19 moonarch joined
09:19 rakete joined
09:19 NopeMarker[m] joined
09:19 aspiwack[m] joined
09:19 gentam[m] joined
09:19 Guest91110[m] joined
09:19 drasich[m] joined
09:19 M92854[m] joined
09:19 Yves[m]1 joined
09:19 TesX[m] joined
09:19 TheWizardTower joined
09:19 zar[m] joined
09:19 gkaplan[m] joined
09:19 <rightfold> But that of any custom recursive type isn't
09:20 unknownln joined
09:20 goodboy[m] joined
09:20 mmmrrr[m] joined
09:20 jascot[m] joined
09:20 juhp joined
09:20 isthatit joined
09:20 <isthatit> I'm looking for a random number generator that uses /dev/random all the time
09:20 zar joined
09:20 <isthatit> no seeding
09:20 <Iceland_jack> Cofree f () = Mu f
09:20 <isthatit> /dev/urandom*
09:21 <* Iceland_jack> . o O ( because right adjoints preserve ... )
09:21 laz joined
09:21 <rightfold> Iceland_jack: I think Cofree f a ~ Mu (f </\> Const a)
09:21 <rightfold> Where </\> is functor product
09:22 xall joined
09:23 <Iceland_jack> Sure
09:23 <Iceland_jack> (</\> is aka Product, from Data.Functor.Product)
09:23 <Iceland_jack> Free f Void is also equal to Fix f
09:23 <* Iceland_jack> . o O ( because left adjoints preserve ... )
09:23 <Iceland_jack> so there are many equations
09:23 richi235 joined
09:24 xtreak joined
09:24 wroathe joined
09:25 <rightfold> Not sure if Product has an infix in Haskell
09:25 <rightfold> I'm a PureScript guy 🙊
09:25 <Iceland_jack> You can use :*: if you want
09:26 <Iceland_jack> that's what GHC.Generics uses
09:26 <rightfold> Ah
09:26 <rightfold> Nice
09:27 <rightfold>
09:27 Mysterious_Ligh1 joined
09:28 <Iceland_jack> You can also write (Cofree f a = Mu (Compose ((,) a) f))
09:28 <rightfold> :)
09:28 locallycompact joined
09:28 xtreak joined
09:30 ogrady_ joined
09:30 locallycompact joined
09:32 zero_byte joined
09:32 silver joined
09:32 sphinxo joined
09:33 xtreak joined
09:33 <Myrl-saki> Functor product?
09:33 saep joined
09:34 <Iceland_jack> data Product f g a = Pair (f a) (g a)
09:34 <Myrl-saki> Ah.
09:34 <Iceland_jack> Instead of a product (f, g) you add an argument (f a, g a)
09:34 _sg joined
09:34 CurryWurst joined
09:35 wroathe joined
09:35 dcoutts_ joined
09:36 oleksiyp joined
09:36 Rodya_ joined
09:36 melop joined
09:37 <Iceland_jack> Similarly there is a sum of products, which is like (Either (f a) (g a))
09:37 <Iceland_jack> data Sum f g a = InL (f a) | InR (g a)
09:37 SimpleL joined
09:37 fermi_ joined
09:38 <Iceland_jack> Pair "hello" (Just 'a') :: Product [] Maybe Char
09:38 <Iceland_jack> Sum cannot be an Applicative or Alternative, unless we know more about the relationship between f/g
09:38 bjz joined
09:38 <Iceland_jack> If you want a sum with Applicative / Alternative there is a special case 'Lift = Sum Identity'
09:39 <Iceland_jack> data Lift g a = Pure a | Other (g a)
09:40 Xanather joined
09:41 mstruebing joined
09:41 doomlord joined
09:43 srbaker_ joined
09:44 Aruro joined
09:45 wroathe joined
09:47 zcourts joined
09:48 ccomb joined
09:49 Wizek joined
09:50 Wizek_ joined
09:51 binaryplease joined
09:51 cpup joined
09:51 CurryWurst joined
09:52 Luna521 joined
09:54 mstruebing joined
09:57 Gurkenglas joined
09:59 filterfish joined
09:59 bhiliyam joined
09:59 fizruk joined
09:59 bjz joined
10:00 filterfish joined
10:01 Aruro joined
10:01 pandinus joined
10:03 unK_ joined
10:03 revprez_atlanta joined
10:05 Luna521 joined
10:05 <pandinus> hii :)
10:05 wroathe joined
10:06 NyanPasu joined
10:08 Luna521 joined
10:10 vritser joined
10:10 <vritser> hello?
10:10 balor joined
10:11 <vritser> i have a question.
10:11 <geekosaur> usually better to just ask it
10:11 <Jinxit> well we can't answer it until you ask it
10:11 so joined
10:12 Aruro joined
10:12 <vritser> I am a novice
10:13 harrismai joined
10:13 <vritser> i can't understand the method foldr
10:13 <Rembane> vritser: What parts of foldr can you understand?
10:14 ccomb joined
10:14 <vritser> foldr f acc (x:xs) = f x (foldr f acc xs)
10:15 <vritser> right =
10:15 <vritser> why not f (foldr f acc xs) x
10:16 <vritser> x is the acc?
10:16 wroathe joined
10:16 <quchen> »acc« is very misleading for foldr, since it does not have an accumulator.
10:16 <Iceland_jack> vritser: You can think of 'foldr' replacing (:) with f, and the empty list [] with acc
10:16 <quchen> Call it »rest« or something.
10:16 <geekosaur> > foldr f z [a,b,c]
10:16 <lambdabot> f a (f b (f c z))
10:17 <Iceland_jack> :t foldr (:) [] :: [a] -> [a]
10:17 <lambdabot> [a] -> [a]
10:18 <quchen> vritser: An example: insert many elements into a Set. foldr Set.insert Set.empty [1, 2, 3] === Set.insert 1 (Set.insert 2 (Set.insert 3 Set.empty))
10:18 <Iceland_jack> vritser: Are you aware that [1,2,3,4] is sugar for (1:(2:(3:(4:[]))))
10:19 <vritser> yeah i know
10:19 <Iceland_jack> ok
10:19 ralu joined
10:19 TheLemonMan joined
10:20 <Iceland_jack> Let's replace (:), [] with (+), 0: (1+(2+(3+(4+0))))
10:20 <Iceland_jack> > foldr (+) 0 [a,b,c,d]
10:20 <lambdabot> a + (b + (c + (d + 0)))
10:21 <Iceland_jack> That sums the elements of the list
10:21 <vritser> ok
10:21 <Iceland_jack> Let's replace (:), [] with (*), 1: (1*(2*(3*(4*1))))
10:21 <Iceland_jack> > foldr (*) 1 [a,b,c,d]
10:21 <lambdabot> a * (b * (c * (d * 1)))
10:23 <rightfold> Replacing constructors is my hobby
10:23 <vritser> I try to understand
10:24 <vritser> Thanks.
10:25 <Iceland_jack> vritser: Consider how you would compute the length of a list like this
10:25 <Iceland_jack> We would want [1,2,3,4] to turn into (1 + (1 + (1 + (1 + 0))))
10:26 wroathe joined
10:26 <vritser> I know, that's one implement of length
10:26 <Iceland_jack> vritser: What if you wanted to get the maximum element of a list?
10:27 howdoi joined
10:28 <vritser> max head $ max tail
10:29 cfricke joined
10:29 biglambda joined
10:30 <vritser> o, they are the same
10:30 <vritser> yes?
10:31 <Iceland_jack> Consider what the maximum of the empty list should be
10:31 inkbottle joined
10:31 <vritser> shoud be []
10:31 <Iceland_jack> What should the type of maximum be?
10:32 <Iceland_jack> Let's assume the input is [Int]
10:32 harrismai joined
10:32 <vritser> It's Int
10:32 <vritser> not [], throw an error?
10:32 eacameron joined
10:33 <Iceland_jack> yeah, that's sadly what Haskell currently does :)
10:33 <Iceland_jack> > maximum []
10:33 <lambdabot> *Exception: Prelude.maximum: empty list
10:36 <vritser> Wrap it with Maybe
10:36 <Iceland_jack> That's one approach
10:36 wroathe joined
10:36 <Iceland_jack> we could also be more specific about the lists we get in
10:36 <Iceland_jack> we want "non-empty" lists, but this is unrelated to your foldr question
10:37 Rodya_ joined
10:37 Icewing joined
10:37 <Iceland_jack> We could write: maximum :: (a, [a]) -> a
10:37 netheranthem joined
10:37 <Iceland_jack> where (a, [a]) models a non-empty list
10:38 eacameron joined
10:38 xall joined
10:38 <* Iceland_jack> . o O (( (a, [a]) already exists as Data.List.NonEmpty.NonEmpty a ))
10:39 <Iceland_jack> so you could write
10:40 <Iceland_jack> maximum' :: (a, [a]) -> a
10:40 <Iceland_jack> maximum' (x, []) = x
10:40 <Iceland_jack> maximum' (x, xs) = foldr max x xs
10:41 <vritser> en
10:41 bennofs joined
10:41 Aruro joined
10:43 <vritser> Thank you.
10:44 <Iceland_jack> So there are different types, and tradeoffs associated with each of them '[a] -> a' (fails on []), '[a] -> Maybe a' (everyone has to deal with the Maybe value), 'NonEmpty a -> a' (recently added data type, user has to change all their lists to NonEmpty's)
10:44 <Iceland_jack> vritser: The definition of NonEmpty is trivial
10:44 danza joined
10:45 fotonzade joined
10:45 <Iceland_jack> data NonEmpty a = Cons a [a]
10:45 <Iceland_jack> The actual definition uses an infix constructor (:|) instead of Cons but it means the same thing
10:45 <Iceland_jack> data NonEmpty a = a :| [a]
10:46 wroathe joined
10:46 carlosda1 joined
10:47 <vritser> yes
10:47 m0rphism joined
10:47 <Iceland_jack> Now the definition of maximum' could be
10:47 <Iceland_jack> maximum' :: Ord a => NonEmpty a -> a
10:47 <Iceland_jack> maximum' (x :| []) = x
10:48 <Iceland_jack> maximum' (x :| xs) = foldr max xs x
10:48 <Iceland_jack> And the type *tells* you what the function needs
10:49 <vritser> Yes. I understand
10:49 <Iceland_jack> Consider the difference between (NonEmpty a -> a) and ([a] -> Maybe a)
10:50 <Iceland_jack> With the latter we do not know when it fails
10:50 oisdk joined
10:50 <phadej> [a] ~ Maybe (NonEmpty a)
10:50 <phadej> so the `latter = fmap former` ;)
10:51 <vritser> That's right
10:51 Aruro joined
10:51 <phadej> but you could "fail" also when the list is of odd length, so latter is less precise
10:53 Luna521 joined
10:53 bennofs joined
10:54 fermi_ joined
10:56 wroathe joined
10:57 mszczygiel joined
10:58 ejay joined
10:59 zeroed joined
10:59 zeroed joined
11:00 cschneid_ joined
11:00 bhiliyam joined
11:02 ziarkaen joined
11:03 nh2 joined
11:04 Iceland_jack joined
11:04 mda1 joined
11:04 Snircle joined
11:04 <Myrl-saki> Is there a way to use Existential types for "equality"?
11:05 <Myrl-saki> Basically, I want to have extensible modes.
11:06 <Myrl-saki> I have a feeling I'm doing this wrong tho
11:06 <Gurkenglas> Going from ([a] -> Maybe a) to (NonEmpty a -> a) only reduces the infinitely many bits of possibility space by, like, one.
11:06 <Gurkenglas> Or maybe O(1) bits
11:07 <Myrl-saki> Gurkenglas: But you don't have to work with functors.
11:07 <Myrl-saki> Or monads.
11:07 <geekosaur> I have no idea what `use Existential types for "equality"' means...
11:08 <vritser> :t foldr
11:08 <lambdabot> Foldable t => (a -> b -> b) -> b -> t a -> b
11:08 <geekosaur> :t GHC.OldList.foldr
11:08 <lambdabot> (a -> b -> b) -> b -> [a] -> b
11:09 <Myrl-saki> geekosaur: Basically... `:: a -> Mode` and compare if the modes are the same.
11:09 <Myrl-saki> I keep a [Mode]
11:09 drninjabatman left
11:10 zcourts joined
11:10 Gurkenglas_ joined
11:11 <geekosaur> that... makes no sense to me. if it's an arbitrary a, it is not necessarily a Mode. nor can types be extended at runtime; they only exist at compile time
11:12 <Myrl-saki> geekosaur: Makes sense.
11:12 <Myrl-saki> geekosaur: I guess I should just keep a [String] ?
11:12 <geekosaur> I could see a data Mode = Mode String (or Int or whatever)
11:12 <geekosaur> and a list or Map defining them, however they need to be defined
11:14 <Myrl-saki> geekosaur: Thanks.
11:15 zar joined
11:17 Guest34001 joined
11:18 detrumi joined
11:19 <Guest34001> whats the coolest programming written in haskell
11:19 <Guest34001> program
11:19 Luna521 joined
11:19 sivs joined
11:19 <lyxia> pandoc
11:20 chichou joined
11:21 ziocroc2 joined
11:21 wroathe joined
11:22 plutoniix joined
11:22 tdfirth joined
11:22 biglambda joined
11:23 plutoniix joined
11:23 leaftor joined
11:23 Luna521 joined
11:25 albertid joined
11:26 <mekeor> Guest34001: xmonad
11:26 <Myrl-saki> mekeor: I think house is higher.
11:27 sdothum joined
11:27 <mekeor> Guest34001: GHC
11:28 <mekeor> darcs
11:28 <Myrl-saki> mekeor: Why darcs?
11:29 doomlord joined
11:29 mtesseract joined
11:29 <mekeor> Myrl-saki: it's cool
11:30 <Myrl-saki> I'll take another look at it.
11:30 goergen joined
11:30 <mekeor> anyway, Guest34001, i think you can browse beginning at https://wiki.haskell.org/Libraries_and_tools to discover cool programs written in haskell
11:31 <chichou> the prelude link gives a 404 :-(
11:32 wroathe joined
11:33 <geekosaur> https://downloads.haskell.org/~ghc/8.0.2/docs/html/libraries/base-4.9.1.0/Prelude.html ?
11:33 zagura joined
11:35 ziyourenxiang joined
11:36 jeltsch joined
11:37 Rodya_ joined
11:39 <Guest34001> nice
11:39 theelous3 joined
11:39 <mekeor> wow, i just discovered that the server of "wire" messenger is written in haskell: https://github.com/wireapp/wire-server
11:42 <quchen> Wire is that Signal alternative?
11:42 <quchen> Encrypted texting?
11:42 jathan joined
11:43 harfangk joined
11:44 anuxivm joined
11:44 <mekeor> yup
11:44 <mekeor> also, the most starred project written in haskell on github is: https://github.com/begriffs/postgrest
11:44 Claudius1aximus joined
11:45 <mekeor> (see http://github-rank.com/star?language=Haskell )
11:49 acarrico joined
11:53 chlong_ joined
11:53 chlong joined
11:57 filterfish_ joined
11:57 moth joined
11:57 <quchen> Wohoo I’m 60-something
11:57 <quchen> Although Agda has < 300 stars, so the metric might be a bit skewed
11:58 asmyers joined
12:00 baldrick joined
12:00 <ongy> quchen: I have 58, so it can't say much (I have like 5 users total)
12:01 ilyaigpetrov joined
12:03 beemo joined
12:03 biglambda joined
12:03 meandi joined
12:04 ragepanda joined
12:05 sheogorath joined
12:05 beemo left
12:06 bennofs joined
12:06 soLucien joined
12:08 imbeemo joined
12:09 yellowj joined
12:09 <sheogorath> random question, is there a nice way to do optional arguments?
12:10 <ventonegro> maybe with Maybe?
12:11 <sheogorath> what if there's a lot of them? can record or record updates do anything?
12:11 <Gurkenglas_> sheogorath, for a large number of them, you can build a record type containing the default arguments
12:12 ClaudiusMaximus joined
12:12 <Gurkenglas_> How did you come to suggest "record or record updates" there?
12:13 <Gurkenglas_> sheogorath, http://neilmitchell.blogspot.de/2008/04/optional-parameters-in-haskell.html
12:13 Durbley joined
12:15 bjz_ joined
12:15 <Gurkenglas_> sheogorath, also https://ocharles.org.uk/blog/posts/2015-07-23-another-approach-to-default-variables.html - and google shows some more
12:15 SimpleL joined
12:16 <sheogorath> I just had some vague concepts and wanted some opinions.
12:16 <sheogorath> thanks, looks nice
12:16 xtreak joined
12:17 insitu joined
12:18 imbeemo joined
12:19 mkoenig joined
12:19 xtreak joined
12:20 Wuzzy joined
12:21 aib joined
12:26 xificurC joined
12:27 Argue__ joined
12:27 Rodya_ joined
12:29 Mysterious_Light joined
12:29 MindlessDrone joined
12:31 dsh joined
12:37 LordDeath joined
12:39 alienbot joined
12:40 <sheogorath> looking at record stuff and makeFields TH just gives the impression that records should have some structural typing or something.
12:41 mtesseract joined
12:41 dhil joined
12:43 abhiroop joined
12:47 Lord_of_Life joined
12:48 carlosda1 joined
12:48 earldouglas joined
12:49 nakal_ joined
12:51 vaibhavsagar joined
12:53 pavonia joined
12:53 jedws joined
12:54 eacameron joined
12:54 tabaqui1 joined
12:56 halogenandtoast joined
12:56 doomlord joined
12:56 <halogenandtoast> Another useless survey, how many people put main at the bottom of their haskell file and how many at the top (and I guess the third option... somewhere else)
12:58 <mutsig> Is there a way to ensure that a state-monad that recurse will fully evaluate its state before the recursion takes place? I have added what I thought was a lot of strictness annotations, but I still have issues with space leak.
12:59 <mutsig> Maybe I'm falling in to some common pitfall here that I don't know about...
13:00 fotonzade joined
13:00 <lyxia> use strict state and only put forced states
13:00 Argue joined
13:00 <lyxia> but that doesn't prevent thunks from refering to older states
13:02 <mutsig> I never put states, except when initializing. Only modify with the strict `modify'`. I also use strict state. But I guess that thunks refering to older states might be the issue then...
13:04 <mutsig> It's a transformer that uses Writer as well, but I use strict Writer also.
13:04 augur joined
13:05 nilof joined
13:05 insitu joined
13:05 Lord_of_Life joined
13:05 mada joined
13:05 cpennington joined
13:05 <c_wraith> If you're using Writer from mtl, it's actually WriterT Identity
13:06 eacameron joined
13:06 <c_wraith> and "strict" WriterT doesn't force the state to WHNF on each tell
13:07 <mutsig> And this isn't true for Writer from transformers?
13:07 <c_wraith> It probably is
13:07 <cocreature> mtl just reexports Writer from mtl so it suffers from the same problems
13:07 <c_wraith> ok. I just hadn't checked
13:07 MindlessDrone joined
13:08 <c_wraith> The problem is actually structural. There's no way to implement >>= for WriterT that is strict in the accumulator
13:09 <cocreature> writer-cps-transformers has a version of Writer that is strict iirc
13:09 <c_wraith> yeah, if you change the data structure it works.
13:10 <c_wraith> however, a cps'd WriterT is the same data structure as StateT
13:10 <cocreature> sure
13:10 <c_wraith> so most people just use StateT with an appropriately restricted interface
13:10 <mutsig> Ah... That might be the problem. would putting the accumulator in the state solve this?
13:10 eacameron joined
13:10 <cocreature> possibly
13:10 <lyxia> mutsig: "modify'" may not be strict enough either. By "put" the state I mean it in the broad sense which includes any time you modify the state.
13:10 <c_wraith> It will help. No guarantee it's the only issue. :)
13:11 <cocreature> mutsig: also make sure that you evaluating your state to whnf as done my modify' actually evaluates all the fields that you want to evaluate
13:11 <cocreature> in particular using a tuple as a state won’t do that
13:12 dhil joined
13:12 <mutsig> Well, I have a rather large state-datatype which i use modify' on. I thought that would do it
13:12 <c_wraith> only if you have the fields you're accumulating marked strict
13:12 <mutsig> And the fields which I modify are strict
13:12 <mutsig> yes
13:13 <c_wraith> that should do, then. As long as *they* are also good. :)
13:13 cur8or joined
13:13 <c_wraith> Like, none of them are String or other [a]
13:14 <mutsig> Ah ok. I will start by removing the Writer-part of the transformer and put it in the state. No, I think all my datatypes are strict :) Thanks
13:14 iAmerikan joined
13:15 jedws joined
13:15 ejay joined
13:15 augur joined
13:16 mszczygiel joined
13:17 Eduard_Munteanu joined
13:17 fizbin joined
13:21 srh joined
13:21 fakenerd joined
13:24 <joe9> code : http://codepad.org/vunaxBRI error http://codepad.org/aX4toP2U . the manual https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#instance-overlap indicates that this situation is ok as there is a more specific instance. Any suggestions on what I am missing, please?
13:25 <c_wraith> joe9: it's ok for them to overlap - if you tell ghc that you want them to overlap
13:25 <c_wraith> joe9: add appropriate pragmas to indicate that the overlapping is intended.
13:26 sheogorath joined
13:26 <c_wraith> instance {-# Overlappable #=} IBFormat a => IBFormat (Maybe a) where ..
13:26 <joe9> c_wraith: Thanks.
13:26 <c_wraith> instance {-# Overlaps #=} IBFormat (Maybe Text) where ..
13:27 <halogenandtoast> If I want to use a custom data type as the "key" for Array do I need to make it an instance of Ix
13:27 <c_wraith> halogenandtoast: yes
13:27 <halogenandtoast> i.e. I have data Position = Position !Int !Int so I need to make that an instance of Ix, is there an easy way to do that?
13:27 crobbins joined
13:28 <halogenandtoast> or just define range, index, and inRange
13:28 <halogenandtoast> and be done with it
13:28 <c_wraith> I'd just define them in terms of (Int, Int) - I assume you want the same behavior as that instance.
13:28 <halogenandtoast> c_wraith: yeah
13:29 <joe9> c_wraith: That does not seem to help. Do I need something in the calling file (where the instance is used)?
13:29 <halogenandtoast> Thanks
13:30 bennofs1 joined
13:30 <joe9> c_wraith: code http://codepad.org/HC9ZPtHD , error http://codepad.org/q704BTwl
13:30 machinedgod joined
13:30 <c_wraith> joe9: It should only be necessary at the instance definitions... But I don't ever write overlapping instances, so my knowledge here is incomplete.
13:31 <joe9> case sensitive? let me try.
13:31 <c_wraith> I don't think pragmas are case sensitive, but it's worth checking.
13:33 <joe9> not case sensitive. must be something else then.
13:33 <c_wraith> oh, maybe you want OVERLAPPING instead of OVERLAPS
13:33 revprez_atlanta joined
13:33 mkollaro joined
13:33 <joe9> no, not Overlapping either
13:33 <c_wraith> Then I'm out of my depth, sorry. Maybe someone else knows.
13:35 TheLemonMan joined
13:36 <mkollaro> could somebody please explain what ((,) e) means? It's in https://wiki.haskell.org/Typeclassopedia in section 3.2
13:36 richi235 joined
13:37 <c_wraith> mkollaro: it's the partially applied pair type.
13:37 <geekosaur> partially applied 2-tuple constructor
13:37 <c_wraith> (a, b) = (,) a b
13:37 bgamari joined
13:38 ystael joined
13:39 <joe9> c_wraith: got it, works: http://codepad.org/BtKaXmqH fails: http://codepad.org/YKwF8qjl , Notice the "IBFormat Text" in the second instance. That was breaking it.
13:40 heebo joined
13:40 guampa joined
13:40 <c_wraith> joe9: oh, hah. Not sure *why* that broke it, but you might note my suggestion lacked that part, as it was clearly unnecessary. :)
13:40 <mkollaro> oh...so how can I get a type like that in practice? "ghci> (42, )" doesn't work...
13:40 <c_wraith> It's a higher-kinded type. You can't have values of it.
13:41 <joe9> c_wraith: my mistake . Thanks.
13:41 <c_wraith> joe9: well, I don't know why it matters, so - yeah, I'm still clueless about overlapping instances. :)
13:41 <c_wraith> mkollaro: it's like saying you can't have a value of type Maybe
13:42 <c_wraith> mkollaro: you can have a value of type Maybe Int, or Maybe String, etc
13:42 <c_wraith> mkollaro: but it's impossible to have values of type Maybe, because Maybe has the wrong kind
13:43 shouyinji1 joined
13:43 heebo joined
13:44 <mkollaro> sigh...can anybody recommend a book or something for somebody who already knows a bit of haskell from school and functional concepts from other languages (e.g. Rust), but not much in the way of Monads and such? At uni it was used as an intro to math thinking, so I know how to code up basic pure functions, how currying and lazy evaluation works, etc. So far everything I found either bores me to death (Real
13:44 <mkollaro> World Haskell) or overwhelms me (Typeclassopedia).
13:45 <c_wraith> I mean, this is *exactly* the feature Rust doesn't have that people keep asking for
13:45 <lyxia> joe9: which version of GHC are you on
13:45 <geekosaur> joe9, c_wraith, technically that's an illegal context and practically I think that might be fallout from the current Constraint vs. * confusion
13:45 <geekosaur> which is confusing the overlapping check
13:45 <c_wraith> geekosaur: ah, that makes sense
13:45 <mkollaro> c_wraith: thanks, I think I get it
13:45 biglambda joined
13:45 <mutsig> To you guys who helped me with the space leak regarding StateT-Writer transformer, *thanks* - The leak is now gone :)
13:45 <joe9> lyxia: 8.0.1
13:46 <c_wraith> mkollaro: so if your main point of familiarity with these features is Rust, yeah, this is a whole new topic to learn. Nothing bad about that. :)
13:46 mizu_no_oto_work joined
13:47 shayan_ joined
13:48 carlosda1 joined
13:49 Sampuka joined
13:50 `^_^v joined
13:51 bennofs1 joined
13:52 Brando753-o_O_o joined
13:53 SimpleL joined
13:55 mudfog_ joined
13:55 cyborg-one joined
13:55 eacameron joined
13:56 darlan joined
13:58 <quchen> c_wraith: Rust people are asking for values of type Maybe??
13:59 takle joined
13:59 <geekosaur> I read that the other way: Rust will give them that with no warning?
14:01 mkollaro joined
14:01 capuk joined
14:02 eacameron joined
14:02 <bjz_> quchen: Rust has Option - just doesn't have a way of writing a common interface over multiple different Monads
14:02 bhiliyam joined
14:02 multichill joined
14:03 <quchen> Oh, the lack of higher-kinded types was the »exactly« thing.
14:03 capuk joined
14:03 <bjz_> yah
14:04 juliench1rch joined
14:05 <mkollaro> I got disconnected...did I miss something?
14:05 robkennedy joined
14:05 danza joined
14:05 <quchen> mkollaro: <c_wraith> mkollaro: so if your main point of familiarity with these features is Rust, yeah, this is a whole new topic to learn. Nothing bad about that. :)
14:06 <joe9> geekosaur: Have you tried curry? any first impressions to share, please? When you have some free minutes
14:06 <geekosaur> I have not
14:06 <quchen> Curry is the one with uniqueness types?
14:06 <dolio> That's Clean.
14:06 <quchen> Ah, right.
14:07 <dolio> Curry is hybrid functional and logic.
14:07 <bjz_> mkollaro: this one is good: http://haskellbook.com/
14:07 ryantrinkle joined
14:08 <mkollaro> got that one, thanks
14:08 eacameron joined
14:08 <bjz_> mkollaro: you are already a leg up with some Rust knowledge, helps a great deal
14:08 <Gurkenglas_> Is there better code to replace "fmap concat . traverse f" with?
14:08 doomlord joined
14:08 zar joined
14:09 <mkollaro> bjz_: thanks, I'll try
14:09 abhiroop joined
14:09 <Iceland_jack> Has the same type as concatMap no?
14:10 <c_wraith> no, it'd be concatMapM
14:10 <c_wraith> which I don't think exists
14:10 <c_wraith> (well, concatMapA)
14:10 kuribas joined
14:10 <Iceland_jack> oh forgot composition
14:10 ccomb joined
14:11 <Iceland_jack> :t \f -> fmap concat . traverse f
14:11 <lambdabot> (Applicative f, Traversable t) => (a1 -> f [a]) -> t a1 -> f [a]
14:11 <bjz_> mkollaro: `Monad` partly answers the question, 'how do I make a common trait between `Option` and `Result`? You'd want to have a generic `and_then` method. See if you can try it in Rust, and then work out what the problem is :)
14:11 <Iceland_jack> :t \f -> fmap concat (traverse f)
14:11 <lambdabot> (Applicative t, Foldable t) => (a1 -> t a) -> [a1] -> [a]
14:11 Wamanuz2 joined
14:16 LordDeath joined
14:16 heebo joined
14:18 clog joined
14:19 simukis_ joined
14:20 kirillow joined
14:20 xtreak joined
14:20 eacameron joined
14:21 ij left
14:21 takle_ joined
14:22 NeverDie joined
14:23 <ertes> Gurkenglas: depending on the monad you may prefer a stream processing solution, because that one builds at least the outer list in memory
14:23 <ertes> "that one" being (fmap concat . traverse f)
14:23 Adam___ joined
14:26 SpaceGazebo3 joined
14:27 <Gurkenglas> > (`evalState` 0) $ fmap concat $ forM [1..] $ \i -> state $ \s -> ([i..i+s],i+s) -- you're wrong, sir
14:27 <lambdabot> [1,2,3,3,4,5,6,4,5,6,7,8,9,10,5,6,7,8,9,10,11,12,13,14,15,6,7,8,9,10,11,12,1...
14:27 Aphex joined
14:29 abhiroop joined
14:30 <Adam___> Hi puzzled beginner here, browsing Data.List module source in haskell.org it seems incomplete, with only isSubsequenceOf defined at the end. Where's the source for all those functons for me to look and learn from? Thanks
14:31 <Gurkenglas> Adam___, https://www.haskell.org/hoogle/
14:31 <geekosaur> these days it mostly reexports Data.Foldable
14:31 <quchen> Adam___: Look in the Data.OldList module, it contains the actual list functions
14:32 <ertes> Adam___: Data.List should only include list-specific functions now, for everything else: what geekosaur said
14:32 mkollaro joined
14:32 <ertes> :t foldr
14:32 <lambdabot> Foldable t => (a -> b -> b) -> b -> t a -> b
14:32 <ertes> Adam___: ^ most of them have been geeneralised
14:32 srh joined
14:32 <Adam___> Aaahh, so the imports in there foldable etc. have all the functions. Seems a bit odd to have only one functon definced in the Data.List module.
14:32 <geekosaur> backweard compatibility hack
14:33 <* geekosaur> asks subconscious whether that was supposed to be "backward" or "backweird" :p
14:33 srh joined
14:33 <ertes> backward compatibility is always a bit weird
14:34 burtons joined
14:34 <Gurkenglas> The (fmap concat . traverse f) thing feels like it should involve alaf somehow
14:34 <Adam___> So the thing to dois just dig down to foldable module (and any inside that) to get the actual source.
14:35 bjz joined
14:35 moth joined
14:35 srh joined
14:36 fiddlerwoaroof joined
14:36 OnkelTem joined
14:37 epsilonhalbe joined
14:37 srh joined
14:38 yaxu joined
14:39 DrMentats joined
14:40 srh joined
14:40 safe joined
14:40 carlomagno joined
14:41 <yaxu> A conundrum:
14:41 <yaxu> I made a function `unwrap :: Pattern (Pattern a) -> Pattern a`, which I now realise is actually `join`
14:41 <yaxu> so I defined bind in terms of it: `p >>= f = unwrap (f <$> p)`
14:41 <yaxu> However looking at the source I see the real join is defined in terms of `>>=`
14:41 <yaxu> This seems a bit wrong/inefficient, to have a function defined in terms of a version of itself via another function.
14:41 <yaxu> But it seems for some reason I can't define a monad with join, only with `>>=`
14:42 <tsahyt> What does ghc-mod refine do?
14:42 <geekosaur> yes, possibly some future will have an extension that will avoid problems but currently it is not possible to backward compatibly move join into Monad and *all* existing instances would break
14:43 <Freundlich> yaxu: I agree that monads should be defined using join but that's not the way it is, unfortunately.
14:43 <tsahyt> or rather, how to use it.
14:43 <cocreature> geekosaur: how would all instances break if you provide a default definition?
14:43 <* ski> thinks there should be an option to define either `join' or `(>>=)'
14:43 <yaxu> Freundlich: ah ok, I'm just after reassurance (or otherwise) that I'm not doing the wrong thing
14:44 <ski> sometimes defining `(>>=)' will be more efficient (assuming no SSC)
14:44 <geekosaur> hm. that was my recollection of the argument, I admit I'm short on sleep (and still choking regularly, sigh) but there were problems with just moving join into the definiton with a default
14:44 <geekosaur> maybe it was an optimization issue
14:44 jship joined
14:44 <geekosaur> there may also be some wiring issues with how ghc desugars do
14:44 <cocreature> hm I’ll have to read up on that at some point. I’ve always thought that moving methods into type classes is mostly unproblematic
14:45 <geekosaur> (or, again. conceivably optimization)
14:45 <yaxu> I'll continue on this path then, thanks all
14:46 <ski> often it's simpler to discover how to define `join' than `(>>=)', though
14:46 <yaxu> ski: yes that's what I've found
14:46 <yaxu> ski: at least, I defined join by accident
14:47 <dolio> geekosaur, cocreature: The problem with join in Monad has to do with roles.
14:47 jhrcek joined
14:47 <dolio> join :: m (m a) -> m a
14:47 stelleg_web joined
14:47 <Freundlich> dolio: Roles?
14:47 <ski> m-hm
14:48 plutoniix joined
14:48 <* Iceland_jack> hisses at roles
14:48 <* ski> smiles
14:48 <stelleg_web> anyone know if there's a way to drop prefixes using c2hs?
14:48 <* geekosaur> hisses at unsafeCoerce :p
14:48 <cocreature> at some point I actually knew what the role of roles (no pun intended) was but it seems like I forgot about everything about it :)
14:48 <dolio> So, if m is nominal, there are problems using generalized newtype deriving to derive Monad.
14:49 <stelleg_web> so instead of underscoreToCase, you could have dropPrefix "lib_"
14:49 <dolio> If join is in Monad.
14:49 carlosda1 joined
14:50 <dolio> And lots of things end up nominal.
14:50 <lyxia> this makes things quite tricky
14:50 hackebeilchen joined
14:51 cross joined
14:51 abhiroop joined
14:51 osa1 joined
14:51 osa1 joined
14:51 oleksiyp joined
14:52 <cocreature> stefan-__: think https://github.com/haskell/c2hs/wiki/Implementation-of-Haskell-Binding-Modules#context-hooks might be what you’re looking for
14:52 ortmage joined
14:52 <cocreature> eh ^ stelleg_web
14:52 <dolio> I think most monad transformers probably have to be nominal, because they include an abstract `f` that is applied (maybe indirectly) to the `a` argument.
14:53 <stelleg_web> cocreature: thanks!
14:53 <dolio> Unless you (co)Yoneda them or something.
14:53 ilyaigpetrov joined
14:53 doomlord joined
14:53 nitrix joined
14:54 nitrix joined
14:54 nitrix joined
14:55 eazar001 joined
14:57 fizruk joined
14:59 oab joined
15:00 oab left
15:00 oab joined
15:00 bennofs joined
15:00 <DrMentats> say I wanted to write a Parsec parser for a programming language while allowing an user of the library to extend it later with new syntax
15:00 <DrMentats> usually, if the user wanted to make a new kind of atom, they'd also have to rewrite the expression parser, then the statement parser and so on
15:01 <DrMentats> is there any way to avoid this duplication?
15:01 pera joined
15:02 <tsahyt> before even worrying about the parser, you'd need your expression tree type to be extendable
15:02 {emptyset} joined
15:02 <DrMentats> true, I'm looking into that right now
15:02 spaniard joined
15:03 <tsahyt> this is known as the expression problem and there are several ways to go at it
15:03 <tsahyt> DrMentats: you might want to read the Data types a la carte paper
15:03 sellout- joined
15:03 bhiliyam joined
15:03 raycoll joined
15:04 <DrMentats> will do, thanks
15:04 yaxu left
15:04 biglambda joined
15:05 ChristopherBurg joined
15:05 flatmap13 joined
15:09 jsgrant_ joined
15:10 iAmerikan joined
15:13 insitu joined
15:14 raichoo joined
15:15 sheogorath joined
15:15 MoALTz joined
15:16 <NemesisD> probably too vague of a question but does anyone know of any techniques for creating annotated record records in haskell. for ex i've got a record and i want to annotate fields with things like descriptions that may get rendered into an HTML form or something
15:16 santoast joined
15:16 <santoast> hello
15:17 <santoast> Okay I've never chatted on an IRC before. Let alone one where I'm trying to learn haskell
15:17 <ski> hello santoast
15:17 <NemesisD> maybe i can come up with some sort of applicative interface, data Foo = Foo { bar :: Bar, baz :: Baz}, documentedFoo = Foo <$> doc "doc for bar" <*> doc "doc for baz"
15:17 <santoast> Is this how you do it? :P
15:17 <NemesisD> santoast: you're doing great
15:18 <lyxia> NemesisD: you could parameterize your records with a type of annotations: data Record ann = Record { field :: ann FieldType }
15:18 <ski> NemesisD : maybe `data Foo f = MkFoo { bar :: f Bar,baz 9~:: f Baz }' setting `f' to `Identity' respectively `(Annotation,)'
15:18 <NemesisD> lyxia: i briefly considered that. the question i guess is if i could generically traverse any record with annotated fields. perhaps actually via generic
15:18 mjhoy joined
15:19 <lyxia> You definitely can
15:20 moth joined
15:20 marvin2 joined
15:20 soLucien joined
15:20 SpaceGazebo3 joined
15:20 urodna joined
15:21 biglama joined
15:21 boombanana joined
15:21 <* ski> idly wonders whether santoast has any question, yet
15:22 <santoast> Hello ski
15:22 bertschneider joined
15:23 <santoast> um not anything specific, I am just checking out this stuff. I am currently learning about algebraic data types and type classes so I'm pretty new
15:23 <* ski> nods
15:23 <ski> feel free to lurk, if you want to
15:23 <Iceland_jack> Like what you see so far santoast?
15:23 <Iceland_jack> Haskell is a lot of fun
15:23 <santoast> and I figure when I do more haskell I'll have more questions so I'm pretty much breaking the ice
15:23 <santoast> LOL yeah I'm definitely lurking
15:23 <ski> newbie questions are welcome
15:24 <shapr> yay haskell!
15:24 <* ski> boings a bit
15:24 cschneid_ joined
15:24 <* shapr> hops cheerfully
15:24 <santoast> awesome, yeah I'm reading a few online tutorials and I am trying to get a feel for how / why I need to learn about the types and classes
15:24 <sheogorath> nono, you're not lurking I'M ... err, damn
15:25 <mizu_no_oto_work> There's also #haskell-beginners, which might be good to lurk on.
15:25 coltfred joined
15:25 <* ski> spots a sheogorath
15:25 <* Iceland_jack> awkwardly shuffles
15:25 <santoast> oh really? cool
15:25 <santoast> I'll have to check that channel out
15:26 bertschn_ joined
15:26 <ski> that channel is connected with a particular Haskell book
15:26 <ski> that's not to say that beginners aren't supposed to ask here
15:27 <santoast> awesome, you guys are cool!
15:27 <ski> (feel free to be joined to both, if you want to)
15:27 kamysh joined
15:28 edejong joined
15:28 <mizu_no_oto_work> And one thing that's helpful to know with IRC is that when you have a question, it's best to just ask it instead of first asking "can anyone help me?". If anyone knows the answer, they'll answer.
15:28 <NemesisD> ski lyxia I may see if i can use optparse-applicative for a pattern. there's actually 3 things i want from this pattern: documentation, form generation and parsing from a more generic structure. seems like this fits close to what OA does and doesn't require any change to the data structure
15:28 <* shapr> hops randomly
15:28 <sheogorath> does anyone know a particularly cool functor?
15:29 <santoast> oh okay
15:29 <santoast> that's good to know
15:29 <* ski> . o O ( diagonal functor )
15:29 <mizu_no_oto_work> And IRC is semi synchronous, like text messages, so asking to ask just kind of wastes your time
15:29 <NemesisD> the functor for (-> r) is kinda cool
15:29 <pmn> "what's your favorite functor?" should be the icebreaker question at every dinner party
15:29 serendependy joined
15:29 <santoast> thanks mizu
15:29 Croniamental joined
15:29 <Iceland_jack> pmn: I do that..
15:30 <* ski> smiles
15:30 <santoast> so when I have a question just jump right in then?
15:30 <mizu_no_oto_work> So someone might answer after 5 or 10 min if it's particularly slow time.
15:30 <ski> sure
15:30 <Iceland_jack> santoast: go for it
15:30 <mizu_no_oto_work> santoast: yes, exactly
15:30 <Gurkenglas> santoast, you're still doing it :P
15:30 <* ski> 's had conversations, on slow channels, with hours inbetween individual messages, spanning over days
15:30 <santoast> LOL :P
15:30 <Iceland_jack> sheogorath: Do non (Type -> Type) functors count?
15:30 <santoast> I am ... I AM!! :D
15:31 <Iceland_jack> santoast: You can evaluate Haskell expressions
15:31 cdg joined
15:31 <* ski> nods to Iceland_jack
15:31 <Iceland_jack> > 1 + 2 + 3
15:31 <lambdabot> 6
15:31 <ski> @type map length
15:31 <Iceland_jack> By adding a "> " in front of your expression
15:31 <lambdabot> Foldable t => [t a] -> [Int]
15:31 <santoast> really? in here?
15:31 <ski> @help run
15:31 <lambdabot> run <expr>. You have Haskell, 3 seconds and no IO. Go nuts!
15:31 albertus1 joined
15:31 <santoast> run 1 + 2
15:31 <ski> @run 1 + 2
15:31 <lambdabot> 3
15:31 <sheogorath> yeah, i like (->) r. most recently i ran into FRP Event's and things. Nice and simple.
15:31 <ski> either `@run ' or `> '
15:31 <Gurkenglas> Nah, better not in here unless you want to show us something. Use /query lambdabot to ask him in private
15:32 <Iceland_jack> sheogorath: Fix and Free are nice functors
15:32 sleffy joined
15:32 beanbagula joined
15:32 <ski> sheogorath : that's not the same as what NemesisD was talking about, though
15:32 <santoast> > 1 + 2
15:32 <lambdabot> 3
15:32 <kamysh> @pl let (a,b) = f x in g a b
15:32 <lambdabot> (line 1, column 5):
15:32 <lambdabot> unexpected "("
15:32 <lambdabot> expecting "()", natural, identifier or "in"
15:32 <ski> `> ' is a short-cut for `@run'
15:32 <santoast> wait I thought you meant you can run haskell expressions in this text box
15:32 trism joined
15:32 NeverDie joined
15:33 <ski> kamysh : `uncurry g (f x)'
15:33 <ski> santoast : you just did
15:33 <kamysh> thanks!
15:33 <santoast> ah I see LOL
15:33 <sheogorath> ski: no? fmap=(.) ?
15:33 <Iceland_jack> santoast: Does this make sense: data Bool = False | True
15:33 <Gurkenglas> Iceland_jack, Fix isn't a Functor, unless you're refering to some category-theoretical thing? "data Fix f = Fix (f (Fix f))"
15:34 <ski> sheogorath : `(->) r' is `(r ->)' is not `(-> r)'
15:34 <santoast> Yeah so False and True are constructors right?
15:34 <ski> data constructors, yea
15:34 <Iceland_jack> that's right santoast
15:34 alx741 joined
15:34 <Iceland_jack> Gurkenglas: Yeah, it is higher-order
15:34 <ski> `Bool' is a type constructor
15:35 <Iceland_jack> fmap :: (f ~> f') -> (Fix f -> Fix f')
15:35 <santoast> okay, so I use the data to define the types and whatnot
15:35 <Iceland_jack> santoast: This is how you would define negation
15:35 <Iceland_jack> not :: Bool -> Bool
15:35 <Iceland_jack> not False = True
15:35 <Iceland_jack> not True = False
15:36 Lu joined
15:36 <santoast> ah that makes sense
15:37 <ski> that's using pattern-matching, matching on particular patterns on input, covering all cases
15:37 <santoast> so the big picture here, at what point will I see the beauty in using/ making my own data?
15:37 <Iceland_jack> > not (not True)
15:37 <ski> `not' is being defined through multiple defining equations, each handling one pattern of input
15:37 <lambdabot> True
15:38 <ski> santoast : when working with particular problem domains, often you'll want to make custom datatypes for concepts that you want to model there
15:38 <mjhoy> Has everyone read this? I very much enjoyed it on many levels. https://aphyr.com/posts/342-typing-the-technical-interview
15:38 <stelleg_web> > :t fix
15:38 <lambdabot> <hint>:1:1: error: parse error on input ‘:’
15:38 <piyush-kurur> is there a reason why xml-couduit-1.5 is not entering stackage? most of the parsing functions in 1.4 have been depreciated so the use is throwing up a lot of warnings
15:38 <Iceland_jack> :t fix
15:38 <ski> that's when you'll reach for `data' (and `newtype')
15:38 <stelleg_web> :t fix
15:38 <lambdabot> (a -> a) -> a
15:38 <lambdabot> (a -> a) -> a
15:38 <santoast> And when is the turning point usually when learning Haskell?
15:38 <Iceland_jack> it depends santoast
15:39 <stelleg_web> > fix not
15:39 <lambdabot> mueval-core: Time limit exceeded
15:39 <ski> > fix show
15:39 <Gurkenglas> Iceland_jack, but then wouldn't that be ambigious in the order in which you turn the levels of f into levels of f'? (Also you're missing (Functor f, Functor f')... unless you're only using one of them, and then the ambiguity is gone, but still)
15:39 <lambdabot> "\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\...
15:39 <Iceland_jack> Gurkenglas: (~>) could package up the Functor instances
15:39 <ski> > fix error
15:39 <lambdabot> "*Exception: *Exception: *Exception: *Exception: *Exception: *Exception: *Ex...
15:39 bodisiw joined
15:39 epsilonhalbe left
15:40 kamysh left
15:40 <Iceland_jack> you are right that there are two equivalent ways of defining
15:40 <Gurkenglas> More like arbitrarily many
15:40 <ski> Gurkenglas : naturality law says that it shouldn't matter in which order you do it
15:41 flohsor joined
15:41 <stelleg_web> > fix $ \x -> "we must go deeper ..." ++ x
15:41 <lambdabot> "we must go deeper ...we must go deeper ...we must go deeper ...we must go d...
15:41 whaletechno joined
15:42 <ski> > (`fix` 12) (\fib n -> case n of 0 -> 0; 1 -> 1; n -> fib (n-1) + fib (n-2))
15:42 <lambdabot> 144
15:42 Itkovian joined
15:43 <ski> > fix (\fibs -> 0 : 1 : zipWith (+) fibs (tail fibs))
15:43 <lambdabot> [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,...
15:43 kosorith joined
15:43 wroathe joined
15:44 <Gurkenglas> Huh he's right, so the (~>) also packaged up an ambiguity resolution :D
15:44 <stelleg_web> fix ("turtles "++)
15:45 <stelleg_web> > fix ("turtles" ++)
15:45 <lambdabot> "turtlesturtlesturtlesturtlesturtlesturtlesturtlesturtlesturtlesturtlesturtl...
15:45 <ski> @type cycle
15:45 <stelleg_web> ok i'm done
15:45 <Iceland_jack> I see #haskell is getting its fix
15:45 <lambdabot> [a] -> [a]
15:45 <ski> @src cycle
15:45 <lambdabot> cycle [] = undefined
15:45 <lambdabot> cycle xs = xs' where xs' = xs ++ xs'
15:45 biglambda joined
15:47 <santoast> Well thanks Iceland and ski and everybody else for being really cool. It was a good ice breaker, now I will try and come here when I have future questions
15:47 <ski> you're welcome
15:47 <Iceland_jack> "icebreaker" D;
15:47 <santoast> LOL
15:47 <sheogorath> gl hf
15:48 abhiroop joined
15:48 <santoast> thanks I will
15:48 <Iceland_jack> good luck santoast
15:48 <santoast> have a good day y'all
15:48 <santoast> ty
15:48 <Iceland_jack> I might could
15:48 <ski> santoast : might want to consider using a stand-alone IRC client, if you're gonne come here often
15:48 <halogenandtoast> Is there a setting I can turn on to complain about exhaustive patterns at compile time?
15:48 <halogenandtoast> I'd prefer errors not warnings, but I'll take what I can get
15:48 <santoast> oh okay, ill look into that
15:49 <halogenandtoast> for this I mean in ghc
15:49 <ski> mIRC, HexChat, Irssi, Colloquy (sp?), AndroIRC, &c.
15:49 <glguy> (glirc)
15:49 <* ski> grins
15:49 <DrMentats> halogenandtoast: I just use -Wall myself and it comes with that as well
15:49 <* ski> isn't sure which are the most common ones, on various platforms
15:50 flatmap13 joined
15:50 <joe9> attoparsec default error messages suck. Just want to check if there is a way to show better error messages
15:50 <joe9> I get this : Left "0: Failed reading: satisfy"
15:50 me1 joined
15:50 <joe9> nothing on the input string, etc.
15:51 flatmap13 joined
15:52 <bennofs1> joe9: good error messages are hard. that's one of the reasons that makes attoparsec fast, it does not have to do all the bookkeeping to generate good ones
15:52 <geekosaur> joe9, it's common to test using marsec/megaparsec and then switch to attoparsec for production
15:52 <geekosaur> *parsec
15:52 <glguy> joe9: You have to annotate your parser with information using <?> and friends
15:52 <bennofs1> geekosaur: you could perhaps even reparse in production if attoparsec fails to pare, go give a better error?
15:53 <bennofs1> assuming that most input will parse successfully
15:53 <geekosaur> I'm vaguely recalling a package on hackage that lets you do that. parsers perhaps?
15:53 <halogenandtoast> DrMentats: okay fair enough, I'll need to see if I can add that as a stack default
15:54 <joe9> i loved aeson's error messages . took the guess work.
15:54 <joe9> s/work/work away/
15:54 Sonolin joined
15:54 <joe9> glguy: Thanks. will check out <?>
15:54 revprez_atlanta joined
15:55 <joe9> glguy: <?> is a good start. Thanks.
15:56 JagaJaga joined
15:56 <DrMentats> halogenandtoast: actually, I faintly remembered an option that turns warnings into errors and upon closer inspection it's -Werror if you're interested
15:56 contextfree left
15:57 pandeiro joined
15:57 <halogenandtoast> DrMentats: Yup I added it
15:57 <halogenandtoast> to my global stack config
15:57 <halogenandtoast> Thanks for pointing me in the right direction
15:57 tig_ joined
15:57 <tig_> ls
15:57 jgertm joined
15:58 meoblast001 joined
15:59 jao joined
16:00 fotonzade joined
16:01 abhiroop joined
16:02 soLucien joined
16:03 someguy left
16:04 bhiliyam joined
16:04 gcross_ joined
16:05 JuanDaugherty joined
16:05 <inkbottle> [noob] [1,10,45,120,210,252,210,120,45,10,1] >>= take 5
16:05 mtesseract joined
16:07 fizruk joined
16:07 fnkl joined
16:07 <ertes> inkbottle: do you have a question?
16:07 cables joined
16:07 <fnkl> I do
16:07 <inkbottle> ertes: Yes, I thought the above line would work, but it doesn't
16:07 gabluc joined
16:07 ystael_ joined
16:07 <ski> > take 5 [1,10,45,120,210,252,210,120,45,10,1]
16:08 <lambdabot> [1,10,45,120,210]
16:08 <ertes> inkbottle: (>>=) :: [a] -> (a -> [b]) -> [b]
16:08 <ertes> take :: Int -> [a] -> [a]
16:08 mattyw joined
16:08 <ertes> you're trying to match the 'a' from the first with the [a] from the second
16:08 <ertes> this only works, if the 'a' from the first happens to be a list type
16:09 <ertes> > ["abcd", "efg", "hijklmn"] >>= take 2
16:09 <lambdabot> "abefhi"
16:09 <inkbottle> ertes: sttarting to see
16:09 cpape joined
16:09 mattyw joined
16:10 <inkbottle> ertes: thanks for the type above...
16:10 mekeor joined
16:11 <ski> @src [] (>>=)
16:11 <lambdabot> xs >>= f = concatMap f xs
16:11 <fnkl> Hya, am I right that this is where Haskell Q's come to be answered?
16:12 <Taneb> fnkl, yes
16:12 <ertes> inkbottle: remember that (>>=) passes each *elements* of the list to the function you supply… your elements are numbers, but (take 5) wants lists as its argument
16:12 <ertes> *element
16:12 abhiroop joined
16:13 <ski> fnkl : it's one such place, yes
16:13 <fnkl> I'm in a picke - I have tons of classes, some with ID record, most w\o. Trying to implement a func which acts like Eq, but ignores the ID field
16:13 <fnkl> *pikckle
16:13 <fnkl> *pickle sorry
16:14 <ertes> @lpaste fnkl
16:14 <lambdabot> Haskell pastebin: http://lpaste.net/
16:14 soLucien joined
16:14 <inkbottle> ertes: I confused it with bash (gnu find) xargs; but I was mistaken... I see now that it has to be a monad
16:15 <ertes> inkbottle: xargs is quite similar, if you use it with -n1
16:16 <nilof> What is the difference between acting on a monad with a monad transformer (say MaybeT List a) and composing it with another monad (MaybeT Identity) List a ?
16:16 justin2 joined
16:16 <ertes> inkbottle: echo a.txt b.txt c.txt | xargs -n1 head -n5
16:16 hdeshev joined
16:17 <ertes> nilof: the difference is that the latter is a kind error =)
16:17 tathougies joined
16:17 <ertes> nilof: MaybeT :: (* -> *) -> (* -> *) -- it takes a monad and returns a monad
16:17 geekosaur joined
16:17 <fnkl> @ertes I have nothing specific, since don't know how to approach
16:17 <lambdabot> Unknown command, try @list
16:17 <nilof> so I fed it the Identity monad?
16:17 <fnkl> ertes: I have nothing specific, since don't know how to approach
16:17 <ertes> so (MaybeT []) is a monad
16:18 <ski> `MaybeT Identity' doesn't want to be applied to `List'
16:18 <ertes> fnkl: then explain your application
16:18 <nilof> ah, MaybeT Identity ( List a) then
16:18 Lord_of_Life joined
16:18 <ski> ah, that's another thing :)
16:18 <ertes> nilof: in that case (MaybeT Identity) is your monad
16:18 hdeshev left
16:19 <ski> @unmtl MaybeT Identity ([] a)
16:19 <lambdabot> Maybe ([] a)
16:19 <ski> @unmtl MaybeT [] a
16:19 <lambdabot> [] (Maybe a)
16:20 <ertes> nilof: getLine :: IO [Char] -- this one also happens to have a list type as its result type, but that's unrelated to IO, the monad
16:20 Rodya_ joined
16:20 <fnkl> I need to encode the concept of equivalence, things that behave the same despite being run at different times. To do so, I want to compare two records (of records, of records, so on), ignoring fields that are specific to the run, e.g. timestamp
16:20 <fnkl> I
16:21 <ertes> fnkl: from your description the only thing you need is a class that is similar to Eq
16:21 indi_ joined
16:21 aarvar joined
16:21 <nilof> How does MaybeT guarentee that the result of applying it to a monad is a monad?
16:21 <fnkl> It's quite boilerplatish
16:21 SpinTensor joined
16:22 <ertes> fnkl: you can save much of the boilerplate by using generics
16:22 dhil joined
16:22 <ertes> fnkl: define instances for basic types, then use generics to derive most others
16:22 <fnkl> as in GHC.Generics?
16:22 <ertes> fnkl: yeah
16:23 <EvanR> with a proper record system you could instead say "compare r1 and r2 after forgetting timestamp"
16:23 <EvanR> without having to define a new datatype or eq algorithm
16:23 <ertes> fnkl: you could make a wrapper type (e.g. newtype Run a = Run { fromRun :: a }) and write a DescEq instance that always compares True
16:24 <ertes> fnkl: alternatively you can create a type class that defines a lens into the description part of a record
16:24 cfricke joined
16:24 <ertes> fnkl: a further alternative is to keep run-time data separate from description
16:24 sellout- joined
16:24 <fnkl> not sure I understand the last suggestion
16:24 <fnkl> *penultimate :)
16:24 <EvanR> thats the best idea
16:25 <EvanR> conceptually
16:25 <ertes> fnkl: i'd most likely pick the last approach
16:25 <Iceland_jack> propreantepenultimate
16:25 <ertes> fnkl: i.e. just don't mix the two types of data in the first place
16:25 <EvanR> instead of doing work to represent part of the monolithic type, dont make it monolithic in the first place
16:25 <ertes> nilof: the Monad instance guarantees it
16:25 oleksiyp joined
16:26 <EvanR> but practically wed still be better off with a record system
16:26 <inkbottle> (>>=) == fmap?
16:26 <ertes> nilof: you can prove that the monad laws for (Monad (MaybeT m)) hold, whenever m is itself a monad
16:26 <Iceland_jack> inkbottle: no
16:26 <inkbottle> ok
16:26 <Iceland_jack> they have very different types
16:27 <inkbottle> Iceland_jack: Quite so, I can see
16:27 iAmerikan joined
16:27 <fnkl> Thanks a lot, I'll look into these
16:28 fosskers joined
16:30 <fosskers> Is it possible to write a test suite for modules living in an executable, or do I have to break the functions I want to test out into a separate library that both my main executable and my test suite can depend on?
16:30 simukis_ joined
16:30 path[l] joined
16:31 JuanDaugherty left
16:32 gk_1wm_su joined
16:32 <lyxia> You must put them in a separate library
16:33 gk_1wm_su left
16:33 detrumi joined
16:34 taktoa joined
16:34 <fosskers> alright, time for a refactor
16:34 bab joined
16:34 thatguy joined
16:34 b4ff3r joined
16:35 gk_1wm_su joined
16:35 hc_ joined
16:35 Berra joined
16:36 <ertes> fosskers: you can add the executable's source directory via hs-source-dirs
16:36 <ertes> fosskers: caveat: you will compile the modules twice
16:36 g0d355__ joined
16:37 zar joined
16:37 gk_1wm_su left
16:40 revprez_atlanta joined
16:40 tathougies joined
16:42 insitu_ joined
16:42 miklcct joined
16:43 jchia joined
16:43 jchia_1 joined
16:45 splanch joined
16:48 gabluc joined
16:48 <tabaqui1> I'm using QuickChech2 with test-framework
16:49 <tabaqui1> how can I specified number of attempts for some test?
16:49 abhiroop joined
16:49 <tabaqui1> for now there are always 100 tests for each case
16:50 osa1 joined
16:51 carlosda1 joined
16:54 t7 joined
16:55 lc_ joined
16:56 dtornabene joined
16:57 <lyxia> tabaqui1: use PlusTestOptions and topt_maximum_generated_tests
16:59 soLucien joined
17:00 albertus1 joined
17:00 fizbin joined
17:02 <shapr> I forget my favorite functor. Must be a forgetful functor!
17:04 <tabaqui1> lyxia: in Property definition?
17:05 bhiliyam joined
17:07 <tabaqui1> lyxia: ah, I see it
17:07 <tabaqui1> thanks
17:12 TheLemonMan joined
17:12 <thimoteus> lol shapr
17:18 peterbecich joined
17:19 tushigushi joined
17:19 <Geekingfrog> How would you go to write and test something like a rate limiter, which depends on a clock ? A typeclass to get the time and a different instance for testing?
17:20 <EvanR> a type class to get the time sounds wrong
17:21 <EvanR> accepting an IO action to get the time, sounds better
17:21 tlaxkit joined
17:21 asmyers joined
17:21 <Geekingfrog> good idea, I like that.
17:22 <EvanR> though IO kind of puts a wrench into the whole testing thing
17:22 govg joined
17:22 <koala_man> maybe you can take any monadic action, so that your tests run in State while prod runs in IO
17:22 <EvanR> removing IO is sometimes a brain bender
17:23 DrMentats joined
17:23 Swizec joined
17:24 <EvanR> honestly i dont know if you want monads for this at all
17:24 <Geekingfrog> The signature is going to be something like Int -> IO () anyway, I don't quite see how I could test that without IO
17:26 <Cale> You might even start with a totally pure specification of what ought to happen -- a pure function which takes, I dunno, perhaps a Seq of scheduled tasks (a queue), and the current time, and produces a (Maybe Task, Seq Task)
17:26 <EvanR> theory: a rate limiter is a function that takes an internal state, a list of (whatever, IO actions) and returns the list split up into items youre allowed to do now and items you have to wait for, and how long, and an updated state
17:26 <EvanR> oh yeah and takes the current time
17:26 <Cale> Oh, and you may also want some other information going into that, info about completion of previous tasks :)
17:27 <Geekingfrog> I think the completion of previous task can be stuff into the internal state
17:27 <EvanR> another component would be responsible for utilizing this information, or testing the dang thing
17:27 <EvanR> the code for this may not need any monadic anything
17:27 darkSeid_ joined
17:28 <Geekingfrog> So something like: InternalState -> CurrentTime -> (Maybe TimeToWait, InternalState) ?
17:29 insitu joined
17:29 kazsakuaraba joined
17:29 gk_1wm_su joined
17:29 sampuka joined
17:29 <* EvanR> tries to come up with the most abstract version of this functionality
17:29 {emptyset} joined
17:30 johnw_ joined
17:30 <EvanR> history of what happened so far -> whether you can do the next thing now
17:30 <EvanR> no state
17:31 <EvanR> (any state can be replaced with a full history of the past)
17:31 <Cale> Geekingfrog: Yeah, something like that
17:31 <Geekingfrog> EvanR, isn't that *really* inneficient ?
17:31 <EvanR> (and stateful programming is like na optimization on that)
17:31 <Cale> Geekingfrog: Perhaps Either TimeToWait Task rather than Maybe TimeToWait
17:31 <EvanR> Geekingfrog: yep
17:31 gk_1wm_su left
17:32 <EvanR> but thats really whats going on
17:32 justin2 joined
17:32 kazsakuaraba joined
17:32 <Cale> It shouldn't be too inefficient. You can delete information about the past that you no longer need as an optimisation.
17:33 <reactormonk[m]> I've got an ADT which have a lot of the same fields - is there a way to shorten that into one? e.g. Enumerating OAuth error responses
17:33 <Geekingfrog> Cale, so you would bundle the task with the rate limiter? I was thinking more of something like acquire myRateLimiter; domything; with the acquire function perhaps blocking the current thread
17:33 <EvanR> ah right, for this thing you can provide a moving window of history
17:33 <reactormonk[m]> https://gist.github.com/b28b1e71230c9bcb18adf3709c48dec6
17:33 <Cale> Geekingfrog: Ah, right, you could just keep the queue separate here, since it's not like it will change your decision about what to pick
17:33 flatmap13 joined
17:34 <EvanR> HistoryWindow -> Bool
17:34 <EvanR> or Maybe TimeToWait
17:34 <EvanR> functional programming rocks
17:34 <Geekingfrog> I'm still not sold on the history of events, but I'll give it a try anyway. Thanks for the suggestions Cale and EvanR
17:35 <EvanR> since the whole history wont be necessary, that solves the efficiency issue
17:35 <Cale> Geekingfrog: Well, it doesn't need to be a complete history, but you need to know how to update it
17:35 <Cale> Geekingfrog: So presumably, it'll be some Set of timestamps
17:35 <Cale> and you can throw away any timestamps which are older than your window
17:35 <EvanR> a list of timestamps
17:36 burtons joined
17:36 <EvanR> you could have done two things at the same time, and that matters
17:36 <Cale> Can you?
17:36 augur joined
17:36 <EvanR> sure why not
17:36 <EvanR> in a post handler, i always save the current time once, then log that into whatever i do
17:36 <Cale> I was assuming that he'd be doing one thing at a time, and then asking the rate limiter again
17:36 codesoup joined
17:36 <EvanR> so it appears that a lot o things happen at the same time
17:37 <Cale> The other reason to use a Set would be that you can efficiently split it at an arbitrary point
17:37 <Cale> So that it becomes easy to discard the no-longer relevant timestamps
17:38 <EvanR> you need a multiset really
17:38 <EvanR> example, you are allowed to do a thing, then immediately ask again and are allowed to do antoher thing
17:38 <EvanR> the assumption that stuff takes time > 0 is kind of flaky
17:38 JagaJaga joined
17:39 <Cale> If you want to allow multiple occurrences at once, then the requests need to say how many items you want to do right at that moment
17:39 <EvanR> if it doesnt show up in the set as having done more at that time, youll never be limited!
17:39 <Cale> Because the resulting amount of time you'll need to wait will depend on that
17:39 gk_1wm_su joined
17:39 replay joined
17:39 ner0x652 joined
17:39 <Cale> Also, if you want to get really cute, there's a potential FingerTree data structure which would be very nice for that.
17:40 recycletrash joined
17:40 <Cale> (Your summaries would have the min timestamp in the subtree, as well as the sum of the task weights)
17:40 tushigushi joined
17:40 <EvanR> highly non cute, list -> bool, done
17:40 <Cale> hm?
17:40 <EvanR> testable, works
17:41 <EvanR> pulling in fancy data structures technology for this seems like overkill
17:41 <Cale> The point is, you need a data structure which is going to let you chop it at some arbitrary point in time, but also you need to be able to know the sum of all the items
17:41 <EvanR> yes overkill!
17:42 gk_1wm_su left
17:42 <EvanR> why do you need that?
17:42 <EvanR> trying to parallelize this simple task?
17:42 <Cale> No parallelism
17:42 coltfred joined
17:43 asmyers joined
17:43 <Cale> You need to be able to tell at what time you'll have enough resource remaining to fit the next task (assuming we're doing the more complicated weighted-tasks version)
17:43 <EvanR> i dont understand why you need to split a list
17:44 <EvanR> its not like you have history of the future
17:44 <Cale> and then having done that, you need to expire things from the history
17:44 <Cale> once they're old enough
17:44 hexfive joined
17:44 <EvanR> oh youre talking about managing the history structure itself, not implementing the rate limiter function
17:44 <Cale> yes
17:44 <Cale> which is the interesting part of the rate limiter :)
17:44 <Geekingfrog> I'm actually going to implement that: https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java which only requires an Int/Double as internal state.
17:45 <reactormonk[m]> Is there a "use the function defined in this class"?
17:45 <EvanR> a functional queue and be done with it
17:45 wroathe joined
17:45 oab joined
17:45 <Geekingfrog> like Seq ?
17:45 <Cale> This whole thing is *much* easier if the tasks are unweighted
17:45 <EvanR> well, i was thinking much simpler than that
17:46 <Geekingfrog> I do need weighted tasks though.
17:46 <geekosaur> reactormonk[m], most classes have more than one function. and, wanting to do that makes me suspect you're trying to use typeclasses as OOP, which won't work
17:46 <Cale> ah, okay
17:46 <reactormonk[m]> Ehh, not class, file.
17:46 <reactormonk[m]> geekosaur: got it, wrong name somehow.
17:46 <reactormonk[m]> ... I wanted "call function in this file". I've got Prelude.error conflict.
17:47 <geekosaur> you can fully qualify any imported name, including the implicit import of Prelude
17:47 <Cale> reactormonk[m]: You can explicitly qualify the module you want by writing it before the name with a dot (and no space) in between
17:47 bennofs joined
17:47 <Cale> Just as you did there with Prelude
17:47 <Cale> But often you'll just want to import the module that you don't want the thing from with "hiding (whatever)"
17:48 <reactormonk[m]> Cale: what if the name is defined in the current module?
17:48 <Cale> e.g. import Prelude hiding (error)
17:48 ubsan_ joined
17:48 <Cale> You can use the current module's name to qualify, but if that's inconvenient, then just hide the import which conflicts
17:48 NyanPasu joined
17:48 psychicist__ joined
17:49 Swizec joined
17:50 balor joined
17:50 <nitrix> How can I prevent this `c` from `Game c a` to bubble up all the way to this `Result c` type?
17:50 <nitrix> https://github.com/nitrix/lspace/blob/develop/kawaii/Kawaii/Game.hs#L9
17:50 <nitrix> https://github.com/nitrix/lspace/blob/develop/kawaii/Kawaii/Ui.hs#L16
17:50 <nitrix> https://github.com/nitrix/lspace/blob/develop/lspace/Main.hs#L39
17:51 <nitrix> I can explain what I'm trying to achieve and my concern with the current solution.
17:52 <nitrix> `Game c a` is a newtype which contains both an internal state for the library, as well as parametrized over `c` which is a custom state the user can manipulate.
17:52 <nitrix> I made the instance `MonadState c (Game c)` following that idea.
17:53 <nitrix> Then the other big piece is that the engine lets you have UIs in your game, and each UI has an update and render phase. The update phase is able to create more UIs...
17:53 <Cale> nitrix: By getting rid of the Switch and Bring constructors?
17:53 <Cale> Or by choosing which c you want to use there?
17:54 <Cale> As you have it defined, Result has an obvious dependency on the choice of c
17:54 <nitrix> Cale: Is it possible to have it implicit or quantified is some manner that I can alleviate this? The library essentially never touches this `c` type.
17:55 mtesseract joined
17:55 <nitrix> Cale: I tried taking a step back with data Ui = forall c. { uiUpdate :: Event -> Game c Result, uiRender :: Renderer c () }
17:55 <Cale> So like, imagine that I just delete the type parameter, and don't tell you which type c is
17:56 <nitrix> Cale: (Silly attempt at cutting that chain of `c` bubbling up)
17:56 <Cale> sure, like that
17:56 <Cale> Now how are you ever going to use those things?
17:56 <EvanR> the library user wont know which Results are which
17:56 <Cale> uiUpdate becomes useless, because, while you can apply it to some Event, you get a result of type Game c Result, where you don't know which type c is
17:56 <EvanR> like you might have one parameterized over c1 and one over c2 and they look the same
17:57 <Cale> and so you can never actually run that thing
17:57 <nitrix> EvanR: updateMainMenu :: Event -> Game LonesomeSpace (Result LonesomeSpace)
17:57 <nitrix> I just find the type ugly.
17:57 <EvanR> client cant use them anyway, but if they could they might mess up
17:57 <nitrix> It's repetitive :(
17:57 <EvanR> you could use a type synonym
17:57 <EvanR> i did that with time bandit clone
17:57 <Cale> nitrix: You can just specify it in the Ui type
17:58 <EvanR> instead of putting TimeBandCloneState everywhere
17:58 freeside joined
17:58 chenshen joined
17:58 <Cale> However, if things really are general with respect to the state, the type parameter is better
17:58 sigmundv_ joined
17:59 <Cale> If you specialise it to LonesomeSpace or whatever, then code which would otherwise be guaranteed not to fiddle with that state can then mess with it.
17:59 <Cale> So there are definite advantages to leaving it as a parameter, if that's possible at all.
18:00 <nitrix> I suppose I can have some ehm... type GameFoo c r = Game c (r c)
18:00 <nitrix> It's just very rare that `Game c a` a ~ Result c
18:00 <Cale> What is it that's bothering you?
18:00 cmsmcq joined
18:01 raichoo joined
18:01 fizruk joined
18:01 <Cale> I don't see anything wrong with just leaving it as Game c [Ui c]
18:02 <Cale> It's a bit interesting that it's a list, but otherwise seems fine
18:02 guampa joined
18:03 <nitrix> Cale: Agreed. It was just to get it to work; I have a note to refactor it.
18:03 splanch joined
18:03 ralu_ joined
18:03 <nitrix> Cale: https://github.com/nitrix/lspace/blob/develop/kawaii/Kawaii/Core.hs
18:03 <nitrix> Cale: The core of the engine is relatively clean though :D
18:04 <Cale> Now, if you end up somehow with several type variables parameterising everything, maybe start to worry :)
18:04 <Geekingfrog> (That's a cute name)
18:04 <Cale> (but even that's not the end of the world, it's possible for that to just be the right thing in a given situation)
18:04 <geekosaur> i l a s sd...
18:04 eschnett joined
18:05 <nitrix> Cale: Long story short, it was always Game a, and Ui, and Result and all. Then yesterday, I figured it would be nice for the user to have their custom state in that Game monad, so I added `c`, then it ended up poluting everything.
18:05 <nitrix> Cale: And I'm really, really, questioning if I still want it now today :/
18:05 <Cale> nitrix: You could just say, oh, you want custom state? Use StateT then.
18:06 bhiliyam joined
18:06 <Cale> Oh, and also get rid of the MonadState instance for Game
18:06 srbaker joined
18:06 freeside joined
18:06 <nitrix> Cale: That's... actually a good idea. Because the library is never, ever going to touch the `c`.
18:06 <Cale> Instead, define a new type class for manipulating the system's game state (possibly with more meaningful operations than 'get' and 'put')
18:07 <nitrix> So, the user can create their own `newtype Foo a = Foo { runFoo :: StateT LonesomeSpace Game a }` :O
18:07 <Cale> and just implement it in terms of the StateT you have there
18:07 <Cale> yeah
18:08 <nitrix> Cale: Oh yeah for sure, the internal state of Game is/will be managed via monadic operations of type Game, you cannot touch the engine gamestate yourself.
18:08 bennofs joined
18:08 <nitrix> Gotta user playerMove :: Player -> Game () and so on.
18:08 <nitrix> *use
18:08 <Cale> I've started to be of the opinion that usually the monads and transformers you define should *not* be instances of the MTL type classes, apart from lifting instances for transformers.
18:09 <nitrix> I really appreciate the rubber ducking by the way. I think I'm headed in the wrong direction and should remove that `c` and the MonadState instance.
18:09 <ystael> rubber duck, vt. to beat about the head and shoulders with a child's bath toy
18:09 <Cale> Instead, always make new type classes exposing part or all of the functionality of the transformers you used, and -- well, this is part and parcel of my old opinion that usually it's best to hide the fact that you're using monad transformers at all
18:11 <nitrix> Right. My previous engine was doing this. I have a little more freedom now because I'm pulling it out as a library and I'm able to chose what's exported, but it's a bit of a cheat :P
18:11 <nitrix> e.g. gameLiftIO. The library is able to lift any IO in that Game monad, but the user cannot.
18:11 a3Dman_ joined
18:12 <Cale> right
18:12 ertesx joined
18:13 <DrMentats> is there anything equivalent to type families without parameters?
18:13 <geekosaur> huh?
18:14 <DrMentats> I'd like the programmer to be able to define new constructors without having to parameterize the type
18:14 <geekosaur> adding constructors to an existing type?
18:14 <freeside> https://wiki.haskell.org/Phantom_type ?
18:14 <DrMentats> basically, yes
18:14 <nitrix> Geekingfrog: I know right :D ? Cute name for a cute engine. Some pieces are clean, some pieces are ugly, and most of it is legacy that needs to be ported, but I'll get there.
18:14 <EvanR> maybe DataKinds ?
18:14 <nitrix> Geekingfrog: I'll show you when I'm done c:
18:15 <geekosaur> how do you expect that to work? types disappear after the typechecker has run
18:15 <DrMentats> well, the use case is this
18:15 <DrMentats> I have: data Value = Bool Bool | Char Char | etc., which represents values in a dynamic language
18:15 ccomb joined
18:15 <ertesx> DrMentats: Either can add constructors to an existing type
18:15 <DrMentats> I'd like to define new cases and pattern match on them, while still being able to make [Value]
18:17 <freeside> https://hackage.haskell.org/package/compdata
18:17 govg_ joined
18:19 asmyers joined
18:21 Claudius1aximus joined
18:22 <Cale> DrMentats: Okay, so what happens when you write a function which knows how to deal with what you consider to be all the constructors of Value at the time, but then someone goes and adds a new constructor? They're going to need to put in information somehow about how to implement these operations you'd already provided, but for the new cases.
18:22 madsj joined
18:23 <freeside> https://en.wikipedia.org/wiki/Expression_problem
18:23 <DrMentats> well, good point
18:23 <Cale> If that's fine, perhaps what you want is to specify the data type in terms of all the operations which you need to know how to perform
18:24 <Cale> i.e. it should be a record type of functions, rather than a sum type
18:24 <Cale> and then you'll have functions which build that record from various sorts of values, for the existing cases
18:25 <Cale> i.e. basically object oriented programming
18:26 <DrMentats> unfortunately I can't know what operations the user may implement later
18:26 fizruk joined
18:26 sleffy joined
18:27 <DrMentats> I know this sounds bad, but I was kind of expecting I could just do a catch-all for the constructors that shouldn't be used and print an error
18:27 <DrMentats> well, never mind
18:27 <Cale> You *could* add a case like data Value a = ... | Other a
18:27 cmsmcq joined
18:28 <DrMentats> yes, that is almost what I'm doing now, except I'm using Data.Dynamic
18:28 <Cale> and then you implement some operations which are polymorphic with respect to that Other case
18:28 <EvanR> haskell might not be the best monkey patchable language
18:29 <Cale> It's possible to engineer anything you might want, it's just you have to make some decisions up-front about how bendable things are going to be.
18:29 <freeside> you can get anything you want at Alice's restaurant -- excepting Alice.
18:29 srbaker joined
18:30 <DrMentats> lol
18:31 <ertes> DrMentats: perhaps what you need is something like the dependent-sum library
18:31 <ertes> i don't know your application, so i can't tell
18:32 mstruebing joined
18:32 <DrMentats> I appreciate all suggestions, at the very least I'll learn something new for a future use case
18:33 cyborg-one joined
18:33 allenj12 joined
18:34 NeverDie joined
18:34 prkc joined
18:35 iomonad joined
18:36 baldrick joined
18:36 gk_1wm_su joined
18:38 gk_1wm_su left
18:38 <freeside> so, i'm building a language that's similar to SQL -- fairly limited syntax intended for business users, so i don't want to give them too much rope. Should I go with Alex+Happy or Trifecta?
18:39 <Tuplanolla> One vote for Megaparsec just because, freeside.
18:40 <freeside> ok
18:41 oleksiyp joined
18:42 <freeside> it's not clear to me how these parsers play with one another -- they all seem to be able to do tokenization, though many seem to prefer to hand tokenization to Alex.
18:43 <Tuplanolla> Parser combinators don't require it at all.
18:43 insitu joined
18:43 <geekosaur> lexing doesn't particularly need to be separate; tht came about because of ancient small memory computers
18:43 Snircle joined
18:45 ccomb joined
18:45 <freeside> megaparsec looks straightforward, thanks. i'll try it.
18:45 <freeside> later, if i want to do stunts, i'll try trifecta.
18:46 Zialus joined
18:46 {emptyset} joined
18:48 saidinwot joined
18:50 biglambda joined
18:50 BlueRavenGT joined
18:51 flatmap13 joined
18:52 pgib joined
18:52 carlosda1 joined
18:54 coltfred joined
19:00 path[l] joined
19:01 gk_1wm_su joined
19:01 govg joined
19:02 Ch0c0late joined
19:03 gk_1wm_su left
19:04 xinming joined
19:06 bhiliyam joined
19:07 noan joined
19:07 detrumi joined
19:08 _sg joined
19:09 Yuras joined
19:10 doomlord joined
19:11 soLucien joined
19:11 robotroll joined
19:15 mekeor joined
19:16 cmsmcq joined
19:16 johnw_ joined
19:17 Kreest__ joined
19:19 peterbecich joined
19:19 the_2nd joined
19:19 halogenandtoast joined
19:19 peterbecich joined
19:20 ma489 joined
19:20 <the_2nd> what is the mapM for "Except e a" ? I was using Either e a before and used mapM there
19:21 akl joined
19:21 <Tuplanolla> What are the options, the_2nd?
19:22 <geekosaur> :t mapM
19:22 <lambdabot> (Monad m, Traversable t) => (a -> m b) -> t a -> m (t b)
19:22 mada joined
19:23 <the_2nd> ah of course. I changed some other part and got confused
19:23 <the_2nd> the transformers are monad themselves
19:25 <freeside> Transformers! Monads in disguise! Transformers! More than meets the eye!
19:26 iAmerikan joined
19:27 xfix joined
19:27 <EvanR> what, transformers arent themselves monads
19:27 <EvanR> they send monads to monads
19:27 sz0 joined
19:28 <EvanR> if m is a monad, ReaderT r m is a monad, but ReaderT is not
19:29 hexfive joined
19:29 <the_2nd> I feel like i activated something :D
19:29 ragepandemic joined
19:30 <thimoteus> freeside: i laughed in real life
19:30 oisdk joined
19:31 heebo joined
19:31 <the_2nd> where would you laugh otherwise?
19:31 <qmm> does it make sense to use parer combinators in a non-strict functional language?
19:31 <thimoteus> the_2nd: in my head
19:31 <qmm> a non-strict, statically typed language
19:32 <qmm> in the ML family, not haskell, clearly :)
19:32 <EvanR> huh
19:32 <thimoteus> why wouldn't it make sense?
19:33 <shapr> qmm: yeah, why not? I've seen parser combinators used to good effect in Java and other languages.
19:33 <qmm> EvanR: i guess you could make it lazy when you need it most for parsers
19:33 <qmm> s/parsers/parsing
19:33 <EvanR> haskell is a non strict statically typed functional language
19:33 <EvanR> did you mean strict?
19:34 <qmm> hah! yeah, i did
19:34 <qmm> was just wondering, thanks for the input!
19:34 <thimoteus> oh, in that case yes, purescript fits the bill and there's a lot of parsing libraries that use parser combinators
19:34 guampa joined
19:35 <geekosaur> the token stream is a stream regardless of whether the language makes random data types behave like streams or not
19:35 TreyHarris joined
19:35 locallycompact joined
19:35 <geekosaur> I mean, parsec 3 still manages even though it supports strict Text as a source of Char tokens
19:36 kamyar joined
19:36 <shapr> qmm: I think the essence of your question is: do parser combinators rely on laziness. Is that correct?
19:36 <kamyar> Hello All
19:37 <shapr> howdy kamyar, how's code?
19:37 <kamyar> please answer my somewhat easy question:
19:37 <kamyar> I know differences between Cabal and Stack for building Haskell
19:37 <kamyar> I know I can use stack to make a new project and ....
19:38 <kamyar> But I want GHC and GHCI to use my .stack directory as default module search path instead of .cabal
19:38 <shapr> stack ghci ?
19:38 <kamyar> I mean when I am not making a new directory for new project, e.g. I am just creating a single file small utility
19:38 <kamyar> I dont want to say "stack ghc" or "stack ghci"
19:38 <geekosaur> stack ghci, stack ghc
19:39 <geekosaur> ghc is a compiler, not an environment manager
19:39 <shapr> kamyar: alias ghci=stack ghci
19:39 <kamyar> Can I change the default path?
19:39 BartAdv joined
19:39 <geekosaur> not usefully, no
19:39 <geekosaur> it;'s not like stack uses a custom ghc, it sets up an environment for ghc/ghci
19:39 <kamyar> I just want GHI and GHCI use .stack instead of .cabal
19:39 <geekosaur> so you have to run them through stack to get hat environment
19:39 <kamyar> within my home directory
19:40 oab joined
19:40 Vorpal joined
19:41 jgt3 joined
19:42 oab joined
19:45 emc2 joined
19:45 insitu joined
19:45 <kamyar> Thanks anyway
19:45 <kamyar> Can I ask another question?
19:46 oab joined
19:46 fizbin left
19:46 fizbin joined
19:46 <geekosaur> one may always ask. the answer may not always be what you hope...
19:46 <geekosaur> (probably shapr's suggestion of aliases is best for your first question btw)
19:46 wroathe joined
19:46 <kamyar> What is the difference between WAI and WARP?
19:46 oisdk joined
19:47 iAmerikan joined
19:47 cmsmcq joined
19:48 <geekosaur> WAI is just routing; it expects to be used with a server, although it has a very simple one built in for testing or etc. Warp is a full-featured web server.
19:49 <kamyar> thanks geekosaur
19:49 <kamyar> Do u recommend me to use Scotty (I like Sinatra-like libs) or use Warp directly for a production service?
19:50 yqt joined
19:50 <geekosaur> I have no recommendations; I don;t normally do web stuff
19:50 eschnett joined
19:51 <kamyar> Thanks :geekosaur
19:51 <kamyar> bye for now
19:53 jsgrant_ joined
19:53 carlosda1 joined
19:54 wildlander joined
19:56 dsh joined
19:57 azahi joined
19:57 revprez_atlanta joined
19:58 flohsor joined
20:00 Mutter joined
20:01 DataComputist joined
20:01 unK_ joined
20:02 Kuros joined
20:02 DataComputist joined
20:03 vicfred joined
20:04 DataComputist joined
20:05 <hexagoxel> is there a new haskell report being planned/worked on?
20:05 DataComputist joined
20:06 DataComputist joined
20:06 <geekosaur> there's a new haskell prime committee; their list seems reasonably active, unlike last time I looked
20:07 <geekosaur> or, hm, maybe not; missing months in archive list
20:07 iqubic joined
20:07 <iqubic> Hello guys.
20:07 <iqubic> What's going on here?
20:07 bhiliyam joined
20:07 iAmerikan joined
20:07 Apocalisp joined
20:08 DataComputist joined
20:08 mtesseract joined
20:08 DataComputist joined
20:08 <iqubic> Anyone have a good lenses tutorial I can look at>
20:08 <iqubic> ?
20:10 <geekosaur> https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/a-little-lens-starter-tutorial ?
20:10 fizruk joined
20:11 subttle joined
20:12 gcross joined
20:13 <hexagoxel> geekosaur: thanks, at least i know the keyword "prime" again :p ("report" doesn't yield much, unfortunately..)
20:14 cdg joined
20:14 kazagistar joined
20:15 augur joined
20:17 danthemyth joined
20:17 eazar001 joined
20:17 <lpaste> fizbin pasted “Strictness questions” at http://lpaste.net/6848677295977136128
20:17 flatmap13 joined
20:18 ragepandemic joined
20:18 <fizbin> Hey, so a bit ago (last Thursday?) I was asking questions about how to avoid a stack space overflow. Here's the follow-up and what I came up with.
20:19 <* geekosaur> thinks NFData might be relevant here
20:19 <fizbin> (Thank you, Cale , for suggesting that what fastInsEdge does to Adj lists was building up unevaluated stuff)
20:19 user22 joined
20:20 <fizbin> geekosaur: Yeah, except for other reasons an NFData constraint on the types "a" and "b" would be tricky, and without that I can't really take advantage of any other NFData instances.
20:21 augur_ joined
20:23 <srbaker> Anyone aware of a not-insignificant GTK app built in Haskell? I'm looking for some tips on how ot organize some ofthis stuff.
20:23 cpup joined
20:24 augur joined
20:24 <fizbin> Anyway, I just kind of threw together that strictify method a bit haphazardly, and I'd love to know what more experienced Haskellers would do to avoid stack overflow there.
20:24 schmichael1 joined
20:24 flatmap13 joined
20:25 gcross_ joined
20:25 dlight joined
20:25 dlight joined
20:26 flatmap13 joined
20:27 <iqubic> Are lenses ever useful in Haskell?
20:28 shesek joined
20:28 <Tuplanolla> Most of the time, iqubic.
20:28 iAmerikan joined
20:28 <geekosaur> fairly often if you are working with records
20:28 <geekosaur> standard Haskell's record story isn't very good
20:29 <iqubic> Should I use Prisms too?
20:29 <Tuplanolla> If you feel like it.
20:29 replay joined
20:29 twanvl joined
20:30 <geekosaur> (there is ongoing work to change this, mostly by automating making simple lenses that can be adapted to work with the lens library or other lens/digestive functor implementations)
20:30 <iqubic> How do I make a lens in Haskell?
20:31 <geekosaur> you probably want to read and understand that tutorial I sent earlier
20:31 exferenceBot joined
20:31 <iqubic> I have. Still a bit confused on how to make Lenses.
20:32 MP2E joined
20:32 <* monochrom> bookmarks it and procratinates learning it :)
20:32 <iqubic> Also, does the over function return a new record?
20:32 <iqubic> Or how does that work?
20:32 <monochrom> But wait, I don't need to be talked down to about forall! :)
20:33 <iqubic> What does forall do?
20:33 <iqubic> :t forall
20:33 <lambdabot> error:
20:33 <lambdabot> • Variable not in scope: forall
20:33 <lambdabot> • Perhaps you meant ‘forAll’ (imported from Lambdabot.Plugin.Haskell.Eval.Trusted)
20:33 <iqubic> :t forAll
20:33 <lambdabot> (STestable prop, Show a) => Gen a -> (a -> prop) -> Test.QuickCheck.Safe.SProperty
20:33 <iqubic> That's not what I want at all, is it?
20:33 <eschnett> iqubic: no, it’s a keyword “forall”, needs to be enabled as extension
20:34 <iqubic> Which extension? TemplateHaskell?
20:34 <Tuplanolla> If you want to understand lenses comprehensively, take a look at Lens over Tea, iqubic.
20:34 brandon-stiles joined
20:34 <Tuplanolla> Just keep in mind it refers to a sea of tea.
20:34 <iqubic> You mean this? https://artyom.me/lens-over-tea-1
20:34 <iqubic> What is a sea of tea?
20:34 insitu joined
20:35 <Gurkenglas> iqubic, try this lens tutorial https://hackage.haskell.org/package/lens-tutorial-1.0.2/docs/Control-Lens-Tutorial.html in particular Ctrl-F for "How do I create lenses?" and "over"
20:35 mizu_no_oto_work joined
20:35 <monochrom> A sea of tea is my dream come true. :)
20:35 Eksiker joined
20:35 augur joined
20:36 <Gurkenglas> iqubic, he meant that you're gonna be drinking a lot of tea if you read that tutorial while drinking tea
20:36 <monochrom> That is not sea of tea. That is so much tea you need to pee.
20:36 <iqubic> What does the Language Pragma Template Haskell add?
20:37 isidore joined
20:37 <Gurkenglas> It allows you to write programs that generate code. If a library asks you to enable Template Haskell to use a feature, that means they need to generate some code for you, for example lens which can define lenses for your data types if you allow it to write code
20:38 <iqubic> I see.
20:38 <iqubic> So Control.Lens requires Template Haskell?
20:39 <Gurkenglas> Only if you want to have it automatically define lenses for your data types
20:40 <iqubic> So to make a lense I just put MakeLenses as a top level statement?
20:40 Itkovian joined
20:40 Uakh joined
20:41 caumeslasal joined
20:41 <Gurkenglas> You're gonna have to spell it like in the example, but basically yes, that's the invocation that tells lens to automatically define lenses for you using TemplateHaskell
20:42 cpup joined
20:42 jgt3 joined
20:44 <iqubic> So, how can I make a lens without TemplateHaskell?
20:44 <Gurkenglas> iqubic, use Ctrl-F -> "How do I create lenses?" on the link I posted above
20:44 phaji joined
20:46 JuanDaugherty joined
20:47 bjz joined
20:47 <monochrom> Wouldn't it be cool if, one day, every what-is question can be answered by "expand pi in binary and start reading at the ________th bit"
20:48 <monochrom> "Hi I need a monad tutorial." "Start reading at the 29038493024834084305th bit"
20:48 <Gurkenglas> The number of the bit would be as long as the tutorial.
20:49 flatmap13 joined
20:49 <JuanDaugherty> i'd need the multiple worlds interpretation for that
20:50 <Gurkenglas> JuanDaugherty, explain.
20:50 <monochrom> OK, next idea. Wouldn't it be cool if, one day, every what-is question were answered by "inverse the SHA256 hash __________________________"
20:51 <thimoteus> we'd need a proof that pi is base-2 normal
20:51 <dolio> No, that wouldn't be cool.
20:51 <JuanDaugherty> there'd be one where anything could be done if infinite time were allowed. In real life I'm vehemently opposed to many worlds.
20:51 <monochrom> "Hi I need a monad tutorial." "Look for the second smallest number that SHA256-hashes to 0x3209f09230a20348aebfe"
20:51 <kadoban> monochrom: xD but wouldn't you have to specify which inverse it is, and wouldn't that take as many bits as the original on average, at least?
20:51 <monochrom> I don't know. These are all 5%-baked ideas. :)
20:51 <Gurkenglas> monochrom, the number in place of "second" would be as long as the tutorial minus the length of the hash.
20:52 <Gurkenglas> entropy be a harsh mistress
20:52 <Tuplanolla> > permutations "fun software" !! 25119930
20:52 <lambdabot> "runoff waste"
20:52 <monochrom> Haha that's cool.
20:52 <Sonolin> lol wut
20:53 <Sonolin> ok I see it now... cool trick though :)
20:53 Jesin joined
20:53 <hc_> lol :)
20:53 vydd joined
20:54 bshelden joined
20:55 <monochrom> How did you found the number 25119930?
20:55 <monochrom> I guess brute-force search works fine.
20:55 <Gurkenglas> JuanDaugherty, manyworlds does not allow NP computations any more than the other interpretations as far as we know, and as far as I know we don't know whether locating a text within pi must be bruteforced.
20:56 <JuanDaugherty> k
20:56 <Cale> fizbin: The thing to do, rather than periodically strictifying things, is just to be cautious/intentional about what is going to be evaluated as you proceed with an algorithm. Sometimes you might not want to just evaluate everything -- but if there's potential for building up large unevaluated expressions, probably more evaluation is warranted.
20:57 <Tuplanolla> It does, monochrom. There's a better algorithm too.
20:57 govg joined
20:57 <Tuplanolla> Unfortunately `permutations` does not generate things in lexicographic order, so it doesn't work as nicely.
20:57 <Cale> monochrom: It would be even cooler if pi were found to not be normal.
20:58 capuk_ joined
20:58 <monochrom> Ah, but the coolest outcome is that pi is not normal and the reason is it contains more monad tutorials than average. :)
20:59 hsgumby joined
20:59 <Cale> ahahaha
20:59 <kadoban> Hah
20:59 PennyNeko joined
20:59 <Cale> As far as we know, it's possible that once you go far enough out, it's just 3's, 7's, and monad tutorials (encoded with 5's and 8's)
21:00 <thimoteus> but infuriatingly they're all misleading tutorials
21:00 <kadoban> That seems like it'd be a proof of ... something metaphysical. Maybe that god exists and he has the worst sense of humor possible.
21:01 <Cale> Or something deep about humanity. We're responsible for defining circles in the first place after all.
21:01 <Gurkenglas> No that doesnt work kadoban, you can posit a hypothetical universe beyond the reach of god where only physics and math reign, and there'd still be monad tutorials in that world's pi
21:02 <monochrom> But you can weaken "proof" to "suggestive evidence"
21:02 <Gurkenglas> So monad tutorials in our pie do not tell whether God exists
21:02 <Cale> Platonism will be the last god we need to kill.
21:02 merijn joined
21:03 <* kadoban> runs away, my head already hurts
21:03 <Gurkenglas> I'd count it as evidence for "this story is wrong" aka descartian demon aka someone played a prank on the pi computation researchers
21:04 a3Dman joined
21:04 <fizbin> Cale: It's unclear to me how that general advice applies in this case.
21:04 vydd_ joined
21:04 <Cale> fizbin: Well, make fastInsEdge better.
21:04 <fizbin> I mean, I'm going to want to do various things to the final graph, with all the edges added.
21:05 <Cale> (or if the existing version of it is deemed important, make a stricter variant of it)
21:05 DrMentats left
21:05 <Cale> Or... well, I forget the scenario, but probably some individual operation on graphs was not sufficiently strict, just at the place where it was doing its work.
21:05 <Gurkenglas> kadoban, oh if you mean that it's evidence that god reached in and replaced some section of pi on your hard drive with a monad tutorial, that's fine.
21:06 cables- joined
21:06 taksuyu joined
21:06 <kadoban> Well, it seems like it'd have to be evidence that *something* is fucking with us at some level, if that were to happen. Though it's unclear at what level would be most probable, or at that point if it's even possible to tell.
21:07 <Cale> Gurkenglas: What if it was that said deity reached into the heads of earlier humans and put circles there so that they would have plenty of monad tutorials later?
21:07 <Cale> lol
21:07 biglambda joined
21:07 <Gurkenglas> There's a simple turing machine that computes pi, circles are irrelevant
21:07 wm41 joined
21:07 <kadoban> Cale: Even more disturbing, and kind of mind bending because it doesn't seem like circles themselves could even be that deeply encoded xD
21:07 <fizbin> Cale: Though I do use this "break a list arg into chunks and strictify after each chunk" pattern in another place where that advice totally applies.
21:08 <Cale> kadoban: Well, they probably can't be.
21:08 bhiliyam joined
21:08 <kadoban> Cale: Or maybe they just seem like they can't be because we've been fiddled with.
21:09 <Cale> Gurkenglas: Circles are only relevant insofar as they're how we came to define pi and regard it as an important thing.
21:09 <Cale> Gurkenglas: There are Turing machines which compute lots of stuff.
21:09 jgt3 joined
21:09 `^_^v joined
21:09 path[l] joined
21:09 <Gurkenglas> Short turing machines that generate monad tutorials are... actually, those are fine. Huh.
21:10 <Cale> pi wouldn't exist without us, and our particular ways of considering circles.
21:10 <JuanDaugherty> srsly?
21:10 <Cale> So far as I'm aware, anyway
21:10 <merijn> Cale: You're making some pretty strong epistemic assertions there ;)
21:10 <monochrom> inb4 <Cale> Platonism will be the last god we need to kill.
21:10 <Gurkenglas> Any flat universe with at least two spatial dimensions has pi
21:10 <thimoteus> you can pry my platonism from my cold dead hands
21:10 <Cale> I have no evidence to the contrary
21:11 <merijn> This discussion is way too complex for this time of day >.<
21:11 <* JuanDaugherty> marks that down, must be important, Pi is a cultural artefact
21:11 <Gurkenglas> There's a bunch of *really* simple series that converge to something to do with pi
21:11 <monochrom> Yes. Study parametricity with me. It's easier. :)
21:12 <merijn> monochrom: I just got back from lifting heavy things and throwing them back down. That's even simpler! Although, suspiciously said things where circles...
21:12 <Cale> Gurkenglas: But when did you ever run into a series untouched by a human?
21:12 <Gurkenglas> Do you also count natural numbers, multiplications etc as touched by humans?
21:13 <Cale> yes
21:13 <merijn> Although, I guess, not necessarily easier...
21:13 <thimoteus> so we've arrived at "the math that humans do is done by humans"
21:13 <Gurkenglas> Give me a place to stand on and I shall move the Earth. What is not touched by humans?
21:13 <Cale> So far as I'm aware, we don't know of any non-humans which are doing mathematics
21:13 <ertes> are we back to the "is math discovered or invented?" question?
21:14 <merijn> ertes: Yes
21:14 <ertes> answer: both
21:14 <thimoteus> i'm pretty sure my computer is "doing mathematics"
21:14 <iqubic> It is a bit of both I think
21:14 <monochrom> My friend has a better question. Is math inflicted? :)
21:14 <Gurkenglas> thimoteus, that doesnt work, he'll say your computer is touched by humans
21:14 <merijn> I say discovered, based on for example, the fact that you can't convince anyone of modus ponens or induction, unless they a priori already believe them deep down
21:14 <monochrom> (A clear "yes" from students, clearly. :) )
21:14 <shapr> ooh, stdlib found an empty flrc repo on https://github.com/IntelLabs with the title "Haskell Research Compiler"
21:15 <Tuplanolla> I also like "do proofs have to involve understanding".
21:15 <monochrom> On that note, to many students, Haskell is also inflicted.
21:15 <ertes> we invented prime numbers, then discovered that 2 is the smallest prime
21:15 <shapr> would be neat to have another Haskell compiler around
21:15 <merijn> shapr: Isn't that the one that optimises Core from 2013?
21:15 <shapr> yup
21:15 <shapr> http://ezyang.tumblr.com/post/62151067095/haskell-the-intel-labs-haskell-research-compiler
21:16 <merijn> shapr: It didn't actually compile Haskell, just had GHC produce Core and used that as a convenient IR to optimise, iirc
21:16 <monochrom> Intel Labs has a super secret Haskell compiler they needed to redact?! :)
21:16 <merijn> Funnily enough, I was at a conference talking to Intel guys doing Haskell and someone mentioned another Intel haskell project and they weren't even aware of it
21:16 JeanCarloMachado joined
21:16 <shapr> monochrom: that they need to release
21:16 <Cale> Is Haskell invented or discovered?
21:16 <merijn> monochrom: Some people in Twente are working on a CPU design for lazy functional languages
21:16 orbifx joined
21:17 <monochrom> Neato.
21:17 <shapr> merijn: something other than the reduceron? tell me more!
21:17 <merijn> Cale: Clearly the answer is neither: It was stolen from Martians
21:17 <shapr> Simons says
21:17 <merijn> shapr: This was 3 years ago, I completely forgot all details, sadly
21:17 takle joined
21:17 <shapr> :-(((
21:18 <merijn> actually...4 years...time flies
21:18 Rodya_ joined
21:18 bennofs1 joined
21:19 <Gurkenglas> You know, pi could contain more monad tutorials than average. It'd just need to contain a computation model and encode the outputs of all programs, some of which are minds that'd think it funny to output monad tutorials, for example us.
21:20 bjz joined
21:20 Micamo joined
21:21 bennofs joined
21:22 <TreyHarris> has it been proven that every possible sequence of digits occurs somewhere in pi's expansion?
21:22 <Tuplanolla> No.
21:23 <ertes> what about every finite sequence?
21:23 <Tuplanolla> Isn't that the same thing?
21:23 <merijn> Tuplanolla: No
21:23 <merijn> Tuplanolla: There's an infinite number of infinite sequences :p
21:23 <monochrom> Neither. (And mathematicians have only considered finite sequences.)
21:24 <merijn> Pretty sure it's uncountably infinite infinite sequences, even
21:24 aib joined
21:24 <monochrom> Yes, unless one insists on a constructive logic.
21:24 <ertes> funny… i thought that it was proven that you can find any finite sequence in the decimal expansion of pi
21:25 <ertes> so it's just a myth? but then it's a fairly common one
21:25 zar joined
21:26 <merijn> Which is trivially proven false by sequences such as "0010110111011110", which can be made infinite and loads of finite sequences are not in it
21:26 <sampuka> but that's a pattern
21:26 <sampuka> isn't pi proved to not be a pattern?
21:27 <ertes> sampuka: no, pi has a pattern, too
21:27 <Cale> pi isn't proved to be normal in any base
21:27 <Cale> It's not even proved that it contains all decimal digits infinitely many times.
21:28 <ertes> at least for some value of "pattern"… you can write a formula for pi
21:28 <kadoban> normal is ... digits are distributed uniformly or sometihng?
21:28 kritzcreek_ joined
21:28 capuk_ joined
21:28 ericdwhite joined
21:28 <Cale> Yeah, normal in base b means that the probability of finding each digit in the base b expansion tends to 1/b
21:28 <kadoban> It would be so cool if eventually there's just no 7s anymore or something wacky.
21:30 <Cale> oh, sorry, that's not enough
21:30 <Cale> It needs to be that the probability of finding a word of length n is 1/b^n
21:30 bjz joined
21:31 <Cale> and it's "normal" if it's normal in every base b > 1
21:32 <Cale> Very few numbers are known to be normal in any base, and all the known examples are fairly contrived.
21:32 darjeeling_ joined
21:32 <kadoban> Pretty interesting. Initially it'd seem like that'd be almost implied by transcendental or irrational or something, but ... ya just totally isn't.
21:33 <Cale> But at the same time, almost all real numbers are normal (in that the set of non-normal numbers can be shown to have Lebesgue measure 0)
21:33 path[l]_ joined
21:33 pandeiro joined
21:34 <kadoban> That's rather funny, almost all of them are, but we know of almost none
21:34 <thimoteus> that's not uncommon in math
21:34 <thimoteus> i once had a professor who said the more things there are, the harder it is to pick out any particular one
21:34 <ertes> > "0." ++ ([1..] >>= \n -> concat (replicateM n ['0'..'9']))
21:34 <lambdabot> "0.0123456789000102030405060708091011121314151617181920212223242526272829303...
21:34 <ertes> this one should contain every finite sequence of digits
21:35 <Cale> Yeah, that thing is actually normal in base 10
21:35 <Cale> It's called Champernowne's number
21:35 <Cale> er, well, almost
21:35 bennofs joined
21:35 <Tuplanolla> Why do number theorists care about base 10?
21:35 <ertes> you could have left me with the illusion that i just invented a super-clever sequence =)
21:35 <Cale> They generally don't.
21:35 <thimoteus> every base is base 10 ...
21:36 <ertes> Tuplanolla: my bases are usually prime
21:36 <Cale> ertes: Actually, yours is slightly different from Champernowne's, his was more like
21:36 <Cale> > "0." ++ concatMap show [1..]
21:36 <lambdabot> "0.1234567891011121314151617181920212223242526272829303132333435363738394041...
21:37 <ertes> i think it's almost the same except for a prefix
21:38 splanch joined
21:38 <ertes> interestingly you can start with any 'n' and still get a sequence that has all subsequences
21:38 ericsagnes joined
21:38 <ertes> > "0." ++ concatMap show [5837495873..]
21:38 <lambdabot> "0.5837495873583749587458374958755837495876583749587758374958785837495879583...
21:38 <ertes> still contains all finite sequences of digits
21:39 <kadoban> Because eventually it wraps to x00000000 and then slowly you get all of the smaller ones, and you get all of the bigger ones of course I guess?
21:39 <ertes> yeah
21:39 strykerkkd joined
21:41 <ertes> here is a fun challenge: prove that there are uncountably many sequences that contain all finite sequences
21:41 <Tuplanolla> Assume not...
21:42 <kadoban> Oh god, that might be beyond me
21:42 <ertes> here is a fun challenge: prove constructively that there are uncountably many sequences that contain all finite sequences
21:42 <thimoteus> you can pry my classical logic from my cold dead hands
21:43 <Cale> http://dx.doi.org.secure.sci-hub.bz/10.1016%2FS0304-3975%2801%2900170-0
21:43 <monochrom> I prefer to be tautological. You can pry my cold dead hands from my cold dead hands. :)
21:45 fragamus joined
21:45 <Cale> The amusing thing is that no digits of their computable absolutely normal number are apparently known
21:46 hostriac joined
21:46 <monochrom> Oh God, just what I was worrying: a computable number that we don't know how to compute.
21:47 wroathe joined
21:47 <Cale> I'm not sure that we don't know how to compute this one, it's just obnoxious
21:47 <monochrom> OK, true.
21:48 fizbin joined
21:48 personal joined
21:50 <srk> I'm looking for qt5 bindings, any suggestions?
21:51 <srk> I would like to port python qt + opengl app to haskell but so far I'm not sure
21:52 personal joined
21:53 hiratara joined
21:53 ubsan_ joined
21:53 cpup joined
21:53 flatmap13 joined
21:54 acarrico joined
21:55 carlosda1 joined
21:55 path[l] joined
21:57 darveter joined
22:00 flatmap13 joined
22:05 CoderPuppy joined
22:06 phaji_ joined
22:06 zero_byte joined
22:07 nick123 joined
22:07 Rodya_ joined
22:08 ljhms joined
22:08 theseb joined
22:08 <thimoteus> ertes: i think i have a proof. the set FS of finite sequences is countable, and if you just consider all the permutations of this set (call it Sym(FS)), that will be a subset of the set of all sequences that contain all finite subsequences. So since FS is countable, Sym(FS) has cardinality |FS|^|FS|
22:08 flohsor joined
22:09 bhiliyam joined
22:09 biglambda joined
22:10 starc joined
22:10 BlueRavenGT joined
22:10 sibi joined
22:10 Natch joined
22:11 chidy joined
22:12 reiijjs0 joined
22:14 vydd joined
22:14 <ertes> thimoteus: nice!
22:15 richi235 joined
22:17 sleffy joined
22:17 Shatnerz0 joined
22:18 path[l] joined
22:20 darjeeling_ joined
22:21 BlueRavenGT joined
22:29 Koterpillar joined
22:33 path[l] joined
22:36 imalison joined
22:36 hamishmack joined
22:36 path[l]_ joined
22:38 jxv joined
22:38 jxv left
22:38 Krymise joined
22:39 Sose_ joined
22:40 jedws joined
22:40 <imalison> I need help figuring out why https://gist.github.com/58170cd945606737c18c4e304c07e70f is giving me ambiguous instanc errors
22:41 <glguy> instance ... => InfoJoinable LayoutInfo l a where
22:41 snowalpaca joined
22:41 <glguy> overlaps with: instance InfoJoinable l l2 a
22:42 <glguy> and that second one also overlaps with instance ... => InfoJoinable l LayoutInfo a where
22:42 <glguy> It doesn't matter that you wrote stuff on the left side of the =>
22:43 <glguy> 'InfoJoinable l l2 a' is the only instance you need, every other instance will conflict with it
22:44 jedws joined
22:46 darlan joined
22:46 <Gurkenglas> :t \f -> fmap fold . traverse f -- Can this be made to require Foldable t instead of Traversable t?
22:47 <lambdabot> (Applicative f, Traversable t, Monoid b) => (a -> f b) -> t a -> f b
22:47 <Gurkenglas> (I smell alaf)
22:47 <glguy> Gurkenglas: There's a newtype I've wanted where you can do that with foldMap
22:47 hiratara joined
22:48 <glguy> It'd probably be: (a -> f ()) -> t a -> f ()
22:48 <glguy> oh, or I guess you could get it with a Monoid b, too
22:49 ystael_ joined
22:49 <glguy> newtype ApMappend f a = AM (f a); instance (Monoid a, Applicative f) => Monoid (ApMappend f a) where mempty = AM (pure mempty);
22:49 <Gurkenglas> :t traverse_ -- For "(a -> f ()) -> t a -> f ()", isn't that just this?
22:49 <lambdabot> (Applicative f, Foldable t) => (a -> f b) -> t a -> f ()
22:50 <glguy> that doesn't use monoid to combine the things
22:50 <glguy> mappend (MA x) (MA y) = MA (liftA2 mappend x y)
22:51 <Gurkenglas> It's App! https://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicative.html#t:App
22:52 <Gurkenglas> (dammit kmett)
22:52 <glguy> :t \f -> foldr (liftA2 mappend . f) (pure mempty)
22:52 splanch joined
22:52 <lambdabot> (Monoid c, Applicative f, Foldable t) => (a -> f c) -> t a -> f c
22:53 <Gurkenglas> (I mean the undeprecated Ap https://hackage.haskell.org/package/reducers-3.12.1/docs/Data-Semigroup-Applicative.html#v:Ap )
22:53 <glguy> :t foldMapBy (liftA2 mappend) (pure mempty)
22:53 <lambdabot> (Monoid c, Applicative f, Foldable t) => (a -> f c) -> t a -> f c
22:54 dan_f joined
22:55 <Gurkenglas> Ooh nice that one's going into the arsenal
22:55 zcourts_ joined
22:55 carlosda1 joined
22:55 <qmm> shapr: that is kind of the essence of the question. another way of putting it: what am i giving up by using parser combinators in a language where laziness isn't optional
22:58 <TreyHarris> That feeling when... out of a general sense of goodwill, you write a patch to do a bunch of messy doc fixes in a package whose documentation is for an older version, create the pull request... and _then_ notice that other people had PRs to do the same months ago and were ignored
23:00 <* TreyHarris> feels very virtuous --> feels like a chump
23:00 <kadoban> TreyHarris: :(
23:02 oisdk joined
23:02 <* JuanDaugherty> would not show a general sense of goodwill on the open savannah
23:03 snowalpaca joined
23:03 <newsham> ?src ixmap
23:03 <lambdabot> Source not found. There are some things that I just don't know.
23:05 Ranhir joined
23:06 lambda-11235 joined
23:08 nick123 joined
23:10 bhiliyam joined
23:11 <Gurkenglas> TreyHarris, that's when you ask hackage to make you the maintainer
23:12 markus1209 joined
23:12 markus1219 joined
23:12 <TreyHarris> Gurkenglas: except the reason I wrote the fixes was because I figured it out struggling with trying to use it, I barely understand the code as written ;-)
23:13 crayhart joined
23:14 <Gurkenglas> That's when, hm. You ask reverse dependencies if they'd like to ask to be made maintainer? Which package is this?
23:14 <TreyHarris> heh. numerals
23:15 theDon_ joined
23:15 <Gurkenglas> Right, coulda just looked on your github
23:16 fakenerd_ joined
23:18 <Gurkenglas> roelvandijk appears very active. Maybe he just doesn't notice those notifications?
23:19 <TreyHarris> Gurkenglas: yeah, I looked at his overall activity before starting the patch and saw the same. I _thought_ I'd checked for redundant PR's but must've flaked
23:20 cables- joined
23:20 indi_ joined
23:20 eacameron joined
23:21 eacameron joined
23:22 <TreyHarris> mine's more complete, though, so maybe he didn't accept the others because they weren't, but he'll see the notification and use mine... think happy thoughts :-)
23:26 lambda-11235 joined
23:26 shutdown_-h_now joined
23:29 Noone joined
23:35 fizbin joined
23:35 johnw_ joined
23:37 eazar001 joined
23:41 meck joined
23:41 hamishmack joined
23:42 nomicflux joined
23:42 wroathe joined
23:42 Arguggi joined
23:43 kriztw joined
23:43 reynir joined
23:43 flohsor joined
23:44 JDevlieghere joined
23:45 liste joined
23:45 vektorweg1 joined
23:46 myfreeweb joined
23:46 tgeeky joined
23:46 Geekingfrog joined
23:47 solarus joined
23:47 Robin_Jadoul joined
23:47 Welkin joined
23:48 oleks joined
23:48 xiinotulp joined
23:49 nakal joined
23:50 acro joined
23:51 reynir joined
23:52 Eduard_Munteanu joined
23:52 dzdcnfzd joined
23:54 JDevlieghere joined
23:54 <dzdcnfzd> I'm making a toy blog using servant. I want it to do exactly two things: show and upload posts. The posts don't need to be stored anywhere other than memory for now. I'm wondering if I'll have to store the posts in some sort of IO reference, or if it's possible to store them in a pure value
23:54 YongJoon joined
23:54 theseb left
23:54 oleks joined
23:55 <dzdcnfzd> If this were an Elm app, it'd be based on a fold where every POST to the server updated the state of the app
23:55 DrMentats joined
23:56 <Welkin> dzdcnfzd: just use sqlite then
23:56 <Welkin> it's easier than trying to store them in memory
23:56 <Welkin> and you don't need to install a database
23:56 soLucien joined
23:57 <dzdcnfzd> Welkin: If I use a DB, I know how to do it
23:57 <Welkin> I suggest using Persistent as your ORM
23:57 <dzdcnfzd> I'm asking more of a conceptual question
23:57 <Welkin> yes, you *can* do this
23:57 <Welkin> but why?
23:57 <Welkin> just use sqlite
23:58 <dzdcnfzd> Because I'm just getting into Servant and so these sorts of questions are how you learn :)
23:58 <Welkin> your question has nothing to do with servant