<    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 <tobiasBora> geekosaur: I also found text-icu, is it supposed to be more efficient?
00:00 <fDev2179> I'm still a Haskell newbie so I'm trying to figure out where I can do better.
00:00 <geekosaur> most system regex libraries *specifically* mishandle character ranges like that, because they expand it to an array and index it with the single-byte character they think you gave it
00:00 <robertkennedy> Does `getBool >>= \b -> return $ if b then 2 else 0` desugar to use fmap?
00:00 <geekosaur> which fails completely with utf8
00:00 bydo joined
00:00 <mniip> fDev2179, getCoordinate could be a record accessor
00:00 atk joined
00:00 <dmwit> fDev2179: Why does `extrudeGrid` need a special case for `[Point []]`? What goes wrong if you leave it out?
00:01 <geekosaur> tobiasBora, it should be
00:01 <fDev2179> Not familiar with Record accessors, that I know of.
00:01 <fDev2179> dmwit, let me look.
00:01 <mniip> brb
00:02 <tobiasBora> geekosaur: I'm not sure to understand what does "ICU library, which is not included". Does it means that the library must be installed from apt-get for example at compile time?
00:02 <dmwit> :t zipWithM
00:02 <lambdabot> Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
00:02 <tobiasBora> *what does ... means
00:03 <sophiag> i'm still confused as to how a data constructor with only one type variable is a binary function...
00:03 <geekosaur> tobiasBora, yes
00:03 <tobiasBora> ok thank you
00:03 <fDev2179> dmwit, you are correct that the special case of extrudeGrid [Point []] isn't needed.
00:03 <fDev2179> Didn't realize that.
00:04 <dmwit> > mapM (\(lo, hi, n) -> [lo + (fromIntegral v/fromIntegral n) * hi | v <- [0..n]]) (zip3 [0,0,0,0] [1,1,1,1] [5,3,2,2])
00:04 <lambdabot> [[0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.5],[0.0,0.0,0.0,1.0],[0.0,0.0,0.5,0.0],[0....
00:05 <fDev2179> Wow.
00:05 <Koterpillar> tobiasBora: it's a C library
00:05 <mniip> sophiag, (,) is a binary function
00:05 <mniip> hmm bad example
00:05 <mniip> data P a = Pair a a
00:05 <mniip> one type variable, Pair is a binary function
00:06 <tobiasBora> Koterpillar: So if I don't manually link the library to the binary, I will need to install it on the user computer as well right?
00:06 <sophiag> ok i see
00:06 WhiskyRyan joined
00:06 <Koterpillar> tobiasBora: s/manually/statically/, then it's correct
00:06 <tobiasBora> Koterpillar: ok thank you!
00:07 <fDev2179> Problem is, I need to write this code in matlab, but I can usually think about recursion more clearly in haskell.
00:07 <dmwit> Implement mapM in matlab. ;-)
00:07 <dmwit> I am kidding. Don't do that.
00:07 <fDev2179> Hahahaha
00:08 <fDev2179> I wish I didn't have to use matlab, but I don't have a choice. I need to try to digest what you wrote.
00:08 <fDev2179> Not too familiar with mapM
00:08 <dmwit> So the lambda is just your `myLinspace`,.
00:08 <sophiag> mniipp: and is the reason you're saying the functions i'm calling them on are unary is because they're wrapped in Maybes? i don't think so because i tested that, but trying to understand since their return types are binary
00:09 mizu_no_oto joined
00:09 <mniip> nah
00:09 <fDev2179> Okay, I can see that.
00:09 <mniip> sophiag, you have a constructor of type 'a -> a -> OpT a'
00:09 <mniip> and you're applying it to a function 'b -> b -> b'
00:09 <dmwit> So forgetting `mapM` for a moment, and thinking of `map` instead, the `map myLinspace (zip3 ...)` constructs a list whose elements are the ranges of each coordinate.
00:09 <fDev2179> you used zip3, but that only works for 3 dimensions, right, dmwit?
00:09 <mniip> perhaps you meant the constructor to be '(a -> a -> a) -> OpT ?'
00:10 <dmwit> fDev2179: No, it works for any number of dimensions but only for three *arguments*. But the three arguments are not the dimensions; the lists are the dimensions.
00:10 <sophiag> mniip: probably the return types of the function to be something like that rather
00:10 <sophiag> lemme give it a try
00:10 np356 joined
00:10 <dmwit> fDev2179: The first argument is the low value for each dimension. The second argument is the high argument for each dimension. The third argument is the number of points in each dimension.
00:11 <fDev2179> Ohhhh, I see.
00:11 <mniip> sophiag, you have to think about what you want to represent
00:11 <mniip> hence my question
00:11 <fDev2179> Very neat!
00:11 <mniip> will the return type of the function be useful?
00:11 <fDev2179> That's kind of hilarious that you just converted my ~50 lines of code into one line.
00:11 <mniip> fDev2179, welcome to haskell
00:12 <dmwit> fDev2179: Then once you have all the possible choices for each dimension (given by `map (...) (zip3 ...)`), you can take all possible ways of choosing one value for each dimension with `sequence`.
00:12 <dmwit> > sequence ["123", "abc", "xyz"]
00:12 <sophiag> mniip: i have. as mentioned initially, i'd like it to be the same as that data type i posted except it makes more sense for it to be a GADT and i don't fully grok how they work yet
00:12 <fDev2179> Haha, thanks, mniip.
00:12 <lambdabot> ["1ax","1ay","1az","1bx","1by","1bz","1cx","1cy","1cz","2ax","2ay","2az","2b...
00:12 <dmwit> fDev2179: (and `mapM` is just a combination of `sequence` and `map`)
00:12 <fDev2179> Oh, okay, that helps.
00:13 <mniip> sophiag, yeah no, I mean, you can put whatever you want into the type of the constructor. The question is will it be useful
00:13 <fDev2179> I'm taking notes.
00:13 <mniip> sophiag, consider an example gadt:
00:13 <dmwit> Actually, it's probably cleaner to use `sequence` and `zipWith3`.
00:14 <sophiag> mniip: i'm saying it worked fine when i used that data type i showed you, but i'd rather use a GADT to do the same thing. it seems cleaner seeing as i need the same language pragma, but primarily i'd like to be able to define some of the arguments recursively
00:14 <mniip> data Expr a where TrueExpr :: Expr Bool; IntExpr :: Int -> Expr Int; IfThenElseExpr :: Expr Bool -> Expr a -> Expr a -> Expr a
00:14 <mniip> here, clearly, Expr a is an expression that evaluates to a "thing" of type 'a'
00:14 <fDev2179> Beautiful. That's why I started learning Haskell. Thanks for the feedback, dmwit!
00:15 <sophiag> mniip: can you give an example of calling one of those constructors using the return value of another function?
00:15 <mniip> IntExpr (3 + 3)
00:15 <mniip> map IntExpr [1..5]
00:15 <mniip> idunno
00:16 fDev2179 left
00:16 <mniip> sophiag, are you trying to represent functions?
00:16 <mniip> you might have more luck with OpT a b
00:16 <mniip> representing a thing that takes a as input and produces b
00:17 zcourts joined
00:17 <sophiag> what i've been asking the entire time is this: if you call "IntExpr func" then what's a suitable type signature for func?
00:17 <sophiag> to put it in concrete terms
00:18 <mniip> func :: Int
00:18 <sophiag> ah ok
00:19 <mniip> @let data Whatever a b c where Constructor :: Int -> (beep, boop) -> Maybe (p -> q) -> Whatever (Whatever a) p (,)
00:19 <lambdabot> Defined.
00:19 <mniip> :t Constructor
00:19 <lambdabot> Int -> (beep, boop) -> Maybe (p -> q) -> Whatever (Whatever a) p (,)
00:19 <mniip> ^whatever you type as the type of the constructor *becomes* the type of the constructor
00:22 <mniip> question: Is there an existing notation for logarithms in type algebra?
00:24 splanch joined
00:25 <mniip> Log a a = 1; Log a (x * y) = Log a x + Log a y; Log a (x -> y) = x * Log a y
00:25 <mrjake> Has anyone used the Matplotlib library? http://lpaste.net/6001640235455217664 http://lpaste.net/4341213425079156736 It basically works as an executable, but I'm having problems trying to generate plots interactively.
00:26 np356 joined
00:26 hydroacoustic joined
00:26 <mniip> pretty similar to the type derivative
00:27 <mniip> defined by something like
00:28 fizbin joined
00:28 <mniip> b = Log a b -> a
00:31 oisdk joined
00:34 jgt joined
00:36 e14 joined
00:37 takle joined
00:37 <sophiag> mniip: i'm testing it without the Maybes for simplicity's sake and still don't have things quite right: http://lpaste.net/354215
00:38 <mniip> you need to drop <$> as well
00:38 <mniip> and <|> makes no sense in absence of Maybe
00:39 <sophiag> ah true
00:39 cmsmcq_ joined
00:39 <mniip> and on top of that
00:39 <mniip> your type is
00:39 <mniip> parseOp :: Exp -> OpT a
00:39 <mniip> can't worl
00:40 <sophiag> why is that?
00:40 <mniip> that type implies that the caller decides what 'a' is
00:40 <mniip> but clearly the function parseOp has to decide, based on the contents of Exp
00:41 <sophiag> so.. parseOp :: Exp -> a -> OpT a ?
00:41 <mniip> generally with GADTs you want to avoid a conflating function like this
00:41 nomicflux joined
00:41 <mniip> no, there's no way it will ever work
00:42 mekeor joined
00:42 <sophiag> so i just can't have a function like this?
00:42 <mniip> ask yourself why do you need one
00:42 <sophiag> because i'm parsing an expression that can be any of those three types
00:43 <mniip> but you use GADTs to explicitly differentiate between the three types
00:43 <sophiag> if i didn't need a generalized type i would have just defined them separately
00:44 <mniip> that much is good, but
00:44 plutoniix joined
00:44 <mmaruseacph2> HCAR Call for Contributions has been sent https://mail.haskell.org/pipermail/haskell-cafe/2017-April/126678.html
00:45 hydroacoustic joined
00:45 <mniip> sophiag, you've defined your types to explicitly avoid conflating OpT Int and OpT Bool
00:46 plutoniix joined
00:46 <mniip> you can't define a function that returns either
00:47 <sophiag> ultimately i need the OpT type
00:47 <mniip> are you sure you have to parse a thing that has to be either of the tree types in the same place?
00:47 takle joined
00:47 <sophiag> yes
00:47 <Koterpillar> well, you can have a cast :: OpT x -> Maybe (OpT y)
00:47 <mniip> if you insist, parseOp :: Exp -> (forall a. OpT a -> r) -> r
00:47 <Cale> Actually, it might make sense to wrap the GADT in an existential... but I kind of feel as if this type hackery might be going way overboard
00:47 plutoniix joined
00:47 <mniip> yeah
00:47 <sophiag> no. no more existentials :(
00:47 <mniip> time to rethink your types
00:47 <Cale> right, exactly
00:48 <mniip> or maybe your call stack?
00:48 <Cale> heh
00:48 <Cale> Yeah, these things aren't quite separate
00:48 <mniip> sophiag, XY?
00:48 <sophiag> Cale: you're the one who told me to do it this way! you even wrote a paste like this...
00:48 <Cale> Yeah, but I was focused on a smaller part of your program
00:48 splanch joined
00:48 <mniip> what are you trying to do on a larger scale
00:48 oisdk joined
00:48 <Cale> I hadn't seen some of this parse-related stuff
00:49 conal joined
00:49 <tobiasBora> Grr I'm getting crazy... I tried to extract email with this regexp: let reg = ICU.regex [] $ T.pack "^(.*[^a-zA-Z0-9]|)([a-zA-Z0-9][-a-zA-Z0-9.]*@[-.a-zA-Z0-9]*\\.[-a-zA-Z0-9.]*[a-zA-Z]).*$"
00:49 <Cale> Yeah, taking a step back is probably warranted
00:49 <thimoteus> oh my
00:49 <Koterpillar> how will you use the result of parseOp?
00:49 <tobiasBora> However, when I run (ICU.findAll reg $ T.pack "I'm myname-real@gmail.com")
00:49 <mniip> tobiasBora, email? regex? just give up
00:49 <thimoteus> i agree with mniip
00:50 <tobiasBora> Then I have "real@gmail.com", but not "myname-real@gmail.com", even find findAll
00:50 splanch_ joined
00:50 <tobiasBora> mniip: Really? Why? I tried to use parser but I was getting very ugly solutions
00:51 <mniip> and regex is somehow cleaner?
00:51 <mniip> also
00:51 <tobiasBora> mniip: Well I hoped that regex would be faster
00:51 <mniip> email addresses are known to be hard to parse properly
00:51 <mniip> faster?
00:51 <mniip> faster to write?
00:51 <tobiasBora> mniip: No, to execute
00:51 <mniip> eeeeenope
00:52 np356 joined
00:52 <tobiasBora> (I made benchmark, and indeed in my test they were twice faster, and my parser was not even recognising the good email form)
00:52 <exio4> a regex is a fancy way to say a finite state machine
00:52 <exio4> so I am guessing it could be quite fast
00:53 <mniip> well, yes, with knowledge of regularity,
00:53 <mniip> a compiled regex can be crazy fast
00:53 <exio4> if you can make the transition function extremely fast, I guess it gotta be faster than most solutions
00:53 <sophiag> mniip, Koterpillar, Cale: what i need to do is store a record of lambdas with one bound variable, which can be each of these three types, and then everything else can be compound forms of all those operators listed and values of the same type as the bound variable.
00:53 <mniip> probably reaching cpu cycle per character speeds
00:54 <tobiasBora> mniip: For example, how would you say with a parser "I want to have the biggest sequence of letter, numbers, dot, and '-', but finish with a letter.
00:54 <lyxia> tobiasBora: you can just drop the first group BTW
00:55 takle joined
00:55 Lyraz joined
00:55 <lyxia> with the ^
00:55 <tobiasBora> lyxia: oh yes of course, you are true
00:55 <tobiasBora> Why did I do that...
00:55 <sophiag> here are example inputs i'd parse and then the output all at once:
00:55 <tobiasBora> Don't know
00:55 <tobiasBora> Well it works indeed
00:56 Fairy joined
00:56 <lyxia> the problem was that the first group didn't exclude -
00:57 <mniip> depending on the combinator library, something along the lines of 'lazyMany anyChar *> (satisfies isAlpha <**> (:) <$> (many (satisfies isAlnum <|> anyOf ".-")))'
00:57 <lyxia> that regex is also pretty restrictive
00:57 <tobiasBora> lyxia: Well if I didn't exclude - I wouldn't be able to parse: "I'm -myname-real@gmail.com"
00:57 Stanley00 joined
00:57 <tobiasBora> (sometimes people do not put space before email...)
00:58 <tobiasBora> lyxia: Yes, I restrict it for the IRC example, but in right, here is what I'm using:
00:58 <tobiasBora> [a-zA-Z0-9][a-zA-Z0-9!.#%&é*+-/=?^_`{|}~]*@[-.a-zA-Z0-9]*\\.[-a-zA-Z0-9.]*[a-zA-Z]
00:59 <mniip> that random é
00:59 benl23 joined
00:59 <lyxia> hahaha
00:59 <pacak> tobiasBora: You don't really want to extract emails with regexp.
01:00 <sophiag> input : "require (\\x -> x + 1)" "require foo (\\y -> y == \"asdf\")" "require bar (\\z -> z >= (1 /3))" output: [[reqTag : Nothing, constraint : \x-> x + 1], [reqTag: Just "foo", constraint : \x -> x == "asdf"], [reqTag : Just "bar", constraint : \x -> x >= (1 / 3)]]
01:00 <tobiasBora> mniip: lazyMany? I didn't know that, I was always dealing with "try many"...
01:00 <pacak> tobiasBora: http://stackoverflow.com/questions/20771794/mailrfc822address-regex
01:01 <nshepperd> tobiasBora: if you're looking to extract email addresses from a document, you could use word boundary marks \b, instead of having the first group there
01:01 vaibhavsagar joined
01:01 <tobiasBora> nshepperd: If I remove this group, doesn't it solve the problem?
01:02 <nshepperd> probably
01:04 splanch joined
01:04 <nshepperd> pacak: there's nothing wrong with finding email addresses using a regex
01:04 <mniip> tobiasBora, that's a made up name
01:04 <mniip> it is implemented differently in different combinator packages
01:04 <pacak> nshepperd: In theory.
01:04 joe9 joined
01:04 <nshepperd> pacak: you're talking about validation
01:05 peterbecich joined
01:06 takle joined
01:06 <nshepperd> it's fine to find X email addresses, and 1 string that's not an email but looks like one, if you validate it later, by one method or another
01:06 <tobiasBora> mniip: Let's say we are using parsec, how would you code "lazyMany efficiently ?"
01:06 <pacak> nshepperd: It will either find a bunch of stuff that not exactly email or will miss some of them. I did some experiments when I was working on spam filtration.
01:06 Supersonic112_ joined
01:07 <mniip> I wouldn't use parsec :)
01:08 <mniip> finding the longest substring is a backtracking operation
01:08 <mniip> and parsec is about all but that
01:09 JoshS joined
01:09 np356 joined
01:09 <mniip> if you don't care about performance then a bunch of try is fine
01:09 <nshepperd> common GUI applications find emails and URLs in text using regexes, because the cost of making a string clickable is not very high if it's not actually an email or URL (the user just won't click)
01:11 <mniip> sophiag, hmm
01:11 <mniip> how are those different
01:11 <mniip> why do you even need OpT to have a type parameter
01:12 <mniip> if you don't differentiate between them in a visible way
01:12 splanch joined
01:12 msko joined
01:14 ali_bush joined
01:14 ali_bush joined
01:14 <sophiag> because i'd like to be able to parse compound expressions
01:15 monochrom joined
01:15 <sophiag> i also have a type that represents all the possible types i could use. so i realized that should be in the signature of parseOp instead of a variable
01:16 peterbecich joined
01:18 hybrid joined
01:19 xyther joined
01:19 raycoll joined
01:21 <tobiasBora> mniip: The thing is that I care about performance... That's why I'm using regexp for now. Do you have a better parser than parsec?
01:21 takle joined
01:22 <sophiag> parsec3 is almost as fast as attoparsec. faster than that and you need to write your own
01:22 augur joined
01:22 ipso_wacko joined
01:23 <sophiag> although i suppose fundamentally working with bytestrings must be faster
01:23 <tobiasBora> And how would you define lazyMany in parsec3?
01:23 <ipso_wacko> Hey anyone in here who I can talk to about /r/place
01:24 <sophiag> tobiasBora: i think if you look at the docs it says something about lazy parsers
01:25 darjeeling_ joined
01:25 <tobiasBora> sophiag: Well maybe lazy is not the good term then, is lazy means "you can deal with lazy string" or means "you can do backtrack like operations". Because it's the second one I need...
01:26 <mniip> ipso_wacko, #haskell-blah
01:26 <sophiag> yeah, actually i'm not sure what i just said is even true
01:26 <sophiag> i took a glance at the docs
01:26 <ipso_wacko> I can't join because I'm on unsecure network or something..
01:26 <ipso_wacko> (using firefox plugin)
01:26 <mniip> ahwell
01:26 j2j joined
01:27 ali_bush joined
01:27 ali_bush joined
01:27 <mniip> shame
01:27 <c0dehero> wat?
01:27 <ipso_wacko> Well I'm the pencil you fighting and I'm looking for truce
01:27 <c0dehero> are there security restrictions for channels?
01:28 <mniip> c0dehero, +S ssl only
01:28 <ipso_wacko> I can talk here but it said SSL only for channel
01:28 <mniip> ipso_wacko, /sslserver irc.freenode.net 6697
01:29 <c0dehero> oh, so you're that guy :D
01:29 <c0dehero> i thought it was fine the way it is?
01:29 <c0dehero> mniip: huh. i did not know that
01:29 <ipso_wacko> Not sure what to do w. that command, sorry. Well I tried xD thanks
01:29 rootnode joined
01:30 <mniip> ipso_wacko, we're not very picky about the border but does the pencil need to be as long
01:30 <c0dehero> okay well. what do you propose?
01:30 <ipso_wacko> Honestly we started it and ran into your border on accident
01:30 <ipso_wacko> I'd just like to see it stay?
01:31 ipso_wacko__ joined
01:31 <c0dehero> i don't mind it the way it is
01:31 <c0dehero> but others might still try to cover the pencil
01:32 <mniip> me neither really
01:32 <ipso_wacko__> Ok well we'll just keep cleaning up then.
01:32 <ipso_wacko__> Mexico tryna eat us anyway
01:33 <c0dehero> really i'm more worried about face guy
01:33 <mniip> which
01:33 <ipso_wacko__> I figured it was yours cus the color
01:33 <mniip> the purple thing with orange eyes thing?
01:34 <mniip> not afaik
01:34 metalbot joined
01:34 <c0dehero> nah. that thing isn't ours
01:35 <c0dehero> it's trying to eat us as well
01:35 animated joined
01:36 <c0dehero> anyways. nice to see that it brought someone here, lol
01:37 ipso_wacko_ joined
01:37 <ipso_wacko_> Might look ok if they invade border but not actual sign, cus you're going purple as far as I can tell
01:37 <c0dehero> you want your free explanation of monads?
01:37 <ipso_wacko_> Might look ok if they invade border but not actual sign, cus you're going purple as far as I can tell
01:37 <c0dehero> i guess
01:37 <mniip> do you want your explanation of free monads?
01:38 takle joined
01:38 <mniip> do you want your free monad of explanations?
01:38 <ipso_wacko_> If I get downtime on ours I'll help you out cus I feel indebted by taking border
01:38 <ipso_wacko_> also no idea if you're talking to me but I have no idea what you're talking about and so I assumed you're not
01:39 <mniip> ipso_wacko_, c0dehero is just trying to convert you to--
01:39 <c0dehero> thanks. i'll help repair the pencil then if i see something
01:39 <mniip> ipso_wacko, c0dehero is just trying to convert you to church Churh
01:39 <ipso_wacko> Church Haskell?
01:39 <ipso_wacko> I'd never heard of you before now x)
01:39 <c0dehero> mniip: hush!
01:40 yezariaely joined
01:40 <ipso_wacko> My coding skills go as far as making sweet myspace layouts and I've never programmed anything so, might be a bit lost on me x)
01:41 <c0dehero> well, are you interested in programming?
01:41 <c0dehero> ah, okay
01:41 <mniip> ipso_wacko, that was a failed attempt at a joke. Alonzo Church is a mathematician fairly relevant to haskell and functional programming in general
01:42 Philonous joined
01:42 <c0dehero> if you ever decide to give it a serious try, you should learn haskell at some point
01:42 <ipso_wacko> honestly no. I wish I could say yes and be welcomed into your lil community but.
01:42 <c0dehero> :D np
01:42 <mniip> doesn't matter
01:43 <mniip> we have documented cases of internet trolls ending up learning the language
01:43 mizu_no_oto joined
01:43 louispan joined
01:43 <tobiasBora> By the way, is it possible to compile a regex from regex-tdfa? I cannot find a way to do that...
01:43 <ipso_wacko> I know I'm like well, *thinking* maybe I could learn this thing
01:43 <c0dehero> mniip: lol rly? :D
01:44 <tobiasBora> Oh wait, I may found it
01:44 <mniip> https://gist.github.com/quchen/5280339
01:45 mpiechotka joined
01:45 <mpiechotka> @pl a %+ f b
01:45 <lambdabot> a %+ f b
01:45 <mpiechotka> @pl \a b -> a %+ f b
01:45 <lambdabot> (. f) . (%+)
01:45 <monochrom> And where is xQuaser now?
01:46 <monochrom> Therefore, I conclude that this documents failing to get a troll to learn Haskell.
01:46 gugah joined
01:47 vaibhavsagar joined
01:47 <mniip> monochrom, ahem
01:47 <jayshua> I'm scrolling around on a /r/place on a tiny cell phone screen trying to find this pencil dispute. Could someone maybe give me a general location for it?
01:47 Rodya_ joined
01:47 splanch joined
01:47 <c0dehero> lol. that is amazing
01:48 <monochrom> Why is everyone coming to #haskell to talk about /r/place?
01:48 <mniip> [08:30:16] <xQuasar> oherrala: i will buy that book now
01:48 <mniip> [08:31:00] <xQuasar> oherrala: i will practice for a year and come back. thank you. bye.
01:48 <c0dehero> jayshua: https://www.reddit.com/r/place#x=281&y=561
01:48 <c0dehero> monochrom: because we're doing advertisement
01:48 splanch_ joined
01:48 <mniip> that book = LYAH looks like
01:49 <c0dehero> it's not like haskell is good at marketing. someone's gotta do it
01:49 <jayshua> Ah thanks c0dehero
01:49 <mniip> monochrom, therefore I conclude you're jumping to conclusions
01:49 <monochrom> OK, then why do they come to ask about pencils as opposed to Haskell?
01:49 <c0dehero> you're welcome :D
01:49 <c0dehero> well...
01:49 splanch__ joined
01:49 <monochrom> mniip, where is xQuaser now?
01:50 YongJoon joined
01:50 <mniip> because "the haskell dispute" is ambiguous
01:50 <c0dehero> :o
01:50 <c0dehero> i can see the bold text o_o
01:50 <mniip> monochrom, that I can't tell
01:51 <mniip> last seen 4w ago
01:51 takle joined
01:51 <c0dehero> he probably wrote a haskell bot to automate trolling
01:52 jmcarthur joined
01:53 <c0dehero> give a man an irc client and he'll troll for a day. teach him to code and he'll troll for a lifetime
01:53 ipso_wacko_ joined
01:53 <ipso_wacko_> I just spent like 10 min on the Haskell homepage playing the interactive tutorial
01:53 <ipso_wacko_> I have no idea what any of this means
01:53 <c0dehero> :D
01:54 <ipso_wacko_> I'm now on wiki reading about what a ''functional programming'' is x)
01:54 <mniip> welcome to the club
01:54 <ipso_wacko_> MEANWHILE MY PENCIL!!
01:54 geekosaur joined
01:54 <mniip> anyway!
01:54 msko joined
01:55 <tobiasBora> I can't understand how to build the CompOption from this page: https://hackage.haskell.org/package/regex-tdfa-text-1.0.0.3/docs/Text-Regex-TDFA-Text.html#t:CompOption
01:55 coltfred joined
01:55 <mniip> it would seem as if all vector spaces are exponential objects over their scalar field
01:55 <mniip> at least, I can't find any that aren't, is that so?
01:56 <tobiasBora> Ah, maybe from https://hackage.haskell.org/package/regex-tdfa-1.2.2/docs/Text-Regex-TDFA-Common.html#t:CompOption
01:56 <mniip> do K-modules also have this property?
01:56 <mniip> I assume not
01:56 ipso_wacko__ joined
01:59 a3Dman joined
01:59 JoshS joined
02:00 Guest22107 joined
02:00 hucksy joined
02:00 conal joined
02:04 takle joined
02:07 jayshua joined
02:08 Allonphone joined
02:11 ljc joined
02:12 louispan joined
02:12 {emptyset} joined
02:14 takle joined
02:16 BlueShark|cloud joined
02:16 exferenceBot joined
02:17 np356 joined
02:18 takle_ joined
02:20 gugah joined
02:21 hexagoxel joined
02:23 <msko>
02:24 splanch joined
02:24 <mniip> but if linear spaces are X -> K
02:24 <mniip> then bases are just X -> X -> K
02:25 <mniip> forall X
02:25 <sophiag> mniip: i'm still struggling with this GADT :/
02:25 <sophiag> would it help to see the full code?
02:25 <mniip> is there a natural isomorphism between Set x Field and Vect?
02:25 <mniip> sophiag, probably
02:28 takle joined
02:28 <sophiag> mniip: here you go: http://lpaste.net/354215. hopefully better than my verbal explanation :p
02:28 Guest5972 joined
02:29 <mniip> uhhuh
02:29 <sophiag> you see i do have that type RhsT that groups together everything that could be in the type variable for OpT
02:29 <mniip> a better explanation would be one including what you're trying to do on large scale
02:29 <sophiag> mniip: i did include that
02:30 <mniip> I only see code
02:30 <sophiag> also i'll be totally honest, this is the first time i'm talking to you...but two other people asked me the same thing when i told them it yesterday
02:30 <mniip> and some errors
02:30 <sophiag> i'm saying i said that right when you asked me earlier
02:30 <sophiag> and gave examples of input and output
02:30 <mniip> because as we already established you need to take a step back
02:30 <mniip> well you need an even further step back
02:30 <mniip> after you've parsed the stuff what are you going to do with it
02:31 rbraun joined
02:31 <sophiag> i'm going to match up the two lists of records and filter the lists in Amb with lambdas in Require when their strings match. if there are no strings then they apply to all the lists
02:32 rbraun left
02:32 <sophiag> and call permutations on them
02:33 <sophiag> i have the behavior very well defined because i've already written it in Scheme, plus hardcoded examples into the list monad
02:33 <sophiag> it's parsing lambdas that's giving me trouble and i figured at the end of yesterday i was almost there
02:33 <mniip> filter sounds like you want all results to be boolean
02:33 <sophiag> what do you mean by results?
02:33 <mniip> well
02:34 <mniip> end result lambdas
02:34 <mniip> or something
02:34 <sophiag> yes, and you can see that's the case in my code
02:34 <sophiag> all lambdas have type (RhsT -> Bool)
02:34 <mniip> then why do you say you need a generic parse?
02:34 <robertkennedy> It looks like you're putting parseNumOp as the first arg of NumOp. Maybe needs an fmap?
02:34 splanch joined
02:35 <sophiag> mniip: i don't understand what you mean by "generic parse"
02:35 <sophiag> robertkennedy: can you expand on that?
02:35 <mniip> sophiag, parseOp :: Op a
02:35 <mniip> forall a
02:35 <mniip> or exists a
02:35 <mniip> either way
02:35 jgt joined
02:35 <sophiag> well it needs to take an expression...
02:36 <mniip> sophiag, with that specification...
02:36 <mniip> I'm afraid GADT isn't the right choice for you
02:36 <sophiag> that's fine. how would you do this?
02:36 <mniip> a GADT could be the output of a typechecker
02:36 <mniip> but not the parser
02:36 <sophiag> i keep getting different advice and then people are like oops, sorry
02:37 conal joined
02:37 xiaohu joined
02:37 <mniip> do you care about type checking/inference/soundness in your DSL?
02:37 <sophiag> you woudln't use a parser? how else do you get strings from a command line into data structures?
02:37 <xiaohu> hello,everyone!
02:37 <mniip> nonono
02:37 <sophiag> mniip: no. obviously the way i defined it it can be abused
02:37 <mniip> that's not what I said
02:38 <mniip> I'm saying you can't directly feed a parser into a GADT
02:38 <robertkennedy> On 135 I would think you'd want something like `parseOp exp = (NumOp <$> parseNumOp exp) <|> (CharOp <|> parseCharOp exp)` etc
02:38 <sophiag> and i'm saying i only used a GADT because someone told me to yesterday and seemed very sure about it
02:38 <mniip> sophiag, then I'd use a regular datatype for an AST
02:38 <mniip> no GADTs involved
02:39 <mniip> then write something like
02:39 <robertkennedy> Sorry that second one should also be `CharOp <$> parseCharOp exp`
02:39 <sophiag> then how would you handle recursive cases? like (\x -> x == (1+2)) or something like that
02:39 <mniip> tryEval :: Value -> Either TypeError Value
02:39 <mniip> it's called Abstract Syntax *Tree* for a reason
02:39 <mniip> are lambdas always unary
02:40 <sophiag> robertkennedy: it appears you're not reading the function that's throwing errors...
02:40 <mniip> and/or can you use lambdas in lambdas
02:40 <sophiag> always unary, no lambdas in lambdas
02:41 kadoban joined
02:41 <robertkennedy> I think the first 10 errors are all about lines 135-138?
02:42 <sophiag> robertkennedy: yes, but i have no idea what you're suggesting. you're using new data constructors without defining them, for example
02:42 <mniip> data Value = IntValue Int | BoolValue Bool
02:42 <mniip> data Expr = ArgumentExpr | ContExpr Value | Operator (Value -> Value -> Maybe Value)
02:42 <jmcarthur> It's very reasonable to make a GADT from a parser, but somehow it's going to have to do typechecking at the same time, and that's just not very fun.
02:42 <mniip> eval :: Expr -> Maybe Value
02:43 louispan joined
02:43 <sophiag> mniip: this code you're throwing out is in place of what>
02:43 <sophiag> *?
02:43 <mniip> all your data structures
02:43 Kundry_Wag joined
02:43 <mniip> ditch OpT and RhsT
02:43 beerdrop joined
02:44 <sophiag> what about all the rest?
02:44 <mniip> o wait
02:44 <sophiag> what about parsing strings?
02:44 <mniip> Operator (Value -> Value -> Maybe Value) Expr Expr
02:44 <mniip> parsing strings stays mostly as is
02:44 <mniip> just produces new AST
02:45 takle joined
02:45 <sophiag> how can it stay as is if i delete the data type it uses?
02:45 <mniip> also if you didn't catch, I'm spewing out very general code
02:45 <mniip> having taken 2 steps back
02:45 <sophiag> i'm not catching *anything* that you're saying
02:45 <mniip> :v
02:46 <mniip> ok
02:46 <mniip> you asked what would I do
02:46 <mniip> and I started explaining what I would do in general if I was presented with this task
02:46 <robertkennedy> sophiag: you're right, I thought I was close enough to be helpful. `parseOp exp = unwrapJust ((NumOp <$> parseNumOp exp) <|> (EqOp <$> parseEqOp exp) ...)`
02:46 <sophiag> you responded that i should delete all my data types yet keep functions that use them...
02:46 <mniip> no
02:47 <mniip> I started with the AST datatype
02:47 <sophiag> robertkennedy: so...my code exactly as is?
02:47 <sophiag> Literal?
02:47 <robertkennedy> Are we looking at the same code?
02:48 <sophiag> i'm having trouble handling two conversations at once
02:48 <sophiag> also with suggestions and not knowing what they refer to
02:49 <mniip> sophiag, okay, forget about your existing code for a bit
02:49 <sophiag> okay
02:49 <mniip> think about a generic expression AST augmented with one feature
02:49 <mniip> a special token that stands for the lambda argument
02:49 <sophiag> ok
02:49 <mniip> that's what I called ArgumentExpr in my case
02:50 <mniip> since you don't care about types, you can evaluate that AST right away once you have the Argument
02:50 <sophiag> how do you construct actual lambdas from AST types, though? i tried that and it didn't work
02:50 <mniip> actual lambdas?
02:51 <sophiag> as in you can't just pass an AST to a function
02:51 <mniip> what distinguishes an actual lambda from a fake lambda?
02:51 naushadh joined
02:51 <mniip> what is a fake lambda
02:51 <sophiag> a lambda vs. the ast of a lambda
02:51 <mniip> that's where 'eval' steps in
02:51 <mniip> you write a function that can evaluate your AST
02:52 <sophiag> well first i obviously need a data structure that lets me store all parts of the asts in a list
02:52 <mniip> what why
02:52 <mniip> why a list
02:52 <sophiag> remember when i described what this code does?
02:53 <sophiag> that was what i said.
02:53 teggi joined
02:53 <sophiag> a few times i think
02:53 <sophiag> i mean, i'm open to other wways
02:53 <mniip> maybe I'm not understanding what you're trying to say
02:53 <mniip> it sounded like you want to represent a single lambda as a list
02:53 <sophiag> no...
02:54 ChaiTRex joined
02:54 <mniip> okay then what is the problem
02:54 Allonphone left
02:54 <mniip> your Require datatype seems to do just that
02:54 splanch joined
02:54 Jeanne-Kamikaze joined
02:54 <sophiag> i'm going to match up the two lists of records and filter the lists
02:54 <sophiag> in Amb with lambdas in Require when their strings match. if there
02:54 <sophiag> are no strings then they apply to all the lists. then call permutations on the lists
02:55 <mniip> what records
02:55 <sophiag> mniip: yes, Require does do that...that's why i wrote it :)
02:55 <mniip> and what is Amb
02:55 <sophiag> Amb is the list of lists
02:55 FjordPrefect joined
02:55 <sophiag> Require is the list of lambdas (plural)
02:56 <mniip> uhhhhh
02:56 <mniip> "the two lists of records" sound like very concrete lists of records but you never mentioned them before
02:56 <sophiag> those sentences above are copied and pasted from a half hour ago
02:56 <mniip> right
02:57 hybrid joined
02:57 teggi joined
02:57 <sophiag> i also said the same thing with a little less detail a few hours ago
02:57 <mniip> I had the same question pop up in my head half an hour ago
02:57 <mniip> but i decided to ignore it because we were focused on something having no relevance to it
02:57 <sophiag> not just in your head...you asked it. and i answered
02:58 <sophiag> and i did say this earlier as well. i'm trying to give as much detail as possible and willing to state it multiple times
02:58 <robertkennedy> Is your current goal to just get the code in http://lpaste.net/354215 to compile?
02:58 <mniip> sophiag, I don't think I've asked until now?
02:59 <sophiag> robertkennedy: basically yes
02:59 <sophiag> mniip: trust me, i don't write long descriptions of code irrelevant to the problem i'm trying to solve unless someone going out fo their way to help me asks
03:00 <mniip> sophiag, okay, I'm going to ask all things I haven't figured out yet
03:00 <sophiag> ok
03:00 sellout- joined
03:01 takle joined
03:01 <mniip> What are you doing on a large scale? What are these predicate lambdas being called with? What are records? What are the two lists? How are they related to the Amb datatype? What is the Amb datatype for? What do the "strings" mean? What are "all the lists"? What do you mean "permutations"?
03:03 <sophiag> there are two records: Amb and Require. Amb is for data and Require is for the lambdas. so far i'm just testing consing the lists with the two state monads of the same names. permutations means the function called permutations
03:03 <robertkennedy> In addition to fixing the error I mentioned before about your missing (<$>) in 135 etc, the type of `parseRequire` may be more prohibitive than you want? You could replace it with `Exp -> Require a` for free I think
03:04 <mniip> what are records
03:04 <sophiag> robertkennedy: i removed <$> because mniip suggested it
03:04 <mniip> [that's missing some context]
03:05 <dfeuer> edwardk: Plonk
03:05 <sophiag> robertkennedy: can you say the names of functions you're specifically referring to as well rather than alternative names? if it's not in my code then i don't know what you're talking about
03:05 <sophiag> mniip: they just use record syntax is all
03:05 <mniip> aha
03:05 <sophiag> that's sort of irrelevant. the point is those two are the highest level data types i use here. they actually store everything
03:06 crelix joined
03:06 <mniip> so Amb is irrelevant to the lambdas issue?
03:06 <sophiag> Amb works fine
03:06 <sophiag> so, yes
03:06 <mniip> we can focus on the lambdas
03:06 <sophiag> exactly
03:06 <mniip> in large you need to parse text into a predicate
03:06 <sophiag> yes, essentially
03:07 <mniip> ok, so far I've explained what would be a good AST to parse into
03:07 <mniip> and you wonder how to make a predicate out of an AST?
03:08 <sophiag> as mentioned, i tried working with raw ASTs but had no clue how to parse one into a lambda
03:08 <xiaohu> I am a newcomer of Haskell. When I install leksah,I meet a problem.I installed it step by step according to the guidance of github. But when I execute ./leksah ,there is an error with displaying " cabal : unrecognised command".
03:08 <robertkennedy> Man Im sorry, I meant `parseReq :: Exp -> Require (RhsT -> Bool)` could be `parseReq :: Exp -> Require a` as it currently is set up
03:08 <sophiag> err eval not parse
03:08 <mniip> sophiag, can you write a function 'eval :: Expr -> Value -> Maybe Value'
03:08 xall_ joined
03:09 justan0theruser joined
03:09 takle joined
03:09 splanch joined
03:09 <mniip> where as said above Expr is an AST and Value is a primitive datatype
03:09 <sophiag> mniip: yeah...basically *all* of the functions in this section are broken down pieces of trying to do that
03:10 <sophiag> right?
03:10 <mniip> no
03:10 <sophiag> yes, that's what i'm trying to do here
03:10 <mniip> I don't see a single piece of evaluation code
03:10 <sophiag> i don't actually evaluate them, but in parseReq i piece them together into lambdas
03:10 <mniip> yeah no
03:10 <mniip> that can't work
03:10 <mniip> wellllllll maybe
03:10 <sophiag> ok
03:11 <sophiag> ok
03:11 ChaiTRex joined
03:11 <xiaohu> When I install leksah,I meet a problem.I installed it step by step according to the guidance of github. But when I execute ./leksah ,there is an error with displaying " cabal : unrecognised command".
03:11 <sophiag> robertkennedy: i've already tried the two things you suggested quite a while ago and they don't fix these errors. have you test them and i'm missing something?
03:11 <jayshua> xiaohu: Did you follow the fistep that said to get ghc and cabal by going to haskell.org/downloads?
03:11 <mniip> okay
03:11 <mniip> it might somewhat work
03:12 <xiaohu> jayshua yes
03:12 <mniip> but your lambdas will still be littered with Value
03:12 <mniip> as you have no types
03:12 <jayshua> xiaohu: Do you know if cabal is in your path?
03:12 <sophiag> they're all of the same type
03:12 <sophiag> RhsT -> Boll
03:12 <mniip> Int vs Bool?
03:12 <sophiag> *Bool
03:12 <xiaohu> The Glorious Glasgow Haskell Compilation System, version 7.10.3
03:12 <mniip> Rhs is the argument of the lambda?
03:13 <sophiag> yes. and the part i'm not typechecking is that it matches the lists i'm filtering it with. that's where you can break the dsl, but i'm okay with that
03:13 <xiaohu> cabal-install version 1.22.6.0 using version 1.22.5.0 of the Cabal library
03:13 <xiaohu> jayshua right?
03:13 <mniip> sophiag, you need a different lambda type
03:14 <sophiag> mniip: i had one and deleted it on someone's advice yesterday
03:14 <mniip> you need a datatype that can hold all intermediate values that arise in the computation
03:14 <mniip> and then your lambdas will have type RhsT -> That
03:14 <jayshua> xiaohu: If you type "cabal" into your command prompt/terminal you should see something along the lines of "cabal: no command given"
03:14 <sophiag> well they do all return Bool
03:14 <mniip> no
03:14 nomicflux joined
03:14 <mniip> in the end they do
03:14 <xiaohu> cabal: no command given (try --help)
03:14 <xiaohu> yes
03:15 <mniip> but their intermediate parts do not neccesairly do that
03:15 <xiaohu> what should I do?
03:15 cpennington joined
03:15 <mniip> think about it structurally
03:15 <sophiag> ok, well between the types i have they do store all that...i just think i need to refactor OpT
03:15 <mniip> if you have xyz == abc
03:16 <xiaohu> I have add the ~/cabal/bin to the PATH
03:16 <mniip> to evaluate that, you evaluate xyz, then evaluate abc, then check if they are equal
03:16 <mniip> you do return Bool
03:16 <mniip> but xyz and abc not so much
03:16 <sophiag> but the lhs in this case is a bound variable
03:17 takle joined
03:17 <mniip> how do I explain
03:17 <sophiag> i think you're referring to the recursive cases on the rhs i was trying to solve with the GADT
03:18 <jayshua> xiaohu: Well, I've never used leksah I'm afraid. Maybe someone else on here can help more. The only thing that comes to mind is restarting to make sure the new path is picked up everywhere. On the other hand, it's possible to learn Haskell without leksah if that's what you're trying to do. Sorry I can't be of more help!
03:18 np356 joined
03:18 <mniip> I understand it intuitively in like 3 separate ways but I can't convey it with words
03:18 <sophiag> mniip: i think most helpful would be to start with the code i have and make concrete suggestions about the parts that aren't working
03:18 <sophiag> i.e. OpT
03:19 <mniip> your whole code is poorly structured
03:19 <mniip> because it can only handle simple expressions
03:19 <mniip> if your expression type was more flexible you could handle expressions in expressions much more easily
03:20 cjh` joined
03:20 <mniip> hence why I'm suggesting you expand the result type to include all intermediate types
03:20 <sophiag> it depends on what you mean by simple. in some ways i am restricting them, in some ways it may just be starting simple in ways that don't scale
03:20 <xiaohu> jayshua: Leksah requires ghc --version >=7.10.3 and cabal --version >=1.24. To get them go to haskell.og/download and choose the Minimal GHC or Haskell Platform.
03:20 <xiaohu> this is from github
03:20 sssilver joined
03:20 mattp_ joined
03:20 <mniip> because that way your complete lambda type is the same as your subexpression type
03:20 <sophiag> but regardless, you don't mean "my whole code" because we already went over the parts that do work
03:20 <xiaohu> cabal-install version 1.22.6.0 using version 1.22.5.0 of the Cabal library
03:21 <mniip> I'm only talking about lambdas now
03:21 <xiaohu> this is the version of cabal in my computer
03:21 <mniip> sophiag, are you familiar with the reader monad?
03:21 <sophiag> yes
03:21 <mniip> ok then
03:21 <mniip> imagine that your lambdas aren't functions
03:21 <sophiag> does that really makes sense here
03:21 <mniip> but rather actions in the reader monad
03:21 Camm1 joined
03:21 <sophiag> ok
03:22 <mniip> \x -> (x + 1) > 5
03:22 <xiaohu> Version is too low ????
03:22 <mniip> do x <- ask; return (x + 1) > 5
03:22 ian-mi joined
03:22 <mniip> now, that's not very structural
03:22 dan_f joined
03:22 <jayshua> xiaohu: Possible, but the problem sounds like Leksah can't find cabal for some reason.
03:22 <sophiag> why not just use \x -> x > 6 ?
03:22 <mniip> example reasons
03:23 <jayshua> xiaohu: Not that it found the wrong version.
03:23 <sophiag> but i'm saying that by restricting it to the cases i already explained i don't need all that generality
03:23 <pikajude> binaries created from haskell programs take about ten billion years to start on WSL
03:23 <pikajude> anyone know what that's about
03:23 <mniip> but then you will not be able to support two-level expressions without a complete overhaul
03:23 <mniip> is that what you want
03:23 <sophiag> i already stated i don't intend to
03:24 <robertkennedy> xiaohu: if you need leksah you may have to hack it up to date; the project is not maintained to my knowledge
03:24 <mniip> you will also write a ton of cases for 'x > 5' '5 > x' etc
03:24 <sophiag> well, only the former
03:24 <mniip> okay then
03:24 <mniip> if that is what you want
03:24 mizu_no_oto joined
03:24 <sophiag> and yes, i will. it's a dsl so that's easy
03:25 <MarcelineVQ> robertkennedy: the github source is active, hackage release is behind
03:26 <sophiag> mniip: i would consider refactoring for very general cases of lambdas if you could communicate how to do so, but it's been literally hours and hours so i'd prefer to just make the way i'm doing it work. right?
03:27 <hamishmack> xiaohu: To upgrade cabal-install run. cabal upate && cabal install cabal-install
03:27 <xiaohu> I do not know why my computer can not find cabal command
03:27 <Camm1> Hello everyone. I need your help to understand the value of a ReaderT Monad Transformer. The example that I've done simple shows that a ReaderT enables me to avoid sending configurations to a function through a parameter. However, I don't really understand the value of that. http://lpaste.net/354225
03:27 <mniip> sophiag, I was trying to explain how to make it structurally better
03:27 <mniip> sorry for wasting your time
03:27 <xiaohu> hamishmack: ok ,I try it now
03:28 <pikajude> ah indeed, it's a bug in WSL's handling of uncommitted pages
03:28 <mniip> sophiag, what you're trying to do is fairly simple
03:28 <pikajude> ignore me everyone
03:28 <Camm1> Could you help me please to understand how could I use ReaderT in other situations?
03:28 <Camm1> When is relevant to use ReaderT?
03:29 <sophiag> mniip: no i'm sure you're correct. i'm just making a distinction between "i'd always like to learn" and "what i actually need here"
03:29 felixsch__ joined
03:29 conal joined
03:29 <Axman6> passing configuration around is the most common use of ReaderT
03:29 <mniip> sophiag, so, you have a fixed set of shapes for your lambda, right?
03:29 <sophiag> yes, currently that's how i'm doing it
03:30 <jle`> Camm1: some people use ReaderT to solve "the configuration problem"
03:30 <Koterpillar> Camm1: a lot of Web frameworks use it for confligration
03:30 <jle`> Camm1: in your case it's a bit overkill
03:30 <Koterpillar> Camm1: so does XMonad, for example
03:30 Rainb joined
03:30 <mniip> then you want to implement that logic into a function of type Exp -> Maybe (RhsT -> Bool)
03:30 <jle`> Camm1: but imagine if you had hundreds of functions like myReader
03:30 <sophiag> as mentioned, if you could even hack together something short explaining a better way i'd definitely try it. but not sure that's going to happen
03:30 <jle`> er, hundreds of actions
03:31 <jle`> Camm1: imagine if they all call each other, from each other. passing parmaeters manually gets tedious, and you also might accidentally pass the wrong parameter
03:31 <sophiag> mniip: yes. i think it just comes down to that GADT. i professed my ignorance from the start
03:31 <mniip> no GADTs here
03:31 <sophiag> ok cool
03:31 <mniip> suppose you have two function shapes
03:32 <sophiag> i probably still need the pragma tho for constraints. something interesting i learned yesterday
03:32 <mniip> x <relation> <number>
03:32 <mniip> x <arith> <number> <relation> <number>
03:32 <sophiag> yes, that's curretnly sort of the form
03:33 <mniip> first you make an auxiliary function that turns "<relation>" into Ord a => Maybe (a -> a -> Bool)
03:33 <mniip> just its name
03:33 <mniip> then the same for the <arith>
03:33 takle joined
03:33 sdothum_ joined
03:33 <mniip> then you let parseOp pattern match the Exp constructors and depending on the shape query the two auxiliary functions
03:33 <mniip> and assemble a lambda out of the results
03:34 robotroll joined
03:34 <sophiag> yes
03:34 <sophiag> this is the same code i've had for days :p
03:34 <mniip> oh sorry
03:35 <mniip> parseLambda
03:35 <sophiag> been trying to debug the same errors and keep getting told one thing then another that turns out not to work :p
03:35 <mniip> parseOp would parse an operation
03:35 <mniip> not something you can do
03:35 <sophiag> well i combined it to just create the record directly
03:35 <sophiag> although frankly i'd rather have a lambda type since i need one version that tags it as well
03:35 <Camm1> jle`: For instance, somethig like this: http://lpaste.net/354226
03:36 ddere joined
03:36 <sophiag> i should probably abandon all suggestions from the person who gave me the one that didn't compile
03:36 <sophiag> i'm establishing a mental list of who not to listen to in this channel :p
03:36 <sophiag> it's hard when you yourself are a newbie
03:36 <mniip> who was that if I may
03:36 <jle`> Camm1: yes, like that. except maybe even more layers of nesting might make it more worthwhile
03:37 <mniip> it's very rare that someone says something wrong and isn't immediately corrected
03:37 <Camm1> Well, I think I understand your point. Thanks jle` :-)
03:37 <sophiag> mniip: i like him so sort of don't want to say
03:37 <jle`> Camm1: it's "easy" to pass parameters directly even in that example, but for large projects with things over multiple files and modules, it gets less trivial
03:37 <mniip> sophiag, it is likely that you misinterpreted what they said
03:37 <jle`> i use implicit params though instead of ReaderT these days. even though there are drawbacks
03:39 <sophiag> plus it's not like it's out of ignorance almost all the time. it's verbal communication problems
03:39 <sophiag> this solution worked in the abstract and/or some other case than mine
03:39 haskellsucks joined
03:39 <sophiag> mniip: he said earlier it was the reverse
03:40 <sophiag> it was an honest mistake
03:40 <mniip> hum
03:40 <sophiag> it's just many honest mistakes amount to 100s of hours of my time :/
03:40 <mniip> ahhhh
03:40 <mniip> all this time I thought you're using TH
03:40 <sophiag> TH?
03:40 <sophiag> oh
03:40 <sophiag> no
03:40 <sophiag> ha
03:41 <mniip> Exp and the constructors had fooled me for a long time
03:41 <mniip> making me reluctant to code up some prototype
03:41 <sophiag> that probably would be a route to achieve this sort of thing, right?
03:41 louispan joined
03:41 <sophiag> but i figure it'd take me a while to learn
03:41 <mniip> quite the opposite
03:41 <Koterpillar> sophiag: maybe you need to prepare a paste that has your problem description and goals on top
03:41 <Koterpillar> (meta-suggestion)
03:41 lostman joined
03:42 <sophiag> koterpillar: i am starting to archive my answers to the same questions so i can answer the same people when they ask several times a day
03:42 <sophiag> "but what does your program do?" *copy and paste the same thing i pasted five times to the same person yesterday*
03:43 sleffy joined
03:44 Kundry_Wag joined
03:46 <Camm1> jle`: Implicit parameters seems interesting! Which type of drawbacks do they have?
03:46 <jle`> the main one is that things get complicated when you want to use more than one configuration in the same program
03:47 otto_s joined
03:47 <jle`> also they can't be used in typeclass instances
03:47 <jle`> i think those are the main ones
03:48 Stanley00 joined
03:48 kierank1 joined
03:49 takle joined
03:50 <Camm1> Ok, thanks jle`
03:51 Camm1 left
03:51 jmnoz joined
03:53 isenmann joined
03:54 <mniip> sophiag, coming up with some code
03:54 <mniip> for recursive expressions
03:54 <sophiag> mniip: all i needed to do to make parseOp compile was ditch the GADT for a normal data type :p
03:55 <sophiag> but then i have lost the recursive definitions
03:55 <sophiag> and still have an error on line 148
03:56 kritzcreek_ joined
03:58 takle joined
04:02 jgt joined
04:02 DataComputist joined
04:02 yellowj joined
04:03 <lpaste> mniip pasted “stuff” at http://lpaste.net/354227
04:03 <mniip> sophiag, ^
04:03 mda1 joined
04:04 <mniip> that's how I'd do it
04:04 <mniip> sans runCode, that's just testing
04:06 <sophiag> wow :D
04:06 <sophiag> ok, lemme try it out
04:06 kau joined
04:07 ner0x652 joined
04:07 takle joined
04:07 <sophiag> Value does need to be Integers, Strings, and Chars
04:08 <mniip> adapt as needed
04:08 <sophiag> also it's confusing to me to say (Value -> Maybe Value) instead of (Value -> Bool)
04:09 <sophiag> mainly evalExpr solves what i haven't been able to i think
04:09 ubsan_ joined
04:09 <mniip> because I'm using evalExpr recursively
04:09 Mysterious_Light joined
04:09 <sophiag> and your structure for parsing is more clever, i.e. less verbose
04:09 <mniip> hence it's not retunrning Bool
04:10 <sophiag> ah ok
04:10 <mniip> runCode "\\x -> x + x + x + 12" (IntValue 10)
04:10 <mniip> IntValue 42
04:11 <mniip> hmmm you probably want to have
04:11 <mniip> evalExpr var (Paren _ e) = evalExpr var e
04:12 <sophiag> yeah, likely
04:13 teggi joined
04:13 <sophiag> i haven't tested this, but i'll be able to call runCode from a state monad like in my broken version?
04:13 <mniip> probably
04:13 <mniip> though you said you want lambdas in a list
04:14 <mniip> you should use evalLambda directly
04:14 <sophiag> oh right
04:15 peterbecich joined
04:15 <sophiag> mainly i'm just debating going home since it's sunday and i'm beat vs. refactoring my program now :p
04:15 <sophiag> this great though :D
04:16 <sophiag> everything i was fooling around with that GADT for i could have just used a recursive function
04:17 cpup joined
04:19 <mniip> 7 am counts as monday, right?
04:20 <sophiag> eastern europe?
04:21 <sophiag> i'm in new york
04:21 <lambdafan> NYC represent!
04:21 <* lambdafan> waves
04:21 <sophiag> ha
04:21 Xanather joined
04:21 <sophiag> if i was rich i'd take out an ad campaign convincing people not to move here
04:21 max joined
04:22 conal joined
04:22 <Guest35162> Anyone available to check why my haskell script does not work? Concurrency related :D (willing to pay via btc it's 50 lines literally. Thanks in advance
04:23 meba joined
04:24 atomi joined
04:25 <lyxia> @lpaste Guest35162 You can just paste your code and link it here.
04:25 <lambdabot> Haskell pastebin: http://lpaste.net/
04:25 <peddie> Guest35162: why don't you post your code on lpaste first and share the link here; people will probably help for free
04:25 <Guest35162> http://lpaste.net/354228
04:26 ploop joined
04:27 aarvar joined
04:27 <mniip> Guest35162, what's not workign?
04:27 <Guest35162> I am new to functional programming :/
04:28 <Guest35162> For some reason it says it's not parsing the input Event
04:28 splanch joined
04:28 Cale joined
04:28 <mniip> ?
04:29 <mniip> ahh
04:29 <Guest35162> That's the problem : http://lpaste.net/6525819317232074752
04:29 <mniip> your indentation is messed up
04:29 <Guest35162> Is there any indentation fixer? :/
04:30 <Guest35162> It's painful every time to fix the indentation
04:30 <mniip> fix?
04:30 <Guest35162> Yah
04:30 <mniip> why is it messing up?
04:30 <Guest35162> I am getting used to the way of thinking of Functional programming but there is a lot ahead
04:30 <sophiag> mniip: thanks so much for your help today. pretty sure that snippet is going to fix the problem i've been pulling my hair out for days dealing with. i think i need to head home and find some food, but will update you next time i see you on here :)
04:30 <Guest35162> the indentation?
04:31 <Guest35162> I tried haskell beautifiers and what not but it did not work for me
04:31 <monochrom> Haskell indentation cannot be automated.
04:31 <Guest35162> Ah thanks for letting me know :P
04:31 <Guest35162> <3
04:31 <mniip> monochrom, sure can?
04:31 <mniip> sprinkle it with {;} and use none?
04:32 <Guest35162> I am willing to pay via BTC for ur time if anyone can help me finish it.
04:32 takle joined
04:32 <monochrom> mniip, I don't think that's worth answering, and you know it.
04:33 eazar001 joined
04:33 <mniip> monochrom, the assignment or the layout pedantry?
04:37 eklavya joined
04:37 <Guest35162> Anyone willing to help?
04:40 seafood joined
04:40 takle joined
04:40 <seafood> I wanted to know what the status of Generic Haskell is.
04:40 conal joined
04:41 vlatkoB joined
04:41 <pacak> Generic Haskell?
04:42 <Jello_Raptor> seafood: mmm? https://wiki.haskell.org/Generics
04:42 <Guest35162> Anyone can help me willing to pay via btc small script 50 lines
04:43 <Jello_Raptor> I mean if you're asking you've probably already seen that, I'm just wondering which of those things you mean by Generic Haskell
04:44 <seafood> Okay, so I was looking at an old paper by Ralf Hinze on deriving zippers for any data type.
04:44 <seafood> And I wanted to look at the source code. But http://generic-haskell.org no longer appears to hold that code.
04:45 <seafood> Looks like an SEO company stole that domain name.
04:45 Kundry_Wag joined
04:45 <Jello_Raptor> seafood: https://hackage.haskell.org/package/instant-zipper-0.0.0 ?
04:46 <Jello_Raptor> hmm that actually doesn't look useful
04:46 <Guest35162> anyone with free time?
04:47 {emptyset} joined
04:48 <pacak> Guest35162: Lots of people, but "small script 50 lines" is not descriptive enough to make a decision.
04:48 <glguy> Guest35162: It doesn't seem like you've asked a question yet
04:48 takle joined
04:49 <mniip> hey glguy I thought you would know,
04:49 <seafood> Jello_Raptor: Hmm, perhaps that could be useful.
04:49 <mniip> is there a common notion of logarithms in type algebra?
04:49 tripped joined
04:49 <Guest35162> Here is my script
04:49 <Guest35162> http://lpaste.net/3614414072793006080
04:50 <Guest35162> Here are the instructions : http://lpaste.net/6525819317232074752
04:50 mstruebing joined
04:50 <Guest35162> Keep getting test.hs:36:3: error: parse error on input ‘Event’
04:50 <lyxia> mniip: that reminds me of this https://www.arxiv.org/abs/1502.04634
04:51 <lyxia> it's not really "common" though
04:51 <pacak> data Event = C Char | Time Char
04:51 <Guest35162> yes
04:51 <pacak> Event <- readChan c
04:51 <Guest35162> Yes?
04:51 <pacak> This line should contain a patternmatch against one of the constructors
04:51 <pacak> Either C or Time
04:52 <pacak> And if it can get arbitrary events - you need to use case
04:52 <Guest35162> I thought of the channel like a queue, and that it could look like that:
04:52 <pacak> You seems to have this case on the next line but it won't typecheck
04:53 <pacak> So it can be
04:53 <Guest35162> 'timer' 9, 'C' 5,'timer' 2 ,'timer' 3
04:53 <pacak> event <- readChan c
04:53 <pacak> case event of
04:53 <pacak> C c -> xxxx
04:53 <pacak> Time t -> yyyy
04:53 <Guest35162> so what I do? I am lost?
04:53 <Guest35162> Yes
04:54 <pacak> I haven't looked at remaining code but fixing event and using case should get you a bit further.
04:54 <lyxia> seafood: I was wondering about generic zippers just recently. I couldn't find an implementation with GHC.Generics, which is the current approach to generic programming in haskell.
04:54 <pacak> Try doing that and we'll have a look at the next error if there's any.
04:54 <Guest35162> So
04:55 <Guest35162> I have to change
04:55 <Guest35162> the typeclass to what?
04:55 <pacak> It's not typeclass, it's data type
04:55 <Guest35162> data type yeah
04:55 <pacak> You need to match against constructors
04:56 <Guest35162> and how do I match? the documentation is not the best I have seen cause I am not used to functional programming :/
04:56 <Guest35162> That's why I am willing to pay for anyone's time, I need to get this done and understand when it actually compiles lol
04:57 <pacak> I can't make you understand, there's no shortcuts into Haskell. You'll have to study on your own :)
04:57 <pacak> https://www.haskell.org/tutorial/patterns.html
04:57 <pacak> This link seems reasonable - you need case expressions
04:58 <Guest35162> Why? are there any shortcuts in other things to be in haskell lol :P
04:58 seafood joined
04:58 <Cale> Guest35162: What documentation are you reading?
04:58 <pacak> If you took other shortcuts without actually understanding you'll get stuck in a different place.
04:58 <Cale> You should get a full tutorial or book of some sort.
04:59 <Guest35162> The lectures I had in uni
04:59 augur joined
04:59 <Guest35162> where super basic
04:59 <monochrom> I learned Haskell from https://www.haskell.org/tutorial/ too.
04:59 <Guest35162> and now out of the blue we have to know this..
04:59 <Guest35162> Those tutorials are 1999 lol
04:59 <pacak> http://learnyouahaskell.com - I like this one
04:59 <Guest35162> and the lecture notes are simple
05:00 Levex joined
05:00 <Cale> http://www.cis.upenn.edu/~cis194/spring13/lectures.html has some decent notes
05:00 <Guest35162> I have seen learnyouahaskell
05:00 <mniip> lyxia, hmm
05:00 <mniip> lyxia, I'm thinking of log_a F(x)
05:00 <mniip> similar to dF(x)/dx
05:00 <mniip> the type derivativw
05:01 <Cale> http://www.cs.nott.ac.uk/~pszgmh/pih.html -- this is a good book
05:01 <glguy> mniip: I don't know of any such syntax myself
05:01 <mniip> err
05:01 <mniip> log_a F(a)
05:01 takle joined
05:01 mmachenry joined
05:04 seafood joined
05:05 <mniip> hmm
05:05 <mniip> every vector space has a dimensionality which is a cardinal number, right
05:05 <mniip> which means that all vector spaces *are* exponential objects of scalar fields
05:06 <mniip> kinda tempted to represent vector spaces as functions
05:06 dec0n joined
05:06 free_beard joined
05:07 takle joined
05:08 sleffy joined
05:09 loorke joined
05:09 mbuf joined
05:09 vektorweg1 joined
05:11 <lyxia> functional analysis is kind of about that
05:11 <loorke> Guys, which one should I learn first -- Haskell or Scheme (Racket)?
05:11 Koterpillar joined
05:14 <pacak> loorke: Depends on a channel you asking. Here the answer would be #haskell.
05:15 doomlord joined
05:16 augur joined
05:16 takle joined
05:16 <mikeplus64> hmmm -- anyone tried building Yi with ghcjs?
05:17 conal joined
05:17 Mysterious_Light joined
05:18 seliopou joined
05:20 Itachi joined
05:24 Sebastian_ joined
05:24 splanch joined
05:25 <mikeplus64> alternatively, and completely tangentially, is there an efficient way to observe laziness (maybe by giving thunks unique ids?) -- maybe just 'data Thunk a = Thunk !Int a'...
05:25 <Sebastian_> I would love to use TVars to solve a particular problem, but I have one problem: modifyTVar/modifyTVar' return () instead of any return value
05:26 <Sebastian_> Is there any way, other than doing insane things like settings a local TVar and then setting the return value to that TVar, to perform a TVar or similar datastructure modification and return a value?
05:26 <Sebastian_> *setting
05:26 <Guest35162> https://www.youtube.com/watch?v=ZhuHCtR3xq8 MoNADS
05:26 atomi joined
05:27 augur joined
05:27 <cocreature> Sebastian_: can’t you just use "readTVar" after "modifyTVar"?
05:28 atomi joined
05:28 <Sebastian_> cocreature: Oh, I could do that within an atomically block and it would be still safely be ... atomic.
05:28 <MarcelineVQ> or do the steps that modify does yourself
05:28 <Sebastian_> cocreature: damn it, it was so obvious
05:28 <Sebastian_> LOL sorry guys, I've been programming in Go and JavaScript for the last little bit. Thanks.
05:30 atomi joined
05:30 MoALTz joined
05:30 <cocreature> no worries
05:31 xtreak joined
05:32 danvet joined
05:32 Koterpillar joined
05:34 takle joined
05:34 osa1 joined
05:34 osa1 joined
05:35 IRCFrEAK joined
05:35 loorke joined
05:37 xtreak joined
05:37 IRCFrEAK left
05:37 centrinia joined
05:42 IRCFrEAK joined
05:44 IRCFrEAK left
05:45 caumeslasal joined
05:46 Kundry_Wag joined
05:47 alexelcu joined
05:48 fizruk joined
05:51 systemfault joined
05:53 <jle`> oh boy first timing turning on -XStrict and it already backfired on me
05:53 <jle`> i'm never writing strict-by-default code ever again
05:53 <jle`> not even once
05:53 takle joined
05:53 <monochrom> haha
05:54 <thimoteus> what happened?
05:54 srhb joined
05:54 <jle`> oh it was kind of silly on hindsight, i just had a function generate an infinite list lazily
05:54 <jle`> but i didn't realize that -XStrict would break it
05:55 hydroacoustic joined
05:56 <monochrom> Yeah, don't use list.
05:56 <jle`> well the function was made to be a lazy pure generator, basically Stream
05:56 <jle`> but i just added a ~ and now things are fine i guess maybe?
05:56 ThomasLocke joined
05:57 <jle`> who knows
05:57 <jle`> reasoning with strict code is so weird
05:58 meandi_2 joined
05:58 insitu joined
06:00 jake__ joined
06:01 xtreak joined
06:03 jgertm joined
06:06 splanch joined
06:07 takle joined
06:07 Itkovian joined
06:07 ubsan_ joined
06:07 augur joined
06:08 JoshS joined
06:08 detrumi joined
06:09 raichoo joined
06:10 mzf joined
06:10 <cocreature> friends don’t let friends turn on -XStrict
06:10 splanch joined
06:13 jhrcek joined
06:14 takle joined
06:17 freusque joined
06:20 afldcr joined
06:20 xtreak joined
06:20 refold joined
06:20 iputra joined
06:20 iputra left
06:22 iputra joined
06:24 meba joined
06:26 zeroed joined
06:27 takle joined
06:27 hurkan joined
06:27 xtreak joined
06:30 raduom joined
06:32 iputra joined
06:34 ali_bush joined
06:34 ali_bush joined
06:35 iomonad joined
06:36 augur joined
06:37 vaibhavsagar joined
06:38 Levex joined
06:40 bennofs joined
06:40 salva joined
06:42 bbcue joined
06:42 augur joined
06:42 sleffy joined
06:44 <vaibhavsagar> what about -XStrictData?
06:44 <cocreature> vaibhavsagar: what about it?
06:44 alfredo joined
06:45 <vaibhavsagar> is that similarly frowned upon?
06:46 baldrick joined
06:46 <cocreature> vaibhavsagar: depends on who you ask. obviously some people like it otherwise they wouldn’t have added it
06:47 <jle`> i don't think either are frowned upon; -XStrict doesn't actually change the semantics of haskell or anything
06:47 <jle`> -XStrict and -XStrictData are basically syntactic sugar
06:47 <cocreature> personally I find it confusing to invert the default behavior so I don’t use either of them
06:47 <cocreature> but that’s at least partially because I’m so used to the old behavior
06:48 <jle`> it's definitely confusing to switch from file to file having to be aware of what the default behavior was
06:48 nick_h joined
06:48 <jle`> but -XStrictData is much less pervasive than -XStrict so it's a little easier to rad
06:49 castlelore joined
06:49 castlelore joined
06:50 i_khsan joined
06:51 zeroed joined
06:52 unK_ joined
06:52 thc202 joined
06:53 taksuyu joined
06:53 louispan joined
06:56 Salih joined
06:57 Croniamental joined
06:58 Aruro joined
06:58 insitu joined
06:59 mattyw joined
07:00 <vaibhavsagar> fair enough, I used it to replace the strictness annotations I was manually putting everywhere
07:02 ragepandemic joined
07:06 raichoo joined
07:07 Swizec joined
07:08 xiinotulp joined
07:09 carlosda1 joined
07:10 mrwonko joined
07:10 vlatkoB_ joined
07:10 xiinotulp joined
07:11 sanett joined
07:12 patbecich joined
07:12 <tsahyt> more likely than not you don't want strictness annotation everywhere in the first place
07:13 guiben joined
07:13 BartAdv joined
07:13 <tsahyt> although strict fields are often a good idea, I'll concede that
07:14 Rainb joined
07:15 nick_h joined
07:15 hydroacoustic joined
07:15 osa1 joined
07:15 osa1 joined
07:15 nick_h joined
07:15 sanett joined
07:18 MrWoohoo joined
07:18 sanett joined
07:19 albertid joined
07:20 magthe joined
07:21 Micamo joined
07:21 connrs joined
07:21 mooooooooo joined
07:23 mooooooooo left
07:24 oish joined
07:26 Wizek joined
07:26 mmn80 joined
07:26 Wizek_ joined
07:26 Sebastian_ joined
07:28 takle joined
07:28 CurryWurst joined
07:33 gfvkdd joined
07:34 refold joined
07:36 peterbecich joined
07:36 ventonegro joined
07:38 augur joined
07:38 cyborg-one joined
07:39 hive-mind joined
07:40 <Magnap> Hey mniip. Better late than never? :P
07:41 kirillow_ joined
07:41 takle joined
07:41 biglama joined
07:43 yinn joined
07:43 chin-tastic joined
07:44 xtreak joined
07:48 Kundry_Wag joined
07:48 augur joined
07:50 alexelcu joined
07:51 takle joined
07:51 uncertainty joined
07:52 zariuq joined
07:54 alexelcu1 joined
07:55 augur joined
07:57 ragepanda joined
07:58 balor joined
07:59 eklavya joined
07:59 Argue joined
08:00 alexelcu joined
08:00 takle joined
08:02 takle_ joined
08:03 mrwonko joined
08:04 Bashmetim joined
08:07 Yuras joined
08:08 Bin4ry joined
08:08 mrwonko joined
08:09 selthas joined
08:09 takle joined
08:09 augur joined
08:10 xtreak joined
08:12 refold joined
08:13 merijn joined
08:14 bbcue_ joined
08:15 xall_ joined
08:16 filterfish joined
08:18 redeemed joined
08:18 afnizarnur joined
08:19 featherlessbiped joined
08:22 jmnoz joined
08:22 afnizarnur joined
08:24 Yuras joined
08:24 bennofs joined
08:25 Sebastian_ joined
08:26 dawehner joined
08:26 BlueShark|cloud joined
08:27 jgertm joined
08:28 mstruebing joined
08:29 suls joined
08:30 zero_byte joined
08:32 t0by joined
08:32 mekeor joined
08:32 inad922 joined
08:33 Wizek_ joined
08:33 jake__ joined
08:33 raichoo joined
08:33 <jake__> .
08:35 Gurkenglas joined
08:36 Rainb joined
08:36 iomonad joined
08:36 Mysterious_Light joined
08:37 petrus joined
08:37 takle joined
08:38 yinn joined
08:39 sgript joined
08:40 Yuras joined
08:41 <Gurkenglas> An Iso' (Tree a) (Cofree [] a) would be nice.
08:41 uncertainty joined
08:42 gpampara joined
08:42 afnizarnur1 joined
08:42 fotonzade joined
08:42 <Gurkenglas> Waaaaaaaaaaait a second. *checks with lamdabot*
08:43 Argue_ joined
08:44 <phz_> hey folks!
08:44 <phz_> is there a good library to connect to a MSSQL database?
08:44 <merijn> phz_: Honestly? I doubt it
08:44 <phz_> merijn: currently, we’re using a C# proxy
08:44 <phz_> but I don’t like that as our codebase is only Haskell for now
08:44 <merijn> phz_: There's a bunch of good/decent ones for Postgres, MySQL, and SQLite, but I haven't seen MSSQL in Haskell before
08:44 <phz_> having two languages around is a mess
08:45 <phz_> arf
08:45 <phz_> what a pity :(
08:45 <Aruro> haskell is Microsoft Research funded, surely there is MSSQL support
08:45 Icewing joined
08:46 detrumi joined
08:46 <merijn> Aruro: You do realise MSR is a non-profit academic research institution that just happens to be funded by MS, no? Not a product development lab
08:46 ebzzry joined
08:46 Bin4ry joined
08:46 prophile joined
08:47 sgflt joined
08:47 dawehner joined
08:50 <Gurkenglas> local ghci says unsafeCoerce works between them :D is this safe?
08:50 <brynedwards> There are a couple of libraries for connecting via odbc in Haskell
08:50 <Aruro> merijn: where did u get non profit part? MR sits under same domain as microsoft, they just fun academics.
08:50 <Aruro> d*
08:50 <brynedwards> Like this https://github.com/hdbc/hdbc-odbc , probably your best choice for MSSQL
08:51 <brynedwards> ...in Haskell
08:51 balor joined
08:51 FjordPrefect joined
08:51 carlosdagos joined
08:51 Cxom_ joined
08:52 n1k joined
08:52 mstruebing joined
08:52 MoALTz_ joined
08:52 burp joined
08:52 Gurkenglas_ joined
08:53 nesqi_ joined
08:53 featherlessbiped joined
08:54 alanb99 joined
08:55 <Aruro> merijn: in fact mircosoft tell us itself : esearchers are embedded in the company’s global network of product creation, and they contribute to products across platforms in addition to shipping their own.
08:56 <Aruro> https://www.microsoft.com/en-us/research/products/
08:56 mda1 joined
08:57 Bin4ry joined
08:59 alanb99 left
09:00 dawehner joined
09:00 switte1 joined
09:02 Chitzaa joined
09:02 <Chitzaa> hi
09:02 Chitzaa left
09:02 mszczygiel joined
09:03 xtreak joined
09:04 augur joined
09:05 iomonad joined
09:05 henriksod joined
09:06 oish joined
09:10 mszczygiel joined
09:10 brokenprogrammer joined
09:13 xtreak joined
09:13 patbecich joined
09:16 oish joined
09:17 Argue__ joined
09:19 yinn joined
09:19 deepfire joined
09:19 mstruebing joined
09:22 Argue_ joined
09:22 yoneda joined
09:23 dawehner joined
09:23 twanvl joined
09:23 laz joined
09:24 tlaxkit joined
09:24 fred-fri joined
09:25 Blkt joined
09:25 <fred-fri> pairs xs = zip xs (tail xs) doesn't give all pairs of a list, what does? (note, i need all pairs, not just all unique pairs)
09:26 <merijn> fred-fri: Are duplicates okay? i.e. should pairs [1..10] include (1, 1)?
09:26 <reactormonk[m]> Carthesian product of a list with itself?
09:26 <merijn> This sounds like a job for...the list monad! ;)
09:27 <fred-fri> fascinating how something so simple can have so much ambiguity =)
09:27 jgertm joined
09:27 <reactormonk[m]> Apparently it's not simple.
09:27 <ertes> > (\xs -> [ (x, y) | x:ys <- tails xs, y <- ys ]) [1..4]
09:27 <lambdabot> [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)]
09:28 <ertes> fred-fri: like that?
09:28 bennofs joined
09:28 <merijn> > let l = [1..4] in do { x <- l; y <- l; return (x,y) }
09:28 <lambdabot> [(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,...
09:29 <ertes> > (\xs -> [ (x, y) | x:ys <- tails xs, y <- x:ys ]) [1..4] -- or that, if elements should pair with themselves as well
09:29 <merijn> Which I suppose is identical to
09:29 <lambdabot> [(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)]
09:30 <reactormonk[m]> > let l x = (,) <$> x <*> x; l [1..4]
09:30 <lambdabot> <hint>:1:36: error:
09:30 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
09:30 bweston92 joined
09:30 <merijn> > let l = [1..4] in [(x,y) | x <- l, y <- l]
09:30 <lambdabot> [(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,...
09:30 <fred-fri> what have i unleashed
09:30 <merijn> fred-fri: Mostly these are slightly different ways to write the same thing :p
09:30 <merijn> fred-fri: only ertes' is different (that one has no duplicates)
09:30 yinn joined
09:31 carlosdagos joined
09:32 <fred-fri> actually im not sure myself whether pair [1,2] should result in just [(1,2)] or [(1,2),(2,1)]. i do know that it shouldnt contain (1,1) or (2,2) though
09:32 Iceland_jack joined
09:32 bbcue joined
09:32 mdarse joined
09:32 <Iceland_jack> Morning y'all
09:33 <merijn> ugh...I just had the annoying realistion that I can't indepedently typecheck my ADTs and definitions, since my ADTs could potentially have definitions in them...
09:34 <fred-fri> i will try some of what you provided and see how i go, thanks
09:35 <ertes> @let select [] = []; select (x:xs) = (x, xs) : map (\(y, ys) -> (y, x:ys)) (select xs)
09:35 <lambdabot> Defined.
09:36 <ertes> > (\xs -> [ (x, y) | (x, ys) <- select xs, y <- ys ]) [1..4]
09:36 <lambdabot> [(1,2),(1,3),(1,4),(2,1),(2,3),(2,4),(3,1),(3,2),(3,4),(4,1),(4,2),(4,3)]
09:36 <ertes> fred-fri: ^ here is one further possibility
09:38 <Iceland_jack> (\(y, ys) -> (y, x:ys)) is (second (x:))
09:38 mszczygiel joined
09:38 da-x joined
09:39 <merijn> @ask phadej Since you're working on bound: Do you know if there's a way to safely check whether all bound variables have been substituted in a Scope? I think instantiate currently only lets you produce bottom when your substitution function doesn't have the relevant variable?
09:39 <lambdabot> Consider it noted.
09:39 <ertes> or (_2 %~ (x :))
09:39 <ertes> or even (_2 <>~ [x])
09:39 <ertes> or …
09:40 maarhart joined
09:40 <Iceland_jack> :)
09:43 fendor joined
09:43 <tsahyt> There was a post on /r/haskell pointing to some linear logic course, but I can't find it anymore. Does anyone have the link?
09:44 <Iceland_jack> tsahyt: https://www.cs.cmu.edu/~fp/courses/15816-f16/ ?
09:44 <tsahyt> yes that's it! thank you!
09:46 dni joined
09:47 da-x joined
09:47 Bashmetim joined
09:48 da-x joined
09:50 Kundry_Wag joined
09:54 atomi joined
09:55 xtreak joined
09:55 <phz_> is there any way to call C# from Haskell?
09:55 <merijn> phz_: C FFI from Haskell to C#'s C FFI
09:55 <dmj`> phz_: System.Process
09:55 <dmj`> shell “app.exe"
09:55 <phz_> duh that’s ugly
09:55 <merijn> dmj`: That seems...a poor idea for most cases
09:56 <phz_> I’m trying to find a way to cope with that MSSQL stuff
09:56 <phz_> we currently have a client written in C# exposing some kind of a webapp
09:56 <phz_> but I don’t like that
09:56 <phz_> because we also have the haskell webapp
09:56 <phz_> that’s like a lever of unnecessary indirection
09:56 <phz_> level*
09:57 <merijn> phz_: The two sane options are: 1) use some IPC (sockets, pipes, whatever) to query the C# version from Haskell or 2) use the FFI to call C# code directly
09:57 <phz_> I want to implement #2!
09:57 <phz_> but it seems a bit overkill, right?
09:57 <merijn> phz_: Honestly, Haskell's FFI is pretty simple
09:57 <cocreature> you just need to implement a inline-c# library analogous to the inline-java library
09:58 <dmj`> yea, simple
09:58 <earthy> https://wiki.haskell.org/Salsa is an experimental third alternative
09:58 <merijn> I have no experience with C#, but I can't imagine their FFI is very hard
09:58 <cocreature> (I’m not being completely serious)
09:58 yinn joined
09:58 <earthy> it's a tad oldish though.
09:58 <phz_> yeah, well… :D
09:58 <earthy> and even older is hs-dotnet http://haskell.forkio.com/dotnet
09:59 <brynedwards> phz_: Have you looked at HDBC-odbc?
10:00 louispan joined
10:00 <brynedwards> Here's a reddit thread from a couple of months ago where people mention using that to work with MSSQL https://www.reddit.com/r/haskell/comments/5ogaoy/mssql_and_haskell/
10:00 <phz_> I saw it kinda sucks?
10:00 <dmj`> phz_: would porting to sql and haskell from c# and mssql be out of the question? How much .net code is it
10:00 MejGun joined
10:00 <earthy> oh, and obviously https://wiki.haskell.org/GHC:FAQ#Why_isn.27t_GHC_available_for_.NET_or_on_the_JVM.3F
10:01 <phz_> dmj`: it’s a lot of code ; we are writing Haskell proxies to it
10:01 <brynedwards> It doesn't look super reliable unODODODfortunately
10:01 <phz_> it’s existant, 10-years old code
10:01 <dmj`> phz_: how many lines
10:01 <phz_> I don’t know, a lot
10:01 <cocreature> phz_: tbh I think just using some ipc is probably the easiest solution
10:01 <reactormonk[m]> Somehow eta is missing on that list
10:01 <dmj`> phz_: is it closed-source?
10:01 <phz_> dmj`: unfortunately, yeah
10:01 <cocreature> unless exposing c# methods via a C ffi is very easy
10:01 <phz_> it’s work stuff
10:01 <phz_> (yeah, I do haskell at work <3)
10:02 Gurkenglas_ joined
10:02 locallycompact joined
10:02 <tsahyt> reactormonk[m]: eta is still relatively new. probably newer than that list
10:03 <dmj`> phz_: so you’re just wrapping the database w/ haskell and accessing it in a read only way?
10:03 deepfire joined
10:03 <phz_> dmj`: currently, we’re writing views to it
10:03 <phz_> readonly, but we’ll have write access soon
10:03 <earthy> phz_: otoh, wouldn't writing an F#-wrapper be a better idea?
10:03 <dmj`> two apps with write access to the same db, make sure they don’t step on each other’s toes
10:05 <phz_> dmj`: we’re decommissioning the old one in favour of the Haskell one
10:05 <phz_> it’ll take time
10:05 <phz_> in the end, we won’t even need the C# stuff anymore
10:05 <phz_> as we’ll be using our own technology
10:05 <phz_> but in the meantime, for an unknown period of time, we’ll need those proxies :/
10:06 <dmj`> sure, makes sense. Is your haskell built on windows?
10:06 gawen joined
10:10 frankfis joined
10:11 dawehner joined
10:11 azahi joined
10:13 bollu joined
10:13 fendoer joined
10:14 <bollu> is there anyone here familiar with the "derivative of a type as a one hole context"? I'm trying to interpret what the derviative of (a -> b) i.e b^a is with respect to b
10:14 <bollu> d(a->b)/db = d(b^a)/db = a . b^(a - 1)
10:15 mbuf joined
10:18 <opqdonut> you have a pair (value, function-for-everything-else-except-value)
10:19 <opqdonut> you've removed f(value), kind of
10:19 petermw joined
10:19 balor joined
10:20 <opqdonut> or that's my intuition
10:20 <opqdonut> you'd need to use virtual (negative) types to formalize that
10:21 quchen joined
10:21 <opqdonut> I haven't really looked at derivatives of function types ever though
10:21 takle joined
10:22 fizbin joined
10:22 <bollu> opqdonut: no, but I'm checking the derivative with respect to _b_
10:22 <bollu> opqdonut: so I removed something in the codomain
10:22 <bollu> opqdonut: which is what I find confusing
10:22 <opqdonut> yes
10:23 <bollu> opqdonut: so the preimage of that thing in the codomain could be many a's, or none at all
10:23 <bollu> opqdonut: I would have expected ([a], b^(a - 1))
10:23 <opqdonut> mmh, right!
10:23 <bollu> opqdonut: but it says (a, b^(a - 1)) which I find strange
10:23 <bollu> opqdonut: tell me more about negative types?
10:24 _sg joined
10:24 <opqdonut> the type a-b is formalized as <a,b> with equality <a,b> = <c,d> <=> a+d = b+d
10:24 <opqdonut> so the usual algebraic trick of introducing inverses
10:24 <bollu> ah
10:25 <bollu> but in this context, "+" being choice?
10:25 <opqdonut> yes.
10:25 <bollu> I see.
10:25 <bollu> opqdonut: do you have a reasonable interpretation of the logarithm of a type?
10:25 <opqdonut> I've thought about that
10:25 <bollu> or, well, anyone here
10:26 mfukar joined
10:26 <opqdonut> but I can't remember what I thought about it :(
10:26 <opqdonut> it somehow turned types into paths
10:26 <bollu> "paths" in the HoTT sense?
10:26 <opqdonut> (a*b -> a+b, so you either went left or right)
10:26 <bollu> ah
10:26 <bollu> interesting
10:26 <opqdonut> (a^b -> b*a, so pick a x and f(x))
10:26 <Phyx-> phz_: C# is designed for interopability with C, in both direction. What it comes down to is that your Haskell library has to host and start the CLR before you can call your C# methods
10:27 <bollu> wow, so you interpret it in terms of the homomorphism. clever :P
10:27 <bollu> (a + b -> gibberish, though)
10:27 <Phyx-> phz_: so you need to use the .NET Hosting APIs https://msdn.microsoft.com/en-us/library/ms404385(v=vs.110).aspx and https://msdn.microsoft.com/en-us/library/dd380850(v=vs.100).aspx should get you started
10:27 <opqdonut> bollu: yeah
10:27 <opqdonut> exponentiation takes X into "set of X"
10:27 <bollu> opqdonut: yeah
10:27 danza joined
10:28 Mysterious_Light joined
10:28 <opqdonut> so logarithm needs to do the inverse, which is a bit mind-boggling
10:28 <opqdonut> but the elements of a^b are pairs b*a, so it kinda makes sense
10:28 <bollu> yeah, I guess
10:28 <Phyx-> phz_: that said, you need GHC 8.2, because of a stack initial size issue with the older GHCs which conflicts with the CLR. Though smaller examples may work..
10:30 <bollu> a + b -> log(a + b). I suppose we should make | log(a) == "path through a" as an axiom
10:30 <bollu> then log(a * b) = log a + log b makes sense
10:30 <Phyx-> phz_: hosting the Haskell runtime in C# is much easier though.
10:30 <bollu> perhaps log(a) = "pick a" is a reasonable interpretation
10:31 <bollu> hmm
10:31 <bollu> log_a(a) = 1
10:31 <bollu> is consistent, there is only one way to pick a out of a
10:31 <bollu> log_a(a^n) = n, still consistent. There are "n" ways to pick "a" out of a^n
10:32 coot joined
10:32 <opqdonut> nice
10:33 carlomagno joined
10:33 <bollu> log_a(c^d) = log_a(c . c . c … (d times)) = d . log_a(c) -> if you have "c" repeated "d" times, the #of ways of picking "a" is the number of choices of "c" you have, multiplied by the number of choices of "a" in "c"
10:33 xwcius joined
10:33 <bollu> neat
10:34 splanch joined
10:35 <opqdonut> in this type algebra case it's important to not mix up a^b as a shorthand for a*a*...*a and a^b as an alternative to b->a
10:35 <opqdonut> the former is easy to handle usually, the latter can be tricky
10:35 <bollu> ah right
10:35 <bollu> crap
10:35 <bollu> hm
10:36 <bollu> opqdonut: actually I'd argue they're the same
10:36 <opqdonut> tuples vs. functions
10:36 <bollu> in some sense
10:36 zargoertzel joined
10:36 <bollu> opqdonut: a function is an "infinite tuple"
10:36 <opqdonut> yeah well the meaning of a^(3-1) is clear, the meaning of a^(Int-1) is less clear :)
10:36 <bollu> opqdonut: yeah
10:36 <opqdonut> sorry I gotta go now, this was an interesting discussion
10:37 <bollu> opqdonut: I would argue that it means this: you have all the variants of Int
10:37 <bollu> opqdonut: np
10:39 hoknamahn joined
10:39 petermw joined
10:39 MindlessDrone joined
10:39 refold joined
10:39 zariuq joined
10:40 <fred-fri> foo [1,2,3,4] should output [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)] my best attempt so far is https://pastebin.com/STYzmJwf but i suspect theres a better way
10:42 <Iceland_jack> > [ (x, y) | x:ys <- tails [1,2,3,4], y <- ys ]
10:42 <lambdabot> [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)]
10:43 <bollu> > let foo xs = (liftA2 (,) xs xs) & filter (uncurry (<)) in [1..4]
10:43 <lambdabot> [1,2,3,4]
10:43 <bollu> >  let foo xs = (liftA2 (,) xs xs) & filter (uncurry (<)) in foo [1..4]
10:43 <lambdabot> [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)]
10:43 augur joined
10:43 <fred-fri> interesting, thanks
10:43 <shiona> :t (&)
10:43 <lambdabot> a -> (a -> b) -> b
10:43 <Iceland_jack> x & f = f x
10:44 <Iceland_jack> (recently added to Data.Function)
10:44 <bollu> Iceland_jack: I much prefer (|>)
10:44 afnizarnur joined
10:44 <bollu> Iceland_jack: but I suppose I lost that battle
10:44 <Iceland_jack> Yes
10:45 oish_ joined
10:45 <fred-fri> bollu, are you saying you prefer what Iceland_jack wrote?
10:45 cpennington joined
10:45 <bollu> fred-fri: no, F# uses the operator called (|>) which is the same as (&). But I find that (|>) carries the intent better (to me at least)
10:46 <bollu> fred-fri: IIRC there was some discussion around what to adopt
10:46 <Iceland_jack> (<|), (|>) are a lot less arbitrary than ($), (&)
10:46 <bollu> yeah
10:46 <bollu> but, the reasoning for & is "x & f & g" is "take x and do f and do g"
10:46 <bollu> which is at least "explainable"
10:46 <bollu> unlike $
10:46 <Iceland_jack> Haskell people are obsessed with money
10:46 <bollu> :P
10:46 <fred-fri> Iceland_jack, correct me if I'm wrong but what you wrote is a list comprehension?
10:47 <Iceland_jack> fred-fri: Correct
10:47 <fred-fri> If so I need to read up that and make this the first list comprehension I "get"
10:47 <Iceland_jack> Well let's first "get" tails
10:47 <Iceland_jack> > tails "hello"
10:47 <lambdabot> ["hello","ello","llo","lo","o",""]
10:47 <bollu> fred-fri: Iceland_jack's code is more general and faster than mine :) I just wrote mine to exploit some cuteness
10:47 <ahihi> > let foo1 xs = [ (x, y) | x:ys <- tails xs, y <- ys ]; foo2 xs = (liftA2 (,) xs xs) & filter (uncurry (<)); xs = [4,3,2,1] in (foo1 xs, foo2 xs)
10:47 <lambdabot> ([(4,3),(4,2),(4,1),(3,2),(3,1),(2,1)],[(3,4),(2,4),(2,3),(1,4),(1,3),(1,2)])
10:48 <Iceland_jack> the list comprehension I wrote involves some "tricks", for example if a pattern match (x:ys) fails it skips that element
10:48 <fred-fri> actually if i had known about list comprehension yesterday i bet this could be improved by it https://gist.github.com/androidfred/057fc0d23fde5b2653f03877f969ed08
10:48 <Iceland_jack> > [ str | str <- tails "hello" ]
10:48 <lambdabot> ["hello","ello","llo","lo","o",""]
10:48 <Iceland_jack> > [ s:str | s:str <- tails "hello" ]
10:48 <lambdabot> ["hello","ello","llo","lo","o"]
10:49 <Iceland_jack> > [ s:v:str | s:v:str <- tails "hello" ]
10:49 <lambdabot> ["hello","ello","llo","lo"]
10:49 <Iceland_jack> > [ x:xs | str <- tails "hello", let x:xs = str ]
10:49 xtreak joined
10:49 <lambdabot> ["hello","ello","llo","lo","o","*Exception: <interactive>:3:36-45: Irrefutab...
10:49 deepfire joined
10:50 Itkovian joined
10:50 <Iceland_jack> I could also have written mine with (concat :: [[a]] -> [a])
10:50 <Iceland_jack> > [ map (x, ) ys | x:ys <- tails [1,2,3,4] ]
10:50 <lambdabot> [[(1,2),(1,3),(1,4)],[(2,3),(2,4)],[(3,4)],[]]
10:51 <Iceland_jack> > concat [ map (x, ) ys | x:ys <- tails [1,2,3,4] ]
10:51 <lambdabot> [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)]
10:51 <fred-fri> i think that last example is the easiest to get for a newbie
10:51 <fred-fri> but the list comprehension one is probably the most idiomatic?
10:52 <fred-fri> optimally you want to generate the end result in one go without having to trim anything
10:53 theelous3 joined
10:54 phaji joined
10:55 <fred-fri> thanks for the help, much appreciated. love this channel.
10:56 xtreak joined
10:56 jmnoz joined
10:57 Levex joined
10:57 weinzwang joined
10:57 silver joined
10:58 <Iceland_jack> fred-fri: yw!
10:58 al-damiri joined
10:58 urodna joined
11:02 dawehner joined
11:03 fotonzade joined
11:05 fendoer joined
11:06 zargoertzel joined
11:07 atomi joined
11:07 <mniip> Magnap, hey
11:08 mattp_ joined
11:08 kuribas joined
11:09 oisdk joined
11:10 <kuribas> Is having recursion as tailcalls an advantage?
11:10 <merijn> kuribas: In Haskell?
11:10 <kuribas> yes
11:10 <merijn> kuribas: In general, no. As, depending on your point of view, either every haskell function call is a tail call, or none are
11:11 Gloomy joined
11:11 <merijn> kuribas: Tail calls are usually used in combination with tail-call optimisation to avoid stack growth for recursive functions. But (GHC) Haskell doesn't use a function call stack, so there's also no call stack growth to avoid
11:12 <kuribas> and in a monadic context?
11:12 <kuribas> say myAction (x:xs) = do anAction x; myAction xs
11:12 <merijn> kuribas: No, but there's some other general overhead for repeated monadic binds
11:12 <merijn> kuribas: Are you familiar with DList?
11:13 <kuribas> sort of...
11:13 <merijn> kuribas: There's "Codensity transform", which is basically DList generalised to (among other things) monads
11:13 afnizarnur joined
11:14 <merijn> kuribas: The main reason to do tail calls is to fix strictness. And there it's just incidental (because that's how you fix the strictness) not a root issue
11:14 patbecich joined
11:15 <merijn> kuribas: Consider "sum (x:xs) = x + sum xs", the problem with this code is that it creates a huge thunk of pluses to evaluate (typical lazy leak), to avoid this leak we want to keep forcing the sum as we go, but we can't do that in this version
11:16 <merijn> "sumHelper n (x:xs) = n `seq` sumH (n + x) xs" solves the leak by forcing 'n' at every step (and happens to be tail recursive). But the speedup/improvement here is fixing the laziness, not the tail call bit.
11:16 <kuribas> merijn: I'd use a strict foldl'
11:16 <merijn> kuribas: Well sure, but someone needs to implement foldl' this way first ;)
11:16 <merijn> kuribas: s/sum/foldl'/ and you have the same problem AND solution :)
11:17 <kuribas> I see, so thunks take place of the stack in other languages...
11:18 mohsen_ joined
11:18 <kuribas> except that the order for the stack is well defined.
11:19 <merijn> kuribas: Haskell uses a pattern matching stack, instead of a function call stack, yes
11:19 ragepandemic joined
11:19 <merijn> kuribas: We only evaluate thunks while performing a case-of, right?
11:19 augur joined
11:19 <kuribas> right
11:20 <merijn> So if we have "case e of { ... }" we need to evaluate 'e', but what if evaluating 'e' to WHNF includes another case? Clearly we need a stack to store whatever pattern we were matching before so we can return to it
11:20 xtreak joined
11:21 <kuribas> So ghc uses the stack for that?
11:21 <merijn> kuribas: Function calls, in contrast, in Haskell are basically compiled to simple JMP instructions in assembly (rather than C's CALL)
11:21 refold joined
11:21 <kuribas> Does it every use call?
11:21 <kuribas> ever
11:21 <merijn> kuribas: Well, it's not like there is a "the stack"
11:21 <merijn> kuribas: The stack is simply "a bit of memory we have reserved to be the stack"
11:21 Yuras joined
11:21 <kuribas> the x86 stack
11:22 <merijn> kuribas: No, GHC doesn't use CALL afaik
11:22 Zimoo joined
11:22 <kuribas> or PUSH, SP?
11:22 <kuribas> except for FFI of course.
11:23 Zimoo joined
11:23 Zimoo joined
11:24 marr joined
11:24 Zimoo joined
11:24 <kuribas> I suppose strict code could use a stack, but that may interfere with lazyness...
11:25 <kuribas> So not using a stack makes it less complicated.
11:26 msl09 joined
11:26 xtreak joined
11:26 <msl09> hello
11:27 benl23 joined
11:27 <msl09> anybody have some experience with postgresql-simple?
11:27 uncertainty joined
11:27 <msl09> I'm trying to make my data an instance of FromRow
11:27 <msl09> fromRow = MessageLog <$> field <*> field <*> field <*> field <*> field <*> field
11:28 dni joined
11:28 <msl09> but I'm getting an error saying that ‘fromRow’ is not a (visible) method of class ‘FromRow’
11:29 <msl09> what does that mean?
11:30 fizbin joined
11:30 <kuribas> msl09: that the class FromRow doesn't have a method called "fromRow"
11:30 Aruro joined
11:30 <lyxia> msl09: Database.Postgres.Simple only exports the class name
11:30 timdiels joined
11:31 jrm joined
11:32 <lyxia> Try deriving Generic instead and leaving the instance of FromRow empty
11:32 pavonia joined
11:32 <kuribas> Maybe you need to import Database.PostgreSQL.Simple.FromRow?
11:32 Yuras joined
11:34 timdiels left
11:35 <kuribas> lyxia: strange, the documentation says you can derive an instance this way...
11:35 <kuribas> lyxia: here: https://hackage.haskell.org/package/postgresql-simple-0.5.2.1/docs/Database-PostgreSQL-Simple-FromRow.html
11:35 <msl09> >Database.Postgres.Simple only exports the class name
11:35 <msl09> what's why does that happens?
11:36 <kuribas> The latest from hackage has: FromRow(..)
11:36 <kuribas> msl09: can you post a snippet?
11:36 afnizarnur left
11:37 <msl09> yeah sure
11:37 <lyxia> kuribas: right, I was suggesting an alternative with less boilerplate
11:37 afnizarnur joined
11:38 <lyxia> kuribas: where do you see FromRow(..)? Isn't the latest https://hackage.haskell.org/package/postgresql-simple-0.5.2.1/docs/src/Database-PostgreSQL-Simple.html ?
11:38 <lpaste> msl09 pasted “postgresql-simple” at http://lpaste.net/354238
11:38 <msl09> there
11:38 MindlessDrone joined
11:38 <kuribas> lyxia: https://hackage.haskell.org/package/postgresql-simple-0.5.2.1/docs/src/Database-PostgreSQL-Simple-FromRow.html#FromRow
11:39 <kuribas> msl09: yeah, you need import Database.PostgreSQL.Simple.FromRow
11:39 <lyxia> Okay but I was talking about the root module
11:39 xtreak joined
11:39 ziocroc joined
11:39 <lyxia> which is what msl09 quoted
11:39 <Myrl-saki> For linear types, when is duplication harmful? Aside from concurrency.
11:39 <kuribas> lyxia: right, I was looking at the other module
11:40 arpl joined
11:40 dni joined
11:40 <kuribas> Myrl-saki: maybe garbage collection? Without duplication you don't need it...
11:41 <Myrl-saki> kuribas: Right. But harmful?
11:41 mzf joined
11:42 <msl09> so to expose "fromRow" Postgresql.Simple would have to list the typeclass as "FromRow(..)" in the module declaration?
11:42 <lyxia> right
11:42 <msl09> ic, thanks!
11:43 erisco joined
11:45 <lyxia> Myrl-saki: duplication of resources is one cause of "use after free"
11:45 Zimoo left
11:45 nomicflux joined
11:45 <lyxia> the resource is consumed both by free and the usage after it.
11:47 <Aruro> msl09: official: https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-1000005.2
11:48 <Aruro> item 4
11:49 <msl09> ah I see
11:49 dec0n joined
11:49 <msl09> thanks Aruro
11:50 lithie joined
11:51 Yuras joined
11:54 bjz joined
11:55 augur joined
12:00 <mniip> hum
12:00 Fairy joined
12:00 <mniip> it appears that vector spaces are related to representable functors
12:01 <mniip> with dimensions being the representation
12:01 sepp2k joined
12:05 <Aruro> and?
12:06 dni joined
12:08 augur joined
12:10 mekeor joined
12:11 <Aruro> mniip: u know that functors first appeared in topology? which in turn is about topological spaces, which in turn are generalisation of metric spaces?
12:12 FjordPrefect joined
12:12 Lord_of_Life joined
12:14 <mniip> Aruro, I'm talking about a stronger relationship
12:14 <mniip> something along the lines of
12:15 <mniip> a functor is a vector space iff it is representable
12:16 tsmish joined
12:16 Lord_of_Life joined
12:17 xtreak joined
12:18 yellowj joined
12:19 afnizarnur joined
12:21 Levex joined
12:22 <Aruro> mniip: do u have any example of representable functor?
12:22 fotonzade joined
12:23 <ertes> "left-to-right associativity"… i can only assume what that means… why do people write stupid prose instead of a clear symbolic expression?
12:23 gawen joined
12:24 FreeBirdLjj joined
12:25 uncertainty joined
12:25 <mniip> Aruro, data Pair a = Pair a a
12:26 <Aruro> how?
12:26 <ertes> mniip: representable by (->) Bool? i have no experience with representable functors
12:26 <Aruro> end cathegory has to be sets, where are sets here?
12:26 <Aruro> and functions
12:27 <ertes> Aruro: in type theory, it's a category of types and functions instead of sets and functions
12:27 <ertes> that's fine, they are similar enough for this
12:27 <Iceland_jack> Aruro: (Pair a) is isormophic to a function from Bool: (Bool -> a)
12:27 <Iceland_jack> to *functions
12:28 <Iceland_jack> The representing type (Bool) acts as a sort of key indexing into (Pair a)
12:28 <Aruro> functions from bool to a dont form cathegory
12:29 fizruk joined
12:29 <Aruro> i dont see from what to what this functor maps stuff
12:29 <ertes> Aruro: they form a functor
12:29 <ertes> @let myPair i = if i then 15 else 20
12:29 <lambdabot> Defined.
12:30 <ertes> @let myBoth p = (p False, p True)
12:30 <lambdabot> Defined.
12:30 <ertes> > myBoth myPair
12:30 <lambdabot> (20,15)
12:30 <ertes> > myBoth (fmap (+ 1) myPair)
12:30 <lambdabot> (21,16)
12:30 <ertes> Aruro: ^
12:30 <Aruro> its not representable functor :)
12:31 <Aruro> first we have to define cathegory which we are Representing
12:31 <ertes> Pair is the representable functor… it's represented by Bool
12:31 <Iceland_jack> ((->) Bool) is also an obvious representable functor :) represented by Bool
12:31 <Iceland_jack> Isomorphism between (Bool -> a) and (Bool -> a)
12:32 <Aruro> Iceland_jack: reread definition of representable functor, this is maximum some endofunctor
12:32 <Iceland_jack> ((->) Bool) and Pair are both (endo)Functors
12:33 bennofs joined
12:33 <Iceland_jack> Have you looked at https://hackage.haskell.org/package/adjunctions-4.3/docs/Data-Functor-Rep.html
12:33 <ertes> Aruro: Hask (a category of types and functions) is used as a substitute for Set here
12:33 <ertes> Aruro: Pair is an endofunctor from Hask to Hask
12:34 <ertes> it is represented by the object Bool
12:34 <Aruro> then there are no representable functors in haskell, if u make it equal to sets
12:34 <Aruro> kills whole point of representable functors
12:34 <Aruro> this all are endofunctors
12:34 <ertes> Aruro: there is no category of sets in haskell or type theory for that matter… it's a different mathematical foundation from set theory
12:35 <Aruro> then its not good idea to use same naming
12:35 <Aruro> better invent something more computing friendly
12:36 <ertes> Aruro: i would almost agree, but category theory itself is usually stated in a foundation-agnostic way
12:36 <ertes> Set is an unfortunate counter-example
12:37 <ertes> fortunately a category of types and functions is so similar to Set that you can pretty much use it as a substitute
12:37 robotroll joined
12:38 mda1 joined
12:44 <Aruro> for CT afficionados, parametric types have to be called homomorphisms and simle types objects :)
12:45 <Aruro> no mix two things in one bucket
12:45 <Aruro> i mean on language level
12:45 netheranthem joined
12:46 <ertes> in Hask only concrete types exist… but there is also a category of kinds and type functions
12:47 ExpHP joined
12:47 <ertes> so yes, something like Maybe would be a morphism in the kind category
12:47 <Aruro> i mean data Bool and data Bool1 a , are obviously two different things
12:47 <Aruro> Bool1 a should not be in data keyword
12:47 MindlessDrone joined
12:47 <ertes> why?
12:47 <Aruro> morph Pair a = Pair a a
12:48 <Aruro> data Bool = False | True
12:48 <ertes> maybe you like this syntax better: data Bool1 :: * -> * where …
12:48 <Aruro> yes, helps
12:49 <ertes> @let data Bool1 :: * -> * where False1 :: Bool1 a; True1 :: Bool1 a
12:49 <lambdabot> Defined.
12:49 <lyxia> why use up more keywords when you can just use one
12:49 <ertes> you're welcome to use it ;)
12:49 <Aruro> lyxia: mental honesty
12:49 <Aruro> and clarity
12:49 gawen joined
12:50 <lyxia> I really don't see what's dishonest about Pair a being a "data type"
12:51 e14 joined
12:51 <Aruro> because its not object
12:51 <Aruro> which data naively implies
12:51 <Aruro> well.
12:51 <lyxia> For every object in Hask, Pair a is an object... isn't that sufficient
12:51 <ertes> Aruro: i don't see anyone with deep familiarity with category theory ever making that mistake… it defines a "type"
12:52 <ertes> s/with/without/
12:52 <lyxia> It's like id :: a -> a actually being id :: forall a. a -> a in a way
12:52 <ertes> Aruro: if you really complain on that level, you should be complaining that Hask is a highly questionable category to begin with
12:52 <Aruro> ^ :)
12:53 <Aruro> well, people seem to like sticking with CT models on top of poor hakell
12:53 <Aruro> wanted to make life easier
12:54 <ertes> Aruro: it's like quantum mechanics (a model) and the real world (the application)… CT is a model for haskell, the real world, and it's "good enough"
12:54 rotty joined
12:54 ebzzry joined
12:54 <Aruro> i would introduce explicit keywords Functor Applicative instead of data
12:54 <ertes> you disregard some of the uglier aspects of haskell when using CT or, indeed, even just equational reasoning
12:54 <Iceland_jack> Aruro: Would "data A a b" have a separate keyword? How about higher-order functors like Fix?
12:55 freeside joined
12:55 <Iceland_jack> They are sufficiently distinguished by their kinds
12:55 <Aruro> like -- functor Pair a = Pair a a where fmap =
12:55 gpampara joined
12:55 kirillow joined
12:55 <Iceland_jack> Aruro: What about invariant constructors, like data Endo a = Endo (a -> a)?
12:55 <ertes> Aruro: otherwise you will not be using any form of logical reasoning for haskell, because it's all invalid from a rigorous logical perspective
12:56 <Aruro> ertes: but people seem to ingore this part
12:57 <ertes> Aruro: so you say that logical reasoning shouldn't be used, unless it's 100% rigorous?
12:57 <Aruro> Iceland_jack: i mean i would fuse functor declaration with its data declaration, to make stuff more clear
12:57 dsh joined
12:57 <Aruro> ertes: have no idea, but that is something i would definitely would say at first :)
12:57 <Iceland_jack> I don't see the benefit
12:57 ziocroc joined
12:58 <ertes> Aruro: then, as i said, you will not be using any logical reasoning with haskell… you will not use the fact that fmap is structure-preserving
12:58 <merijn> Fast and Loose Reasoning is Morally Correct! *duck*
12:58 <ertes> Aruro: because it's invalid
12:58 <ertes> Aruro: you see what i mean?
12:58 sdothum joined
12:59 <Aruro> ertes: thats why i would argue for field tested layman alternative to CT
12:59 <ertes> Aruro: why not use CT itself as a model? every model and associated proofs we construct in CT are *valid*, and then we apply them to haskell
13:00 <msl09> can I pattern match an IO?
13:00 <msl09> ioReverse :: IO (String) -> String ioReverse (return (a)) = reverse a
13:00 <msl09> oops
13:00 <ertes> msl09: n
13:00 <ertes> no
13:00 <msl09> why?
13:00 <Iceland_jack> msl09: fmap reverse
13:00 <ertes> msl09: what would (ioReverse getLine) be?
13:01 <ertes> msl09: please state the answer in the form of an equation
13:01 <Aruro> Iceland_jack: u think there is no benefit mergin Functor declaration with its datatype declaration?
13:01 <lyxia> I also think so.
13:01 <ertes> msl09: if, right now, you're thinking: "that doesn't make sense", you're absolutely correct… it doesn't make sense =)
13:01 <merijn> Aruro: Well, why make functor special and not, e.g. also Applicative and Monad?
13:01 <Aruro> i suggest that
13:02 <Iceland_jack> Your proposal is too vague to evaluate
13:02 <Aruro> functor Pair a = Pair a a where fmap =
13:02 <merijn> ertes: You can pattern match IO, though...it just means reaching into GHC's voodoo guts :)
13:02 cobreadmonster joined
13:02 <ertes> merijn: pssssssht
13:03 <Iceland_jack> Not everything "data P a" is a functor, it may not even be "Type -> Type"
13:03 <Aruro> Iceland_jack: then its data
13:03 <Iceland_jack> Not loving the idea :) sorry
13:04 <Aruro> is data P a a data then?
13:04 <Aruro> what is it?
13:04 <merijn> Aruro: I think you're overthinking things
13:04 <Aruro> im reading your code. what shoul i think?
13:04 detrumi joined
13:04 <msl09> ahh I see ertes
13:04 kirillow joined
13:04 <Iceland_jack> It's invalid Haskell
13:05 <ertes> msl09: https://www.vex.net/~trebla/haskell/IO.xhtml
13:05 Itkovian joined
13:05 <Aruro> Iceland_jack: u just got used to data meaning anything :) fine aswell.
13:06 <Iceland_jack> No, I get that meaning from the kinds
13:06 <Aruro> not everybod writes them
13:06 <Iceland_jack> so you want mandatory kind signatures?
13:06 <msl09> the result of (return a) and the result of getLine are completely different things, even though they have the same type declaration
13:06 <Iceland_jack> That's a much better direction imo
13:07 <lyxia> Or have haddock generate it
13:07 <Aruro> no need of mandatory, just said data can be confusing in terms of CT naming convention
13:07 <Aruro> Iceland_jack: ^
13:08 <Aruro> if u will declare something in first place as functor,it CAN (can not) help somebody read your code
13:09 <Iceland_jack> okay
13:09 <ertes> msl09: the thing is: any answer you might give (let's say: ioReverse getLine = "blah"), i would follow up with: "so (ioReverse getLine = ioReverse (return "blah"))? why don't you just use "blah" in the first place?"
13:09 augur joined
13:09 plutoniix joined
13:10 <ertes> msl09: the tutorial i linked explains why it doesn't make sense, and how to actually do it properly *in general*
13:10 stephAne_ joined
13:11 <Iceland_jack> I'd need something more concrete, not saying it couldn't be useful
13:11 jdnavarro joined
13:12 <ertes> Aruro: haskell is not a categorical language
13:12 mmhat joined
13:12 <ertes> CT is just a model we use one abstraction layer above
13:12 <msl09> well I understand that I shouldn't use ioReverse (or that it shouldn't be possible create it in the first place)...
13:12 <msl09> ahhhhhhhhhhhh
13:13 <Aruro> ertes: i agree with u.
13:13 <msl09> I would also be breaking the purity
13:13 <ertes> msl09: first understand what purity means: essentially it means that you can use equational reasoning
13:13 <ertes> with that in mind ioReverse would not make sense at all
13:13 <ertes> msl09: example: this is unconditionally true: getLine = getLine
13:14 <ertes> because equality is reflexive
13:14 <Aruro> msl09: he tells that good haskell program is gian formula and few lines of IO code
13:14 <Aruro> *t
13:14 <ertes> therefore clearly getLine cannot be a string, not even a "tainted string" as some people mistakenly interpret it
13:14 <msl09> yes
13:15 <ertes> Aruro: no, that's not what i'm saying
13:15 <ertes> my code is quite IO-heavy in fact =)
13:15 <Aruro> no? what is equational reasoning then?
13:15 <ertes> Aruro: using equations, along with the usual laws that equality follows
13:15 coot joined
13:15 <Aruro> well that is formula :)
13:15 patbecich joined
13:16 <Aruro> symbolic construction
13:16 <ertes> Aruro: not in code, in reasoning
13:16 Elish joined
13:16 augur joined
13:16 <ertes> for example the monoid laws are stated as equations
13:16 <ertes> but they don't appear explicitly in code
13:16 <Aruro> yes, and allow to treat pure code as formula
13:16 <ertes> of course any equations you write explicitly in code, are also valid equations
13:16 <ertes> foldr f z [] = z -- for all f and z
13:17 fizbin joined
13:17 Detrumi joined
13:17 <msl09> yeah no I'm confused again
13:17 <msl09> I have to read that tutorial
13:17 <ertes> msl09: yes =)
13:17 <mniip> ertes, one catch
13:18 <Aruro> msl09: pure also means returning same result on same input, IO does not have that
13:18 takle joined
13:18 <mniip> f () = 1; f () = 2
13:18 <stephAne_> merijn: I tried implementing your exercise for understanding MonadTransformers, with MyState.hs and MyStateT.hs, but I'm blocked on MyStateT.hs, i have a compile error which I cannot deal with. It's in the implementation of modify and fmap. I have put the compilation error at the top of my code: http://lpaste.net/354240
13:18 <ertes> mniip: indeed, yeah
13:18 <ertes> Aruro: IO is pure
13:18 aarvar joined
13:18 <Aruro> until u run it yes
13:19 uncertainty joined
13:19 <ertes> "until you run it"? you never do in haskell
13:19 <Aruro> main = print
13:19 <mniip> Aruro, of course IO doesn't have that
13:19 <mniip> IO isn't a function
13:19 <mniip> there is no input
13:19 <merijn> stephAne_: line 35, what is the type of mVal?
13:19 <mniip> putStrLn is a function and it returns the same result on same input
13:19 <Aruro> readFile there is input
13:19 <ertes> Aruro: i think you're also using the "tainted" interpretation, and it doesn't really do you any good
13:19 <ertes> Aruro: is getLine a string to you?
13:20 <mniip> Aruro, referential transparency is only concerned about functions
13:20 jgertm joined
13:20 <stephAne_> merijn: i would say m (a, s)
13:20 <mniip> Aruro, we require that 'f (g x) (g x) == let y = g x in f y y'
13:20 <mniip> nothing more
13:20 <merijn> stephAne_: Do you know how "s <- foo; return s" desugars?
13:21 carlosdagos joined
13:21 <mniip> requiring that "do y <- g x; y' <- g x; f y y' == do y <- g x; f y y" would be silly
13:21 <mniip> consider
13:21 <stephAne_> I have to write it down, let me a minute
13:21 <merijn> @undo do { s <- get; return s }
13:21 <lambdabot> get >>= \ s -> return s
13:21 <merijn> stephAne_: So it implicitly uses >>=
13:21 <merijn> :t (>>=)
13:21 <lambdabot> Monad m => m a -> (a -> m b) -> m b
13:21 <ertes> @quote /bin/ls
13:21 <lambdabot> shachaf says: getLine :: IO String contains a String in the same way that /bin/ls contains a list of files
13:22 <mniip> > let g = enumFromTo 0; x = 1; f = (,) in do y <- g x; y' <- g x; f y y'
13:22 <stephAne_> yep, but i always have to rewrite the function bind awaits
13:22 <lambdabot> error:
13:22 <lambdabot> • Couldn't match type ‘(,) Integer’ with ‘[]’
13:22 <lambdabot> Expected type: [b]
13:22 <ertes> Aruro: ^
13:22 <mniip> > let g = enumFromTo 0; x = 1; f = (return .) . (,) in do y <- g x; y' <- g x; f y y'
13:22 <lambdabot> [(0,0),(0,1),(1,0),(1,1)]
13:22 <mniip> > let g = enumFromTo 0; x = 1; f = (return .) . (,) in do y <- g x; f y y
13:22 <lambdabot> [(0,0),(1,1)]
13:22 <mniip> this does not break referential transparency
13:22 <merijn> stephAne_: Well, the 'a' in 'MyState s m a' is basically the 'a' in 's -> (a, s)'
13:22 <mniip> likewise, readFile producing different "results" does not
13:22 <merijn> stephAne_: So the fmap on line 36 is redundant
13:23 <merijn> stephAne_: You want to just do "f mVal"
13:23 <Myrl-saki> lyxia: Thanks.
13:23 bjz_ joined
13:23 <Aruro> mniip: ertes: https://wiki.haskell.org/Pure
13:23 <Aruro> i did not write that page :)
13:23 ogrady joined
13:24 <stephAne_> merijn: do you mean it desugars both from MyStateT and m monad ?
13:24 <ertes> Aruro: it says "function" there
13:24 <ertes> getLine is not a function
13:24 <Aruro> so then its impure
13:24 <merijn> stephAne_: There is only one monad "MyStateT s m" is the monad :)
13:24 <ertes> Aruro: is (3 :: Integer) impure?
13:24 <stephAne_> yep but m is a monad also ?
13:24 <Aruro> its not function as u said
13:24 <Aruro> :t getLine
13:24 <lambdabot> IO String
13:24 <Aruro> ok same here
13:25 <Aruro> :t readFile
13:25 <lambdabot> FilePath -> IO String
13:25 <merijn> stephAne_: Yes, but that's irrelevant now, because GHC isn't using that one, it's using the "MyStateT s m" one
13:25 <ertes> Aruro: readFile is a function, and yes, it's pure
13:25 <Aruro> how?
13:25 <merijn> stephAne_: You used the 'm' monad while implementing "Monad (MyStateT s m)"
13:25 <ertes> Aruro: (readFile "blah.txt") is always the same IO action
13:25 <ertes> Aruro: remember that the result of readFile is *not* a string
13:25 <merijn> stephAne_: But I have a meeting now, I'm sure others here can help you, though :)
13:26 <ogrady> For how long on average does one have to use haskell until one doesn't go to hoogle.com instead of haskell.org/hoogle any more?
13:26 <brynedwards> :D
13:26 <Aruro> ertes: well u just shifted logical meaning towards IO Something being not something
13:26 <stephAne_> I'm going back at it with your remarks, thanks
13:26 <ogrady> *.org
13:26 Yuras joined
13:26 <ertes> Aruro: an IO action is something fundamentally different from its result… see the /bin/ls quote
13:26 <merijn> ogrady: I setup chrome so that "h <search term>" in my address bar just directly searches hoogle ;)
13:27 <merijn> ogrady: Pretty sure firefox let's you do the same :)
13:27 <Aruro> but r <- readFile x is not pure function in Mathematical sense as a function from x to r
13:27 <mniip> 1491225977 [16:26:17] <Aruro> ertes: well u just shifted logical meaning towards IO Something being not something
13:27 <mniip> that's the entire idea
13:27 <ogrady> merijn: that's what I'm about to do. Just trips me up every time
13:27 <mniip> Aruro, you can't write r <- readFile x in haskell
13:28 <ertes> Aruro: let's use a valid example: do l <- getLine; putStrLn l
13:28 <Aruro> no
13:28 <Aruro> there is no argument
13:28 robertkennedy joined
13:28 <Aruro> add argument
13:28 <ertes> Aruro: do s <- readFile "blah.txt"; putStr s
13:28 <ertes> better?
13:28 <mniip> I think they mean \x -> do s <- readFile x; putStr s
13:28 <ertes> (of course putStr(Ln) takes an argument itself, but nevermind) =)
13:29 robkennedy joined
13:29 bennofs joined
13:29 <ertes> it's difficult to tell what they mean =)
13:29 <Aruro> mniip: yes
13:29 <ertes> ok
13:29 tomboy64 joined
13:29 Unhammer joined
13:29 <Aruro> argument is passed to readFile
13:29 <ertes> (\fp -> do s <- readFile fp; putStr s)
13:29 <ertes> good?
13:29 <Aruro> yes
13:30 <Aruro> from fp to s
13:30 <ertes> (\fp -> do s <- readFile fp; putStr s) "blah.txt" -- this is the same IO action every time you write it
13:30 <Aruro> and we are not they :D
13:30 <ertes> indeed, you can replace ((\fp -> do s <- readFile fp; putStr s) "blah.txt") by (do s <- readFile "blah.txt"; putStr s) and get the same program every time
13:31 <ertes> the point is: you're substituting IO actions, not their results
13:31 <Aruro> ertes: i think u want to say that pure implies ref transp but ref transp does not require pure?
13:31 nbro joined
13:31 lush joined
13:31 <ertes> Aruro: no
13:31 arpl left
13:32 <ertes> purity is a vague term
13:32 <Aruro> i gave wiki link
13:32 <Aruro> written by haskell folk
13:32 <Aruro> https://wiki.haskell.org/Pure
13:32 <ertes> and referential transparency is something from linguistics i'm not even sure i understand whether it can be used for a language like haskell
13:32 jathan joined
13:32 <mniip> Aruro, purity implies every function can be implemented with a mathematical function
13:33 afnizarnur joined
13:33 <mniip> and that is not different for readFile
13:33 <ertes> mniip: however, purity implies that you can use equations
13:33 <mniip> hence readFile is pure
13:33 <Aruro> it will give different results depending on the content of the file
13:33 <mniip> no?
13:33 <mniip> it will not
13:33 <ertes> it does not make sense to write something like (f() = g()) in javascript
13:33 <ertes> but in haskell it makes sense to say (x = y)
13:34 <ertes> Aruro: (readFile "blah.txt") does not depend on the file's contents
13:34 <Aruro> (\fp -> do s <- readFile fp; putStr s)
13:34 <mniip> that function is also pure
13:34 <Aruro> this function from fp to s, can give different results on the same fp
13:34 <mniip> no
13:34 <mniip> it is not
13:34 <Aruro> late on in time?
13:34 <Aruro> i changed the file
13:35 <mniip> it is a function from String to IO ()
13:35 AndoBando joined
13:35 <mniip> for the same string
13:35 <mniip> it produces the same IO ()
13:35 <ertes> Aruro: even if you change the file contents during the run-time of the program (readFile "blah.txt") will still be the same IO action
13:35 <ertes> it will still be the IO action that reads the file's contents
13:35 <mniip> Aruro, you cannot conflate functions (a -> IO b) with functions (a -> b)
13:36 <Myrl-saki> I think the "interpreter" "definition" of IO might help.
13:36 <Iceland_jack> yes
13:36 <Aruro> mniip: yeah, u just removed IO a-> a functions, what are we talking about then ? :D
13:36 <Aruro> so long
13:36 locallycompact joined
13:36 <Aruro> all my functions return () therefore im golden
13:36 <ertes> Aruro: what Myrl-saki is trying to say is that you might interpret IO as this: data IO :: * -> * where GetLine :: IO String; PutStr :: String -> IO (); …
13:37 <mniip> there isn't an IO a -> a function (*)
13:37 <ertes> Aruro: in other words: IO does not have any side effects
13:37 ChristopherBurg joined
13:37 <ertes> it's just a DSL
13:38 <Aruro> simply beacuse main is always ()
13:38 <Iceland_jack> (PutStr "hello") versus (PutStr "hello")
13:38 <Myrl-saki> Welp.
13:38 <Myrl-saki> Aruro: Nope.
13:38 splanch joined
13:38 <mniip> Aruro, you're trying to prove that IO is impure
13:38 <Myrl-saki> Aruro: Basically, IO is just a "structure" of the program.
13:38 <Aruro> in above example putStrLn was Discarded as result of program and () was proclaimed as result, problem solved :)
13:38 <mniip> let's define a set of axioms of purity
13:38 <ertes> haskell has composable first-class actions: getLine is the action that reads a line from stdin, (putStrLn s) is the action that writes s to stdout, (getLine >>= putStrLn) is the action that reads a line and then writes it to stdout
13:39 <Myrl-saki> Aruro: It's a "definition" of how the program will run. It's not how the program runs.
13:39 <Myrl-saki> Or something.
13:39 mizu_no_oto_work joined
13:39 <ertes> Aruro: feel free to replace "action" by "program" or "recipe" or whatever
13:39 <ertes> getLine is *not* a string
13:39 <ertes> it's an action/program/recipe that would produce a string
13:39 ystael joined
13:39 <Aruro> ertes: btw lets look at its definition :) what is it?
13:39 <mniip> forall f :: X -> Y. forall x, y :: X. x == y implies f x == f y
13:40 <ertes> Aruro: doesn't matter
13:40 <mniip> Aruro, can you disprove this axiom in case of haskell?
13:40 <mniip> actually, let's be more explicit
13:40 <Myrl-saki> mniip: No swearing please.
13:40 <Myrl-saki> /s
13:40 <mniip> forall X, Y :: Type. forall f :: X -> Y. forall x, y :: X. x == y implies f x == f y
13:41 afnizarnur1 joined
13:41 <ertes> i would write "=" instead of "=="
13:41 <Iceland_jack> PARENTAL ADVISORY #haskell EXPLICIT LANGUAGE
13:41 <Myrl-saki> mniip: forall x :: X. forall y :: Y. ?
13:42 <mniip> x,y,z::t is haskell syntax
13:42 <Aruro> ertes: ok lets sum up, what getLine is?
13:42 <Myrl-saki> mniip: Oh whoops. I misread.
13:42 <Aruro> ertes: u have to define what recepie is, is it a type?
13:43 <ertes> Aruro: a recipe that produces an X is a value of type IO X
13:43 <Myrl-saki> Aruro: It's an action that will return a String.
13:43 <Myrl-saki> s/return/produces/
13:43 afnizarnur joined
13:43 <Aruro> so show is not action?
13:44 <Aruro> :t show
13:44 <lambdabot> Show a => a -> String
13:44 <Myrl-saki> Aruro: No.
13:44 dawehner_ joined
13:44 <ertes> Aruro: correct
13:44 <Aruro> :)
13:44 <Myrl-saki> Err
13:44 meba joined
13:44 <mniip> Show is not an action
13:44 <Myrl-saki> No meaning "no, it is not an action."
13:44 <Aruro> so whole program is pure?
13:44 <ertes> Aruro: 'show' is a value of type (Show a => a -> String), not a value of type (IO X) for some X
13:44 <Myrl-saki> Aruro: It's confusing, isn't it? xD
13:45 <Aruro> :)
13:45 <ertes> it's not that confusing, if you think really really simple
13:45 <Aruro> so all haskell programs are pure? right?
13:45 <ertes> Aruro: correct
13:45 <Aruro> since IO is pure, we are good
13:46 <Myrl-saki> Aruro: Okay, how about this. `int main (void) { printf("Hello world!"); }` should* result in the same code when compiled, right? (* not really)
13:46 <ertes> IO does not break purity, because haskell doesn't allow you to actually execute IO actions
13:46 eschnett joined
13:46 <ertes> there is a good reason why there is no function of type (IO a -> a)
13:46 <Aruro> of course there is
13:46 <Aruro> only outside haskell
13:47 `^_^v joined
13:47 <Aruro> when haskell code is used as intermediate
13:47 <ertes> you could say that
13:47 mada joined
13:47 <Myrl-saki> Aruro: You seem to be starting to get it.
13:47 <ertes> Aruro: but it's not really a haskell function of type (IO a -> a)… it's really just a process outside of haskell that has no in-language counterpart
13:48 AlexRnd_ joined
13:48 <Aruro> so all haskell programs are functions of the type a-> IO ()?
13:48 crobbins joined
13:48 <ertes> a haskell program is typically of type (IO ()), namely the 'main' action
13:49 <Myrl-saki> Aruro: Just IO ()
13:49 <Iceland_jack> All Haskell programs are (IO a)
13:49 <AlexRnd_> Hello! I'm trying to use stack to script my ghc program for the first time and got an error which recommends to add some packages to extra-deps. Details are here - https://pastebin.com/PyRMQtqw , any suggestions?
13:49 <ertes> 'main' can actually have a different result type, because the result of 'main' is ignored
13:49 <ertes> main :: IO String -- so this is allowed, but the resulting String is ignored
13:50 <Aruro> when i type ghc MyGreatCode , isnt ghc :: a -> IO () ?
13:50 bennofs joined
13:50 <Iceland_jack> what is the 'a'
13:50 <Myrl-saki> Aruro: More like IO () -> Obj
13:50 <Aruro> String?
13:50 <Myrl-saki> I think.
13:50 <Myrl-saki> Oh.
13:50 <ertes> Aruro: there is nothing in haskell that corresponds to the "ghc" command
13:50 <ertes> unless you could 'id'
13:50 <ertes> *count
13:51 <Iceland_jack> Aruro: Not within the Haskell language, but you can think of runhaskell as such
13:51 <Myrl-saki> @hoogle (String -> IO ())
13:51 <lambdabot> Prelude putStr :: String -> IO ()
13:51 <lambdabot> Prelude putStrLn :: String -> IO ()
13:51 <lambdabot> Debug.Trace traceIO :: String -> IO ()
13:51 <shiona> what's the philosophy of return codes from programs in haskell? To me it would make sense to have main :: IO Word8 (although that might be too environment-specific)
13:52 <ertes> Aruro: you could imagine a highly magic function of type (IO a -> ByteString) that takes an IO action and produces a compiled program
13:52 <ertes> Aruro: but i would question that it makes much sense
13:52 <ertes> such a function would have to produce an infinite ByteString for something like (forever (putStrLn "blah"))
13:53 <Iceland_jack> shiona: You use special functions for that (exitWith (ExitFailure 4)) just like program arguments
13:53 <Iceland_jack> Main could in theory be defined "[String] -> IO Word8"
13:53 <Iceland_jack> :)
13:54 <ertes> shiona: a 'main' that executes to the end can be interpreted as successful, therefore exitWith actually throws an exception
13:54 <Myrl-saki> @hoogle (IO String)
13:54 <lambdabot> Prelude getLine :: IO String
13:54 <lambdabot> Prelude getContents :: IO String
13:54 <lambdabot> System.Environment getProgName :: IO String
13:54 <Aruro> ertes: mniip: ty was interesting discussion
13:55 <ertes> shiona: some libraries unfortunately abuse IO exceptions for *successful* exits though, like many command line option parsers
13:55 <ertes> (for stuff like "--help")
13:56 <Myrl-saki> I forgot how to free monads lmao
13:56 <lpaste> mniip pasted “IO” at http://lpaste.net/354241
13:56 <mniip> Aruro, take a look at this
13:57 <mniip> this is a pure implementation of IO
13:57 <mniip> with a separate function that "converts" our pure IO into haskell's built-in IO
13:58 Kreest__ joined
13:59 <Aruro> mniip: nice
13:59 CurryWurst_ joined
13:59 <mniip> I could write a readFile in the same fashion
13:59 lush joined
13:59 <mniip> and it would definitely be pure
13:59 coltfred joined
14:00 simukis_ joined
14:01 <Myrl-saki> I was writing one with free monads. <.<
14:01 <Aruro> nice Join :)
14:01 mmachenry joined
14:02 geekosaur joined
14:03 earldouglas joined
14:03 splanch joined
14:03 bjz joined
14:04 geekosaur joined
14:04 rmfnqo joined
14:06 ragepanda joined
14:07 <ertes> Myrl-saki: https://gist.github.com/esoeylemez/93aa5b1553a76469b63d50a2d15eb694
14:07 <Myrl-saki> Oh cool. I wasn't too far off.
14:08 <ertes> i used the church-encoded Free, because 'compile' is easier to write
14:08 <Myrl-saki> http://ix.io/pxU
14:08 <Myrl-saki> I was able to define a functor, but died in the end.
14:08 jgertm joined
14:08 trism joined
14:09 <ertes> Myrl-saki: putStr' :: String -> Interpreter' ()
14:09 augur joined
14:09 <ertes> putStr' s = liftF (PutStr s ())
14:09 gregman_ joined
14:10 <ertes> note: i tend to put the continuation argument first, because it makes those actions a bit nicer to write
14:10 gawen joined
14:10 <ertes> putStr' = liftF . PutStr ()
14:11 puokoy joined
14:11 <ertes> oh, and of course the actual type of putStr' can abstract over the underlying free monad constructor =)
14:11 <Myrl-saki> ertes: Pointfree best freee.
14:11 <ertes> putStr' :: (MonadFree Interpreter' m) => String -> m ()
14:11 <Myrl-saki> ertes: Thanks.
14:11 <ertes> now you can use putStr' with F, Free, FreeT and FT
14:11 puokoy left
14:12 <Myrl-saki> ertes: I forgot how Free is defined. Whoops.
14:12 <ertes> most of the time it doesn't even matter =)
14:12 <ertes> it matters sometimes for interpreters, but very often you can just use iter/iterT
14:12 Rainb joined
14:12 <Myrl-saki> ertes: True, but it would have helped me make the code. :P
14:13 <Myrl-saki> Like, I literally forgot everything about Free except `instance (Functor a) => Monad (Free a)`
14:14 <ertes> instance Monad (F f) -- =)
14:14 <Myrl-saki> ertes: :o It doesn't need a functor instance?
14:14 <ertes> nope
14:14 <lyxia> "Functor a" makes me a bit uncomfortable
14:15 <lyxia> fmap :: (f -> g) -> (a f -> a g)
14:15 <Myrl-saki> lyxia: lmao. I just realized it when I said it.
14:15 <Myrl-saki> lyxia: /o\
14:15 <Myrl-saki> lyxia: How to get banned from a Haskell convention.
14:15 mvr_ left
14:17 <ertes> "i wrote an implementation of the factory/facade pattern in haskell, with full dependency injection… it uses singletons (not the kind of singletons you're thinking of, but REAL singletons)"
14:17 burtons joined
14:17 albertus1 joined
14:18 Randy joined
14:18 aarvar left
14:18 <ystael> ertes: because everybody knows all awesome software contains Spring -- you can't be awesome if you don't have Spring
14:20 dzdcnfzd joined
14:21 yellowj joined
14:21 <mniip> wow
14:21 lithie joined
14:21 <mniip> C++17 is going algebraic
14:21 FreeBirdLjj joined
14:21 <dzdcnfzd> Once again, I'm working with SQL, and once again, I'm desperately wishing that it made select statements / joins / where conditions first class objects that could be manipulated on their own and combined, copied, etc... using variables. Is there a Haskell library that does this sort of thing?
14:22 <mniip> std::variant being a disjoint union type
14:22 <brynedwards> dzdcnfzd: esqueleto , opaleye if you're using postgresql
14:22 <dzdcnfzd> I don't want to have something that takes care of fetching results for me or packing them into records or anything. I just want to be able to manipulate SQL syntax programmatically
14:23 Levex joined
14:24 Sigyn joined
14:25 augur joined
14:26 Luke_ joined
14:27 <dzdcnfzd> brynedwards: thanks!
14:28 <brynedwards> np
14:29 cdg joined
14:29 nbro joined
14:29 crobbins joined
14:32 dni joined
14:33 thallada joined
14:33 uncertainty joined
14:33 BlueShark joined
14:34 chenyu` joined
14:34 carlosdagos joined
14:34 bjz_ joined
14:34 augur joined
14:34 BlueShark|cloud joined
14:35 eazar001 joined
14:36 cpup joined
14:37 thallada joined
14:38 Younder joined
14:38 Benzi-Junior joined
14:42 simendsjo joined
14:42 Luke__ joined
14:43 mattyw joined
14:45 chlong joined
14:45 kadoban joined
14:45 JuanDaugherty joined
14:47 Rodenbach joined
14:47 fkurkowski joined
14:48 squotro joined
14:49 coltfred joined
14:50 FreeMonads joined
14:51 <erisco> is there a modern package for finding prime factors?
14:51 <kuribas> the ghci debugger sucks so much...
14:52 <cocreature> I’ve been meaning to try using the ghci debugger but I always just use printf debugging because I’m too lazy to figure out how to use it
14:53 zariuq joined
14:53 dcoutts_ joined
14:53 <kuribas> cocreature: I wish you could tell it which parts of the evaluation graph to descend, and which to simply force.
14:53 <shapr> I like to write tests.
14:53 tlaxkit joined
14:54 <cocreature> shapr: but what do you do if a test fails? :)
14:54 <shapr> Usually I have enough tests that I know how to fix it.
14:54 NeverDie joined
14:54 <kuribas> shapr: I have this big stateful algorithm, it's hard to test.
14:54 <shapr> oh
14:55 <shapr> No way to break it into pieces?
14:55 <kuribas> I guess I should...
14:55 <shapr> I've heard that debuggers cover a different part of ... programming? than tests, but I don't get it.
14:56 Alphi1 joined
14:56 moongazer joined
14:57 alpha joined
14:58 <cocreature> shapr: well it’s more about when you want to know intermediate states in your tests instead of just knowing that the final result is incorrect. in some cases splitting your test up so that this is not necessary is not possible or more work than just using a debugger
14:58 <kuribas> I have a set of curves, and a new curve which should be added to it, but for some reason it doesn't...
14:58 rossberg joined
14:58 lep-delete joined
14:58 <kuribas> With a proper debugger I should find the reason quickly...
14:58 <Cale> kuribas: There was a tool (or set of tools) called hat which could do this
14:59 <cocreature> tbh 99% of the time when I’m opening gdb/lldb I just want to fix a segfault :)
14:59 HoierM joined
15:00 <dolio> Someone was still developing hat up to 2015.
15:00 <dolio> But it seems to have stopped again.
15:00 <kuribas> The thing I miss in ghci is fine grained control.
15:00 <erisco> you could say it hit a break point
15:01 <kuribas> erisco: If you know the precise location of the error
15:01 hugofirth joined
15:01 <dolio> No, that was a pun.
15:01 <shapr> hit a breakpoint?
15:02 <Cale> Hat's development did ;)
15:02 <kuribas> dolio: oh, right :)
15:02 <dolio> Except I'm not sure hat has breakpoints. That's not the debugging model it's going for mostly.
15:02 <erisco> has that been portmanteau'd already? okay
15:02 raycoll joined
15:03 <Cale> Yeah, it's mostly about unfolding evaluation interactively
15:03 <kuribas> dolio: isn't it just a big dump of the whole execution trace?
15:03 marsam joined
15:03 <dolio> Yeah, with tools to interact with it.
15:03 <geekosaur> wasn't hat replaced by hood/ghood which in turn was replaced by ghc-vis?
15:04 <geekosaur> specifically because hat does evil things that break with every new ghc?
15:04 dcoutts_ joined
15:04 <dolio> geekosaur: If so, that's confusing, because the hat page says it has stuff inspired by hood.
15:04 <geekosaur> would guess that's a backport
15:04 uglyfigurine joined
15:05 <erisco> cabal install primes
15:05 <geekosaur> by whoever picked it up again after its hiatus
15:05 <Cale> Hood and Hat have been developed in parallel over a long period of time
15:05 <erisco> after that compiles I just need to cabal install composites and I'll have all the integers defined
15:05 <Cale> In fact, both were already around when I started programming in Haskell :)
15:06 mmachenry joined
15:06 FreeBirdLjj joined
15:06 cpennington joined
15:07 boombanana joined
15:08 bjz joined
15:11 JagaJaga joined
15:11 <kuribas> this looks interesting: https://wiki.haskell.org/Hoed
15:13 <erisco> > partition False [1]
15:13 bennofs joined
15:13 yinn joined
15:13 <lambdabot> error:
15:13 <lambdabot> • Couldn't match expected type ‘a -> Bool’ with actual type ‘Bool’
15:13 <lambdabot> • In the first argument of ‘partition’, namely ‘False’
15:13 <ventonegro> > partition (const False) [1]
15:13 <lambdabot> ([],[1])
15:14 bjz joined
15:14 np356 joined
15:17 patbecich joined
15:17 <stephAne_> hi, in this code http://lpaste.net/354242 , can someone indicates me why I can write let newVal = f mVal at line 12, for me mVal is not of type s, but of type m(a,s), thus could not be a parameter of f :: s -> s. I'm still stuck at this point.
15:17 <Cale> because mVal :: s
15:18 itachi joined
15:18 <Cale> stephAne_: mVal is the result of executing get, which is an action whose result has type s
15:18 Salih joined
15:19 <geekosaur> stephAne_, look at the desugaring in the comment below, and look at the type of (>>=)
15:19 <geekosaur> :t (>>=)
15:19 <lambdabot> Monad m => m a -> (a -> m b) -> m b
15:20 <stephAne_> but get :: Monad m => MyStateT s m s , contains a function which returns (s,s), not s, isn't it ?
15:20 <stephAne_> m(s,s) I meant
15:20 <glguy> stephAne_: As a technicality, note that let doesn't desugar into a lambda like that, even though it works out in this case to be the same
15:20 <Cale> Internally, but that's an implementation detail
15:20 <ph88> hey guys, i want to send commands to a device, but some sequences of commands are invalid, how can i build some software that checks the sequence before it executes?
15:21 eklavya joined
15:21 <glguy> ph88: You can build some software using Haskell
15:21 <Cale> ph88: Well you see, you build some software that checks the sequence before it executes.
15:21 fizbin joined
15:21 FreeBirdLjj joined
15:22 <ph88> i can interpret it using haskell, but what language ? i can't ask other people to write haskell sorry
15:22 <stephAne_> So in fact I don't understand the get, how it can returns an s, instead of m(s,s)
15:22 <geekosaur> stephAne_, you're confusing the monad with its result
15:22 <Cale> stephAne_: Look at its type
15:22 <Cale> What is the type of get?
15:22 mda1 joined
15:22 <stephAne_> MyStateT s m s
15:23 <Cale> right
15:23 <ventonegro> stephAne_: modify just builds a chain of function calls, `s` will be provided in the future
15:23 <geekosaur> or rather confusing the monad with its desugaring
15:23 <Cale> So this is M s for our monad M = MyStateT s m
15:23 <ventonegro> stephAne_: when it comes, >>= will pass it around
15:23 serendependy joined
15:23 <Cale> So its result simply has type s
15:23 sssilver joined
15:23 <Cale> Don't worry about the internal details of how it's implemented at all
15:23 <stephAne_> as if type s = MyStateT s m s
15:24 <Cale> hm?
15:24 osa1 joined
15:24 osa1 joined
15:24 <Cale> No.
15:24 <stephAne_> or MyStateT s' m s'
15:24 <Cale> Nope, there's only one s
15:24 cloudhead joined
15:24 <Cale> stephAne_: In a do-block for some monad M, when you write:
15:24 <Cale> v <- x
15:24 mthek joined
15:25 <Cale> If x :: M t, then v :: t
15:25 <stephAne_> ohhhhhhhhh i get it
15:25 <stephAne_> many thanks
15:25 <Cale> You can read that as "let v be the result of executing x"
15:26 <stephAne_> sorry for insisting, moment of illumination
15:26 FreeBirdLjj joined
15:26 alexelcu joined
15:27 <ventonegro> insisting till understanding is good
15:27 afnizarnur joined
15:27 <ventonegro> unless your brain starts to hurt, then a pause is also good
15:28 binaryplease joined
15:29 <erisco> I don't think you have nerve endings in your brain
15:29 <ventonegro> interesting... how do headaches work then?
15:30 thimoteus joined
15:31 <erisco> probably similar to a brain freeze
15:32 <geekosaur> over (or sometimes inside; see: sinuses) the skull, not under
15:32 hybrid joined
15:33 yinnn joined
15:33 squotro joined
15:33 <ventonegro> so pretend I just meant "headache"
15:34 squotro left
15:34 tsou joined
15:34 Luke joined
15:34 jmelesky joined
15:34 <ventonegro> the hardest part for me when first learning State was to always keep in mind that the actual state would only come later
15:34 carlosdagos joined
15:35 GreySunshine joined
15:35 Berra joined
15:36 <erisco> > (fmap (product *** product) . zipWith splitAt [0..] . repeat) [2,2,5,5]
15:36 <lambdabot> [(1,100),(2,50),(4,25),(20,5),(100,1),(100,1),(100,1),(100,1),(100,1),(100,1...
15:36 <erisco> thought that was fun :)
15:37 <erisco> um, hm, slight mistake :P
15:37 <michi7x7> erisco: is that arrows?
15:37 conal joined
15:37 <erisco> well I tried to work around an aux definition using zipWith and splitAt
15:37 <erisco> but it is supposed to just give you the partitions
15:38 <Iceland_jack> michi7x7: (***) is from Control.Arrow, but Data.Bifunctor.bimap does the same thing in this case
15:40 <Iceland_jack> @ty [(***), bimap]
15:40 <lambdabot> [(b -> c) -> (b' -> c') -> (b, b') -> (c, c')]
15:40 <erisco> though it is sensitive to ordering. I miss (10, 10) for example
15:40 <rotaerk> hmm, how important was it for the restriction that types start with capital letters and values start with lower-case letters? as in if that restriction were suddenly lifted, what else would have to change to compensate?
15:41 fresheyeball joined
15:41 osa1 joined
15:41 osa1 joined
15:41 meoblast001 joined
15:41 Levex joined
15:41 <glguy> rotaerk: There's no such restriction that types start with capitals and values start with lowercase
15:41 <Athas> rotaerk: you need some other way of doing certain syntactic disambiguation.
15:41 <rotaerk> oh is that just convention?
15:41 oish joined
15:41 <glguy> rotaerk: No, what you wrote just isn't the case. Maybe you meant something different?
15:41 <Athas> rotaerk: no, there is a lexical distinction, but the rule is more complicated than that.
15:42 <Athas> glguy: I feel what is important in the question is not the specifics of the rule, but the purpose it serves.
15:42 <itachi> Hi if I write "let ioi = readIO "1" :: IO Integer"
15:42 <itachi> Is there anyway to use "show ioi"
15:42 <kuribas> > (-1) <$> Just 1
15:42 <itachi> ?
15:42 <lambdabot> error:
15:42 <lambdabot> • Could not deduce (Num a0)
15:42 <lambdabot> from the context: (Num (a -> b), Num a)
15:42 <glguy> Athas: The question as written is just based on a completely false assumption
15:42 <Iceland_jack> itachi: fmap show ioi
15:43 <glguy> Athas: so it's important to understand what is meant before guessing the answer
15:43 <Iceland_jack> fmap show (readIO "1" :: IO Integer) --> "1"
15:43 <rotaerk> well now I have two questions then...
15:43 <itachi> Thanks Iceland_jack
15:43 <Iceland_jack> you're welcome
15:43 <kuribas> why would (-1) <$> Just 1 give Just (-1)?
15:44 <rotaerk> 1) if there were no lexical distinction between type-names and value-names, what would break, what would have to be done to compensate?
15:44 <rotaerk> 2) what exactly is that lexical distinction if not for the case of the starting character
15:44 <Athas> rotaerk: consider a type ascription like 'x : Foo a. With the current rules, you know that 'a' is a type variable. Without it, maybe it's some type 'a' in scope. Maybe 'Foo' is a type variable, too.
15:45 <glguy> rotaerk: constructors are capitalized, variables are lowercased. When a type signatures uses variables we know they are unique to that type signature, but that the type constructors are not
15:45 <Athas> rotaerk: Pattern-matching also becomes more complicated. Maybe a function clause 'f x = x' is a binding of the variable 'x' to any value, and maybe it's matching the constructor 'x'.
15:45 <Athas> (Standard ML has this latter problem, and it's a mess.)
15:45 <glguy> at the value level, constructors can be used in patterns as their own identity while variables introduce new names
15:45 <lyxia> are we talking about values vs types or constructors vs variables
15:46 <monochrom> constructors vs variables
15:46 jao joined
15:46 <rotaerk> got it; thanks
15:47 <Athas> Haskell's solution is very elegant. I believe OCaml does it that way, too.
15:47 govg joined
15:47 vtomole joined
15:47 mtesseract joined
15:47 <monochrom> SML did a right thing at the type level. x is a type constructor. 'x is a type variable.
15:47 augur joined
15:48 <monochrom> Imagine going the last step of doing it at the value level too :)
15:48 <ystael> were those apostrophes originally intended as an ASCII shorthand for Greek letters?
15:48 <Athas> I think Haskell's approach is prettier. Although my favourite approach is to require explicit quantification of type variables, like Purescript does it.
15:48 <Athas> ystael: yes.
15:48 <monochrom> Yes I think so.
15:48 oisdk_ joined
15:48 <Athas> Although I don't think they imagined that it would ever be possible (like the modern Unicode shenanigans in Haskell).
15:49 <ystael> agda syntax is best syntax :D
15:49 <ystael> your code is not awesome until you need a TeX symbol translator to type it
15:49 <erisco> so I need the partitions of all the rotates as well
15:50 <lpaste> mtesseract pasted “Heterogeneous Maps” at http://lpaste.net/354243
15:50 tobiasBora joined
15:50 <rotaerk> I was just wondering because someone mentioned to me that there have been times when haskellers got frustrated over being unable to use upper-case greek letters as variable names
15:51 <rotaerk> so I wondered what would be the harm in lifting that restriction
15:51 <kuribas> how is (-1) <$> Just 1 not a type error (in my ghci session)?
15:51 <Athas> That does sound like something only a Haskeller could get upset about.
15:51 <Athas> I guess it would be harmless to lift it for non-ASCII letters.
15:51 <erisco> kuribas, what does it evaluate to?
15:51 <mtesseract> Hi. I have a question regarding the above pastebin (http://lpaste.net/354243). I am trying to implement heterogeneous maps, but I am wondering if that could be done without OverlappingInstances. The issue is that I have two instances for HMapContains. Is there another way to "propagate" this existence of a key/value pair without such a rather hacky solutions (or is it not to be considered hacky?)?
15:51 <glguy> kuribas: Because you have the Num instance in scope for functions
15:51 <kuribas> erisco: Just (-1)
15:52 augur joined
15:52 <ertes> rotaerk: well, uppercase letters are used for constructors
15:52 <glguy> kuribas: You can use ':i Num' to see all the Num instances as well as the module that's defining an instance on `(->) a`'
15:52 <Iceland_jack> kuribas: it's using a Num (a -> b) instance
15:52 <glguy> oops, left of a variable there
15:53 <rotaerk> ertes, yep, that's what they were saying above
15:53 <glguy> and a letter off of of
15:53 <kuribas> glguy: it says NumInstances-1.4:Data.NumInstances.Function
15:53 <rotaerk> constructors vs variables, not types vs values
15:53 <glguy> kuribas: mystery solved!
15:53 <Iceland_jack> there you go
15:53 SpinTensor joined
15:53 <Iceland_jack> Drinks are on me!
15:53 <ertes> rotaerk: in order to allow that, it would require a special case, and i would actually mind more special cases
15:53 <lyxia> mtesseract: I don't think overlapping instances is *that* hacky
15:53 <erisco> I am not sure how the Num instance for functions makes that type check
15:53 FreeTheMonads joined
15:53 <lyxia> mtesseract: especially if it remains within a single module
15:54 <ertes> rotaerk: we already have enough special cases of that sort (for example type operator variables are no longer possible, because at some point they decided to allow arbitrary operator symbols for type constructors)
15:54 <erisco> (<$>) :: Functor f => (a -> b) -> f a -> f b
15:54 <erisco> ah, because (-1) is polymorphic
15:54 <erisco> that's sneaky lol
15:54 <Iceland_jack> (-1) becomes "const (-1)"
15:54 <lyxia> mtesseract: I just wrote something very similar yesterday, but I didn't think of tracking the keys in the types. https://github.com/Lysxia/type-map/blob/master/src/Data/TypeMap/Internal.hs
15:55 cmsmcq_ joined
15:55 <mtesseract> lyxia: Hmm. Thanks for the comment. I am not really familiar with type-level programming, so I'm not sure if I'm missing something obvious here. :-)
15:55 <erisco> I am not sure how I feel about that
15:55 <ertes> rotaerk: something like (C (-->) a b -> a --> b) used to be possible, but it no longer is, because (-->) can now be a type constructor
15:55 <erisco> it defines number application, and that is weird
15:56 <erisco> i.e. 1 2 = 1
15:56 <mtesseract> lyxia: Yeah, I wanted to get rid of the "Maybe" during a lookup so that it more resembles a record created at runtime.
15:56 <rotaerk> hah
15:57 <ertes> i guess type operator variables are rare enough, but i did use them quite extensively at one point, and i had to rewrite a lot of code when that change happened
15:57 <mtesseract> lyxia: I think there is a general pattern behind this kind of "HasXY"-classes. They can easily be implemented inductively. This means, as I see it, two instance declarations.
15:58 tristanp joined
15:58 dni joined
16:01 sssilver joined
16:01 <Aruro> :t fmap 1 Just 1
16:02 <lambdabot> (Num (Maybe t -> t1), Num t) => t1
16:02 <Aruro> :t fmap 1 (Just 1)
16:02 <lambdabot> (Num (a -> b), Num a) => Maybe b
16:02 <lyxia> mtesseract: yes indeed, but I think you'll still need some form of overlappingness at some level
16:02 <erisco> ah, fun! you can find all the rotations just from the partitions
16:03 <mtesseract> lyxia: Thank you for your input
16:03 <Aruro> :t fmap (1 Just) 1
16:03 <lambdabot> (Num ((a -> Maybe a) -> a1 -> b), Num (f a1), Functor f) => f b
16:03 <erisco> > partitions [1..4]
16:03 <lambdabot> [([],[1,2,3,4]),([1],[2,3,4]),([1,2],[3,4]),([1,2,3],[4]),([4,3,2,1],[])]
16:03 <erisco> see where the rotations are? :)
16:04 raichoo joined
16:05 <lyxia> mtesseract: the hlist package (Data.HList.HList module) has stuff you can reuse here.
16:05 tlaxkit joined
16:05 Gloomy joined
16:05 plutoniix joined
16:05 infandum joined
16:06 <infandum> Is there a way to read a function? Like, read "take 2" :: ([a] -> [a])?
16:06 CurryWurst_ joined
16:06 <Iceland_jack> no
16:06 sssilver joined
16:06 <infandum> Iceland_jack: So there is no way to have a function as a command line input to a program?
16:07 <erisco> > fmap (uncurry (++) . swap) . partitions $ [1..4]
16:07 <lambdabot> [[1,2,3,4],[2,3,4,1],[3,4,1,2],[4,1,2,3],[4,3,2,1]]
16:07 <glguy> infandum: There are packages for helping you to use GHC as a library like mueval and hint
16:07 Sonolin joined
16:08 <Aruro> infandum: problem with types, different functions with have different types
16:08 ragepandemic joined
16:08 <Iceland_jack> infandum: First ask if you need the full power of Haskell
16:09 <Iceland_jack> Do you want to support arbitrary functions or some domain-specific subset
16:09 <monochrom> Yeah, if your usage is limited, it may be more lightweight, and also less security vulnerability, to parse and interpret yourself.
16:09 <infandum> Iceland_jack: I want to let the user input any function they want with type (Data.Sequence Text -> Text)
16:09 <mtesseract> lyxia: I was actually having a look at precisely this module, but didn't find anything helpful for me at first glance (neither did I see something about overlap), but I will check again.
16:10 <infandum> monochrom: I would be most worried about security.
16:11 <infandum> monochrom: But if it's a pure function, there *should* be nothing to worry about
16:11 <infandum> of that type
16:11 <Iceland_jack> infandum: Do you want to parse lambdas? How do you use the resulting function
16:11 argent0 joined
16:11 FreeTheMonads joined
16:12 <Iceland_jack> Lambdas like (\_ -> "hi")
16:12 <infandum> Iceland_jack: That would be fine, yes
16:12 <erisco> > nub . fmap (product *** product) . concatMap partitions . rotations $ [2,2,5,5]
16:12 <lambdabot> error:
16:12 <lambdabot> Variable not in scope: rotations :: [Integer] -> [[t]]
16:12 <Iceland_jack> Hm
16:12 <erisco> > nub . fmap (product *** product) . concatMap partitions . rotations $ [2,2,5,5]
16:12 <lambdabot> [(1,100),(2,50),(4,25),(20,5),(100,1),(10,10),(50,2),(5,20),(25,4)]
16:13 <lyxia> mtesseract: HMember seems relevant, I'm not sure how to use it, but it uses HEq which has the two overlapping instances.
16:13 <glguy> mtesseract: A minor adjustment I'd recommend for your HMapContains class would be to make the class method have type hMap -> proxy key -> valType, rather than making instances with (proxy key) as one of the matched parameters
16:13 <erisco> probably not the best way to do it
16:13 urodna joined
16:15 <monochrom> infandum: If you use mueval or hint, and you check the type, and you know that unsafePerformIO is not imported, then yes.
16:15 ner0x652 joined
16:15 <infandum> monochrom: I'm looking at hint right now (holy moly it's amazing what you can do)
16:15 <infandum> I just need to figure out how to use it
16:17 <infandum> It's looks like I would have to run another interpreter inside the program though, that might be a bit overkill and slow performance down...
16:17 <mtesseract> glguy: Thanks
16:18 <glguy> mtesseract: Are you aware of the vinyl package? It seems to address a similar problem.
16:18 <geekosaur> infandum, yes, haskell is not interpreted, and even if you could so imputting machine code at the terminal is painful
16:18 Argue__ joined
16:19 justan0theruser joined
16:19 <geekosaur> (and wouldn't help much since most functions don't actually work that way in ghc... they're labeled STG graph nodes)
16:20 pera joined
16:21 obadz joined
16:22 <infandum> geekosaur: Maybe I should just provide a bunch of different pre-coded methods and the user can choose
16:22 azahi joined
16:22 <mtesseract> lyxia: I'm looking at it!
16:22 sz0 joined
16:23 <mtesseract> glguy: Yes, looked at it briefly.
16:23 umib0zu joined
16:25 Simted joined
16:26 fotonzade joined
16:27 <erisco> give them K and S and let them at it
16:28 ichor joined
16:30 petercommand joined
16:30 petercommand joined
16:31 zcourts joined
16:33 <nbro> hi guys
16:33 <nbro> I have a Java program to tokenize
16:33 <nbro> do you have any idea what’s meant by "which tokens should get associated lexical values?"
16:33 <nbro> what’s exactly a lexical value?
16:34 fendor joined
16:34 uncertainty joined
16:35 eyck joined
16:35 <erisco> if I was to guess I'd say it was a token, heh
16:35 moongazer joined
16:36 <erisco> maybe they mean, for example, an integer is a lexical value and an INTEGER token maybe associated with this value
16:37 selthas joined
16:37 <erisco> so whatever intermediate values there are to construct tokens with
16:39 FreeBirdLjj joined
16:39 FreeTheMonads joined
16:39 selthas joined
16:39 joe9 joined
16:39 FreeBirdLjj joined
16:39 sssilver joined
16:39 Wuzzy joined
16:39 wraithm joined
16:40 atomi_ joined
16:40 FreeBirdLjj joined
16:41 initiumdoeslinux joined
16:43 sleffy joined
16:43 bennofs joined
16:45 dni joined
16:46 FreeBirdLjj joined
16:46 ludat joined
16:47 <monochrom> nbro: I am going to guess, too, take it with a grain of salt. If I am to write an algebraic data type for tokens, it may go like "data Token = It'sAComma | It'sANumber Integer | It'sAnIdentifier String | It'sADoubleQuote | ..."
16:48 <monochrom> in which the It'sANumber case and the It'sAnIdentifier case are associated with values, whereas It'sAComma and It'sADoubleQuote are not.
16:48 dni_ joined
16:49 <erisco> that is more or less what I meant
16:50 <monochrom> If the input string is like "5,v", my token stream will be like [It'sADoubleQuote, It'sANumber 5, It'sAnIdentifier "v", It'sADoubleQuote]
16:50 <nbro> monochrom: ok, but that depends on the implementation of the lexer
16:50 <nbro> this is actually a manual exercise
16:50 <nbro> so I cannot know which "lexical values" are associated with a token if not in the context of a lexer or scanner
16:51 augur joined
16:51 tathougies joined
16:51 connrs joined
16:56 umib0zu left
16:57 umib0zu joined
16:57 Rainb joined
16:57 <erisco> monochrom, do you prefix all your tokens with It'sA ?
16:58 Gloomy joined
16:58 <rotaerk> data Mario = It'sAMe
17:01 squotro joined
17:01 <lep-delete> i compiled some .hs file to an .o file. how can i load this file in ghci
17:01 nwf joined
17:01 <lep-delete> loading the .hs-file is bad since it takes very long to compile
17:01 <itachi> guys why does "fmap (*2) $ Just 2" work but not "fmap (*2) Just 2" ?
17:02 <shapr> :t fmap
17:02 <lambdabot> Functor f => (a -> b) -> f a -> f b
17:02 <lep-delete> doing just `ghci compiled.o` doesn't work
17:03 <monochrom> erisco: I was being silly. :)
17:03 <infandum> :t flip fmap
17:03 <lambdabot> Functor f => f a -> (a -> b) -> f b
17:04 <infandum> :t fmap (*2) Just 2
17:04 <lambdabot> (Num (Maybe t), Num t) => Maybe t
17:04 <infandum> fmap (*2) (Just 2)
17:04 <erisco> itachi, because fmap (*2) Just 2 is ((fmap (*2)) Just) 2
17:04 darkSeid_ joined
17:04 <infandum> :t fmap (*2) (Just 2)
17:04 <lambdabot> Num b => Maybe b
17:05 <robkennedy> Itachi: the second thing would have fmap as a function of three values whose second argument is `Just` and whose third arg is 2
17:05 Swizec joined
17:05 <itachi> ohh makes sense. I usauly get confused with the order
17:05 <erisco> with the association
17:06 <erisco> which is left-associative for function application
17:07 <itachi> when a fuction is defined as a->b->c->d it is ((a->b)->c)->d right?
17:07 <robkennedy> > fmap (+3) (*5) 10
17:07 <lambdabot> 53
17:07 <robkennedy> Oh crazy didn't know that would work. I don't like it tho
17:08 kosorith joined
17:08 <itachi> Things like these get me confused :/
17:08 zcourts_ joined
17:08 <rotaerk> > (+3) <$> (*5) $ 10
17:08 <lambdabot> 53
17:08 augur joined
17:08 <itachi> How do we get the order in which function will apply?
17:09 <lyxia> itachi: it's the other way around. a -> (b -> (c -> d))
17:09 <erisco> itachi, no, -> associates to the right
17:09 <itachi> So what associates to left?
17:09 <erisco> many things, such as function application
17:09 athan joined
17:10 <itachi> what do you mean be function application?
17:10 <erisco> f x
17:10 <infandum> 2 ^ 2 ^ 3
17:10 <infandum> one day it'll listen to me
17:11 <jle`> infandum: for normal function application, it associates from the left
17:11 <jle`> * itachi
17:11 <jle`> itachi: so f x y z is ((f x) y) z
17:11 <ertes> itachi: f x y = (f x) y
17:11 <erisco> when you juxtapose two expressions in Haskell that means to apply the left expression to the right expression
17:11 <jle`> f 1 2 3 4 5 is ((((f 1) 2) 3) 4) 5
17:11 <itachi> k
17:12 <ertes> itachi: and that's in correspondence with the right-associativity of (->): a "function of two arguments" (A -> B -> C) is really a function of one argument that returns a function (A -> (B -> C))
17:12 kirillow joined
17:12 <infandum> jle`: Which makes perfect sense with the right association with (->)
17:12 <ertes> itachi: so if you apply a function to an argument (f x), the result is a function that you can apply: (f x) y
17:13 JuanDaugherty left
17:13 <itachi> so when I have two function supose f and g when using "f g x" what will happen?
17:13 <infandum> f takes in one argument, 1, returns a function that takes one argument, 2, etc., and in the type you have that same effect, but the parentheses are mirrored because that's how the function is typed (takes one argument, a, etc.)
17:13 oberstein joined
17:13 <erisco> same thing, it is (f g) x
17:13 <jle`> infandum: that's (f g) x
17:14 <ertes> itachi: let's use a practical example: 'map' is a function that takes a function as its first argument
17:14 <ertes> > map sin [1,2,3]
17:14 <jle`> * itachi : that's (f g) x
17:14 <lambdabot> [0.8414709848078965,0.9092974268256817,0.1411200080598672]
17:14 <jle`> do you see the pattern?
17:14 <jle`> f 1 2 3 4 is (((f 1) 2) 3) 4
17:14 <jle`> so f g x a b is (((f g) x) a) b
17:14 <ertes> itachi: but: map sin [1,2,3] = (map sin) [1,2,3]
17:14 <jle`> etc.
17:14 <infandum> :t (.)
17:14 <jle`> it doesn't matter what the variables are called.
17:14 <lambdabot> (b -> c) -> (a -> b) -> a -> c
17:14 <ertes> itachi: (map sin) is the function that applies the 'sin' function to each element of its argument list
17:15 <ertes> > (map sin) [1,2,3]
17:15 <lambdabot> [0.8414709848078965,0.9092974268256817,0.1411200080598672]
17:15 <APic> sin > cos
17:15 <itachi> k. get it now :)
17:15 <jle`> btw, functions are just normal values in haskell
17:15 <APic> Good.
17:15 <ertes> itachi: keep in mind that functions in haskell only ever take exactly one argument =)
17:16 <APic> > (map sin [cos 1, cos 2, cos 3]
17:16 <infandum> itachi: That's what makes curry so powerful
17:16 <lambdabot> <hint>:1:31: error:
17:16 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
17:16 <jle`> so saying "what happens when x is a value for (f x) vs. g is a function for (f g)" is silly, because functions in haskell *are* just values
17:16 <infandum> well it IS currying actually
17:16 <APic> > (map sin) [cos 1, cos 2, cos 3]
17:16 <jle`> so if it works for values, then it works for functions
17:16 <lambdabot> [0.5143952585235492,-0.4042391538522658,-0.8360218615377305]
17:16 <APic> 🙌
17:16 <erisco> help from the Haskell hydra
17:16 rjg_ joined
17:17 <ertes> swarm, not hydra
17:18 patbecich joined
17:18 JuanMiguel joined
17:19 marr joined
17:21 cyborg-one joined
17:21 chlong joined
17:24 Luke joined
17:24 BlueRavenGT joined
17:25 mkoenig joined
17:25 phyrex1an joined
17:25 yhhko joined
17:25 carlosdagos joined
17:27 Sebastian_ joined
17:28 <johnw> jle`: except for 'case', perhaps?
17:28 _sras_ joined
17:28 dni joined
17:30 Salih joined
17:31 oberstein joined
17:34 ixti joined
17:39 <_sras_> How can I do this? http://lpaste.net/177974356595441664
17:39 sigmundv joined
17:39 kirillow joined
17:39 marsam joined
17:40 pgiarrusso_ joined
17:40 <johnw> do you mean: mapM (\(Client amt payAmt) -> Client <$> convert amt <*> convert payAmt) listOfClients
17:41 Rodya_ joined
17:41 plutoniix joined
17:41 <yhhko> _sras_: maybe you want to have a CurrencyRates data type for passing around the going rates for various currencies?
17:41 <yhhko> so you can read that once and use it often
17:42 <erisco> _sras_, updating items in a list is just creating a new list with the items updated
17:42 <erisco> _sras_, so this is just done with fmap
17:42 <_sras_> johnw: Doesn't that make one db call for every client?
17:43 nbro joined
17:43 gillesmajor joined
17:43 gillesmajor left
17:43 <erisco> you can look at the Reader monad to store the currency conversion table
17:43 <erisco> can you retrieve the whole thing?
17:43 <mniip> hmm
17:43 <_sras_> erisco: I am looking for a way to do it in a single db call
17:43 <johnw> _sras_: so, I didn't fully understand your question
17:43 <mniip> since when has lpaste been augmented like this
17:43 <erisco> yes, that is what I am describing with the Reader monad
17:43 fizbin joined
17:44 <erisco> your convert function is going to also take the conversion table
17:44 <_sras_> erisco: I am already inside a reader.
17:44 <erisco> that's fine
17:44 augur joined
17:45 <erisco> you can either add the conversion table to your state or add another reader
17:45 chrisdotcode joined
17:45 <_sras_> erisco: I am aware of that option. But I want the interface of the function to be really simple.
17:45 <erisco> or you do not have to use reader and can use parameter passing
17:45 <dmwit> _sras_: assuming `getConversion :: M (Decimal -> Decimal)` (for some monad `M`), you can `do f <- getConversion; return [Client (f bill) (f payment) | Client bill payment <- clients]`.
17:45 <erisco> well the reader lets you hide away the extra parameter
17:45 jgertm joined
17:46 <lyxia> mniip: That may be what you get with a "private" paste
17:46 <erisco> you cannot have it simpler than it needs to be
17:47 <erisco> Einstein told me
17:47 pdgwien joined
17:49 Xanather joined
17:49 <rotaerk> sure you can; it'll just be wrong
17:50 <dmwit> _sras_: I think erisco's Reader suggestion is overkill, for what it's worth.
17:50 hybrid joined
17:50 <johnw> the _sras_ the mapM statement I wrote would work under Reader as well as under a query environment
17:51 rjg_ joined
17:52 <_sras_> johnw: But it makes two db calls for every client, right?
17:52 <dmwit> Only if `convert` makes a DB call.
17:53 <dmwit> _sras_: What is the type of your DB call?
17:53 rejagr joined
17:54 <_sras_> dmwit: It is a Logger monad wrapped in a Reader..
17:54 pdgwien joined
17:54 <dmwit> _sras_: Let's call your whole monad stack `M`. What is the type of your DB call?
17:54 <erisco> _sras_, I know, try implicit parameters
17:54 <erisco> that should keep your code perfectly concise
17:55 <dmwit> Ignore erisco. This is a simple problem, and begs for a simple solution, not overengineering.
17:55 eacameron joined
17:55 <erisco> dmwit, are you serious?
17:55 mtesseract joined
17:55 <dmwit> I am.
17:55 <erisco> well you're just wrong
17:55 <erisco> try out implicit parameters and you'll see it can work for this problem very well
17:56 <erisco> just bring the conversion table into scope and then any call to convert can pick it up implicitly
17:56 troydm joined
17:56 TesX[m] joined
17:56 <dmwit> Boring old explicit parameters work just fine as well.
17:56 <_sras_> :dmwit convert :: [Money] -> Currency -> m [Maybe Money]
17:57 <dmwit> _sras_: Hm. Is `Money` a number-like type?
17:57 bollu joined
17:58 <_sras_> dmwit: It wraps a Currency and a number.
17:58 <_sras_> Currency is just newtype over string..
17:59 locallycompact joined
17:59 <dmwit> _sras_: Cool. How hard would it be to write `[Currency] -> Currency -> m [Money -> Maybe Money]` instead?
17:59 <dmwit> Or perhaps something like `[Currency] -> Currency -> m [Maybe Multiplier]`?
18:00 connrs joined
18:00 ragepanda joined
18:00 <dmwit> Sorry, the first suggestion should be something like `[Currency] -> Currency -> m [Maybe (Decimal -> Decimal)]` or so.
18:01 deepfire joined
18:02 <_sras_> dmwit: That interface is too complex...
18:02 kuribas left
18:02 bollu joined
18:02 <dmwit> Too complex for you to understand, too complex to implement, too complex to use?
18:03 <_sras_> Too complex to use.
18:03 <dmwit> Okay. Unfortunately there is a fundamental tradeoff between simplicity and efficiency that pervades computer science.
18:03 <_sras_> This is a simple functionality..
18:03 yellowj joined
18:03 <dmwit> Also, `Currency -> Currency -> m (Maybe Multiplier)` or similar doesn't *seem* complex to use to me.
18:04 <_sras_> dmwit: Ofcourse..I don't debate that. Just wondering if there is some thing obvious that I am missing....
18:04 Robert5 joined
18:05 <dmwit> Well. I think you could potentially use the type you gave (`[Money] -> Currency -> m [Maybe Money]`). But then there will be some annoying work to do to convert your `Client`s to `[Money]`s and back.
18:05 <dmwit> Whereas the interface I'm proposing will be much simpler to use on `Client`s directly, and I think not that much more cumbersome for implementation and other uses.
18:07 pdgwien joined
18:07 <sm> in johnw's first suggestion (eg) you just bind "convert" once, it won't keep calling the db
18:08 <_sras_> dmwit: Isn't it better to 'seed' a function with conversion rates, using partial application, and use it to convert all the clients?
18:08 <dmwit> _sras_: Isn't that what I'm suggesting?
18:08 <_sras_> In a way, yes
18:09 <dmwit> `[Maybe (Decimal -> Decimal)]` is the list of (possible) conversion functions, partially applied to the source and destination currencies.
18:09 <dmwit> Or `[Maybe Multiplier]` is the "reified" version, under the assumption that all conversion functions are just multiplications.
18:09 uglyfigurine joined
18:10 Kundry_Wag joined
18:10 vydd joined
18:10 vydd joined
18:10 <athan> Anyone here ever mess around with deriving storable?
18:11 moongazer joined
18:11 <sm> dmwit: pardon me if I'm out of line but aren't you too complicating it now :)
18:11 <dmwit> sm: I'm perfectly open to simpler suggestions.
18:12 augur joined
18:12 ertesx joined
18:12 <dmwit> sm: I'm operating under a few assumptions that make me think I'm not complicating it, though, which may not be apparent. The main one being that fetching multiple conversions from the DB at once can be done more efficiently than making multiple fetches of single currency pairs.
18:12 <athan> er wait, why aren't lists storable?
18:12 <dmwit> Storable instances all have fixed in-memory sizes.
18:13 <athan> ...or CStrings? :(
18:13 <dmwit> :t sizeOf
18:13 <lambdabot> error:
18:13 <lambdabot> • Variable not in scope: sizeOf
18:13 <lambdabot> • Perhaps you meant one of these:
18:13 <glguy> CStrings have fixed size, they are pointers
18:13 <sm> I probably missed some extra requirement in there..
18:14 <dmwit> Well. `sizeOf :: Storable a => a -> Int`, but also the documentation demands "The value of the argument is not used.".
18:15 <glguy> sizeOf hails from a simpler time when people didn't know properly guard their proxy arguments
18:15 <dmwit> athan: `instance Storable (Ptr a)` and `type CString = Ptr CChar`
18:15 Argue__ joined
18:15 <athan> wait I'm silly, sorry. Thanks dmwit
18:15 <c_wraith> yeah, Storable isn't appropriate for recursive data structures
18:15 <athan> sorry yall :x
18:17 <dmwit> (Aside: since johnw didn't show the implementation of `convert`, I'm not convinced that "it won't keep calling the db".)
18:18 chaosmasttter joined
18:20 Levex joined
18:22 troydm joined
18:23 ph88^ joined
18:24 tobhe joined
18:25 event_null joined
18:25 event_null left
18:25 crobbins joined
18:25 pdgwien joined
18:26 Shatnerz0 joined
18:27 <_sras_> dmwit: It is no big deal..
18:31 a3Dman joined
18:32 Younder joined
18:32 augur joined
18:33 Apocalisp joined
18:33 mmachenry joined
18:34 gpampara joined
18:34 <johnw> dmwit: convert :: MonadReader m Prices => Decimal -> Decimal
18:36 troydm joined
18:36 kickliter joined
18:36 Itkovian joined
18:37 kickliter left
18:38 a3Dman joined
18:39 MrWoohoo joined
18:41 filterfish_ joined
18:41 Guest6344 joined
18:41 featherlessbiped joined
18:41 space-marmot joined
18:41 Sebastian_ joined
18:41 noan joined
18:42 litchblade joined
18:42 ChaiTRex joined
18:42 simukis_ joined
18:42 JuanMiguel joined
18:43 Rodya_ joined
18:43 subttle_ joined
18:43 pdgwien joined
18:45 vydd joined
18:45 TheLemonMan joined
18:48 azahi joined
18:49 dfeuer joined
18:50 Levex joined
18:52 twanvl joined
18:52 bollu joined
18:54 fizbin joined
18:56 marcopullo joined
18:57 augur joined
18:57 <dmwit> Earlier I dismissed erisco and his contributions out of hand, rather than focusing on technical advantages and disadvantages of various approaches. That was unprofessional, and I apologize for losing my cool in that way.
18:57 crobbins joined
18:57 <erisco> thank-you dmwit. you're a frequent and positive member of the community and I think we can put this incident behind us
18:58 marsam joined
18:58 caasih joined
18:58 mda1 joined
19:00 fizbin joined
19:01 subttle_ joined
19:02 nbro joined
19:03 <NemesisD> hey folks. i'm working on a logging library and was looking for some advice. internally every time you log it pushes it into a bounded queue and a background worker for each backend reads from this queue and basically calls a callback for it in IO
19:05 zcourts joined
19:05 <NemesisD> this means that the worker can be blocking since its inputs are already buffered. but what if a backend wants to have a pool of concurrent threads. one option is they could start a bounded queue themselves and maintain a worker pool that reads from it. another is to use an MVar and have the threads fight over it. is this a Very Stupid Idea?
19:05 fizruk joined
19:06 <ocharles> If I have a [Map k1 (Map k2 (Map k3 a))] - what's the best way to collapse that list down into a single Map k1 (Map k2 (Map k3 a)) ? I can use Map.unionsWith (Map.unionWith (Map.unionWith mappend)) , but it seems a shame to have to drop straight down to pairwise combination from the first map
19:06 <NemesisD> the disadvantage with having a backend maintain its own queue is that at worse you're using up 2x queue bound * message size of memory, whereas using an MVar at the inner level it would be queue bound * message size + message size
19:08 <Cale> NemesisD: I don't think it would be too silly to use an MVar
19:08 <Cale> It also shouldn't be too bad to use an unbounded Chan
19:08 <Cale> I haven't ever run into issues with either
19:08 <NemesisD> well an unbounded chan is dangerous here if the backend goes offline
19:08 <Cale> Basically because it's very rare to be doing so much logging that it would be an issue
19:09 Rodya_ joined
19:09 <Cale> Why would it? Won't you just have a tight "forever" that takes things off the Chan and writes them?
19:09 <c_wraith> I've run into issues with a Chan for logging.
19:09 <NemesisD> so for instance one backend is elasticsearch. if elasticsearch gets congested or has temporary networking issues, your logs will build up in memory
19:10 <Cale> ohh
19:10 <NemesisD> by using a bounded queue i'm saying if the queue is full, your writes get dropped
19:10 <c_wraith> it's easily possible to outpace the logging output if it's not going to file.
19:10 <Cale> okay, I was thinking it would just be writing to a file
19:10 <NemesisD> oh sorry, we support that but also other backends
19:10 <Cale> Yeah, use an MVar then
19:11 Aruro joined
19:11 <ocharles> Oh, unionsWith isn't anything but a bunch of mappends anyway
19:11 <Cale> Well, it'd be fair to use a bounded channel, that will eventually behave like the MVar once enough congestion happens, and block things
19:11 <NemesisD> i should just benchmark. i guess the test would be to pump N messages through outer bounded queue -> inner bounded queue -> worker pool, stop timing when all queues are flushed vs outer bounded queue -> inner mvar -> worker pool, stop timing when outer queue is empty, mvar is empty
19:12 <NemesisD> ocharles: i was staring at the problem and couldn't see why mconcat wouldn't work
19:12 <Cale> But it might be a little bit nicer when there's no congestion
19:12 <ocharles> NemesisD: it all works fine, I just wondered if there was anything more efficient
19:12 <ocharles> though mconcat on Map itself is useless, as is Map's monoid instance
19:12 caumeslasal joined
19:13 <NemesisD> ah ok so you're trying to merge values when keys match
19:13 tobhe joined
19:13 subttle_ joined
19:13 Rodya_ joined
19:14 <NemesisD> @ocharles i just recently heard of https://hackage.haskell.org/package/containers-0.5.10.2/docs/Data-Map-Merge-Strict.html in a blog post http://teh.id.au/posts/2017/03/03/map-merge/index.html but i havn't read it yet. maybe check it out
19:14 <lambdabot> Unknown command, try @list
19:14 <NemesisD> whoops, this isn't twitter
19:15 nbro joined
19:16 augur joined
19:16 <ocharles> NemesisD: Mmm, I do know of that - it's quite cool
19:16 herr_jth joined
19:19 Discovery joined
19:20 loli_angel joined
19:20 loli_angel left
19:21 splanch joined
19:23 darjeeling_ joined
19:23 <Myrl-saki> Errr
19:23 grayjoc joined
19:23 tempu joined
19:24 marcopullo joined
19:24 <Myrl-saki> According to Linear types can change the world, is `f : U -o V |- f : U -o V` valid?
19:24 <Myrl-saki> With VAR rule
19:25 augur joined
19:26 bodisiw joined
19:27 <tempu> what does this mean? "Normal a a Normal m s is a normal distribution with mean m and stddev sd." (from https://hackage.haskell.org/package/random-fu-0.2.7.0/docs/Data-Random-Distribution-Normal.html)
19:27 <tempu> or is it just a typo?
19:27 tathougies joined
19:27 carlosdagos joined
19:27 pmikkelsen joined
19:28 oberstein joined
19:28 <shapr> In Python, I really miss being able to know what input type a function requires.
19:28 <Myrl-saki> tempu: Not really.
19:28 <Myrl-saki> tempu: I guess it should be Normal m sd.
19:28 <Myrl-saki> tempu: But the `Normal a a` is correct. For the type to be correct.
19:29 mstruebing joined
19:29 <tempu> Myrl-saki: thanks, doesn't "a a" imply that it takes two arguments of the same type?
19:29 <Myrl-saki> tempu: Mhm.
19:29 <n1k> yesx
19:30 <yhhko> Myrl-saki: i don't know that paper but it looks like an instance of the identity function, which is usually linear?
19:30 abra0 joined
19:31 <Myrl-saki> yhhko: U -o V is not linear.
19:31 <Myrl-saki> s/linear/identity/
19:31 <yhhko> Myrl-saki: the map (U -o V) -o (U -o V) is
19:31 <Myrl-saki> yhhko: Ah. It's the VAR rule, which is `x : T |- x : T`
19:32 <Myrl-saki> rule/axiom
19:32 <yhhko> (do you mean i answered your question?)
19:33 <Myrl-saki> yhhko: Indirectly, I think.
19:33 <Myrl-saki> I also see no other way to introduce a -o.
19:36 Itkovian joined
19:38 bjz joined
19:40 deepfire joined
19:40 mizu_no_oto_work joined
19:41 Mon_Ouie joined
19:42 govg joined
19:42 lush joined
19:42 <tempu> where am i wrong? i'm trying to a random value from a normal distribution (via Data.Random.Distribution.Normal) "normal 4 (Normal 0 1)"
19:43 <* tempu> is struggeling with the syntax
19:44 augur joined
19:44 <Myrl-saki> tempu: the type of 4 is different from (Normal 0 1)
19:44 ccomb joined
19:44 <Myrl-saki> 4 :: Num a => a; (Normal 0 1) :: Num a => Normal a
19:46 <tempu> Myrl-saki: how else would i include the seed?
19:47 <Myrl-saki> tempu: Is 4 the seed?
19:48 Coldblackice joined
19:48 <tempu> oh no, i assumed Normal includes it
19:48 <Myrl-saki> tempu: What do you mean?
19:50 obadz joined
19:50 subttle_ joined
19:51 <tempu> Myrl-saki: oh, i'm supposed to use "normal 0 1" instead, since it constructs the Distributed Normal right?
19:51 `^_^v joined
19:52 chlong joined
19:52 <* tempu> is confused
19:53 fotonzade joined
19:53 <Myrl-saki> tempu: Seems so.
19:53 <Myrl-saki> tempu: Though, you might want to use stdNormal
19:53 hybrid joined
19:54 bollu joined
19:54 <tempu> i'd like to make sigma variable
19:56 gpampara joined
19:56 oisdk joined
19:57 <tempu> means stdNormal seems out of question (assuming i got the docs right=
19:57 gawen joined
19:57 squotro joined
19:59 slacker joined
20:00 chaosmasttter joined
20:00 squotro joined
20:02 nycs joined
20:03 augur joined
20:03 mizu_no_oto_work joined
20:05 kolko joined
20:07 fXl joined
20:07 yellowj joined
20:08 Rodya_ joined
20:09 squotro joined
20:09 <Myrl-saki> From Wadler's Linear types can change the world, I can only define id and nothing else. =_=
20:09 Ferdirand joined
20:09 <Myrl-saki> x : T |- x : T
20:10 <Myrl-saki> |- (\x : T. x) : T -> T
20:10 <Myrl-saki> Anything else seemes Impossible...
20:10 cloudhead joined
20:11 <fXl> Hello guys, i am trying to implement the question on geeksforgeeks. I am getting these errors https://hastebin.com/ugoqudixih.sql , http://www.geeksforgeeks.org/find-missing-number-arithmetic-progression/
20:11 <Myrl-saki> I mean -o
20:11 <fXl> The code also in there, can you guys have a look at ?
20:11 Philonous joined
20:12 dni joined
20:13 augur joined
20:14 hackebeilchen joined
20:14 sophiag joined
20:15 <hexagoxel> fXl: `search y:ys` is parsed as `(search y):ys`. you'd probably get a better error when adding a type signature for `search`.
20:16 mattyw joined
20:17 <erisco> hrm, if you have an enumeration, how might you start the enumeration at a favourable element?
20:17 Coldblackice joined
20:17 <erisco> so for example, say you have the Cartesian product of two lists of integers, and you prefer to see pairs of square numbers first
20:19 <fXl> hexagoxel: okey i added type signature
20:19 markasoftware joined
20:19 <Myrl-saki> erisco: sortBy?
20:19 dawehner joined
20:19 <erisco> so I want to express all the elements of the numeration but be flexible in the order they are enumerated
20:20 <erisco> no the point is that they have to be enumerated in a favourable order to begin with, not ordered after the fact
20:20 <ski> Myrl-saki : `|- (\x : T. \f : T -o U. f x) : T -o ((T -o U) -o U)' should be possible
20:21 cdg joined
20:21 sssilver joined
20:22 augur joined
20:23 np356 joined
20:23 <ski> Myrl-saki : with "either", "tensor", "with", "void", "unit", "erase", "of course", more interesting stuff should be possible
20:23 otulp joined
20:23 <Myrl-saki> ski: Of course! (no pun intended)
20:24 <Myrl-saki> ski: (Actually, pun totally intended.)
20:24 <Myrl-saki> ski: What I'm confused about though is how he got ther.
20:24 <Myrl-saki> ski: I've been playing with my pencil and paper for so long already, and the only thing that I can define is id (or I).
20:24 <Myrl-saki> s/ther/there/
20:25 aglorei joined
20:25 ChaiTRex joined
20:25 Sh4rPEYE joined
20:25 <ski> Myrl-saki : `flip' should be totally possible
20:25 <Sh4rPEYE> Hello. I'm going through Haskell Book and I'd like to ask, why should foldMap for Constant be defined like this. Could somebody elaborate?
20:26 <Sh4rPEYE> newtype Constant a b = Constant a
20:26 <Myrl-saki> ski: I'm curious how to do it using the inference rules.
20:26 <Sh4rPEYE> instance Foldable (Constant a) where foldMap _ _ = mempty
20:26 fnurglewitz joined
20:27 <erisco> :t foldMap
20:27 <lambdabot> (Monoid m, Foldable t) => (a -> m) -> t a -> m
20:27 <ski> Myrl-saki : if you're familiar with inference rules, it shouldn't be too hard to figure out (since they're syntax-directed here .. except for weakening and contraction (and exchange if you include that), but in this case those only applies for "of course" (and "why not") but you don't use that for `flip')
20:27 <Myrl-saki> ski: Should I just skip Linear types can change the world and go to A taste of linear logic*?
20:28 Rodya_ joined
20:28 <Myrl-saki> ski: I'm not too familiar with them, to be honest.
20:28 hackebeilchen joined
20:28 <ski> Myrl-saki : if you're not that familiar with inference rules, then perhaps "Polymorphic Type Inference" by Michael I. Schwartzbach in 1995-03 at <http://web.cecs.pdx.edu/~antoy/Courses/TPFLP/lectures/TYPE/typeinf.p(s|df)> could be of some use
20:29 <* ski> doesn't recall which of "Linear types can change the world" and "A taste of linear logic" would be more demanding
20:29 <Myrl-saki> ski: Also, I'm currently only interested in the linear system as defined by Figure 2.
20:29 carlosdagos joined
20:30 Kundry_Wag joined
20:31 <erisco> :t foldMap :: Monoid m => (b -> m) -> Constant a b -> m -- does it make sense now Sh4rPEYE?
20:31 <lambdabot> error:
20:31 <lambdabot> • Could not deduce (Foldable (Constant a1))
20:31 <lambdabot> arising from a use of ‘foldMap’
20:32 <erisco> okay, well, it would specialise in that way
20:32 <Myrl-saki> ski: Oh wait. I think I've been overthinking it.
20:32 <Myrl-saki> ski: Do I literally just define it using VAR?
20:33 <ski> ok, so that gives you "void","either","unit","tensor", but not "erase","with","bot","par","of course","why not"
20:33 augur joined
20:33 <ski> define what using `VAR' ?
20:33 <Myrl-saki> The combinators.
20:34 <ski> .. i also don't what you mean by "defining something using `VAR'"
20:34 mmhat_ joined
20:34 <ski> for `id' above, you used `VAR' to introduce the identifier expression `x'
20:34 <Myrl-saki> ski: Right.
20:34 <Myrl-saki> ski: How would I work with flip?
20:34 <ski> i wouldn't call that defining anything, but perhaps this is what you meant
20:35 <Sh4rPEYE> erisco: Oh, of course. At first I though you would have to return 'f b', but as b is discarded, I have to return mempty.
20:35 locallycompact joined
20:35 <Myrl-saki> ski: Mhm. That's what I meant.
20:35 ompaul joined
20:35 balor joined
20:36 <erisco> Sh4rPEYE, as far as I can tell there is actually no obligation to use f in any implementation
20:36 centrinia joined
20:36 <ski> Myrl-saki : very commonly, it's easiest to construct a derivation tree employing inference rules, by first setting out the root (the end goal) (possibly not having pinned down the (whole) expression to derive yet, only the context and the type of the expression), and then work backwards/upwards from that
20:36 <Myrl-saki> ski: I see.
20:36 <erisco> but in spirit you're supposed to
20:36 takle joined
20:36 <ski> i would say that `VAR' establishes a use of an identifier
20:37 Rodya_ joined
20:37 <ski> if reading the derivation tree top-down (from leaves to root/goal), then `VAR' could be said to introduce a variable (both into the context, and into the expression on the right)
20:38 <ski> if reading the tree bottom-up, then the rule for lambda, and the one for `case', introduces variables
20:38 <Sh4rPEYE> erisco: It makes sense this way... Sort of "I have b, I want to have m. Luckily I also have m->b"
20:39 Gloomy joined
20:39 <erisco> I mean if the foldMap instance for [a] also just returned mempty I don't see what law that violates
20:39 eacameron joined
20:40 <erisco> other than it clearly goes against the spirit of Foldable
20:40 Itkovian joined
20:40 <Sh4rPEYE> Oh, yes, it is possible to define it like that.
20:41 fizruk joined
20:41 <Sh4rPEYE> Anyway, thanks :-) Good night
20:41 uglyfigurine joined
20:41 <erisco> though it should alarm that there may be problems with Foldable...
20:41 <erisco> if I can write a universal instance
20:41 squotro joined
20:43 <ski> given `sing :: a -> t a', one could want `forall f. foldMap f . sing = f', aka `(. sing) . foldMap = id'
20:43 <Myrl-saki> ski: Question. What does it mean/imply when the left side of the turnstile is empty?
20:43 <ski> that the expression has no free variables, that it is a combinator
20:44 <Myrl-saki> ski: Ohhh
20:44 <Myrl-saki> ski: Right. Since the assumption list is a context?
20:44 <ski> the context/environment, the list of free-variable & type associations is empty
20:44 <Myrl-saki> ski: I see. Thanks.
20:45 <ski> Myrl-saki : did you look at the Schwartzbach paper i mentioned ?
20:45 <Myrl-saki> ski: Mhm.
20:45 <erisco> ski, maybe Foldable should have been defined with a sing then
20:45 <Myrl-saki> ski: Still at page 4-5. Went back to Wadler's though, to try going from bottom-to-top on the combinators.
20:46 fresheyeball joined
20:46 <ski> Myrl-saki : ok
20:46 <erisco> ski, I am not sure it fully captures the wishes though
20:46 squotro joined
20:46 <erisco> for example, why couldn't the list instance ignore all but the head
20:47 <erisco> since sing will only give singleton lists
20:47 <ski> erisco : maybe. it's not that clear how much is has to do with "folding", though
20:47 <fresheyeball> anyone here know how to tell xmonad to use my whole display for the layout?
20:48 fXl left
20:48 squotro joined
20:49 <erisco> if it is Alternative then perhaps foldMap f (x <|> y) = foldMap f x <> foldMap f y
20:49 <* ski> was just thinking of `Alternative'
20:49 anuxivm joined
20:49 <ski> but then how should `foldMap' interact with `(<*>)' ?
20:50 squotro joined
20:50 le_frogballs joined
20:51 Rodya_ joined
20:51 squotro left
20:52 takle joined
20:52 Salih joined
20:54 balor joined
20:55 <Myrl-saki> ski: I think I'm close. :D
20:56 vimto joined
20:56 <Myrl-saki> ski: I've done all the -oIs now. I just need to do the -oE.
20:57 diegoksp joined
20:58 <erisco> ski, I don't know, how are <|> and <*> supposed to interact?
21:00 <Myrl-saki> ski: Thanks. I understand way better now.
21:02 strykerkkd joined
21:03 <ski> erisco : <https://en.wikibooks.org/wiki/Haskell/Alternative_and_MonadPlus#Other_suggested_laws>
21:03 <Myrl-saki> ski: In Schwartzbach's paper, does A differ from ellipses?
21:03 <erisco> http://stackoverflow.com/a/13081604/260584
21:04 <Myrl-saki> ski: Page 4's inference rules.
21:04 Itkovian joined
21:04 <ski> `A' there is a meta-variable standing for a context / type environment / "symbol table"
21:05 <Myrl-saki> ski: So A is there verbatim?
21:05 <ski> for the variable rule, `...,x : sigma, ...' means a context with `x : sigma' occuring in it somewhere
21:05 <Myrl-saki> ski: Ah.
21:06 <ski> a common alternative way to write this would be `A_0, x : sigma, A_1'
21:06 <ski> or even `A, x : sigma', if we take the context to be a set (or at least bag), rather than a list
21:06 mekeor joined
21:06 <ski> this notation is also used in the rule for lambda there
21:06 <Myrl-saki> ski: Right. Such as Wadler's VAR for nonlinear type.
21:07 <erisco> seems we're too late for Alternative/Applicative laws
21:07 <erisco> not sure how one became a sub class of the other without the laws prescribed
21:07 <Myrl-saki> ski: Okay. I'm pretty sure I'm getting this so well now.
21:07 squotro joined
21:07 <Myrl-saki> ski: So, in the case of `A |- 0 : Int`, there's nothing required of the context.
21:07 squotro left
21:08 <Myrl-saki> ski: It can be literally anything.
21:08 peterbecich joined
21:08 <sophiag> i'm a bit confused about how to use overlapping instances. i have two data types with a Maybe field and one requires me to derive an instance of Show. in addition to the regular derived instance, i had to derive one for (Maybe a) as well (a bit confused as to why), which i guess overlaps with the Maybe field in the other data type. and putting the overlapping pragma in the derived instance for Maybe didn't resolve the error. would
21:08 <sophiag> anyone mind explaining how this works?
21:08 <ski> Myrl-saki : yep
21:08 <Myrl-saki> I'm pretty sure I read something similar in one of Wadler's papers.
21:09 <ski> Myrl-saki : you can think of it as an implicit weakening on all unused variables being built-in to all "leaf" rules there
21:09 hamishmack joined
21:09 <Cale> How to use overlapping instances: Step 1. Fix your instances so that they don't overlap. Step 2. Thank yourself later.
21:09 <ski> Myrl-saki : and similarly an implicit contraction being built-in to the branching rules
21:09 <Myrl-saki> ski: Makes sense.
21:09 <Cale> sophiag: What are your instances?
21:10 <geekosaur> why would you need to derive an instance for Maybe a?
21:10 Itkovian joined
21:10 beerdrop joined
21:11 <erisco> ski, foldMap (uncurry f) (x >*< y) = fold (f <$> f <*> y)
21:11 <erisco> where (>*<) x y = (,) <$> x <*> y
21:11 <Myrl-saki> "the first because -oI places no constraint on the assumption list, and the second because ->I places no constraint on the argument or result type." (A taste of linear logic, p. 13)
21:11 <ski> Myrl-saki : this is handy if you're building your derivation bottom-up (from root to leaves), since you delay the choice as much as possible. if you instead wanted to build your derivations top-down (from leaves to root), then you'd "go to the other extreme", so to speak
21:11 <erisco> sorry, that should be fold (f <$> x <*> y) on the right
21:12 <Myrl-saki> ski: Wait, which part here is the root and which part here is the leaves?
21:12 <ski> erisco : "Warning: Singleton variables : `x'"
21:12 <Myrl-saki> ski: Oh wait. Root is the end, right?
21:12 <sophiag> Cale: well as mentioned, one is for (Maybe as), which i'm confused as to why i needed it just because the other field in the data type (i'm using record syntax) needed it derived. the one that's actually throwing the error is another with record syntax and a similar Maybe String field that i don't need a standalone instance for
21:12 squotro joined
21:12 <ski> Myrl-saki : yep
21:12 <erisco> ski, hm?
21:12 <ski> root is the end goal
21:12 squotro left
21:12 <sophiag> *that should read (Maybe a)
21:12 <Myrl-saki> ski: Thanks.
21:12 <ski> erisco : `c' doesn't occur on the right hand side of that equation
21:12 <ski> er, `x', not `c'
21:12 azahi joined
21:13 <erisco> ski, see my correction
21:13 <ski> ah
21:13 <Cale> sophiag: I can't tell why they'd overlap if I don't know all the instance heads
21:13 <sophiag> Cale: these are the ones that are overlapping: http://lpaste.net/354249
21:14 <Cale> oh, you can't derive an instance of Show for Maybe because that already exists
21:14 <sophiag> yeah, hence why i'm confused...
21:14 <Cale> So just delete that line
21:14 <erisco> ski, it doesn't look so pretty but that is what I could think of
21:14 squotro joined
21:14 <sophiag> without that the instance below it throws an error tho
21:14 <Cale> Yeah, but what error?
21:15 <sophiag> "No instance for (Show (Val -> Maybe Val)) arising from a use of ‘showsPrec’ (maybe you haven't applied a function to enough arguments?)"
21:15 BlueShark left
21:15 <ski> erisco : i suspect that can be derived from interaction with `fmap'
21:15 <* geekosaur> just saw that. yes, you cant Show a function
21:15 <erisco> ski, eh, I think that is already covered by the stated relation to fmap
21:15 <geekosaur> has nothing to do with Maybe
21:15 <Myrl-saki> ski: This reminds me. What's with Linear types can change the world's grammar? I can follow it, but it seems less... formal/
21:16 <sophiag> geekosaur: i suspected as much. i'm always freaked out when things compile that don't make sense to me
21:16 <ski> Myrl-saki : page ?
21:16 <erisco> ski, yeah I really have to pull the <*> outside but I am not sure how that would be done
21:16 <geekosaur> well, you can "show" it but you can't derive it, you have to write your own instance that ignores or prints a constant string for the function
21:16 <Cale> sophiag: The problem there is that you have no instance of Show for functions.
21:16 <Myrl-saki> ski: Page 5, for example.
21:16 <sophiag> Cale: so what geekosaur said?
21:17 <Myrl-saki> T ::= K | (U -> V)
21:17 <Myrl-saki> Why not, say, `T :: = K | (T -> T)
21:17 <sophiag> i need to actually write the instance?
21:17 <sophiag> err function rather
21:17 Rodya_ joined
21:18 <ski> Myrl-saki : some people would say `t,u,v ni T ::= K | (T -> T)'
21:19 <erisco> but regardless we can have the <|> interaction which is straight-forward
21:19 <Myrl-saki> ski: That makes me a bit more confused, what happens to t, u and v?
21:19 <Cale> sophiag: An instance of Show for functions, yeah, and there really isn't a possible good instance, so you have to write a half-assed one if you want that Show instance.
21:19 <erisco> and <|> in turn interacts with <*>
21:19 <Myrl-saki> ski: Why state it when it's not anywhere else?
21:19 <Cale> sophiag: So something like instance Show (a -> b) where show _ = "<function>"
21:19 <sophiag> Cale: are we talking something similar to to Show1 from prelude-extras?
21:19 <Myrl-saki> ski: Oh wait. I think the problem is that I don't understand the grammar of the grammar either.
21:20 <ski> Myrl-saki : in that version `t',`u',`v' would be actual meta-variables, while `T' should be thought as the (meta-)type of them. cf. `data T = Base K | Fun T T'
21:20 <Cale> no
21:20 <Myrl-saki> ski: Ahh
21:20 <Cale> Just plain Show from ordinary Prelude
21:20 <Cale> sophiag: So just stick in that line that I wrote
21:21 <sophiag> just asked because Show1 seems to have a similar implementation to what you wrote
21:21 <Cale> and it should be able to give you a Show instance for the other thing
21:21 <erisco> together with the sing law, though it would be now the pure law, you get exactly how it should work for lists
21:21 <edwardk> import Text.Show.Functions -- its in base for the silly reason that its a godawful terrible orphan but at least this way it only comes from one place if you need it
21:21 <sophiag> anyway, i'm a little unsure what the actual function body should be...
21:21 <Myrl-saki> ski: Thanks so much. ; ^ ;
21:21 <ski> Myrl-saki : the purpose of ⌜t,u,v ∋ T ∷= ⋯⌝ would be to express the intent of using ⌜t⌝,⌜u⌝,⌜v⌝ as meta-variables for terms
21:21 <sophiag> edwardk: thanks! must be the power of keyword notifications :)
21:22 <edwardk> sophiag: just good timing =)
21:22 Rodya_ joined
21:22 <erisco> foldMap f (pure x <|> pure y) = foldMap f (pure x) <> foldMap f (pure y) = f x <> f y
21:22 <edwardk> sophiag: Show1 is for containers that are showable if their arguments are showable
21:23 <edwardk> that is a different concern
21:23 <sophiag> ah ok. i know someone in another channel who has it set so he just pops up whenever someone mentions his name or anything he's worked on
21:23 fizbin joined
21:23 ubsan_ joined
21:23 <mniip> hey edwardk do you know of a construct diverse enough to represent vector spaces in a useful way?
21:23 <Myrl-saki> ski: i don't quite understand why \ni.
21:23 <sophiag> but Text.Show.Functions provides functions for types that aren't showable otherwise?
21:23 <mniip> representable functors are kind of close
21:23 <edwardk> i do pop up when my name is mentioned or when a couple of keywords get mentioned (i rotate the keywords occasionally) but if my machine dinged whenever anybody mentioned anything i wrote, i'd go mad ;)
21:24 <mniip> but apparently there are vector spaces that aren't representable
21:24 <edwardk> mniip: all vector spaces are free vector spaces, so representable functors are exact. everything else is a cheat ;)
21:24 <edwardk> there are _modules_ that aren't free
21:24 <mniip> yeah but
21:24 <ski> Myrl-saki : er, sorry, on second thought that should be `\in'
21:24 <edwardk> but all vector spaces are
21:24 <Myrl-saki> ski: Ah. Makes sense now. Thanks.
21:25 <ski> (maybe i've seen ⌜T ∈ t,u,v ∷= ⋯⌝ ? not sure)
21:25 <edwardk> ideals for rings aren't a free module for instance
21:25 <mniip> edwardk, the vector space of Z_2 sequences with finitely many ones
21:25 <mniip> edwardk, it is countable, and aleph-null-dimensional
21:25 <mniip> while 2^aleph-null = aleph-1
21:25 <Cale> sophiag: What did you mean by "the actual function body"?
21:26 <Cale> sophiag: You can't *actually* turn a function into a string in a meaningful way most of the time
21:26 <edwardk> mniip: how does that get in the way of it being representable?
21:26 <mniip> hey sophiag still battling your lambdas issue?
21:26 <Cale> sophiag: So the best you can do is just produce a stupid string like "<function>" because it's essentially a black box.
21:26 Rodya_ joined
21:26 <mniip> edwardk, the space isn't an exponential object at all
21:27 <sophiag> Cale: i know what you meant now because it's in the docs for the library edwardk showed me
21:27 <Cale> ah :)
21:27 <sophiag> something like: "showsPrec _ _ = showString \"\<function\>\""
21:27 <Cale> Yeah, I literally meant the code that I wrote -- I didn't mean for you to fill that bit in or anything :)
21:27 <geekosaur> sophiag, if you could access the function body it would be an STG graph, not meaningful to anyone who saw it
21:27 <sophiag> i didn't realize that
21:28 <geekosaur> this is not python or some other interpreted language, the source does not exist at `show` time
21:28 <sophiag> geekosaur: no i thought he was using a placeholder, like "fill this part in"
21:28 <mniip> edwardk, there is not a D for which 2 -> D ~ N
21:28 azahi joined
21:28 <mniip> no wait
21:28 <mniip> D -> 2
21:28 <Cale> Though I think it would be really cool if you could build programs in a mode where the runtime expression graph would be useful to humans.
21:29 <hpc> lisp? ;)
21:29 <edwardk> You have (N -> Z_2) with the constraint on the function that the function can only return 1 for a finite number of D. so here's where we run into the issue with variance involved with the representable form.
21:30 <mniip> representable functors imply an isomorphism don't they
21:30 <edwardk> In a real free vector space we'd be able to say you have some kind of map from basis elements to values, that is only finite in length. this would be covariant in the basis.
21:30 AndreasK joined
21:30 <mniip> here we clearly have a one-way injection
21:30 carlosdagos joined
21:30 <edwardk> the problem here is that using (R^x) directly we've incurred an extra 'twist'
21:31 <edwardk> there is an adjunction * -| *, so if we look at the form i tend to encode vector spaces with in haskell, then what we really do is move to the 'free vector space' and then compose with the * above.
21:31 <mniip> *?
21:32 <edwardk> unfortunately this can be bigger
21:33 <edwardk> the dual space operator
21:33 <mniip> ah
21:33 <edwardk> anyways this is why we can get back to a monad for (a -> r) ->_L r
21:33 <edwardk> where ->_L is assumed to be a linear functional
21:34 <edwardk> this is the underlying 'lie' that makes linear, etc. all work
21:34 <hpc> not gonna lie, i read that as bottom for a second
21:34 <edwardk> which is why the docs there talk about them as useful for 'low dimensional' vector spaces
21:34 <* ski> did as well
21:34 <edwardk> hpc: =)
21:35 kadobanana joined
21:35 <scav> what kind of editor are you guys using? just emacs/vim or anything heavier? coming from a java/scala background I am used to everyone just running the same IDE.
21:35 <edwardk> i live in vim personally.
21:35 <ski> emacs here
21:35 Younder joined
21:36 robertkennedy joined
21:36 <edwardk> there are plugins for emacs/vim that make your haskell development feel IDE-like. i've not had much in the way of good experiences with them. YMMV. Others seem to get by
21:36 <scav> well, i generally just enjoy some kind of auto-complete, i don`t need a full blown ide experience
21:36 azahi joined
21:37 <thimoteus> neovim here
21:37 <mniip> plain vim with no completiong here
21:37 <mniip> 1491255213 [00:33:33] <edwardk> anyways this is why we can get back to a monad for (a -> r) ->_L r
21:37 <mniip> edwardk, mind expanding on that?
21:37 tput- joined
21:38 <edwardk> i don't mind, but my thinking is pretty fuzzy today. (i'm at the end of a long diet before i do a radiation thing tomorrow, and my ability to think is pretty frazzled)
21:39 Rodya_ joined
21:39 <edwardk> i wrote up a bunch of this somewhere to turn into an article. i just don't know where i put it
21:39 <mniip> ouch
21:39 <sophiag> Cale: to be clear, it can only print <function> in ghci, but the function is still there when i want to use it, right? i finally got all the parsing to compile so want to make sure it's working correctly...
21:40 <scav> thank you for your answers guys, still trying to find a non-intellij editor i can live with :)
21:40 <sm> good luck edwardk
21:40 <mniip> get well soon then!
21:40 <geekosaur> sophiag, it's there, just not in a form that prints nicely
21:40 <edwardk> anyways, a 'proper' free vector space would only have a finite number of non-zeroes, so you could put it into a covariant form like [(e, r)] or Map e r.
21:40 <edwardk> once you add the *'s that come along above, it gets bigger, allowing an infinite number of non-zeroes
21:41 <sm> scav: I'm using intellij along with emacs, but no real completion/smart jumps, just project-wide search
21:41 <sophiag> geekosaur: thanks. i don't need it to actually print
21:41 <edwardk> but we recover the size stuff by using the requirement of linearity in the ->_L, when we talk about the new "dual" space
21:43 <edwardk> e.g. instead of looking at sequences of Z^2 with finitely many 1s, we can look at linear functionals (N -> Z_2) ->_L Z_2, which can only query at finitely many locations and still be linear. the problem turns on its head.
21:43 <edwardk> the trick then becomes dualizing all of your problem statements in this manner ;)
21:43 ebzzry joined
21:43 squotro joined
21:44 <edwardk> i've had some success doing this with things like geometric algebra to get a form of geometric coalgebra, etc.
21:44 <edwardk> but i also never really wrote any of that up
21:46 <edwardk> anyways this ->_L thing is a rather dubious story, which is what led me to work out with a coworker what is really going on involving the composition of the free -| forget adjunction for free vector spaces and the * -| * adjunction for dual spaces
21:46 <mniip> edwardk, wait
21:46 <mniip> is this the same lie
21:47 <mniip> as X ~ (X -> Bool) -> Bool
21:47 <edwardk> its related, here we're not requiring the last function to be any function but rather ->_L which is more constrained. you can get more information out
21:47 <mniip> where your function can only be so complex because it has to be expressed with a finite piece of code and executed in finite time?
21:47 squotro joined
21:47 <Cale> sophiag: That's right.
21:48 <edwardk> but as intuitions go, you're on track
21:48 bjz joined
21:48 <mniip> no wait
21:48 <edwardk> we're basically working with Cont, but requiring linear operators for instance denies you callCC.
21:48 <mniip> that was something else
21:49 <mniip> I think it was Eq a => Eq ((a -> Bool) -> Bool)
21:49 <edwardk> instance Eq a => Eq (Cont Bool a) ?
21:50 hamishmack joined
21:50 <edwardk> both that and the ~ you gave come down to the same issue
21:50 <mniip> http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/
21:50 <edwardk> but on the other hand (forall r. (a -> r) -> r) ~ a
21:51 <edwardk> so if we put constraints on how we use 'r' we can get more information out.
21:51 <mniip> forall r. sure
21:51 ebzzry joined
21:51 <edwardk> i'm offering up Codensity here as an example
21:51 <edwardk> all the free vector spaces can't care what 'r' is in their operation
21:51 <edwardk> so its closer to truth than you'd think
21:51 <Cale> It would be interesting to think about whether other continuation-y types have compact topologies
21:51 Eduard_Munteanu joined
21:52 <edwardk> anyways, yeah, i was going to point you to the seemingly impossible functionals bit =)
21:52 hiratara joined
21:53 <mniip> wondering if it'd be possible to define a Representable'y typeclass for vector spaces that is actually useful
21:54 <edwardk> mniip: linear just gives up and adds an 'Additive' class that is completely ad hoc and suite to dealing with maps, etc. as infinite dimensional sparse vector spaces
21:54 squotro joined
21:55 <mniip> problem is,
21:55 <edwardk> i wonder if i should consider a form of linear algebra based on discrimination to fold over common basis elements
21:55 <mniip> R-> is a vector space functor
21:55 <mniip> so it gets to be an instance
21:55 <mniip> what can we do with it in haskell? Nothing
21:55 <mniip> basis? it exists. Can we see it? nah
21:56 <edwardk> i can add them, subtract them, give you a zero vector... ;)
21:56 <mniip> well
21:56 <mniip> that much you can do with Representable
21:56 <edwardk> i can query it at individual basis elements to figure out the projection onto that basis
21:56 <mniip> f + g = tabluate (\x -> index f x + index g x)
21:56 <edwardk> by dint of it being, you know, a function =)
21:56 <mniip> yeah no
21:57 <mniip> you can't query it at basis elements that have infinite support
21:57 <mniip> and there isn't a basis of only finite support in R->R I don't think
21:57 <edwardk> well, sure, we're stuck in constructive 'at the end of the day i have to compute something' land
21:58 <edwardk> once you start talking about infinities everywhere you get all sorts of things you can only talk about obliquely
21:58 <edwardk> maybe what you really want is a theorem prover
21:58 `^_^v joined
21:58 <mniip> hmm
21:58 e_svedang joined
21:58 <mniip> what *is* (X -> Bool) -> Bool
21:59 <mniip> if -> is from Hask and not Set
21:59 azahi joined
21:59 <mniip> that is, has a computable implementation
21:59 squotro joined
21:59 <ski> (do you mean it's algorithmic, or only that it's computable ?)
22:00 eschnett joined
22:00 <mniip> ski, algorithmic?
22:00 bjz joined
22:00 <ski> implementable as a finite program, with lambda calculus or whatever
22:00 <edwardk> it lets you smuggle out as much information about X as you can get by asking it a finite number of boolean valued questions. to do more you need to know more about that function.
22:00 <jle`> mniip:
22:00 <mniip> ski, no like it can run on TM in a finite amount of steps
22:01 robkennedy joined
22:01 <edwardk> in Hask there is no requirement that it runs in a finite amount of steps
22:01 <edwardk> just that you get _|_ if you try to do more
22:01 <jle`> oh, sorry
22:01 <edwardk> as Bool isn't just True and False, but also potentially _|_
22:01 <ChaiTRex> True | False | FileNotFound
22:02 <edwardk> i find thinking about hyperfunctions and the like informative when you play with questions like these, because they highlight the importance of _|_ in the language
22:02 <hpc> ChaiTRex++ for putting true and false in the objectively correct order :D
22:02 <ski> you could imagine a program of type `(Nat -> Y) -> Z' being fed a stream of input from the external world (perhaps temperature readings or something), without needin to know whether those temperature readings can be described by an algorithm
22:02 <edwardk> if we require computability in finite time for all inputs the space of programs shrinks alarmingly.
22:03 <edwardk> and you get things like Cont Bool Natural ~ Natural !!?!?
22:03 <mniip> they're all countable
22:03 <ski> (ditto for implementing addition of real number represented by cauchy sequences. it doesn't matter whether here those sequences are algorithmic, it only matters whether you can compute them, somehow)
22:03 <edwardk> N = 2^(2^N) is completely nonsensical in Set, but here in Hask, restricted to computations that terminate in finite time holds.
22:04 <* ski> . o O ( bar induction )
22:04 <edwardk> https://github.com/ekmett/hyperfunctions/blob/master/examples/Cantor.hs#L33
22:04 <mniip> ski, f :: (X -> Bool) -> Bool, such that, assuming x :: X -> Bool is computable then f x is computable
22:04 contiver joined
22:05 <* ski> nods
22:05 meandi joined
22:05 <edwardk> ^- that code shows an isomorphism between Natural and (Natural -> Bool) -> Bool in hask
22:05 <edwardk> where the latter are constrained to be any function that terminates in finite time for all inputs
22:05 squotro2 joined
22:07 <edwardk> did i ever mention that hyperfunctions are weird =)
22:07 silver joined
22:07 <edwardk> they make mockery of many Set-based assumptions
22:07 e14 joined
22:08 <edwardk> ChaiTRex: you got the capitalization wrong: =) https://hackage.haskell.org/package/acme-php-0.0.3/docs/Prelude-PHP.html
22:09 kgadek_ joined
22:09 <hpc> to be fair it took me a couple of hours to write that package
22:10 <hpc> even i can't get code to work perfectly the first time
22:10 <edwardk> =)
22:10 <mniip> type Bool = Int#
22:10 zipper joined
22:10 <Eduard_Munteanu> @src Bool
22:10 <lambdabot> data Bool = False | True deriving (Eq, Ord)
22:11 <edwardk> mniip: my current code is basically implementing booleans as a 256 bit wide register full of 8 32 bit ints that are all 0 or ~0, so not too far off base. =)
22:11 <ph88^> how does this parser work? https://hackage.haskell.org/package/megaparsec-5.0.0/docs/src/Text-Megaparsec-Combinator.html#endBy let p = char 'a'; let end = char ';' then a; should be ok .. but aa; should fail ?
22:11 <mniip> ~0 :D
22:11 <mniip> just like BASIC
22:11 <mniip> seriously though that thing was genious
22:11 <mniip> logical and same as bitwise and
22:11 Supersonic112_ joined
22:12 <ChaiTRex> edwardk: The mathematics functions in that are nice.
22:13 <Eduard_Munteanu> ph88^, yes
22:13 <mniip> weird
22:13 <mniip> did my acme-iot package get lost
22:13 ExpHP joined
22:13 <edwardk> ph88^: endBy p sep = many (p <* sep) -- does what it says on the tin.
22:13 <mniip> or did I never submit it
22:14 texasmynsted joined
22:14 <pikajude> someone really needs to start designing tins for library functions
22:14 <mniip> ah there it is https://hackage.haskell.org/package/acme-iot
22:14 <edwardk> e.g. endBy (many (char 'a') semi) parses aaaa;aaa;aaaa;aaaaa; but you have to rememberthe trailing ;
22:14 <mniip> should fix up the categries
22:14 fizbin joined
22:15 <edwardk> in your case aa; fails because it matches 'a' then it goes to match the ';' and fails to find it between the first a and the second.
22:15 <ph88^> edwardk, ya actually i know it does that out of experience .. but by reading the code for it i don't understand the why. Because i thought when you try to parse first p and then end and end fails that the whole parser fails and many stops trying another time
22:15 <edwardk> this combinator doesn't include a try block, but if megaparsec is like all the oher parsec/trifecta/etc. alikes thenyou giveup
22:16 <mniip> https://hackage.haskell.org/package/acme-iot-0.1.0.1/docs/Control-Monad-Trans-IO.html#t:IOT
22:16 <edwardk> ph88^: ah you're confused by try semantics
22:16 <edwardk> ph88^: in general parsec style parsers only try the next <|> if they left hand side didn't consume any input
22:16 <edwardk> er the
22:17 SkinnyFart joined
22:17 <edwardk> so 'p' "consumed" an a before end failed, so the many can't fail over to its other case.
22:17 deepfire joined
22:17 <ph88^> so the fact that something was already consumed makes the parser succeed ?
22:17 <splanch> the consumed cont is infectious
22:18 <ph88^> i'm talking about the (p <* end) parser
22:18 <ph88^> which i read: parse p and then parse end and return p
22:18 <ph88^> so if end fails it still returns p ?
22:18 <edwardk> lets take many q = qs where qs = (:) <$> q <*> qs <|> pure []
22:18 <edwardk> and consider many (char 'a' *> char ';')
22:18 <edwardk> er <*
22:19 <ph88^> oh you fmap : over the parser ?
22:19 <edwardk> just supplying a stock definition of 'many'
22:20 squotro joined
22:20 <edwardk> http://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html#many writes it in an ass-backwards manner, but it translates ot thesame thing
22:21 <ph88^> q stands in for the result of (p <* end)
22:21 HallaSurvivor joined
22:21 <edwardk> q _is_ p <* end
22:22 fXl joined
22:22 <edwardk> many (p *< end) = qs where qs = ((:) <$> (p <* end) <*> qs) <|> pure []
22:22 <edwardk> added some unnecessary parens for emphasis
22:23 <HallaSurvivor> Hey, why can I write: data Tree a = Node (a, [Tree a]) deriving Eq
22:23 <HallaSurvivor> Shouldn't I need to place an Eq restriction on a?
22:23 <edwardk> many (p <* end) = qs where qs = do { x <- p; _ <- end; xs <- qs; return (x:xs) } <|> pure [] -- if you prefer do notation
22:23 <ph88^> so you run the parser, it consumes input, and then gives that input back and then you cons it
22:23 <HallaSurvivor> but GHCI is totally fine with it
22:23 <edwardk> HallaSurvivor: if you look at your derived instance, it figures out it needs that Eq
22:23 <edwardk> and writes instance Eq a => Eq (Tree a)
22:23 <fXl> hello, i am trying to implement this in Haskell. http://www.geeksforgeeks.org/find-missing-number-arithmetic-progression/ , i couldnt make it happen, can anybody help me on this one ?
22:23 <fXl> here what i did so far, https://hastebin.com/imelinepey.vbs
22:23 <jle`> HallaSurvivor: use :i Tree to see
22:23 <ph88^> i just thought that if _ <- end fails that it doesn't get to return (x:xs)
22:24 <edwardk> if you need particularly tricky constraints you can't use 'deriving' but have to use 'standalone deriving' where you can hint to the compiler that stuff
22:24 <edwardk> but in this case the compiler is smart enough to figure it out
22:24 <HallaSurvivor> edwardk: that's pretty cool O.o
22:24 <HallaSurvivor> jle`: thanks! I almost never use :i, so i forget it exists, haha
22:24 <ph88^> edwardk, does return (x:xs) still work because the result of end (the _) is not used in the return statement ?
22:25 <edwardk> it doesn't make it there
22:25 <edwardk> it fails to parse, thenit doesn't terminate the list either
22:25 <edwardk> so the whole failure cascades out
22:25 <edwardk> a;a;a; parses fine
22:25 <edwardk> a;a;aa fails and parses _nothing_
22:25 <edwardk> it complains about a parse error at the second a in aa
22:25 <ph88^> ya ok, but how can aa; parse fine ?
22:25 <edwardk> it can't
22:26 <edwardk> endBy (char 'a') (char ';') applied to aa; will fail
22:26 <ph88^> oh ok
22:26 <Eduard_Munteanu> endBy (many1 (char 'a')) (char ';') would succeed, though.
22:26 <edwardk> aa; -- will complain about no parse being available because it expects a ; at the second a
22:26 <edwardk> :t some
22:26 <lambdabot> Alternative f => f a -> f [a]
22:27 <edwardk> endBy (some (char 'a')) (char ';') will parse aa;aaaaa;aaa;aa;
22:27 <ph88^> i understand it now
22:28 <edwardk> endBy (many (char 'a') (char ';')) will parse a;a;;;;aaaaa;;;;; so long as the last thing is a ;
22:28 <edwardk> er i missed a paren
22:28 <edwardk> endBy (many (char 'a')) (char ';') will parse a;a;;;;aaaaa;;;;; so long as the last thing is a ;
22:28 e14 joined
22:29 <edwardk> the key to all of this is knowing that parsec doesn't backtrack and try the <|> branch when you've consumed input and that 'try' resets knowledge that you've consumed input on failure, erasing error location information, but allowing you to try the other branch.
22:29 <ph88^> i just got tripped up on that if you do (many (char 'a')) on aa; that you think it fails on ; but actually it doesn't because it succeed on aa
22:29 <ph88^> it's like try one 1 parser
22:30 <edwardk> many p -- always succeeds, so long as p either consumes something or fails without consuming anything
22:30 Wuzzy joined
22:30 <edwardk> if you had many (char 'a' *> char 'a') then tried to parse an even number of 'a's it'll give you a list of the results. if you try to parse an odd number of 'a's it'll die hard with an error pointing to the last one.
22:31 hiratara joined
22:31 <edwardk> many (try (char 'a' *> char 'a')) -- will succeed regardless, and consume an even number, leaving the last odd one there if it was unmatched
22:32 <edwardk> try semantics are important to error reporting. this is why attoparsec can never give you real error messages.
22:32 <edwardk> because it always backtracks and has no clue what to say was the problem
22:32 <edwardk> the flip side is that 'try' is a terrible combinator for error reporting
22:32 squotro joined
22:32 <edwardk> because you always should use try p <?> "something"
22:33 <edwardk> so that error reporting has a thing it can say was the missed alternative
22:33 nomicflux joined
22:33 <ph88^> an idea i had for maybe later is first try to parse with attoparsec for speed and then if it fails reparse the whole thing with megaparsec
22:33 fizbin joined
22:33 SkinnyFart left
22:33 <edwardk> ph88^: you can do that with the combinators in 'parsers', btw.
22:33 <edwardk> well, i never wrote megaparsec instances because that wasn't a thing and i don't see the point, but anyways
22:34 <edwardk> i can parse with attoparsec or whatever then switch to trifecta for nice errors.
22:34 tswett_to_go joined
22:34 jayshua joined
22:34 <ph88^> you reparse the whole input or backtrack a little bit and then reparse with trifecta ?
22:35 <fXl> hello, i am trying to implement this in Haskell. http://www.geeksforgeeks.org/find-missing-number-arithmetic-progression/ , i couldnt make it happen, can anybody help me on this one ?
22:35 <edwardk> good question. right now? just reparse the whole thing. i don't have much in the way of support infrastructure around this
22:35 <fXl> here what i did so far, https://hastebin.com/imelinepey.vbs
22:35 <edwardk> i just write my combinators generic in the "TokenParsing" instance or whatever, then just invoke it twice
22:35 chreekat joined
22:35 Warrigal joined
22:36 <edwardk> the problem is attoparsec doesn't know what code path 'doomed' it to failure
22:36 <ChaiTRex> fXl: To do it in O(n) time, you'll need arrays rather than lists.
22:36 <edwardk> backing up a little bit would require knowledge of what went wrong and why
22:36 <ChaiTRex> fXl: I mean O(n log n)
22:36 anuxivm joined
22:36 <ChaiTRex> fXl: log n*
22:36 <ph88^> edwardk, ye me too, i have a typeclass where i write the code once and then depending on what i want returned i get a parser or a printer, but i can easily add a parser from another library
22:37 <edwardk> i've had bad luck writing mixed parser/pretty printing libs in haskell, but i'm glad its working out for you
22:37 LeNsTR joined
22:37 <edwardk> i do use a trick like that in c++ though
22:37 <fXl> ChaiTrex: i am just trying to implement it first, but couldnt make it :D
22:38 <monochrom> Haha yikes, parse the second time in case of parse error :)
22:38 <ph88^> eh sorry i don't mix the parser with the printer .. i mix the parser with the arbitrary generator
22:39 <ChaiTRex> fXl: You can use (!!) to get an element at a certain index, much like using arr[i].
22:39 <edwardk> the general approach in the crytek serialization library / glenn fiedler's articles:http://gafferongames.com/building-a-game-network-protocol/serialization-strategies/ works really well there
22:39 <ph88^> monochrom, when you have a big repository with source files and you are working on a file and for checking if everything is ok you also need to check other files (which are likely to be ok) then those can be fast
22:39 <edwardk> i use it to write one serializer and get a binary format, json encode/decode for humans, immediate mode user interface for editing, wire format...
22:39 <ChaiTRex> fXl: To directly translate the code, that's a better approach, since they use arr[...] a bit.
22:40 <edwardk> an automatic quantizer that duplicates the effect of sending the data over the wire in place..
22:40 <fXl> ChaiTrex: can you tell me why my approach doesnt work ?
22:40 <edwardk> overall, good power to weight ratio =)
22:40 <ChaiTRex> fXl: Let me take a look.
22:40 <fXl> thank you
22:41 <ph88^> oh ye you are big into c++ as well
22:41 <edwardk> i use it when i need a break from haskell
22:41 <edwardk> and my current work can't be expressed in haskell until we fix the compiler in some ways
22:41 <edwardk> so, c++ it is!
22:41 <edwardk> =)
22:41 <ph88^> :)
22:42 <ph88^> maybe you can put your thought for the compiler in a ghc ticket
22:42 <edwardk> its already being worked on
22:42 <ph88^> does it have a ticket ?
22:42 <edwardk> but we won't see results until 8.4 at the earliest
22:42 <edwardk> ben gamari made one iirc
22:42 <ph88^> when is 8.4 due for ?
22:42 augur joined
22:43 <edwardk> next year this time
22:43 <ph88^> oh that's quick
22:43 <edwardk> i raised the issue a month or so
22:43 <edwardk> er ago
22:43 Aruro joined
22:43 e14 joined
22:43 <ph88^> well good thing you're doing c++ then
22:43 <edwardk> basically our calling convention doesn't allow passing 256bit or 512bit vector types in ymm or zmm registers
22:44 <edwardk> so they always spill
22:44 <monochrom> :S
22:44 alex4 joined
22:44 <edwardk> this means i can't write fancy custom c-- primops to implement assembly opcodes we cant write directly in ghc and then hope for link time optimization to inline them
22:44 <ph88^> what would be cool if you have a big number, say 1500 bit integer and you can write an abstraction so that the compiler automatically figure out if and how it can use avx for that in the most efficient way
22:44 <edwardk> because they'll just inline to messy spill logic, op, messy spill logic
22:44 <edwardk> rather than 'op'
22:45 <edwardk> ph88^: i'm currently working on a lot of SPMD-on-SIMD code.
22:45 <ph88^> nice
22:45 <ph88^> i was thinking of doing some hardware simulation on the long term
22:45 <ph88^> so i need to handle large bit vectors
22:45 <fXl> ChaiTrex: any suggestions ?
22:46 <edwardk> in general trying to get obvious simd parallelism out of simd opcodes for one straightline flow of code is a sucker's game. you can generally scale up to about a 4x lane width, but anything further gets under utilized
22:46 <edwardk> you need to spot all sorts of non-obvious independencies properties, etc.
22:47 <ChaiTRex> fXl: Why are you checking whether the difference of things is 2?
22:47 <ph88^> don't know about that
22:47 <edwardk> on the other hand, gpu code works great and it executes 'sideways', where you have, say 8 'copies' of the code running at the same time on different data, and a current execution mask of what parts of the simd registers you are using right now
22:47 <fXl> ChaiTrex: the list i gave is [1,3,5,9,11] so it should say 7 is missing
22:47 <monochrom> Oh sweet, 3-address instructions make a comeback.
22:48 Koterpillar joined
22:48 <edwardk> then if you compute a boolean (as 8 booleans computed, simd style) and branch on it with an 'if' what you do is figure out if any of the 8 bools was true, if so, mask off all the cases where it holds, and take the true branch, flip the mask, then check if any were false, then take the false branch
22:48 <ph88^> was just considering which language can have nice abstractions (including for parallelism) and give as much raw performance as possible .. not that i think the GC is so much a bottleneck, but i still i have a feeling that mutable would be faster
22:48 <fXl> ChaiTrex: the elements should have 2 in difference
22:48 <edwardk> mutable doesn't really matter here
22:48 <edwardk> its more about this style of control flow
22:48 <alex4> Hey guys, I was wondering if any of you knew of any reference material for conventions in haskell? Things like organizing a projects/modules, best practices (concepts like avoiding explicit recursion, etc.), perhaps some kind of architectural models
22:49 <ph88^> for the hardware simulation or for your simd you're working on ?
22:50 <edwardk> alex4: no idea. my code is typically unorganized (ask anyone), and i use lots of explicit recursion =)
22:50 jlael joined
22:50 <edwardk> ph88^: no hardware simulation here. i'm running on x86-64
22:50 <ChaiTRex> fXl: search [1,3,5,9,11] is 7.
22:50 squotro joined
22:50 <ph88^> edwardk, ya ok .. i mean i was just saying i would like these optimization to get more performance when doing simulations ..
22:50 <edwardk> just saying that i don't need my host language to be all fancy about mutation, i can get by with haskel like semantics and in many way they encourage a better style of code for me
22:51 <edwardk> ah
22:51 kosekilokai joined
22:51 <ph88^> ye that's cool
22:51 <edwardk> as for why haskell-like stuff works better, i have to keep that execution mask around, right? which i need when doing scatters/gathers from main memory
22:51 <ChaiTRex> fXl: As an aside, one bug is that x isn't the element right next to the middle element.
22:51 <alex4> I'm no expert in haskell by any means, but I was thinking about working on collecting knowledge for writing conventional, practical haskell in real applications in a single place of reference (probably the haskell wiki)
22:52 <alex4> I was just curious if such a thing has been done
22:52 <edwardk> but when if i use explicit ternary blends with a mask and two source operands, i don't need to care about my mask, reducing my operation count
22:52 <edwardk> but in c++ with operator overloading i can't tell that reusing a temporary without changing my execution mask shouldn't bother to mask off before re-assignment
22:52 <edwardk> it'd be better for me to be using fresh variables everywhere in the loop
22:52 <edwardk> but c++ makes that hard
22:52 le_frogb_ joined
22:53 <fXl> ChaiTrex: can you try this one ? [1,3,5,7,9,11,13,17,19]
22:53 <fXl> 15 should be the missing
22:53 <ph88^> edwardk, i'd prefer the good stuff be moved into haskell, because i bet on there :P
22:53 RGamma joined
22:53 <edwardk> sure.
22:53 <edwardk> i'm writing my code in c++ at the moment so i can figure out how to write a compiler for it in haskell ;)
22:54 <edwardk> that and its still nicer to write graphics stuff out in c++ than in haskell
22:54 <edwardk> as sad as that may be
22:55 <edwardk> it continually astonishes me that we don't have a std::vector equivalent to make it easy to do push_back style growth of arrays, etc.
22:56 <edwardk> there are some obvious gaps in our libraries
22:56 <edwardk> maybe i should fix that one at some point =)
22:56 <ChaiTRex> fXl: Right, and that searches [1,3,5,7,9,11,13,17,19], then [11,13,17,19]. At that point, x is 11 rather than 13.
22:56 kosekilokai left
22:57 chreekat left
22:57 mizu_no_oto joined
22:59 <edwardk> (yes you can roll your own atop an IORef and a Mutable Vector)
22:59 alasi joined
22:59 amut joined
23:00 <ChaiTRex> fXl: Your code has no chance of working properly. You can't tell where an element is missing by looking at only whether two elements surrounding the middle one have the proper distance.
23:00 <ChaiTRex> fXl: To see why, tell me whether I should look left or right if the middle elements are 9, 11, 13?
23:00 <ChaiTRex> fXl: There's no way of telling which way to go.
23:00 ludat joined
23:01 ebzzry joined
23:02 <fXl> ChaiTrex: yeah, i couldnt think how to handle if nothing misses :D if understood you correctly
23:04 <mniip> edwardk, [] and :?
23:04 <mniip> : is literally push_front
23:04 qzo joined
23:04 Warrigal joined
23:04 <Koterpillar> no random access though
23:05 justanotheruser joined
23:05 suls joined
23:06 dan_f joined
23:08 <Sonolin> is there a common way to short circuit a monad (i.e. "throwM"), but recover the previous result (before the exception)?
23:08 darjeeling_ joined
23:08 anuxivm left
23:08 <Sonolin> for example, one implementation of my simple interpreter is "Maybe" - I want a "Nothing" value anywhere in the chain to just return the previous Just
23:08 robertkennedy joined
23:09 <Koterpillar> Sonolin: you aren't even going to know the type of that result
23:09 <Koterpillar> maybe you want some kind of ContT?
23:09 <* ski> supposes Sonolin wants `[Maybe a] -> Maybe a
23:09 <ski> '
23:09 <Sonolin> Hmm yeaw I was thinking of ContT
23:09 bgb joined
23:09 <Sonolin> and ski perhaps I can just implement my interpreter for [Maybe a] instead of Maybe a hmm..
23:10 <jle`> Sonolin: the main problem is that, yeah, the last Just in a (Maybe a) might not have type 'a'
23:10 ddere joined
23:10 fizbin joined
23:11 <Sonolin> well the type of the function in question returns a "Maybe a" for an "a" value
23:11 <Sonolin> that's the one I'm trying to "short circuit"
23:11 <Sonolin> so I guess I technically know that if its a "Just" value the value inside will be the same as the parameter
23:11 <monochrom> I think it would be the clearest if you wrote some mock code and say what it should do. "Previous result" doesn't seem to be meaningful.
23:12 <Koterpillar> Sonolin: do { x <- Just 1; y <- Nothing; return (Just "hello") }
23:12 Achylles joined
23:12 <Koterpillar> Sonolin: it'll error on Nothing, do you want 1 instead of "hello"?
23:12 <Sonolin> yea I guess you're right
23:12 <Sonolin> I think I just want ContT
23:12 <Sonolin> well I'll try that at least, thanks guys
23:13 <jle`> Sonolin: also do { x <- Just 1; y <- Nothing } :: Maybe String
23:14 <jle`> the last Just was 1, but like, how would you know that if you had Maybe String
23:14 <Sonolin> yay ConT has MonadThrow
23:14 <jle`> * do { x <- Just 1; Nothing } :: Maybe String
23:14 <Sonolin> I think that should work :)
23:15 <johnw> Sonolin: how about ExceptT (a, String) b?
23:16 sssilver joined
23:16 amut left
23:16 forker joined
23:17 amut joined
23:17 theDon_ joined
23:19 le_frogballs joined
23:19 amut joined
23:21 <jle`> johnw: for some monad b?
23:21 nakal_ joined
23:22 markus1189 joined
23:22 umib0zu left
23:22 markus1199 joined
23:22 <fXl> ChaiTrex: thank you for your help
23:24 fizbin joined
23:25 Tertiary_ joined
23:26 <ChaiTRex> fXl: You're welcome.
23:27 fizbin joined
23:28 gregoire joined
23:31 ebzzry joined
23:32 carlosdagos joined
23:33 Ptival joined
23:34 <Ptival> what are possibilities for a Haskell program segfaulting? the program only uses readFile, readCreateProcess, writeFile
23:34 <Ptival> can it be some OOM issue?
23:34 <jle`> segfaulting during runtime usually comes from bad ffi
23:35 <jle`> or an unsafe interface
23:35 peterbecich joined
23:35 robkennedy joined
23:35 gienah joined
23:36 <dmj`> Ptival: can you paste code?
23:37 cpennington joined
23:38 nomicflux joined
23:39 <Ptival> dmj`: trying to reduce the culprit space a bit before, but will do :)
23:39 <dmj`> as jle` said, if you have your own ffi bindings to stuff, those are prime candidates
23:41 hybrid joined
23:41 louispan joined
23:42 eacamero_ joined
23:43 vaibhavsagar joined
23:43 <johnw> jle`: oops :)
23:45 dsantiago joined
23:45 darjeeling_ joined
23:46 louispan joined
23:47 eacameron joined
23:47 mekeor joined
23:48 e14 joined
23:50 afnizarnur joined
23:51 LeaChim joined
23:52 safe joined
23:53 leat joined
23:54 eacameron joined
23:55 <Ptival> no, the code does almost nothing, it just opens files, calls git commands through `readCreateProcess`, and writes files
23:55 <Ptival> it takes forever to crash so testing is slow :)
23:55 cic joined
23:56 <Ptival> I am now testing with less memory contention, I'm not sure whether it will segfault, will see :\
23:56 Boomerang joined
23:58 jsgrant joined