<    April 2017    >
Su Mo Tu We Th Fr Sa  
 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  
00:00 <bbear> how would you write the function readNCartesianCoordinate :: IO [Coord] ?
00:00 <centril> :t \i m -> sequenceA $ replicate i m
00:00 <lambdabot> Applicative f => Int -> f a -> f [a]
00:01 <bbear> not sure it helps.
00:01 <bbear> don't even understand the syntax \i m
00:01 <centril> bbear: first create: getCoord :: IO Coord, then just say: read10CartesianCoordinate = replicateM 10 getCoord
00:02 <centril> bbear: \x -> f x is a lambda abstraction with an argument x and "function body" f x
00:02 <centril> \i m -> f i m = \i -> \m -> f i m
00:03 <bbear> :t \i m -> ()
00:03 <lambdabot> t1 -> t -> ()
00:03 <bbear> ok so you can chain arguments
00:03 <bbear> :t \x,y -> ()
00:03 <lambdabot> error: parse error on input ‘,’
00:03 <bbear> :t \a b c -> ()
00:03 <lambdabot> t2 -> t1 -> t -> ()
00:03 <centril> bbear: all haskell functions are curried - there are in reality no two-argument functions
00:03 <centril> that is just syntactic sugar
00:04 <bbear> I have readIntList :: IO [Int] and readCoord :: [Int] -> Coord
00:04 <centril> bbear: :: a -> b -> c == :: a -> (b -> c)
00:04 <bbear> How can I link them together ?
00:05 <centril> readCoord <$> readIntList
00:05 <bbear> readIOCoord :: IO Coord
00:06 apolih joined
00:06 takle joined
00:06 {emptyset} joined
00:07 <centril> readCoord <$> readIntList = readIntList >>= pure . readCoord = readIntList >>= \x -> pure . readCoord $ x == readIntList >>= \x -> pure $ readCoord x = do x <- readIntList ; pure $ readCoord x ;
00:07 <bbear> centril: thanks
00:07 <centril> pure = return
00:07 <bbear> I stepped into that world of functors.
00:08 <centril> yw
00:08 FjordPrefect joined
00:08 <bbear> don't know why it even works
00:08 <centril> bbear: what works ?
00:09 <bbear> readIOCoord = readIntList >>= \x -> return (readCoord x)
00:10 FjordPrefect joined
00:10 <bbear> why is it the same than readIOCoord = readCoord <$> readIntList ?
00:10 <bbear> and why does it matter :p ?
00:10 stef_204 joined
00:10 <bbear> what is the functor in this stuff I mean
00:10 <centril> bbear: IO is a functor, which means it defines a function (<$>) :: (a -> b) -> IO a -> IO b, let a = [Int], b = Coord, then you get ([Int] -> Coord) -> IO [Int] -> IO Coord
00:11 <bbear> ha yes
00:11 <centril> and readCoord :: [Int] -> Coord, so it fits
00:11 <bbear> so IO is a monad and IO is also a functor ?
00:11 <bbear> are all monads functor as well ?
00:11 <centril> bbear: all monads are applicative functors, all applicative functors are functors
00:11 <ertes> bbear: yes, and the laws require that your example in terms of (>>=) and 'return' is equivalent
00:11 <centril> Monad => Applicative => Functor
00:12 <ertes> fmap f c = c >>= return . f -- by law
00:12 <bbear> is there something before `Monad` in your last sentence centril (I mean even more specialize object that is an instance of the three others)
00:12 <centril> the syntax class Applicative f => Monad f where ... is a bit confusing, the arrow should be flipped really
00:13 FjordPrefect joined
00:13 <bbear> yes I get the point though.
00:13 <bbear> hom
00:13 cosmodanger joined
00:14 benl23 joined
00:14 <bbear> map is kind of a functor then
00:14 <bbear> but it's also a function
00:14 <bbear> that's confusing. You should tell your kid.s
00:14 <rotaerk> map is the function supported by functors
00:14 <glguy> [] (list) is also a functor
00:14 <centril> bbear: no, a list [] is a functor for which map defines its functor instance
00:14 <glguy> map is the implementation for fmap in that function instance
00:14 <bbear> ha ok
00:14 <glguy> Functor instance*
00:15 <centril> :t map
00:15 <ertes> mathematically speaking 'map' is indeed a functor
00:15 <lambdabot> (a -> b) -> [a] -> [b]
00:15 <centril> :t fmap
00:15 <lambdabot> Functor f => (a -> b) -> f a -> f b
00:15 <ertes> but ignore that =)
00:15 <bbear> okay
00:15 <ertes> > fmap (+ 1) [3,5,7]
00:15 <centril> bbear: https://en.wikipedia.org/wiki/Functor
00:15 <lambdabot> [4,6,8]
00:15 <ij> SIGINT produces an Exception while TERM dies without exceptions?
00:16 <bbear> hey in my mind Grothendieck is the real founder of category theory. Is that true ?
00:16 <ertes> ij: i'm pretty sure that SIGTERM is translated into an exception, too… perhaps ThreadKilled
00:17 <ij> I hoped so, but can't catch it, maybe I'm doing something wrong. The ^C is caught.
00:17 <ertes> let me check
00:17 <sophiag> lyxia: you seem to know a lot about haskell asts. i'm parsing lambdas with a function like this: "parseLambda (Lambda _ [PVar (Ident var)] body) = parseExpr var body" and it's failing on the string in SrcLoc, which doesn't make sense to me since i'm using a hole for it. any idea what i'm doing wrong?
00:17 Guest72276 joined
00:19 soLucien joined
00:19 <centril> ertes, glguy : any ideas on how to traverse an AST with an out-of-AST rosetree with decorations ?
00:19 takle joined
00:19 <ertes> ij: indeed, i couldn't catch SIGTERM either… i guess you need to install a signal handler
00:20 <centril> also, what is the role of IndexedTraversal ?
00:20 j2j joined
00:21 <centril> :t IndexedTraversal
00:21 <lambdabot> IndexedTraversal i s t a b -> ReifiedIndexedTraversal i s t a b
00:21 jbiesnecker joined
00:21 <ij> An exception would've been nicer. Now I've to make a MVar to notify the code to stop execution in the program's intestines.
00:21 <qmm> the haskell community is wonderful
00:22 <ertes> ij: you can throw an exception at the main thread
00:22 utdemir joined
00:22 <bbear> I have a problem : here is my type signature readGiantPos :: IO (IO [Coord], Int, Int)
00:22 <qmm> i appreciate all of you who have helped me this past year, as well as your continued effort to help everyone in IRC :)
00:22 lambda-11235 joined
00:22 <bbear> I would like readGiantPos :: IO ([Coord], hitNumber, giantNumber)
00:22 <ertes> ij: main = do mainTid <- myThreadId; installHandler sigTERM (CatchOnce (throwTo mainTid (userError "test"))) Nothing; …
00:22 <bbear> I do readGiantPos = readIntList >>= \[x,y] -> (return (readCoordList y, x, y))
00:23 <bbear> with readIOCoord = readIntList >>= \x -> return (readCoord x)
00:23 <ertes> ij: that works
00:23 <ij> Woo! I'll try it out! qmm, lots of helpful folks here, indeed.
00:24 <ertes> ij: i guess you can also just use killThread
00:24 <ertes> then SIGTERM acts like killing the main thread
00:24 systemfault joined
00:24 <ertes> ij: indeed, that works
00:24 <ertes> do mainTid <- myThreadId; installHandler sigTERM (CatchOnce (killThread mainTid)) Nothing
00:25 <ertes> i guess that the RTS runs signal handlers in a separate thread
00:25 cchalmers joined
00:25 systemfault joined
00:25 <ertes> indeed, the installHandler docs confirm that
00:25 <centril> bbear: readGiantPos = do [x, y] <- readIntList ; y' <- readCoordList y ; pure (y', x, y)
00:25 <bbear> that's it : readGiantPos = readIntList >>= \[x,y] -> (readCoordList y) >>= \coordList -> return (coordList, x, y)
00:25 <bbear> I try to avoid do notation
00:26 <bbear> it has too much of the imperative perfume I want to get rid of.
00:26 <bbear> thanks anyway
00:26 <centril> bbear: thats a good idea
00:27 <lyxia> sophiag: I'm not sure what's going on with only that.
00:27 <ij> ertes, Yeah, it totally works!
00:27 <lyxia> sophiag: can you give more details
00:27 abhiroop joined
00:27 <bbear> wouw
00:27 <bbear> now time to go t o bed
00:27 <bbear> it's 2:30 here.
00:27 <bbear> yes guys you have been wonderful
00:28 <bbear> thank yous
00:28 <ij> 03:28:33
00:29 <ertes> there are as many time zones as there are seconds in a day
00:29 <ertes> so 86400 +- 1
00:30 <sophiag> lyxia: sure i'll paste a snippet
00:32 <centril> ertes: that sounds wrong... are there really as many TZs as seconds in a day?
00:32 <Cale> ertes: Don't forget to multiply by at least two for observation of daylight savings time
00:33 <centril> i mean, whole central europe only has 1 TZ: CET - and it's a big area
00:33 <ertes> and CEST… sometimes
00:33 <centril> well, still 2
00:33 eacameron joined
00:33 <ertes> i'm actually in CEST right now =)
00:34 <ertes> centril: i'm just making fun of humans
00:35 <sophiag> lyxia: here's how i'm parsing the lambdas: http://lpaste.net/354439. but since it's failing on the first argument to the constructor, it seems only the last line is relevant. i'm passing it something like (Lambda r1 r2 r3)
00:36 castlelore joined
00:37 <centril> ertes: what country ?
00:37 <EvanR> preposterous there are 10 divisions of each second so multiply by 10
00:38 <lyxia> sophiag: what do you mean "it's failing on the first argument"
00:38 <ertes> centril: germany
00:39 <ertes> … i think… let me check the current borders
00:42 <sophiag> lyxia: i mean the SrcLoc, which i have a hole for. i'm just ignoring it in all that code. the error is "Exception: fromParseResult: Parse failed at [<unknown>.hs] (1:11): Parse error: ->
00:42 <sophiag> CallStack (from HasCallStack):" and <unknown>.hs is the string in SrcLoc
00:43 eacameron joined
00:43 <lyxia> this just looks like a parse error
00:45 <sophiag> well, same as with the list...i don't get that calling parseExp on lambdas in ghci
00:46 <sophiag> so i would assume it has to do with how i'm passing them as an argument to that function except i don't see anything wrong with it: (Lambda r1 r2 r3)
00:46 <lyxia> What code are you running in ghci, what code are you running outside ghci
00:46 <sophiag> outside ghci i have a whole repl set up
00:46 markasoftware joined
00:47 <sophiag> in ghci i'm just running fromParseResult $ parseExp
00:47 <lyxia> it's pretty hard to debug code I can't see.
00:47 mac10688 joined
00:48 <sophiag> well if you don't see anything wrong with that paste from before i would assume it has to be here: http://lpaste.net/354439
00:48 <sophiag> that was what i needed to change to correct parsing lists
00:48 <lyxia> "Parse failed" tells me the error is in the input
00:48 <lyxia> whatever string you are parsing
00:48 <sophiag> oh ok
00:49 <sophiag> i've been testing it like this: \\x -> x == 0
00:49 <sophiag> it seems to be failing on the arrow
00:49 <sophiag> yeah, ok. i was wrong thinking it was SrLoc
00:49 <sophiag> *SrcLoc
00:49 <sophiag> that's just identifying *where* it's failing
00:50 Majiir joined
00:51 <lyxia> Could it be parseExp is not receiving the string you think it should receive?
00:51 wroathe joined
00:52 splanch joined
00:53 <sophiag> i don't think so since in order to get that error it would have to be parsing the first part of it
00:53 <sophiag> idk, could having to escape the backslash have to do with it?
00:55 <lyxia> I just checked, and this error is in fact raised by a parse error, just like it says
00:56 eacameron joined
00:56 <sophiag> i'm not doubting the error code. just confused about what could be wrong with that input
00:56 sigmundv joined
00:57 <lyxia> One thing you can do to be 100% sure you're looking at the string being passed to parseExp is to use Debug.Trace
00:58 <lyxia> Clearly it's not "\\x -> x == 0" because there is no -> at the 11-th column.
00:59 <sophiag> oh...i didn't know how to read it like that
01:00 <Sornaensis> what is the purpose of Data.Monoid.Product
01:00 <sophiag> does column essentially mean character?
01:00 <sophiag> because if so it would be the x
01:00 acarrico joined
01:00 <sophiag> given what comes before it in the string
01:01 <sophiag> trace returns <function>, presumably because there's no show instance for functions?
01:01 <lyxia> Yes. The 11-th character in "\x -> x == 0" is ' '.
01:01 <sophiag> no, there's a string before it
01:02 <lyxia> you're using trace wrong
01:02 <sophiag> in the dsl the string read in in that example was "require \\x -> x == 0" making the 11th x
01:02 jgt1 joined
01:02 <sophiag> oh, you mean call trace on parseExp?
01:03 <lyxia> no, trace the string before passing it to parseExp
01:03 fizruk joined
01:03 <sophiag> yes that's what i did
01:03 <sophiag> and it output
01:03 <sophiag> oops
01:03 <sophiag> "<function>"4
01:03 <lyxia> I would do it like this: parseExp (traceId myString)
01:04 <sophiag> ok got it
01:04 <lyxia> require \\x -> x == 0 is not valid haskell
01:04 <sophiag> yes, it's a dsl...
01:04 abhiroop joined
01:04 <lyxia> it fails at \\
01:04 zylinx joined
01:04 <sophiag> it's a string parsed into a dsl
01:04 <lyxia> 1) you gave me an error which complains at ->, not \
01:04 <sophiag> yes
01:05 <lyxia> 2) parseExp parses Haskell expressions
01:05 des_ joined
01:05 <lyxia> I am now quite confused
01:05 <sophiag> you need to escape backslashes...
01:05 eacameron joined
01:06 <lyxia> Sure but that's not my point
01:06 <sophiag> anyway trace says it is failing at 11
01:06 Yuras joined
01:06 mbw joined
01:06 <sophiag> oops \\
01:06 <lyxia> What I want to know is the exact string you are giving parseExp and the corresponding error
01:07 <sophiag> i just told you
01:07 <lyxia> You have been giving me inconsistent information
01:07 <sophiag> "require \\x -> x == 0"
01:07 <mbw> I want to build an executable using stack via the llvm backend. However, I have several versions installed. Is there a way to specify the path to the llvm3.7 bins/libs needed without having to fool around with update-alternatives?
01:07 raycoll joined
01:07 <sophiag> the error is "Parse failed at [<unknown>.hs] (1:12): Parse error: ->
01:07 <sophiag> CallStack (from HasCallStack):"
01:07 <lyxia> sophiag: But why do you expect that to succeed, it's not valid haskell
01:07 <sophiag> it's a dsl
01:07 <sophiag> dsl stands for domain specific language
01:07 <lyxia> so what
01:08 <sophiag> it works because i wrote a parse for it
01:08 a3Dman joined
01:08 <lyxia> parseExp parses Haskell
01:08 <sophiag> ...
01:08 <alx741> hello everyone, I'm having a bit of a problem using the cryptonite package from GHCI (not in a stack project), it collides with crypto hash, so doing `import Crypto.Hash` says 'Ambiguous module name ... found in multiple packages', how may I proceed?
01:08 <sophiag> it parses plain strings into strings as well
01:08 <lyxia> sophiag: you wrote a function transforming a Haskell AST
01:08 <sophiag> yes
01:08 <sophiag> when i parse lists they're followed by a function in this dsl as well...
01:08 <sophiag> that works. lambdas do not
01:09 <lyxia> I know what a DSL is BTW.
01:09 <sophiag> i just figured i'd clarify rather than simply repeating myself
01:09 <sophiag> anyway, the space before the lambda seems to be the problem
01:09 <sophiag> that wasn't a problem with lists
01:09 <lyxia> The string you give to parseExp must be valid Haskell
01:10 <sophiag> strings are valid haskell
01:10 <lyxia> if you do not have such a string, then do not use parseExp
01:10 utdemir joined
01:10 <sophiag> i do...
01:11 Cthalupa joined
01:11 bjz joined
01:12 stef204 joined
01:12 <zylinx> is ghc in debian package repo ? i can't afford to dl haskell-platform :<
01:12 cpennington joined
01:13 wroathe joined
01:14 <zylinx> stupid question, i leave until i find dsl line.
01:14 vaibhavsagar joined
01:14 <sophiag> lyxia: i fixed it by adding parens
01:15 splanch joined
01:15 vydd joined
01:16 <lyxia> Anyway, next time please try to make runnable test cases.
01:16 zylinx left
01:16 <sophiag> i did
01:17 thimoteus joined
01:17 <lyxia> sophiag: none of what you pasted was relevant to the error you had, which was a parse error
01:17 ultalbot joined
01:17 eazar001 joined
01:17 <lyxia> and then there was a misunderstanding about a string being quoted
01:17 SimpleL joined
01:17 eacameron joined
01:17 thimoteus joined
01:18 <sophiag> lyxia: no strings were quoted. you were confused that one can use haskell-src-exts to parse strings in order to create a dsl
01:18 <lyxia> Well then I still haven't understood what the problem was
01:18 <sophiag> yes, i think so
01:18 <lyxia> it involved giving invalid strings to parseExp
01:18 <sophiag> but thanks for telling me about how to use Debug.Trace
01:20 <lyxia> Weren't we talking about this parseExp https://hackage.haskell.org/package/haskell-src-exts-1.19.1/docs/Language-Haskell-Exts-Parser.html#v:parseExp
01:20 <sophiag> yes
01:22 <lyxia> and so the current string you have is "require (\\x -> x == 0)" ?
01:22 <sophiag> yes
01:22 <lyxia> okay
01:22 <sophiag> and that works
01:22 <lyxia> so now I understand
01:22 <sophiag> but i'm also matching for the parens obviously
01:22 <sophiag> oh wait not quite
01:22 <sophiag> with the parens i don't need to escape the backslash
01:22 <lyxia> it's exactly what I said, require \\ x -> x == 0 is not valid haskell
01:22 <lyxia> then you mentioned DSLs
01:23 <lyxia> I don't see how that contradicts anything I said
01:23 <sophiag> i didn't take "valid haskell" to mean anything like what you meant
01:23 wroathe joined
01:23 sleffy joined
01:24 <lyxia> Maybe I should have said "it's not a haskell expression".
01:24 <sophiag> i still wouldn't have gotten it
01:24 <sophiag> lambda syntax?
01:24 <sophiag> idk
01:25 <lyxia> You cannot apply a function directly to a lambda. you need parentheses or an operator.
01:26 <lyxia> f (\x -> x) or f $ \x -> x
01:26 <sophiag> i know that normally, but i was confused because it parses fine on its own
01:26 <sophiag> it was the space with a term before
01:26 <lyxia> what parses fine on its own
01:28 Cthalupa joined
01:28 <sophiag> a lambda not wrapped in parens
01:30 <lyxia> Anyway, what I would have rather seen to understand the situation straight away would be: here is my code fromParseResult $ parseExp "require \\x -> x" , here is my error "...".
01:30 <lyxia> so much simpler
01:31 <joe9> anyone knows an attoparsec parser to parse UTCTime? I can use parseTime but I am reading the string from a socket and I cannot guarantee that the string has been completely received.
01:31 <joe9> with attoparsec, I can do incremental parse
01:31 eacameron joined
01:32 <lyxia> sophiag: maybe you didn't pinpoint it to that bit at first, but then you should have pasted enough code that I can just copy and run myself to immediately reproduce the error
01:32 <sophiag> lyxia: i did say that, but with a lot of extraneous code first
01:33 <sophiag> the problem, as noted, was it worked in ghci yet not with the repl i set up and i didn't figure i should have pasted the whole program for you to run. maybe i should have
01:33 <lyxia> that would have helped indeed
01:34 thimoteus left
01:34 splanch joined
01:35 JeanCarloMachado joined
01:37 <lyxia> joe9: it seems aeson has one
01:37 jao joined
01:38 <lyxia> alx741: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#package-qualified-imports
01:39 a3Dman joined
01:39 eacameron joined
01:39 <lyxia> joe9: https://github.com/bos/aeson/blob/master/attoparsec-iso8601/Data/Attoparsec/Time.hs#L125
01:39 <joe9> lyxia: Thanks.
01:41 thimoteus joined
01:42 Sgeo joined
01:43 brynedwardz joined
01:43 eacameron joined
01:43 wroathe joined
01:45 thimoteus left
01:48 eacameron joined
01:48 thimoteus joined
01:51 fotonzade joined
01:52 Supersonic112_ joined
01:53 Vibor joined
01:57 eacameron joined
02:00 hucksy_ joined
02:02 tzh joined
02:02 a3Dman joined
02:02 takle joined
02:04 wroathe joined
02:05 iqubic joined
02:10 exferenceBot joined
02:13 abhiroop joined
02:14 samba1 joined
02:14 hexagoxel joined
02:15 eacameron joined
02:15 jrajav joined
02:15 raycoll joined
02:16 vydd joined
02:16 vydd joined
02:16 splanch joined
02:18 xall joined
02:18 <alx741> lyxia: thanks. Unfortunately I already tried, the moment I tried to use a function from the module it still complains about the ambiguous interface, very weird
02:19 samba1 left
02:21 aarvar joined
02:23 eacameron joined
02:24 zv joined
02:24 a3Dman joined
02:27 wagle_ joined
02:30 infinity0 joined
02:30 eacameron joined
02:32 significance joined
02:33 splanch joined
02:33 infinity0 joined
02:33 <lyxia> alx741: what is the actual error
02:34 takle joined
02:34 eacamero_ joined
02:34 wroathe joined
02:35 splanch_ joined
02:36 infinity0 joined
02:37 whaletechno joined
02:37 pita joined
02:38 infinity0 joined
02:39 zennist joined
02:42 louispan joined
02:42 cpup joined
02:43 <alx741> lyxia: this one: http://sprunge.us/GjWB
02:44 <alx741> lyxia: oops sorry, wrong output, just a second
02:44 <alx741> lyxia: http://sprunge.us/SEZC
02:44 Xandaros joined
02:44 a3Dman joined
02:46 <lyxia> Even from a fresh ghci session?
02:48 <alx741> lyxia: yes, notice though I'm using `stack ghci`
02:48 <alx741> when I use `ghci` the error is: Could not find module ‘Crypto.Hash’
02:48 <alx741> Perhaps you haven't installed the "dyn" libraries for package ‘cryptonite-0.22@cryptonite-0.22-Bkmtpxnzy0e2o9946AJnoQ’?
02:51 bjz joined
02:51 Argue joined
02:53 metaQuux joined
02:54 <sveit> is there a reason product in Data.Foldable isn't implemented with foldl'?
02:55 meandi_2 joined
02:55 wroathe joined
02:55 edvorg joined
02:55 metaQuux left
02:55 <benzrf> :t foldl'
02:55 <lambdabot> Foldable t => (b -> a -> b) -> b -> t a -> b
02:55 <benzrf> huh
02:55 <benzrf> sveit: good question
02:56 <lyxia> alx741: stack ghci --ghci-options "-hide-package cryptohash"
02:58 <lyxia> https://ghc.haskell.org/trac/ghc/ticket/13168 looks like an open issue
02:59 <alx741> lyxia: fantastic, it worked! thank you very much
02:59 iqubic joined
03:00 <Gurkenglas> sveit, I heard it's because Num isn't guranteed to be strict and optimization fixes that one anyway
03:01 a3Dman joined
03:02 madsa joined
03:03 thunderrd joined
03:04 fizruk joined
03:05 splanch joined
03:09 eacameron joined
03:11 <qmm> has anyone been successfull installing lambdabot on osx?
03:11 <qmm> how did you do it?
03:11 <qmm> (if so)
03:12 abhiroop joined
03:13 beerdrop joined
03:15 wroathe joined
03:17 vydd joined
03:18 splanch joined
03:20 gk_1wm_su joined
03:22 felixsch__ joined
03:23 <glguy> qmm: To build it I ran: cabal get lambdabot; cd lambdabot-; cabal new-build
03:23 gk_1wm_su left
03:23 sanett joined
03:23 <glguy> and then it looks like it get to dependent-sum and stopped :)
03:26 nonzen joined
03:26 <glguy> so I'm allowing dependent-sum-0.4 now and it's proceeding
03:26 hagnar joined
03:26 Goplat joined
03:27 <glguy> and then it triggered : malformed mach-o: load commands size (52104) > 32768
03:27 <glguy> which I thought GHC 8.0.2 was supposed to help with, but maybe I don't have the corresponding fix to Cabal
03:28 Swizec joined
03:28 revprez_atlanta joined
03:29 <Vibor> Hi, I wrote 2 functions in Haskell two calculate natural logarithm, https://ptpb.pw/-bml both using series, but both seem to be imprecise tested in ghci, I wonder why , thanks.
03:31 dfeuer joined
03:36 sanett joined
03:39 athan joined
03:39 otto_s_ joined
03:39 louispan joined
03:40 <rotaerk> hmm is there some way in haskell to do something like: type GetArg a = ...; type Foo = GetArg [Int]; -- and now Foo is Int
03:40 <Cale> Vibor: Series expansions for log tend to converge pretty slowly. You'll find that your series expansion does rather well for values close to 1.
03:41 significance joined
03:42 soLucien joined
03:42 <Cale> rotaerk: no
03:43 a3Dman joined
03:44 gk_1wm_su joined
03:44 <glguy> rotaerk: You can use a type family for that
03:44 <Vibor> Cale: Thanks for the response. So what is the correct way(like the way Prelude log does) to achieve the goal precisely?
03:45 <Cale> Well, let's perhaps look at how the Prelude does it. I suspect it probably just asks your CPU to compute it.
03:45 <Cale> (for Float and Double, at least)
03:45 <rotaerk> ah k
03:46 <lpaste> glguy pasted “for rotaerk” at http://lpaste.net/8620043846048284672
03:46 wroathe joined
03:46 <rotaerk> thanks
03:46 <Cale> Whoa...
03:46 <Vibor> Cale: and how to do that? write assembly?
03:46 <Cale> glguy: Hmm, how is that not a huge problem?
03:47 <Cale> Especially in the presence of type families...
03:47 <glguy> Cale: Umm, how is it a huge problem?
03:47 <Cale> f may not be injective
03:47 <glguy> Cale: Type families must always be fully saturated
03:47 gk_1wm_su left
03:47 <glguy> so 'f' will never be instatiated to an unsaturated type family
03:47 <glguy> so there's no issue there
03:48 <Cale> ah, so we're just letting it syntactically pull apart the expression
03:48 <Cale> That's... kind of uncool, but I guess it's fine
03:48 <glguy> It's not so much syntactic
03:48 <glguy> it just never matches a type family
03:49 <glguy> f will only be a type expression comprised of distinct types like those introducd by data and newtype
03:49 hamishmack joined
03:49 <Cale> hm
03:49 <glguy> rather than synonyms introduced by type or type family
03:49 hive-mind joined
03:50 <glguy> so it's never ambiguous as to what 'f' might be
03:51 <Cale> I suppose that's fair enough.
03:51 <Cale> For some reason it makes me feel rather uncomfortable though.
03:51 <glguy> It's the same kind of comfort you get whe nyou use (e.g.) map
03:51 <glguy> or at least fmap
03:51 <glguy> :t fmap
03:51 <lambdabot> Functor f => (a -> b) -> f a -> f b
03:52 <glguy> We can pull apart some type 'f a'
03:52 <glguy> and learn what a was
03:52 bl4z3r21 joined
03:52 <Cale> That's true
03:55 <Cale> Vibor: Yeah, ultimately it'll be dependent on which backend code generator you're using to fill in the operation
03:56 wroathe joined
03:57 begriffs joined
03:59 pavonia joined
04:00 <Cale> Vibor: ah, apparently it uses libm's log
04:01 Kuros` joined
04:03 BartAdv joined
04:03 dijonmus1ard joined
04:04 sanitypassing joined
04:04 <Vibor> Cale: c library?
04:08 <Cale> yeah
04:08 <Cale> At least on x86, that's what seems to happen:
04:08 <Cale> https://github.com/ghc/ghc/blob/46246a6d57c35ebf12032d13a4cd7ff18f713770/compiler/nativeGen/X86/CodeGen.hs#L2648
04:12 sleffy joined
04:13 a3Dman joined
04:14 <Vibor> So can I fix the problem by using CReal with arbitrary fixed digit precision? if I want to interpret log using haskell purely?
04:15 abhiroop joined
04:15 <Vibor> Data.Number.CReal
04:16 alphonse23_ joined
04:16 <Cale> Well, unless you use the log that's built in to CReal, that's going to be even worse
04:16 <Cale> CReal is terrible at adding up lots of numbers
04:16 the|auriscope joined
04:16 <Cale> > sum [1..1000] :: CReal
04:16 <lambdabot> 500500.0
04:16 <Cale> > sum [1..10000] :: CReal
04:16 <lambdabot> mueval-core: Time limit exceeded
04:16 wroathe joined
04:16 <Cale> It gets really really slow :)
04:17 <Cale> Better would be to choose an algorithm which converges faster
04:17 <Cale> Something like using Newton's method to invert exp
04:18 vydd joined
04:19 <Cale> Just to be clear, your problem isn't rounding error with Float, it's just the fact that it takes a *lot* of terms in the sum before you really get very close to the actual value of the logarithm by that method.
04:21 <Cale> *or* take a bunch of square roots and pull out factors of 2 until the number you're trying to take the log of is pretty close to 1
04:21 <Cale> (and you can compute square roots using Newton's method)
04:22 <MarcelineVQ> chemists like to cook, mathmaticians like to play horseshoes
04:24 fakenerd joined
04:24 <Cale> actually, hmm
04:26 <Cale> ah, yeah, that seems to work fairly well
04:29 <Cale> Vibor: http://lpaste.net/354442
04:29 sleffy joined
04:31 <Vibor> Cale: Amazing OoO
04:32 electrostat joined
04:33 <Lokathor> seems i can't install gl on windows using stackage 8.8
04:33 <Lokathor> http://lpaste.net/354443
04:34 <Lokathor> in previous LTS versions i couldn't install GLFW-b, but now I can't install gl
04:34 <* Lokathor> shakes fist at sky
04:35 steeze joined
04:36 <MarcelineVQ> :( stack unpack it and see if you can work it out locally
04:37 <Lokathor> as with many things haskell, I'm not skilled enough in the details to actually do that
04:37 <Vibor> Cale: "*or* take a bunch of square roots and pull out factors of 2 until the number you're trying "
04:37 <Vibor> to take the log of is pretty close to 1
04:38 <Lokathor> I only know enough to report the error :P
04:38 <Vibor> Cale: Could you please explain why?
04:38 <geekosaur> looks like it needs hxt as a setup-depends
04:38 <geekosaur> re gl
04:38 <MarcelineVQ> typcially it goes: stack unpack foo &&​ cd foo-version && stack init --solver && stack build
04:38 <geekosaur> possibly need to upgrade stack for setup-depends support?
04:39 <MarcelineVQ> there was some fixing done to sorting out setup-depends in stack 1.4.1, and possibly 1.4.0
04:39 <Lokathor> hmm
04:40 <Lokathor> i'm on stack 1.3, i'll try 1.4
04:40 <geekosaur> although tbh that error looks like it needs at build time as well as a TH dependency
04:41 <geekosaur> so possibly this requires adding hxt as a normal build dependency as well as a setup-depends
04:41 <Cale> Vibor: Well, the explanation will depend on which series we choose, but most of the series formulas you'll see for log tend to be centred around 1, just because that's a point where log behaves specially, and has a nice value and first derivative
04:42 <Lokathor> there seems to be a bit pile of stuff to download for 1.4, so this is taking a bit
04:43 <iqubic> How do I check my version of Stack?
04:43 <Cale> Vibor: https://en.wikipedia.org/wiki/Taylor%27s_theorem tells us something about polynomial approximations obtainable from the derivatives of a function at a given point
04:43 <Lokathor> iqubic, stack --version
04:43 <geekosaur> I'd presume stack --version
04:43 <iqubic> Looks like I have version 1.4
04:43 <geekosaur> like pretty much anything else
04:43 <iqubic> Is that the latest version?
04:44 <Lokathor> iqubic, yep
04:44 <Lokathor> geekosaur, hey not all of us are so versed in command line normals :P
04:44 <MarcelineVQ> you can get newer on git :>
04:44 <Lokathor> geekosaur, with stack 1.4 in use, gl seems to be building hxt as a dependency just fine
04:44 <MarcelineVQ> gl seems to be properly bumped to requiring 1.24.* cabal so hopfeully the stack upgrade helps
04:44 <Cale> Vibor: Depending on how you prove the theorem, there are a few different forms in which you can get the "remainder" -- the error term shown at the end there, but look for instance at the integral form of the remainder
04:45 <Lokathor> the next question is if i'll be able to build GLFW-b or not :P
04:45 fresheyeball joined
04:45 <Lokathor> but gl takes quite a while to build so we won't be able to find out for a few minutes
04:45 <iqubic> Also, why are people talking about LTS versions? Are there Long Term Support versions of Haskell?
04:45 <Cale> Vibor: The thing to notice is that it's an integral from a to x, where a is the point at which we're taking the nth derivatives of the function, and x is the value at which we're evaluating the whole expansion
04:45 <Lokathor> iqubic, yes, stack picks package versions using an LTS system
04:46 <iqubic> Ah.
04:46 <Cale> Vibor: So naturally, this will tend to be small when x is close to a
04:46 <Lokathor> iqubic, https://github.com/fpco/lts-haskell#readme
04:47 wroathe joined
04:49 Swizec joined
04:49 <Cale> Vibor: i.e. if we take a series expansion for the logarithm at 1, we have log(1 + x) = x - x^2/2 + x^3/3 - ..., or to put it in the form that it appears in the page on Taylor's theorem, log(x) = (x-1) - (1/2)(x-1)^2 + (1/3)(x-1)^3 - ...
04:49 justanotheruser joined
04:50 <Cale> Then this will approximate log for values close to 1, but will be a poor approximation for anything too large or too close to 0
04:50 <Cale> (In fact, the fact that log misbehaves at 0 will also prevent *this* form of the series from even converging for values 2 and above)
04:52 dan_f joined
04:53 <iqubic> What are we talking about? CReal?
04:53 <Cale> Vibor wrote some Haskell functions using series expansions to compute log, and wondered why they weren't converging very well
04:54 <iqubic> Ah.
04:54 abhiroop joined
04:54 Argue_ joined
04:55 <iqubic> Why not use an actual log function built into Haskell using C or C++?
04:55 <Cale> I guess just exploration of the mathematics :)
04:55 <iqubic> And why use Haskell for that? Is Haskell the right tool for that?
04:55 <Cale> It's not a bad tool for it
04:56 <iqubic> Can one use Haskell for web applets?
04:56 <Cale> Yes
04:56 <iqubic> Is that recommended? Is it hard?
04:56 <Lokathor> iqubic, setting up haskell to run in the browser is a little tricky to learn at first, so it's probably not a good first project with Haskell
04:57 <Cale> That's actually my day job -- I'm working for Obsidian Systems developing web applications pretty much entirely in Haskell
04:57 <iqubic> Let's say I want to write a GUI application in Haskell. Not web applications, just local Haskell programs with a GUI component.
04:57 <Cale> We use ghcjs to compile our frontends to Javascript which runs in the browser, and ghc to compile them to native ARM code for mobile devices
04:57 <iqubic> What library do you recomend I use?
04:58 <iqubic> I see.
04:58 <Cale> and of course native x64 code for the backend :)
04:58 <iqubic> That sounds good.
04:58 <iqubic> What Library should I use for GUI applications.
04:58 <Lokathor> iqubic, SDL2 and OpenGL are both solid in Haskell, but actual GUI toolkits aren't quite as easy to work with
04:59 <Cale> Well, the library we use is called reflex-dom
04:59 <iqubic> Alright. What's the difference between SDL2 and OpenGL?
04:59 <Lokathor> iqubic, SDL2 is oriented towards 2d graphics, and OpenGL is usually used for 3d graphics
05:00 <iqubic> Alright, I want SDL2 than.
05:00 <Cale> http://cale.hn.org/Demos/ -- I have some little reflex-dom demos here
05:00 <iqubic> What Library will give me the Haskell Bindings?
05:00 <Lokathor> iqubic, https://hackage.haskell.org/package/sdl2 you can read all about the package here
05:00 <Lokathor> iqubic, are you on windows or linux?
05:01 <iqubic> Linux.
05:01 <iqubic> Does that make things easier or harder to do?
05:01 <Lokathor> ah, then you'll have an easy time getting it set up
05:01 eazar001 joined
05:01 <Lokathor> linux is easy mode for the world of Haskell
05:01 <Lokathor> windows is hard mode
05:02 <iqubic> I hate Windows. But now's not the the time, and here isn't the place to discuss that.
05:02 <Cale> http://cale.hn.org/Demos/Audio/Audio.jsexe/ -- simple media player widget implemented in reflex-dom (obviously using the audio support in the DOM)
05:02 <Cale> You can click the progress bar to seek :)
05:02 <iqubic> Why does SDL2 depend on OpenGL?
05:03 <Lokathor> iqubic, SDL is built on top of lower level systems. in most cases it's built on top of OpenGL (which talks directly to the graphics card)
05:03 <Cale> I'm not sure I'd consider either SDL2 or OpenGL to be GUI libraries
05:03 <iqubic> Also, can I have an SDL2 program that responds to keyboard and mouse input?
05:03 <Cale> I mean, they're graphics libraries
05:04 <Lokathor> iqubic, yep, you can.
05:04 <Cale> and SDL2 does have some input handling stuff
05:04 <Cale> But neither of those have much in the way of actual user interfaces
05:04 <iqubic> Cale: I want to do graphics stuff. Not so much GUI.
05:04 <Lokathor> Cale, they don't have widgets, but Haskell doesn't have the best support for actual widget toolkits anyway, as far as I've seen
05:04 <Cale> iqubic: If it's enough to just get some simple shapes and such on the screen in a hurry, perhaps look at gloss
05:04 <iqubic> I want to be able to take user input so I can do stuff like panning around an image, or zooming in and out.
05:04 <monochrom> Graphical Unstopped Iterations :)
05:05 <Cale> https://hackage.haskell.org/package/gloss
05:05 <iqubic> Cale: What I want to do is program the Mandlebrot set. So I just need a way of coloring each pixel in a window seperatly.
05:06 fizruk joined
05:06 <geekosaur> SDL2 depends on opengl because opengl is the graphics backend it uses. X11's graphics primitives are a bit too primitive
05:07 <iqubic> What features doe s SDL2 have that are not present in GLOSS?
05:07 wroathe joined
05:08 <geekosaur> SDL was designed for writing games in a cross-platform manner. Gloss is a simple wrapper around OpenGL
05:08 <Lokathor> iqubic, SDL2 allows you more control, but that also means that you have to manage more of it yourself. Gloss takes away some of the control flow and manages it for you
05:08 <iqubic> So GLOSS is the simpler library?
05:08 <geekosaur> so SDL2 abstracts over OpenGL, DirectX, etc.
05:08 <geekosaur> yes
05:08 <Lokathor> yes
05:08 <iqubic> Are there any GLOSS tutorials out there?
05:08 <Cale> Also, people don't usually write gloss in all caps
05:09 <iqubic> Sorry bout that.
05:09 <iqubic> Still new here.
05:09 <Cale> Gloss is almost so simple that a tutorial is barely necessary
05:09 <Cale> https://hackage.haskell.org/package/gloss-
05:09 <iqubic> So I install gloss with Stack.
05:09 <Cale> start here
05:09 <Cale> So, there's a type for representing pictures
05:09 <Lokathor> iqubic, the gloss github has many examples, https://github.com/benl23x5/gloss/tree/master/gloss-examples
05:10 <Lokathor> if you want to see how a "complete" program is arranged
05:10 <iqubic> Thanks lokathor.
05:10 <Cale> Unfortunately, your task is going to immediately take you to the one part of Gloss which is a little bit rough -- you're probably going to want to use bitmapped data
05:10 {emptyset} joined
05:10 <iqubic> Is gloss the right program for the mandlebrot set. What I want to do is color each pixel idividually.
05:11 <jle`> well, it's meant for gui's
05:11 <Cale> jle`: what is?
05:11 <iqubic> What is meant for GUIs? gloss?
05:11 <Cale> So, the thing you'll need to do is produce a ByteString containing the bitmap data you want to display
05:12 <jle`> hm, i was going to say gloss, but i think not, now
05:12 <iqubic> How do I create a ByteString?
05:12 <iqubic> Is there a tutorial for that?
05:12 <jle`> seems like it's meant for vector graphics
05:12 Argue__ joined
05:12 <iqubic> Yes it is.
05:12 <Cale> ah, how new are you to Haskell, btw?
05:12 <jle`> but if you just want to make a bunch of pixels from an arbitrary function, you can probably just use JuicyPixels instead
05:13 <jle`> JuicyPixels basically lets you work with pictures as an array of pixels
05:13 <iqubic> Quite new
05:13 <iqubic> jle` I will take a look at that.
05:13 <Cale> Oh, right, JuicyPixels might be a good way to construct it
05:14 <jle`> JuicyPixels is what simon marlow uses for his mandelbrot set example in his book
05:14 <jle`> for what it's worth
05:15 <iqubic> I will use that then.
05:15 <iqubic> What is Simon Marlow's book called?
05:15 mmachenry joined
05:15 <* Lokathor> is also interested in such a demo
05:16 <Cale> iqubic: Okay, so, here's a quick rundown of the bits of documentation you'll be interested in from JuicyPixels and Gloss
05:16 <jle`> iqubic: Parallel and Concurrent Programming in Haskell
05:16 Xanather joined
05:16 <Cale> https://hackage.haskell.org/package/JuicyPixels- -- this is the pixel type you'll want to use to match up with Gloss
05:16 <jle`> the relevant function is generateImage :: (Int -> Int -> a) -> Int -> Int -> Image a
05:17 <Cale> right
05:17 <iqubic> So I'll be using gloss and JuicyPixel together?
05:17 <jle`> give generateFunction a height and width, and then a function that takes an x and y and returns a pixel, and it makes an image
05:17 tathougies joined
05:17 <jle`> you can directly export an 'Image a' to a file using juicypixels
05:17 <Cale> iqubic: Yeah, JuicyPixel to generate the image to be displayed, and gloss to put it on the screen
05:17 nomicflux joined
05:17 <iqubic> Alright cool.
05:17 wroathe joined
05:17 <tathougies> Is there any package providing nice type families for `DataKinds`? In particular, I'm looking for a type-level `(&&)` operator over booleans
05:17 <iqubic> What does the type Image a mean?
05:18 <Cale> encodeBitmap :: forall pixel. BmpEncodable pixel => Image pixel -> ByteString
05:18 <Cale> Image a is an image made up from pixels of type a
05:18 monochrom joined
05:18 <jle`> iqubic: an 'Image a' is a picture whose pixels are a's
05:18 <Cale> And you'll want to use PixelRGB8 as your pixel type, because that matches up with what Gloss will want
05:18 <Cale> I just said that :)
05:19 vydd joined
05:19 vydd joined
05:19 <iqubic> So I install both Libraries with Stack, and then what do I do?
05:19 <Cale> https://hackage.haskell.org/package/gloss-
05:19 mmachenry joined
05:19 <iqubic> How do I use these libraries in actual programs.
05:19 <iqubic> ??
05:20 takle joined
05:20 <Cale> Once you have the ByteString from encodeBitmap, you can pass the width, height, the pixel format PxRGBA, and then the ByteString (and then probably True because you'll want caching)
05:20 <Cale> and bitmapOfByteString will get you a gloss Picture
05:20 <iqubic> Also, how do I make this graphics program react to user input to do things like panning and scrolling.
05:20 <jle`> tathougies: there's singletons if you want to get a batteries-included vesion
05:21 <jle`> tathougies: and there are light libraries like type-combinators that have one
05:21 <iqubic> Now, do I install these with Stack, and import the libraries to use them? Is that all?
05:22 <dunx> buffer 44
05:22 <jle`> tathougies: from singletons, http://hackage.haskell.org/package/singletons-2.2/docs/Data-Singletons-Prelude-Bool.html#t::-38--38-
05:22 <Cale> iqubic: You're in luck, that's sort of what gloss does by default actually, but you'll probably want to actually render new images as the user zooms, so you'll end up wanting to override that by using the "play" function from Graphics.Gloss.Interface.Pure.Game
05:22 <jle`> tathougies: the type is funny because it's directly promoted from the definition of && in prelude using template haskell
05:22 <Cale> iqubic: https://hackage.haskell.org/package/gloss-
05:23 <jle`> tathougies: from type-combinators, http://hackage.haskell.org/package/base- , which defines it directly
05:23 <Cale> iqubic: Well, start with just getting a picture on the screen using the similar but simpler function called display
05:23 <Cale> https://hackage.haskell.org/package/gloss-
05:23 <tathougies> http://hackage.haskell.org/package/singletons-2.2/docs/Data-Singletons-Prelude-Bool.html#t::-38--38- thanks for the Data.Type.Bool link. I think i'd rather use it from there.. this is a library so trying to keep my dependencies low
05:24 <iqubic> How do I use libraries from hackage in my own programs? Is that hard to do?
05:24 <jle`> iqubic: just throw them in your cabal file :)
05:24 <jle`> it's all pretty smooth
05:24 <Lokathor> jle`, I don't think they've used a cabal file before
05:24 <iqubic> What cabal file? I know hardly anything about Stack's inner workings.
05:24 <Cale> iqubic: Yeah, if you're using stack, you should be able to add these libraries to your cabal file and then import the relevant modules into your code, and it should load.
05:24 <iqubic> Or cabal's for that matter.
05:24 <jle`> tathougies: be aware that if you do a lot of type level stuff, you might eventually just want the singletons library in general
05:25 jbiesnecker joined
05:25 <jle`> also Bool is awkward at the value level, and it is just as awkward if not more at the type level
05:25 <jle`> so there's a chacne your program might look better w/o Bool in the first place, and using something else
05:25 <iqubic> I don't know enough about Stack or Cabal to know what a cabal file is.
05:25 <tathougies> @jle` I'm familiar with singletons, but my use case is very limited. Certainly not at the singletons level. I'm just doing some simple calculations with Nat, and the (<=?) type family returns Bool. Thanks for the tips though
05:25 <lambdabot> Parse failed: Parse error: my
05:26 sleffy joined
05:26 <Cale> iqubic: Okay, so start with "stack new mandelbrot"
05:26 <iqubic> So can someone explain to me what a cabal file is? And how to get Hackage libraries working in my programs.
05:27 <iqubic> I will do that.
05:27 <Cale> iqubic: A cabal file explains what your project is, what dependencies it has, and other information relevant to building it. Cabal-install and Stack (both of which use the Cabal library) use the information in that file to know how to build your project.
05:27 FreeBirdLjj joined
05:27 <jle`> tathougies: no problem. yeah, <=? from TypeLits is kind of weird to ues directly too in the big picture. i feel like it's mostly meant for low-level interfaces, and the hope is that you would use them indirectly through other libraries
05:28 wroathe joined
05:28 <jle`> but for a simple case then yeah oh well, heh
05:28 <Cale> iqubic: Once that stack command finishes, cd into the directory it created, and have a look at mandelbrot.cabal
05:28 <iqubic> I will do that.
05:28 <Cale> (in whatever text editor you like)
05:28 <jle`> the entire GHC.TypeLits module is more like a ghc api/internals than meant for actual end usage
05:29 <iqubic> There is a lot of stuff in that .cabal file already.
05:29 <Cale> iqubic: It seems that stack just assumes you're going to build something that will both have a library and an executable
05:29 <Cale> yeah
05:29 <Cale> It just gets you started with some sensible default stuff
05:30 <Cale> You can see the "library" section with its indented stuff, you might just want to get rid of that.
05:30 <Cale> and then the executable section following it
05:30 <Cale> notice the "build-depends" fields?
05:30 <Cale> Those list the packages that the various parts of your project depend on
05:30 <iqubic> Why? Why should I get rid of the library and executable sections?
05:31 <Cale> No, just the library section, assuming you're building an executable program and not a library
05:31 <Cale> You can keep both if you want though
05:31 <iqubic> I am building an executable, and not a library. That is right.
05:31 vlatkoB joined
05:31 <iqubic> Should I remove the test section, or no?
05:32 <Cale> Eh, for now, why not? Let's keep it simple.
05:33 takle joined
05:33 <Cale> So, you'll want to add gloss and JuicyPixels to the build-depends list
05:33 <iqubic> Alright, currently I only depend on base and mandelbrot
05:33 <iqubic> What else do I add to the dependecy list?
05:33 <Cale> and actually, remove mandelbrot
05:33 <iqubic> Why?
05:33 <Cale> because that's assuming your project is split into a library and an executable
05:34 <iqubic> Ah.
05:34 <Cale> so the executable depends on its library
05:34 ryxai joined
05:34 <iqubic> Ah.
05:34 <iqubic> So, I depend on base, gloss and JuicyPixels.
05:34 <Cale> yeah
05:34 <iqubic> How do I tell stack that I depend on the latter two things.
05:34 <iqubic> ??
05:34 <Cale> build-depends: base, gloss, JuicyPixels
05:34 sleffy joined
05:35 <iqubic> Cool.
05:35 <Cale> Now, try running stack repl
05:35 <iqubic> And then I just put my code in src folder?
05:36 <Cale> It'll be app/Main.hs
05:36 <iqubic> What is the src file for?
05:36 <iqubic> Compiled code?
05:36 <Cale> That was for the library
05:36 <Cale> You can configure this in the .cabal
05:36 <iqubic> So I can remove the src folder?
05:36 <Cale> You'll see hs-source-dirs: app
05:37 <Cale> You can change that to src if you'd prefer to put code in src
05:37 <iqubic> Also, running stack repl is downloading the libraries I depend on. That's cool
05:37 <Cale> yep
05:37 <iqubic> What does this setup.hs file do that I have in this project folder now?
05:37 <iqubic> I mean it was created as part of the template.
05:38 wroathe joined
05:38 <iqubic> What does that setup.hs thing do?
05:38 SimpleL joined
05:38 <Cale> You only ever edit that if you really want to program more carefully how the Cabal library deals with configuring, building and installing your package. Very few projects ever touch that.
05:38 <iqubic> Also do I need to worry about stack.yaml at this moment?
05:39 <iqubic> Is that important?
05:39 <Cale> The main thing in stack.yaml is that you can choose which repository of packages it's going to get things from
05:39 suds13_ joined
05:39 <iqubic> I'll use the default.
05:40 <iqubic> I assume that'll be fine for me.
05:40 <iqubic> Gosh, OpenGL takes forever to install.
05:41 <iqubic> How do I compile my project? Stack Build?
05:41 <iqubic> How do I run it? Stack exec?
05:41 <suds13_> join #haskell-beginners
05:41 <Cale> When it finishes, you'll probably get a compile failure with "failed to load interface for Lib" because we stripped out the Lib component
05:41 <cocreature> "stack build"
05:41 <Cale> suds13_: hm?
05:42 <Cale> Yeah, stack build will build the executable.
05:42 <ski> (presumably missed hitting the `/' key on the keyboard)
05:42 <Cale> ah
05:42 <suds13_> Cale: hehe wrong place to put command
05:42 revprez_atlanta joined
05:43 <Cale> suds13_: that's all right -- at first I wondered if you were suggesting we take the discussion there
05:43 <Cale> I want to emphasise that #haskell is also a fine place for beginner discussion, despite the existence of the other channel :)
05:44 <iqubic> You know, I just went ahead and rebuilt my project with the simple template, becuase stack recommended that to me.
05:44 <iqubic> It has only the barebones stuff.
05:45 <MarcelineVQ> simple won't be much different than what you ended up with, except your Main.hs will be in src/
05:45 <iqubic> Now, do I want to create a github repo to go with this project, or no?
05:45 <iqubic> Note: I know enough about git to do that on my own.
05:46 osa1 joined
05:46 osa1 joined
05:46 <cocreature> stack doesn’t really care if you have a github repository for your project but if you want to have one, sure go ahead
05:47 <iqubic> I don't want one for this project.
05:47 <iqubic> Actually, yes I do.
05:47 <iqubic> Scratch that.
05:47 <Cale> iqubic: Well, it's up to you :)
05:48 wroathe joined
05:48 <iqubic> Alright, I have a question.
05:49 <lpaste> IQubic pasted “yaml default config” at http://lpaste.net/354444
05:50 MrWoohoo joined
05:50 <iqubic> If you look at that paste, you'll see that stack is telling me I can create a yaml file with default parameters. How would I do that?
05:50 <cocreature> it pretty much tells you the two options, no?
05:51 <iqubic> Yeah.
05:51 <cocreature> so I guess I don’t understand your question
05:51 <iqubic> I want to go the .yaml file way, but I don't know what the yaml file would look like.
05:51 <cocreature> you can literally just copy the yaml that this error message shows
05:51 <cocreature> so line 3-9
05:51 <iqubic> Oh, I can. LOL
05:52 _sras_ joined
05:52 <cocreature> replace value by the actual values :)
05:52 <iqubic> I will
05:52 <_sras_> Is there any rule one can follow to not end up with circular dependencies?
05:53 <jle`> there's one obvious rule
05:53 <lpaste> Cale pasted “Starter for gloss” at http://lpaste.net/354445
05:53 <jle`> but there are some general heuristics too
05:53 <Cale> iqubic: ^^ try that :)
05:54 <jle`> a lot of libraries use a 'Types' module that just exports types
05:54 <Cale> iqubic: You should be able to stack repl, and then just type main
05:54 <Cale> iqubic: and if all is well, you'll get a black window with a red circle in it
05:54 <Cale> iqubic: and you can drag the circle around and mousewheel zooms
05:55 <iqubic> Cool. I'll try that.
05:55 <Cale> huh, there's some interesting jankiness zooming out
05:55 <iqubic> Why is that?
05:55 <Cale> I'm guessing GL weirdness
05:56 <iqubic> Is GL usually weird?
05:56 <Cale> The circle turns into an octagon once you're zoomed out a ways
05:56 <Cale> Yes.
05:56 significance joined
05:56 <iqubic> Oh, that's odd.
05:57 paulsh94 joined
05:57 <iqubic> So I loaded up the repl.
05:57 <Cale> Try main
05:57 <iqubic> Typed main, and that appears to be a Hello World program.
05:58 <Cale> Oh, did you copy over the code I put on lpaste?
05:58 Noldorin joined
05:58 <iqubic> No.
05:58 <iqubic> Should I do that.
05:58 wroathe joined
05:58 <Cale> Yeah, give it a shot
05:58 <Cale> Just edit Main.hs
05:58 <Cale> and then :r in ghci
06:00 <iqubic> Looks like I now get an error.
06:00 <iqubic> *** Exception: user error (unknown GLUT entry glutInit)
06:00 <Cale> aha
06:00 <iqubic> Cale, I tried your code and it didn't work.
06:00 <Cale> You'll want to install freeglut3-dev
06:00 <iqubic> From hackage?
06:00 <Cale> Or whatever the equivalent package is in your linux distribution
06:00 ner0x652 joined
06:01 <iqubic> Ah, from my package manager.
06:01 <Cale> yeah
06:01 <iqubic> Why is that needed>
06:01 <iqubic> ?
06:01 <tsahyt> I'm starting to think that Data.Constraint.Nat doesn't really work that well
06:01 <Cale> Because that's a C library which the libraries we're using involve a binding to
06:01 <tsahyt> this time I managed to just outright segfault after successful typechecking
06:02 <iqubic> Ah
06:02 <iqubic> Do I need the latest version of freeglut?
06:02 <iqubic> I.E> 3-dev?
06:02 <Cale> Should be fine
06:02 <iqubic> Cool.
06:02 <iqubic> I'm just installing that now.
06:03 <ertes> are there any music composition libraries that still work? i can't get Euterpea or haskore running
06:03 <Cale> That's just the development package for freeglut3
06:03 <iqubic> Let's see if this will work
06:03 <cocreature> tsahyt: if you are only interested in the .Nat part of constraints, https://hackage.haskell.org/package/ghc-typelits-natnormalise is probably a better choice
06:03 <tsahyt> this segfaults http://sprunge.us/ISQY?hs
06:03 abhiroop joined
06:03 <tsahyt> cocreature: yeah I've also tried with the typechecker plugins, and it works. although here I need the one to deduce KnownNat
06:03 <iqubic> Looks like that is working just fine.
06:04 <tsahyt> I wonder whether I should report that as a bug
06:04 <iqubic> I got the red circle to work for me.
06:04 <tsahyt> or whether it's my own ineptness causing it
06:04 <Cale> iqubic: cool
06:04 <tsahyt> but then again, a Haskell program shouldn't segfault after successful compilation
06:04 <iqubic> It really shouldn't
06:04 <Cale> tsahyt: It's probably a bug of some sort.
06:05 <Cale> tsahyt: But you might want to try simplifying things a bit and seeing whether you can still cause it
06:05 <iqubic> Question is, can I import gloss and JuicyPixel modules into my repl and look at the types of the functions and what not?
06:05 <Cale> tsahyt: TypeApplications are new -- maybe try not using them?
06:05 <tsahyt> hmm yeah I could try explicit signatures
06:06 <iqubic> What's the right way to stop main without killing my repl?
06:06 <iqubic> I just tried to close the window, and my repl closed down too.
06:06 <cocreature> I wouldn’t expect TypeApplications to result in runtime segfaults
06:06 <Cale> iqubic: Ah, dang, I forgot about that. That's just a general problem with OpenGL applications in GHCi.
06:06 <iqubic> Is it?
06:07 <iqubic> I'll just have to deal with that then.
06:07 <iqubic> Not too bad really.
06:07 <Cale> cocreature: Well, I wouldn't expect any of this stuff to result in runtime segfaults :P
06:07 <cocreature> Cale: constraints contains a sufficient amount of unsafeCoerce for that to happen :)
06:07 <tsahyt> nope, still crashes
06:07 <Cale> cocreature: ah, right, there's a bit of that
06:08 <tsahyt> in particular those KnownNat entailments all work using unsafeCoerce
06:08 wroathe joined
06:08 <cocreature> tsahyt: I’ll see if I can reproduze the segfault using 8.2rc1. give me a minute
06:08 <tsahyt> i.e. plusNat and timesNat, which I'm using here
06:10 <tsahyt> The packages from the clash-lang people have most of what I need too. I can define the Divides constraint in terms of GCD.
06:10 <iqubic> Where does stack put my compiled code?
06:11 <Cale> iqubic: It should tell you when it builds
06:11 takle joined
06:11 <iqubic> How do I run my code once I have compiled it?
06:11 <tsahyt> iqubic: stack exec <executable-name>
06:11 <iqubic> So it doesn't put it in that folder?
06:11 <Cale> ah, right
06:11 <Cale> and it does put it somewhere relative to the project root
06:12 <Cale> I got mandelbrot/.stack-work/install/x86_64-linux/lts-8.8/8.0.2/bin/mandelbrot-exe
06:12 <jle`> if you do 'stack install', then it'll install it in your home directory too so you can use it in other contexts
06:12 <iqubic> Yeah, that's where it put it for me too.
06:12 <jle`> *somewhere in your home directory
06:12 <tsahyt> jle`: ~/.local/bin, at least by default
06:12 <iqubic> Just want to know, so I can add that folder to my .gitignore.
06:12 <cocreature> tsahyt: well now I’m confused. I inlined the necessary definitions http://sprunge.us/efBU?hs because I don’t have a good setup for using external packages outside of creating a cabal project with 8.2rc1 but the segfault is gone now even with 8.0.2
06:13 <iqubic> Or does git already ignore dot files?
06:13 <jle`> iqubic: i just have .stack-work in my gitignore
06:13 <jle`> git does not ignore dot files
06:13 <tsahyt> cocreature: and it does output Just Foo?
06:13 <cocreature> tsahyt: yep
06:13 <iqubic> Alright then, I'll add it to my .gitignore
06:13 <tsahyt> this is very strange
06:13 <jchia_1> Is there a more succint way to define gg, perhaps using some variant of traverse_ that takes one more argument?
06:13 <jchia_1> gg :: (Text -> Text -> IO ()) -> [Text] -> [Text] -> IO()
06:13 <jchia_1> gg f x y = sequence_ $ liftA2 f x y
06:14 <cocreature> :t zipWithM_
06:14 <lambdabot> Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
06:14 <cocreature> ^ jchia_1
06:14 <jle`> slightly different
06:15 <jle`> liftA2 applies the function over every combination
06:15 <cocreature> oh right.
06:15 <jle`> zipWithM "zips" the lists
06:15 <cocreature> I was only looking at the types :)
06:15 <jchia_1> cocreature: cocreature: I don't think zipWithM gives a cartesian product.
06:15 <jle`> fair enough. ship it
06:15 <jle`> to be honest, gg right now looks pretty succinct already
06:16 <Cale> jchia: I wouldn't bother trying to make that any more succinct, yeah
06:16 <cocreature> maybe make the type signature more general
06:16 <jchia_1> jle`: I just want to know whether there's a standard function I can use to replace sequence_ & liftA2
06:17 <jchia_1> I suppose if there isn't I'll just use the current definition.
06:17 <iqubic> What should I put in my git ignore? Just .stack-work?
06:17 <jle`> just .stack-work should be ok, if you're using stack
06:17 <jle`> and any other project-specific stuff
06:17 <jle`> like if you had your secret mendelbrot-based bank credentials stored in the directory
06:17 <tsahyt> cocreature: I tried it and with the inlined definitions it works for me too
06:18 <cocreature> tsahyt: that’s going to make it hard to produce a self-contained example for a bugreport :)
06:18 <jle`> but just from stack alone, you only need to worry about .stack-work
06:18 <iqubic> Cool
06:18 <tsahyt> cocreature: Maybe it still breaks across a simple module barrier
06:18 wroathe joined
06:19 vydd joined
06:20 takle joined
06:21 <cocreature> tsahyt: nope
06:21 <tsahyt> so it only breaks when the definition comes from another package?
06:22 abhiroop joined
06:22 <cocreature> using the exact module structure used by constraints might be worth a try
06:22 <cocreature> but I’m too lazy for that :)
06:22 <tsahyt> I don't see how the module structure could possibly be the case
06:23 <iqubic> I just realized why Stack is considered to be a reproducible build environment.
06:23 <tsahyt> okay now I'm really confused
06:23 <tsahyt> so I tried this earlier with stack ghci and stack runghc in the global resolver
06:24 <tsahyt> and got segfaults in both cases. with the inlined definitions it works with runghc in the global resolver
06:24 <iqubic> Anyone can clone my git repo, and run "stack build" to build my project. All required libraries would be pulled in for them.
06:24 <tsahyt> in a separate stack project, it just works
06:24 <tsahyt> regardless of whether I inline or use constraints or have the definitions in a separate module
06:24 <iqubic> You can inline functions in Haskell?
06:24 <iqubic> What benefits does that give you?
06:25 <tsahyt> iqubic: yes, but here I just mean copy-pasting functions from a library in my file
06:25 <tsahyt> iqubic: actual inlining is at the very heart of GHCs optimizer.
06:25 <tsahyt> you can try and force it to inline something by using pragmas
06:26 <tsahyt> whether that's actually beneficial or not depends on the situation. there are plenty of examples where more optimizations can fire after inlining
06:27 <iqubic> So, now that I have to libraries installed, do they just live on my computer, or will stack have to fetch the libraries each time I run "stack build"
06:27 <tsahyt> in many cases it doesn't help nor harm, and in some cases you can end up with worse performance for some reason that I've never investigated
06:27 <iqubic> Rather, can I compile this program while offline?
06:27 <tsahyt> iqubic: as long as you use the same resolver, it does not refetch any packages
06:27 <iqubic> Good.
06:27 <tsahyt> it would fetch something if you added a dependency for example
06:27 <iqubic> And the pacages are saved on my computer, so I can compile offline?
06:28 <iqubic> *packages
06:28 <tsahyt> and if you change the resolver it may refetch a few things that have been updated, while using the existing ones for things that haven't
06:28 twistedbot joined
06:28 <tsahyt> yeah you can use it offline unless you do something that requires fetching more stuff
06:28 <iqubic> Cool that's wonderful.
06:28 <iqubic> I'm going to look into using gloss and JuicyPixels together now.
06:29 <iqubic> But before I go, what's a resolver?
06:29 <iqubic> Also, can I search hoogle for functions that come from libraries?
06:29 <tsahyt> the stackage snapshot
06:29 <tsahyt> e.g. the latest nightly, or lts-8.8, or whatever
06:29 wroathe joined
06:29 <iqubic> Like can I search hoogle for the "play" function from gloss?
06:30 <tsahyt> you can use stack hoogle in your project directory to search through everything your stuff depends on
06:30 <cocreature> iqubic: http://hoogle.haskell.org/?hoogle=play%20package%3Agloss
06:30 <tsahyt> shameless plug https://github.com/tsahyt/hdocview
06:31 splanch joined
06:32 <iqubic> Looks like I need to generate a hoogle database for this project first.
06:32 <tsahyt> cocreature: I think I figured it out. my global stack resolver is still lts-8.5
06:32 <tsahyt> which apparently had a constraints version that suffered from a bug here. using lts-8.8 it works
06:33 <cocreature> ah ok
06:33 <iqubic> I think I'll stick to the command line interface. Though that hdocviewer looks wonderful.
06:34 <iqubic> tsahyt: Did you write hdocviewer in Haskell?
06:34 <tsahyt> yep
06:34 <iqubic> What did you use for GUI? GTK?
06:34 <tsahyt> it really just reuses hoogle underneath and provides a GUI on top
06:34 <tsahyt> gi-gtk
06:35 <tsahyt> everything tied together using reactive-banana
06:35 <tsahyt> and of course reusing hoogle for search underneath
06:35 <iqubic> What is reactive-banana?
06:35 <tsahyt> https://hackage.haskell.org/package/reactive-banana
06:36 <iqubic> Alright, I have seen the term thrown around a bunch of times, but I don't know what it means. What exactly is FRP?
06:36 <tsahyt> functional reactive programming
06:36 <tsahyt> and I'm not very good at explaining it I'm afraid
06:37 <iqubic> I know what it stands for, I have no Idea what it is.
06:38 <iqubic> Why do you have to Init nothing???
06:38 <iqubic> In main of hdocviewer.
06:38 <tsahyt> init is a gtk function
06:38 <tsahyt> I'm just initializing all the gtk stuff there
06:38 Beetny joined
06:38 <tsahyt> and apparently init takes an optional parameter
06:38 <iqubic> You do know that the arrow is pointless on that line.
06:39 bntr joined
06:39 <iqubic> As you never actually use the return value.
06:39 wroathe joined
06:39 <tsahyt> that's exactly why it's there
06:39 twistedbot joined
06:39 <tsahyt> you get a compiler warning for a discarded return value when compiling with -Wall
06:39 <tsahyt> I'm just discarding it explicitly
06:39 <iqubic> You do? why???
06:40 <tsahyt> well I discard it explicitly because I have acknowledged the warning and decided that I know what I'm doing. you get the warning because you might have forgotten about something.
06:40 <cocreature> because if there is a return value you might want to do something with it :)
06:40 simukis_first_ni joined
06:41 <iqubic> cocreature: Isn't there always a return value? Isn't that one of the tennants of functional programming?
06:41 <iqubic> Even putStrnLn has a return value: IO ()
06:41 <cocreature> iqubic: sure but () only has one value so you don’t gain any information by inspecting the return value
06:42 kody joined
06:42 <iqubic> So compiling with -Wall won't see throwing away a value of IO () as an error?
06:42 <Cale> iqubic: Functional reactive programming is a way of writing interactive programs by describing things that change over time.
06:43 <iqubic> What the heck does that mean? Sounds complex as all heck.
06:43 <Cale> iqubic: In particular, there are two major concepts
06:44 <Cale> There are things which, whenever you care to look at them, will have some value. These are called behaviours, and there will typically be some type like Behaviour a for such a thing which has a value of type a at any moment.
06:44 <iqubic> So a text box has a behavior?
06:44 <rotaerk> text-contained-by-text-box is a behavior
06:44 <iqubic> because when ever you look at it there will always be some text in the text box
06:44 <Cale> For example, the current position of the mouse, the current hitpoints of a monster, the current location of the character in a game world, the current contents of a text box, the current time, the current scene being drawn on the screen, etc.
06:44 <Cale> Yeah
06:45 bntr left
06:45 bntr joined
06:45 <iqubic> Alright, what's the other main concept?
06:45 <Cale> Then you have things which happen at certain moments in time, and have a value just at those moments.
06:45 <Cale> These are called events.
06:45 <tsahyt> e.g. a clicked event on a button
06:46 <iqubic> So an event is like clicking a button on screen, or pressing the spacebar.
06:46 <Cale> You'll have things like the sequence of mouse clicks, the sequence of attacks made by a monster, the sequence of sound clips to be played, the sequence of keystrokes typed by a user, the sequence of edits made to a textbox
06:46 <iqubic> How do you translate that to code?
06:46 <iqubic> Or there FRP libraries?
06:46 <Cale> The sequence of requests made to a network server, and the sequence of responses coming back :)
06:46 mojjo joined
06:46 <iqubic> Is see.
06:46 <iqubic> *I
06:47 <tsahyt> iqubic: yes, reactive-banana is one of them. there's also reflex which is quite popular nowadays.
06:47 <tsahyt> and a plethora of other libraries as well, but those are the two that see the most use today
06:47 <Cale> I actually do my work in reflex :)
06:47 <tsahyt> Cale: is there a good write up on the design of reflex that does not go into reflex-dom?
06:47 <iqubic> How does reflex work?
06:47 <Cale> So, FRP libraries typically will implement some Behavior and Event types and then a bunch of operations for combining events and behaviours to form additional events and behaviours
06:48 <iqubic> And you have to define your own behaviors, right?
06:48 abhiroop joined
06:49 <Cale> Well, you might get them from some library you're using
06:49 wroathe joined
06:49 <iqubic> And I assume you can compose behaviors yourself if you want.
06:50 <Cale> Another way to characterise events and behaviours is that events are sort of like "push" notifications -- something which receives an Event can compute some stuff based on it every time that it occurs.
06:50 <tsahyt> you can also define a behavior in terms of events. for example you have a mouse click event carrying coordinates where the click was made. then you can define a behavior that "holds" the last pair of coordinates
06:50 <Cale> while behaviours are "pull" -- you're never notified when a behaviour updates, and so it may be updated continuously
06:50 <iqubic> Cool.
06:50 <iqubic> I'll look into this stuff later.
06:50 <Cale> but at any moment when an event is occurring, you can observe the present values of the behaviours
06:51 <tsahyt> Cale: well, reactive-banana allows you to listen in on a behavior and get a change event in return
06:51 <tsahyt> but that uses future values
06:51 <Cale> tsahyt: That's fairly naughty of it ;)
06:51 pwnz0r joined
06:52 <iqubic> Well, time to learn more about Gloss and JuicyPixels
06:52 iqubic left
06:52 <Cale> The fact that you can't necessarily be informed when a behaviour is updating is actually a bit key to designing FRP systems which interact in a way that will perform well.
06:52 twistedbot joined
06:52 <tsahyt> I should really look more into reflex. I've just stuck to r-b for my FRP needs so far, because I'm still staying as far away as possible from web programming.
06:52 <tsahyt> and it seems like there are mostly web things related to reflex
06:52 <Cale> Behaviours can be used to safely allow a high-frequency part of the system communicate with a part of the system which must run at a lower frequency
06:53 <tsahyt> hmm why do I get a PM from twistedbot every time I mention web things
06:53 <Cale> without worry about whether you'll accidentally cause lots of additional updates
06:53 <Cale> For example, perhaps one part of your system deals with processing audio and has an event firing at 44kHz
06:53 <tsahyt> hmm I see
06:54 <Cale> and then you have a part responsible for rendering graphics running at 60Hz
06:54 <tsahyt> I've actually tried doing audio with FRP and JACK and found the performance to be rather appalling
06:54 <tsahyt> both with r-b and wires
06:55 hallowed joined
06:55 <tsahyt> triggering events at this sort of rate was just eating away at the CPU like nothing
06:55 <Cale> I believe it was imalsogreg who managed to get some audio processing going in reflex.
06:56 <tsahyt> I ended up foregoing the FRP abstraction for the actual sample generation and introduced a new type for it
06:56 hybrid joined
06:56 <Cale> Is hallowed a bot?
06:56 <tsahyt> I think it is
06:56 <tsahyt> so I'm not the only one getting PMs all the time?
06:56 was kicked by Cale: hallowed
06:57 <Cale> actually, maybe should have picked a different option there for the mask
06:57 <ski> same IP
06:57 <Cale> yeah
06:57 <ski> (also same as another nick)
06:58 <MarcelineVQ> getting calls from an cute robut?
06:58 <Cale> bntr: okay
06:58 <tsahyt> Cale: I should say it was running, but it wasn't performing as well as I hoped. some very simple oscillators already took up about 30% of one core.
06:59 <Cale> tsahyt: ah, okay
06:59 <tsahyt> Cale: it was likely also a problem because of the context switching between the FRP thread and the JACK thread.
06:59 dan_f_ joined
06:59 wroathe joined
07:00 <tsahyt> so instead I wrapped a type describing a wave, which itself was a behavior in the FRP part and was shared with JACK via an IORef. the JACK callback would then just evaluate as much as it needed of that wave, put it in a buffer and return. That got CPU usage down to <1%
07:00 <Cale> tsahyt: Well, that is also insanely higher frequency than most users are actually using it. I think there's some potential to eventually make that kind of thing perform well, but no promises about whether it'll require special compiler support.
07:00 takle joined
07:01 <tsahyt> unfortunately, the sampling theorem mandates this kind of frequency for audio.
07:01 <Cale> Of course :)
07:01 <cocreature> arguably you shouldn’t write audio software in a high-level language such as haskell anyway :)
07:01 <cocreature> at least not realtime audio software
07:01 <Cale> cocreature: You're crazy
07:01 <Cale> hahah
07:01 <tsahyt> but using this sort of wave trickery, you can get the frequency of FRP events down and everything works :)
07:02 <tsahyt> cocreature: but I want to :P
07:02 <cocreature> Cale: :)
07:02 <ongy> good old walkman days. Where we had ocaisonal skips because reasons. just that it's GC instead of a bump
07:02 JuanMiguel joined
07:02 raichoo joined
07:03 <tsahyt> something something linear types
07:03 <tsahyt> but in my tests I actually had no problems with the GC, since I was never handling significant amounts of data.
07:03 <Cale> I wonder if Ryan has any plans with respect to compact regions
07:03 <Cale> It's quite plausible
07:03 <tsahyt> as long as you're just processing buffers of reasonable size, I don't think it'd be much of an issue
07:04 <ongy> how often does major GC happen?
07:04 <Cale> It probably depends, but once every 5 minutes or so?
07:05 <Cale> At least, that's what it was back in 2011 the last time I cared about that statistic
07:06 <mniip> Cale: bntr?
07:06 <Cale> mniip: hm?
07:06 <bntr> hiya?
07:07 splanch joined
07:07 <Cale> mniip: I was about to ban because of a misbehaved bot, but bntr showed up and apologized for it, so I cancelled that.
07:07 fizruk joined
07:07 JuanDaugherty joined
07:07 <mniip> ah ha
07:07 <mniip> okay!
07:08 boombanana joined
07:09 chaosmasttter joined
07:09 takuan joined
07:09 wroathe joined
07:11 vlatkoB_ joined
07:11 iomonad joined
07:12 oish joined
07:14 takle joined
07:15 slomo joined
07:20 vydd joined
07:22 bennofs joined
07:22 t0by joined
07:23 presiden joined
07:24 danvet joined
07:24 iomonad joined
07:25 whiteline joined
07:26 fuzzy-id joined
07:26 Mysterious_Light joined
07:30 yellowj joined
07:30 wroathe joined
07:30 Sgeo joined
07:30 abhiroop joined
07:31 ruuns joined
07:33 Mon_Ouie joined
07:33 <tsahyt> so with the constraints based solution I was unable to pattern match on an explicit proof that c ~ Gcd c n, now with the ghc-typelits-extras based solution it's unable to infer that n ~ Gcd n n.
07:33 <tsahyt> this is getting slightly frustrating
07:34 <tsahyt> and unfortunately I cannot mix the two approaches because they use different type families for the gcd
07:34 ddere joined
07:34 blocus joined
07:35 albertus1 joined
07:35 MoALTz joined
07:35 SpinTensor joined
07:36 <tsahyt> I'll just abuse fromJust then and leave that final proof obligation of gcd being idempotent for now.
07:36 <Cale> tsahyt: You've gotta expect dependently typed programming in Haskell to be pretty frustrating though
07:37 <tsahyt> Cale: I do, but I'm stubborn like that
07:37 <Cale> Given that it's not actually dependently typed :P
07:37 <tsahyt> there's a bit of a backstory here. In a course I'm attending we've been told to first implement factorization in a language of our choice and then in Why3 which utilizes SMT underneath to check against specification
07:38 <tsahyt> so I thought it'd be a fun exercise to write a haskell implementation with the same static guarantees. or at least almost the same. I want to get as close as possible.
07:38 <tsahyt> just to show that it's possible to get very strong guarantees in a production ready language today by just utilizing types. the production ready part also rules out idris.
07:40 <tsahyt> in Haskell I've hit the same roadblock as usually. I could quickly define a type that only allows valid factorizations, but actually building values of that type at runtime is tricky.
07:41 kody joined
07:41 <Cale> ah, that's a fair enough motivation
07:42 bntr joined
07:43 lerax joined
07:45 shayan_ joined
07:46 <cocreature> tsahyt: arguably idris is about as production ready as the almost dependently typed part of Haskell :)
07:46 <lerax> almost all the libs I see is dependent of idris
07:47 <tsahyt> cocreature: even then I've immediately been turned off by it being strict by default. I've actually written at least part of the factorization algorithm and even for this small example I found laziness to just be nicer
07:47 <tsahyt> to be fair, all I'd need there are lazy lists so I can use them as a control structure, but still
07:48 <tsahyt> I know there are people complaining about lazy evaluation in Haskell, but imo it's just the better default
07:48 <cocreature> tsahyt: oh I’m not arguing that you should be using idris. I just don’t think the production-ready argument is very strong in this area
07:48 Ch0c0late joined
07:48 <tsahyt> the more time I spend with this, the more I'm inclined to agree
07:49 <cocreature> also competing with SMT solvers using types or even type-theory based theorem provers is really hard when it comes to proving properties about numbers
07:49 <tsahyt> though to be fair, a lot of my problems here are due to my inexperience with this sort of thing
07:49 <tsahyt> cocreature: I noticed that. I've also started a liquid haskell based solution, but didn't get too far with it yet.
07:50 <tsahyt> I find it rather interesting how I'm routinely expressing structural invariants in types, but arithmetic properties turn out to be so much harder to work with
07:50 <cocreature> you can ofc build a typechecker plugin that uses an SMT solver to resolve constraints (and I think I’ve seen that for GHC somewhere) but at that point you are just using an SMT solver :)
07:51 detrumi joined
07:52 <tsahyt> well, so far I can now find the smallest prime factor of a composite (or determine that the input is not composite)
07:52 <tsahyt> now on to the recursion
07:53 LnL joined
07:54 infinity0 joined
07:54 Swizec joined
07:55 Swizec joined
07:56 Swizec joined
07:56 Swizec joined
07:57 Swizec joined
07:58 <cocreature> tsahyt: it might be a bit more pleasant if you build your own inductively defined natural number type and lift that to the typelevel via DataKinds
07:58 <cocreature> GHC.TypeLits is especially annoying because it’s builtin magic
07:59 <tsahyt> I've found that over the last year or so it has become less of a pain to work with as there are now libraries cropping up that make good use of it
08:00 <cocreature> I’m mostly annoyed by having to pass around the KnownNat constraints everywhere instead of getting some singleton-like interface where I can just get the value by pattern matching
08:00 wroathe joined
08:01 Argue joined
08:02 kody1 joined
08:02 feynhat joined
08:05 __main__ joined
08:08 <mniip> cocreature, an idea of a library has been haunting me
08:08 <mniip> I mean, I don't think there's a way to GADT-ize typelits safely, so
08:09 <mniip> you're better off doing unsafeCoerce in a library where it can be checked by others
08:09 <mniip> than making ad-hoc implementations of the same thing
08:09 zero_byte joined
08:09 <tsahyt> │ • Could not deduce: (n1 * (n0 + 1)) ~ (n + 1)
08:09 <tsahyt> │ from the context: (Divides n1 (n + 1), KnownNat n1)
08:09 <tsahyt> so close and yet so far
08:10 supki joined
08:10 <cocreature> mniip: I’m not sure I understand you correctly. are you talking about something like Data.Constraint.Nat from the constraints package?
08:10 supki joined
08:10 augur joined
08:10 richi235 joined
08:11 <mniip> ooh
08:11 <mniip> that looks nifty
08:11 <mniip> yeah
08:11 LnL joined
08:11 <cocreature> well as tsahyt can tell you, it’s not super pleasant to work with :)
08:11 <mniip> edwardk beat me to it as always
08:11 <* edwardk> shrugs.
08:12 HugoDaniel joined
08:12 <tsahyt> it's not so much unpleasant as it didn't work for my case. At one point I needed a proof that c ~ Gcd c n, which I can get out by using sameNat and pattern matching on the Refl
08:12 <mniip> cocreature, I had a different construction in mind but yes, this works just as well
08:12 <tsahyt> but due to things I do not understand properly GHC just refused to do that with the Gcd in constraints
08:12 <edwardk> the combinators in Data.Constraint.Nat aren't exhaustive, they are just 'what i could think of in the moment'
08:12 <tsahyt> and gave me an inaccessible code error
08:12 <edwardk> i wrote it over the course of an hour or two
08:12 <edwardk> and then forgot about it
08:13 <tsahyt> I like the idea of using :- to prove things to the compiler though
08:13 revprez_atlanta joined
08:13 <tsahyt> in a way I'm more fond of it than pulling in some magical type checker plugin for it
08:13 <edwardk> *nods*
08:13 takle joined
08:13 <tsahyt> edwardk: is it possible that I get this inaccessible code error because Gcd has no equations?
08:14 lep-delete joined
08:14 <tsahyt> the paste is still somewhere in my logs if you need a minimal example
08:14 <edwardk> i've debated about writing some template haskell that would let you write the stuff at the value level and lift it to related type families on types with singleton representations easily
08:14 <cocreature> tsahyt: can you match on timesDistributesOverGcd to get to c * Gcd 1 n and then match on gcdOne or something like that?
08:14 supki joined
08:14 <edwardk> tsahyt: not sure. did you paste code somewhere?
08:14 supki joined
08:14 <tsahyt> edwardk: I did, let me dig up the link
08:15 <tsahyt> edwardk: this is the most minimal example I could come up with http://lpaste.net/354432
08:15 <mniip> edwardk, cocreature, what I had in mind was more like p n -> (p 0 -> r) -> (forall m. p (1 + m) -> r) -> r
08:15 <mniip> spiced with some KnownNat probably
08:16 <cocreature> mniip: ah so an induction principle
08:16 <mniip> kinda
08:16 <bollu> doesn't GCD make this process somewhat undecidable?
08:16 <mniip> pattern matching on zero/succ rather
08:16 <mniip> but yes, the idea was to implement various inductions
08:16 <tsahyt> bollu: sameNat evaluates at runtime, hence why it needs the KnownNat constraints, and why I do this entire construction using Maybe
08:16 <mniip> I just never decided which
08:16 <cocreature> oh right that’s not induction
08:16 <bollu> tsahyt: I see
08:16 <mniip> e.g
08:17 <mniip> data Binary = Zero | TimesTwo Binary | TimesTwoPlusOne Binary
08:17 <mniip> is not a singleton
08:17 <mniip> because Zero = TimesTwo Zero
08:17 <edwardk> tsahyt: ghc is being a bit over-eager there
08:17 <mniip> data Binary = Zero | TimesTwoPlusOne Binary | TimesTwoPlusTwo Binary
08:17 <mniip> is a singleton
08:17 <mniip> but is annoying to work with
08:17 <edwardk> odd, i usually get to treat type families like that uninterpreted functions then perform equations on them
08:18 <cocreature> mniip: yeah I see what you mean. looking forward to your library :P
08:18 <mniip> hmm
08:18 <mniip> I suppose I could sketch something
08:18 <mniip> like
08:19 <tsahyt> edwardk: the way I read that was that GHC believes that there's no way to ever build Refl and hence thinks it's all dead code anyhow
08:19 <mniip> a lot of recursion schemes make sense only for nonzero naturals
08:19 <tsahyt> this got particularly apparent when I added a Nothing case underneath, which then compiled with just a warning iirc
08:19 raichoo joined
08:19 <edwardk> if i drop the 'where' from the type family definition for Gcd does it work?
08:20 <edwardk> testing real quick
08:20 harfangk joined
08:20 <edwardk> damn, same result
08:21 wroathe joined
08:21 vydd joined
08:21 vydd joined
08:22 <mniip> edwardk, you could define a broadly-kinded family with an equation
08:22 <mniip> and then shrink it to the required kind with a tysyn
08:22 <mniip> implying that the equation doesn't apply to the restricted kind
08:23 supki joined
08:23 shutdown_-h_now joined
08:23 <edwardk> gcdNat isn't a KnownNat, so you first need to use gcdNat to make it known
08:23 <edwardk> er GcdNat
08:24 supki joined
08:24 <bollu> tysyn = ?
08:24 <mniip> type synonym
08:25 <tsahyt> edwardk: but I am using gcdNat here to even make the sameNat typecheck, since it requires two KnownNats
08:25 supki joined
08:25 <tsahyt> do I need to use it again somewhere?
08:26 kritzcreek_ joined
08:26 <edwardk> i'm guessing so, trying to figure out what is going on
08:26 castlelore joined
08:26 castlelore joined
08:26 chaosmasttter joined
08:26 <edwardk> i'm _guessing_ that ghc has a bug here somewhere though, it shouldn't be ruling this out as inacessible, once i fix the type family to be open rather than closed it has no grounds to assume that the type can't reduce in another context
08:26 supki joined
08:27 plutoniix joined
08:28 <edwardk> when i have type family Gcd :: Nat -> Nat -> Nat where then ghc is probably in a good place theoretically ruling out the match
08:28 <edwardk> but without the where? it seems its on shaky moral ground
08:28 <tsahyt> on a related note, from what I can see axiom is defined in much the same way as unsafeCoerceConstraint. so if I find myself missing any entailments to prove a property, I could use unsafeCoerceConstraint to introduce it (assuming that I've proven it).
08:28 <edwardk> articulating that in a form that'd convince simon/richard is another matter
08:28 <tsahyt> oh wait, no that's wrong
08:29 <edwardk> yeah axiom just basically lets you force the type checker to believe you that two types are equal
08:29 <edwardk> axiom :: forall a b. Dict (a ~ b) -- is just evil
08:29 <tsahyt> it is, but from what I can tell it's a necessary evil for this kind of functionality
08:29 <edwardk> yep
08:29 <bollu> edwardk: do you know some place where I can read about how to use ConstraintKinds?
08:29 <bollu> it seems very useful, but I don't know how :)
08:30 <edwardk> i wrote a blog post a few years ago
08:30 <edwardk> http://comonad.com/reader/2011/what-constraints-entail-part-1/
08:30 <edwardk> that post was the first attempt i know of to use constraint kinds in interesting ways
08:30 <mniip> edwardk, convince them about what
08:30 <mniip> your unsafeCoerce usage?
08:31 jeltsch joined
08:31 <bollu> edwardk: ooh, thanks
08:31 <edwardk> mniip: convince them that ghc is being too eager to rule out that Refl as unreachable code
08:31 <edwardk> its nothing to do with unsafeCoerce
08:31 <mniip> ah
08:31 <mniip> well
08:31 wroathe joined
08:31 <mniip> it's kinda obvious when the tyfam is open
08:31 <edwardk> and more to do with treating a type family with a missing case as an uninterpreted function / stuck symbol
08:31 <mniip> you could add an equation and make it outright wrong
08:32 e_svedang joined
08:32 <edwardk> nothing prevents a module that we're not in adding stuff to the type family that would 'unstick' things in another context.
08:32 <edwardk> trick is articulating it in a way they'll accept
08:32 <edwardk> and that doesn't let in all sorts of other crap
08:33 <tsahyt> why is it important that it can flag something as inaccessible code anyhow? from a correctness perspective that is.
08:33 <edwardk> https://ghc.haskell.org/trac/ghc/ticket/11066
08:33 Mon_Ouie joined
08:34 Berra joined
08:35 bntr joined
08:35 <tsahyt> all I wanted to do was implement an unreasonably type safe factorization algorithm, and now I've first submitted a PR to an edwardk library, and then encountered a compiler bug..
08:35 Ferdirand joined
08:35 blocus joined
08:35 <tsahyt> so it goes. I guess I'll have to wait then
08:36 blocus_ joined
08:36 <tsahyt> unfortunately, the type checker plugins broke somewhere else, and with them I can't really write up a proof. or maybe my code is just wrong.
08:37 <cocreature> tsahyt: http://lpaste.net/354446 seems to work
08:38 govg joined
08:38 <cocreature> but only with the explicit type signature
08:38 <cocreature> hm
08:39 mmn80 joined
08:39 <tsahyt> cocreature: what is the timesNat and second gcdNat for?
08:39 ryxai joined
08:39 <tsahyt> I don't quite understand why this would work and the other one doesn't
08:39 augur_ joined
08:40 <cocreature> tsahyt: ignore that. it works once you add a type signature even for your old version
08:40 Wizek_ joined
08:40 <tsahyt> hmm, the original code where the numbers weren't fixed had a type signature and didn't work.
08:41 wroathe joined
08:43 harfangk joined
08:43 <tsahyt> well at least I still get a warning
08:44 <cocreature> yep but the version I posted actually evaluates to ()
08:45 <tsahyt> it still works with a case alternative for Nothing and returning Maybe ()
08:45 nazrhom joined
08:45 <tsahyt> but as soon as I want to actually use the n ~ Gcd n m, I get the error again
08:46 rumble joined
08:46 <tsahyt> http://sprunge.us/RCaH?hs
08:47 <tsahyt> unrelated, does lpaste have a way to be used from the command line?
08:47 koneida joined
08:48 thc202 joined
08:51 abhiroop joined
08:52 <edwardk> tsahyt: i added your code to the issue i linked
08:53 azahi joined
08:53 <seequ_> Is there any nifty function to split a list to arbitrarily many lists at a specific item? So, a -> [a] -> [[a]] or (a -> Bool) -> [a] -> [[a]]
08:53 <cocreature> even http://lpaste.net/354448 fails with the same error
08:53 ragepandemic joined
08:54 <cocreature> seequ_: are you looking for https://hackage.haskell.org/package/extra-1.5.2/docs/Data-List-Extra.html#v:wordsBy
08:54 <tsahyt> edwardk: thanks for reporting this in the right place! I searched for a bit last night and didn't find anything relevant to the error.
08:54 <seequ_> cocreature: yup!
08:55 <tsahyt> about your comment on (+), I have tested this with (n + 2) ~ (2 * n) for some n as input, and it did work after using the appropriate axioms from Data.Constraint.Nat.
08:55 <tsahyt> so it might not always break I guess
08:56 <edwardk> the issue looks to me that ghc gets really picky when it finds a term that doesn't have type variables in it
08:56 <edwardk> when in doubt, move back a step then make the combinator parameterized in a more general fashion
08:57 <edwardk> then use that to prove your more specific fact
08:57 <edwardk> it thinks it should be able to compare `Gcd 3 6` directly as it doesn't involve any type variables
08:57 <edwardk> and there isn't a type instance matching it that it can see
08:58 <tsahyt> edwardk: the issue originally came in a setting where I'd be getting a SomeNat, then matching out the specific Nat c and checking for c ~ Gcd c (n + 1), where n was given by the type signature
08:58 bab joined
08:58 jedws joined
08:58 <cocreature> seequ_: it’s also in the "split" package if you prefer to depend on that over extra
08:59 <tsahyt> edwardk: so in this case it was fully polymorphic
08:59 takle joined
08:59 <* edwardk> shrugs.
08:59 <edwardk> it seems like there be bugs in ghc land ;)
08:59 <tsahyt> luckily I hardly ever encounter one
08:59 <edwardk> they tend to be in crazy corner cases like this
08:59 <tsahyt> and this isn't exactly critical code that I'm working on right now, it's really just a toy to see how far I can push the type system
08:59 <tsahyt> and it seems I've pushed it a bit too far
09:00 <edwardk> compared with scala? i'll take it =)
09:00 <tsahyt> the most I usually ask from typelits is vector bounds and the like.
09:01 <edwardk> likewise
09:01 a3Dman joined
09:01 wroathe joined
09:02 <tsahyt> I've now spent many hours on this problem actually, and I started out with an implementation that could be proven correct via equational reasoning within a matter of minutes. I suppose there's a lesson to be learnt here
09:02 <cocreature> tsahyt: proving things is hard? :)
09:02 jedws joined
09:03 <cocreature> or rather convincing computers that your proof is correct is hard
09:03 <tsahyt> cocreature: rather that pulling everything into types will lead to an explosion in complexity
09:04 <tsahyt> and that there's a triviality threshold where it just doesn't pay anyhow. I mean I've spent considerable effort trying to make the compiler understand that if n `mod` x == 0, x actually divides n.
09:05 <tsahyt> (technically I ended up doing it via Gcd but oh well)
09:06 fizruk joined
09:07 eklavya joined
09:08 zariuq joined
09:09 SyloSybe joined
09:09 piyush-kurur joined
09:12 <edwardk> tsahyt: add an axiom
09:12 Jackneill joined
09:13 HugoDaniel joined
09:14 <tsahyt> Mod n x ~ 0 :- Divides x n? but then I still need to take the value level check to the type level and end up with much the same problem I think
09:14 <tsahyt> unless the problem doesn't exist for Mod for some reason
09:15 KunoMark joined
09:16 <KunoMark> Goodest of mornings to you all!
09:16 <abhiroop> I am stuck with a problem in parsing using ReadP. Can someone help? http://lpaste.net/354450
09:17 iulian joined
09:17 warlock joined
09:18 dawehner joined
09:19 klottie joined
09:20 <KunoMark> How do I do spawn-and-forget, with exception safety, for example when writing an asynchronous server that receives requests and spawns threads to process them?
09:20 jgt1 joined
09:21 <cocreature> KunoMark: what do you mean by exception safety in that context?
09:21 <KunoMark> cocreature: I mean, exceptions in child threads bubble up to parents. Basically, using the Async library.
09:22 vydd joined
09:22 vydd joined
09:22 wroathe joined
09:22 <KunoMark> cocreature: A crude way to spawn-and-forget is to use forkIO, but then exceptions do not propogate to the parent, and one misses out on errors.
09:23 <cocreature> KunoMark: and you can’t use wait because you don’t want your main thread to block?
09:23 <KunoMark> Async allows you to get child exceptions, but only if you `wait` for the result of the child thread, meaning, crudely, you are blocked on the child thrwad
09:23 <KunoMark> Exactly! cocreature
09:24 <cocreature> KunoMark: make a separate thread that only “waitAnyCatch"es and then throws that exception asynchronously to your main thread
09:24 aib joined
09:24 <KunoMark> Let me whip up a quick paste to show you what I'm currently doing...
09:24 <KunoMark> Huh? @cocreature
09:25 javjarfer joined
09:26 louispan joined
09:26 <cocreature> KunoMark: let me make an example
09:30 hurkan joined
09:30 <cocreature> KunoMark: http://lpaste.net/354452 should do what you want I think
09:31 <KunoMark> Here's how I'm doing it currently, cocreature: http://lpaste.net/354453
09:31 <KunoMark> Let me take a look at your example. Thanks. :-)
09:31 catsup joined
09:32 catsup joined
09:33 <KunoMark> Oh! That's very smart, cocreature. Seems about perfect!
09:33 dawehner joined
09:33 <KunoMark> I fee a bit dirty about reverting back to forkIO, though, but hey...
09:33 <KunoMark> As long as it's exception-safe, I'm happy. :-)
09:34 SimpleL joined
09:36 Guest64035 joined
09:36 iomonad joined
09:38 <cocreature> KunoMark: http://lpaste.net/354454 is probably slightly safer
09:38 <KunoMark> Why's that better, cocreature?
09:39 <KunoMark> Please remind me what `mask` does in this context?
09:39 iqubic joined
09:39 <mniip> cocreature, edwardk
09:39 <cocreature> mask blocks async exceptions
09:39 <lpaste> mniip pasted “typelit singletons” at http://lpaste.net/354455
09:39 Ferdirand joined
09:39 <cocreature> KunoMark: I guess it doesn’t matter too much in this case
09:40 simukis_first_ni joined
09:40 cchalmers joined
09:40 <iqubic> How good is the gloss-juicy library at interfacing between the JuicyPixels library and gloss?
09:41 <iqubic> Is it the right thing to use? Or not?
09:41 <KunoMark> Hmm... I need to think deeply and read up on the implications of what you said, cocreature.
09:41 <cocreature> KunoMark: read simon marlows book on this
09:41 <KunoMark> Thanks so very much for your help! :-D :-D
09:41 <KunoMark> Yes, I was thining I should. :-D
09:42 wroathe joined
09:43 <iqubic> So, what do people think of the gloss-juicy library?
09:46 fizruk joined
09:46 <cocreature> mniip: neat
09:46 ali_bush joined
09:46 ali_bush joined
09:47 <mniip> cocreature, now
09:47 <mniip> I wanted to include some other stuff
09:48 <mniip> like a binary induction scheme and the like
09:48 <mniip> but I'm not sure which ones would be useful
09:48 bntr joined
09:48 <cocreature> mniip: my main complaint is that the cases in your induction scheme are in a different order than your data constructors :P
09:48 <mniip> oh but
09:48 <mniip> undoubtedly, N = Z | S N
09:49 <mniip> yet induce looks so much like foldr
09:49 <cocreature> exactly, so your induction scheme should reflect that :)
09:50 merijn joined
09:50 fotonzade joined
09:52 abhiroop joined
09:55 <Adeon> iqubic: I just checked gloss-juicy documentation and it looks okay, it takes juicypixel images and outputs gloss pictures, which is pretty much what I would expect of such library
09:55 <Adeon> plus it has some convenience functions
09:55 <Adeon> I mean, this is all of the library right here: https://hackage.haskell.org/package/gloss-juicy-0.2.2/docs/Graphics-Gloss-Juicy.html
09:55 <iqubic> So if I want to create something like the mandlebrot set, how would JuciyPixels help me.
09:55 vydd joined
09:56 <Adeon> juicypixels is about loading and manipulating images and gloss already have pictures then I think it would not really help you
09:56 <Adeon> IIRC it does have that one convenient function where it calls your function for all pixels to generate an image
09:56 <Adeon> which could be used to make a mandelbrot set image
09:56 <Adeon> and then convert that to gloss
09:57 <Adeon> you can probably do that in gloss too, just not sure if it has the relevant convenience functions
09:57 <Adeon> which would mean some more work
09:58 <Adeon> https://hackage.haskell.org/package/JuicyPixels- look for `generateImage`, that might be what you are looking for
09:58 <iqubic> Adeon, what function does JuicyPixels have that would take a function, and create an image from that?
09:58 <Adeon> see above
09:59 <Adeon> you give it width and height of the image and then a function and juicypixels will call it for every pixel
09:59 <Adeon> and in this function you can the mandelbrot set or whatever computation you want
09:59 <iqubic> That looks like It will work for me.
09:59 <Adeon> there's an example that writes to png; if you want it to gloss you can maybe use that gloss-juicy library on the resulting image
09:59 <Adeon> or maybe save it to disk and load it from there
10:00 <iqubic> But can I do the same with gloss only?
10:00 <Adeon> I think you can do the same with gloss as well, it's just that it doesn't have readily available functions (skimming through it's documentation)
10:00 <Adeon> so you sort of have to manually implement `generateImage`-like function in gloss
10:00 <iqubic> I'll look for something.
10:00 <iqubic> Ah, I see
10:01 <Adeon> https://hackage.haskell.org/package/gloss- looks like there are functions to make gloss pictures out of foreignptrs and bytestrings
10:01 <Adeon> those would be the low-level interface and on top of that you would implement such a function
10:01 <iqubic> Why does gloss picture data have kind *? and what does that mean?
10:01 <Adeon> unless I missed something else in gloss docs
10:01 <iqubic> https://hackage.haskell.org/package/gloss-
10:02 <Adeon> it means it doesn't take any type parameters
10:02 <Adeon> data Picture :: * means the same as data Picture actually
10:02 <Adeon> I'm not actually sure why it's there
10:02 Kreest__ joined
10:02 wroathe joined
10:03 <Adeon> I think the docs pick up the explicit kind definition if it's written like that in the source code
10:03 <Adeon> and maybe there's a reason they did that explicitly behind the scenes but it isn't apparent in the documentation
10:03 <iqubic> Ah. I see.
10:04 <Adeon> either that or there is something about kinds I don't know about
10:04 <iqubic> No. I think that it actually takes zero arguments.
10:05 abhiroop joined
10:06 edvorg joined
10:06 <Adeon> similar thing happens with ScopedTypeVariables, if you specify e.g. "func :: forall a. a -> a" to get the scoping of 'a' right then that forall shows up in documentation
10:06 <mniip> Adeon, because the datum is imported from another package
10:06 <mniip> I think that's relevant, at least
10:07 <merijn> Adeon: I suspect Picture is written using either GADTSyntax or something causing it to render like that?
10:07 <Adeon> no idea
10:07 <Adeon> importing it from another package would be a reason although I don't know why it works like that
10:07 <mniip> I mean, e.g
10:07 <iqubic> I think that there is no convienent way to create a generateImage function with just gloss functions.
10:07 <mniip> https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-State-Lazy.html#t:StateT
10:07 <mniip> likewise mtl reexports a datum from transformers
10:08 <Adeon> huh
10:08 <Adeon> well for the state one it's useful documentation
10:08 <mniip> I think what happens is,
10:09 <mniip> it is possible to have a datum imported, but not its constructors
10:09 <iqubic> Yeah. So I think I'll generate an image with JuicyPixels, then convert it to gloss for display.
10:09 <mniip> so, if that was the case, haddock would have no useful information to show
10:09 <mniip> other than the kind
10:10 <mniip> so, preemptively, haddock writes out the kind for all data reexported from another package
10:10 <mniip> because for other data it either has the constructors or can hyperlink them
10:10 <iqubic> Unless there is a simpler way to create a picture from a function using only gloss.
10:11 <Adeon> I would probably just hook up juicy to gloss like you are doing and do gloss-only if I find that part became a bottleneck for something
10:11 <Adeon> productivity over efficiency when efficiency is not that important
10:12 <iqubic> Yeah, I'll do that then.
10:12 <iqubic> Sounds good.
10:12 Ferdirand joined
10:13 wroathe joined
10:13 t7 joined
10:14 <iqubic> The only ways to simply create an image in gloss is with a Bytestring, or a ForeignPtr.
10:14 <iqubic> Neither of which sounds very simple
10:14 Kreest_ joined
10:15 <Adeon> it's possible to do but yeah it's a bit more complicated
10:16 <Adeon> probably have to muck around with pixel formats and so on unless you target only one bitmap format
10:16 <iqubic> So using JuicyPixels generateImage function is certainly easier.
10:17 <Adeon> yup
10:18 <iqubic> Is there anyway to view documentantion for these libraries without having use the internet?
10:18 jaguar joined
10:18 <Adeon> I don't do it myself but IIRC if you install packages with cabal and you have the correct settings in ~/.cabal/config then you get like a local documentation repository
10:19 <Adeon> it's been a while since I've looked at local docs so there may be some better workflows that I don't know about for viewing documentation
10:19 <iqubic> Cool, thanks
10:19 <Adeon> I haven't touched cabal the command-line program in a while...it's all stack now
10:19 <merijn> iqubic: You can make cabal build local docs, yes
10:20 defanor joined
10:20 <merijn> iqubic: You want to make sure ~/.cabal/config has "documentation: True"
10:21 <merijn> And it'll give a local copy of the html docs for every installed package
10:21 <iqubic> Adeon, I only use Stack mysel
10:21 ertes joined
10:21 <Adeon> no idea if stack does anything with docs
10:21 jaspervdj joined
10:21 <Adeon> can probably build at least docs for the package you are working on
10:21 <Adeon> stuff like cross-linking between many packages is kind of convenient
10:22 jennyrgb joined
10:23 <iqubic> I don't need local docs.
10:23 <iqubic> It's cool
10:23 NickHu_ joined
10:23 <jennyrgb> a b c d e .. shouldn't that first run a on b, and then the result on c and run that result on d and that result on e?
10:23 ziocroc joined
10:23 <jennyrgb> 1+2*3 does not follow that pattern
10:23 <jaspervdj> jennyrgb: That's because of operator precedence
10:23 <merijn> jennyrgb: There's special rules for operators
10:24 <jaspervdj> 1+2*3 is parsed as 1+(2*3) which is kinda like `(+) 1 ((*) 2 3)`
10:25 <merijn> jennyrgb: i.e. some names of function are defined to be "operators" and are treated like infix operators, like regular math notation, in cases of multiple operators (like 1+2*3) the precedence of the operators defines how things are grouped
10:26 <jennyrgb> what do I use "let" for?
10:26 edvorg joined
10:27 <jennyrgb> I mean, works fine without it
10:27 <merijn> jennyrgb: Can you put an example on lpaste.net to show what you mean?
10:27 <jennyrgb> let string = "aaaaaa", same as string = "aaaaaa"
10:27 <merijn> jennyrgb: In ghci?
10:27 <iqubic> What's the point of generateFoldImage in JuicyPixels?
10:27 <iqubic> https://hackage.haskell.org/package/JuicyPixels-
10:27 <jennyrgb> merijn: sure
10:27 klottie joined
10:29 <iqubic> Also, what does withImage do? Isn't that the same thing with the parameters reversed
10:29 <iqubic> Same as generateImage I mean.
10:30 <maerwald> jennyrgb: try it in a source file, you'll see the difference
10:30 eklavya joined
10:30 Destol joined
10:30 <Adeon> iqubic: it's monadic so the pixel-generation function can be an IO-action, whereas generateImage, your generation function has to be pure
10:30 Lord_of_Life joined
10:31 ragepanda joined
10:31 <Adeon> also the ordering of parameters means you can do something like this: withImage 800 600 $ \x y -> doStuff x y
10:31 <maerwald> unfortunately the error message will most likely be a cryptic GHC parser error
10:31 <Adeon> looks a bit nicer
10:31 rcat joined
10:31 <Adeon> withImage 800 600 $ \x y -> do
10:31 <Adeon> doStuff x y
10:31 <iqubic> Adeon, why is that helpful? Does it let you inline the creation function?
10:31 epsilonhalbe joined
10:32 <iqubic> Now what does generateFoldImage do?
10:32 <Adeon> well aside from being able to thread a monad inside otherwise it seems just accommodating different way of calling it
10:32 <Adeon> generateFoldImage threads a state inside the generation function
10:33 <iqubic> What does that mean
10:33 <Adeon> the value `acc`, is called in each function, you can modify and at next pixel generation you can get the modified `acc` to you
10:33 <iqubic> ANd how will that help anyone?
10:33 BartAdv joined
10:33 wroathe joined
10:33 <Adeon> it means that what's on another pixel can depend on what you did on some other pixel
10:33 <Adeon> not actually sure of any obvious use cases
10:34 <Adeon> I would at least like to know in which order the thing will call all the pixels
10:34 <Adeon> oh it tells you
10:34 <iqubic> Left to right, top to bottom
10:35 <Adeon> there are probably some use cases
10:35 <iqubic> I don't think I need that however.
10:35 <Adeon> I think otherwise nobody would have come up with that function
10:35 <iqubic> Yeah, I guess you're right.
10:35 <iqubic> Actually, I do have a use for that function.
10:36 <iqubic> I need a state that I can pass to ever single point as it gets created.
10:36 <Adeon> does that state change as you are writing more pixels?
10:36 <Adeon> if the answer is yes then the fold function is for you
10:37 <iqubic> Yeah. It will.
10:37 <Adeon> if it's the same state for every pixel then you don't need it
10:37 <Adeon> okaydokey
10:37 <Adeon> I suppose it could do things like collect statistics
10:37 <Adeon> "I wrote 12382 red pixels"
10:37 <Adeon> you get the state back at the end
10:37 Deide joined
10:37 <iqubic> So you do.
10:39 <iqubic> Is there a way that I can take some input, and just return a funtion.
10:39 <iqubic> ??
10:39 <iqubic> Like plusN
10:39 <iqubic> Which has type int -> (int -> int)
10:40 ner0x652 joined
10:40 Nik05 joined
10:40 <iqubic> So that the function returned will add N to the input.
10:40 <cocreature> Int -> Int -> Int is the same as Int -> (Int -> Int)
10:40 <iqubic> Where N is passed in when creating the function.
10:40 <cocreature> so you can just use +
10:40 <cocreature> :t (+) 4
10:40 <lambdabot> Num a => a -> a
10:41 <iqubic> right, but in this case I want to do something more clever.
10:41 <iqubic> I want to take my generateImage function, and parameterize it.
10:42 <iqubic> What I mean to say is I want a function that is called: createGenerateImage.
10:42 noteshui joined
10:42 <dmwit> jennyrgb: http://stackoverflow.com/q/42988950/791604
10:43 <iqubic> Which allows me to pass in a few starting parameters to my generateImageFunction.
10:43 abhiroop joined
10:43 wroathe joined
10:44 <dmwit> iqubic: I don't understand the question yet. Perhaps you can make it a little more concrete by describing what you plan to do.
10:44 <iqubic> dmwit, it's fine.
10:45 <iqubic> All I really needed to know was that: "int -> (int -> int)" is the same as "int -> int -> int"
10:46 sepp2k joined
10:46 <iqubic> So basically it's possible to have the output of one function be a function itself.
10:47 <cocreature> yep
10:48 <iqubic> In other words, this is a possible function "plusN n = (+) n
10:48 phyrex1an joined
10:48 <iqubic> And you can call it like this: "plusN 5 $ 5"
10:48 <iqubic> And that would return 10.
10:48 <dmwit> Yes. Or `plusN = (+)`.
10:48 <cocreature> you don’t need the $ here
10:48 javjarfer joined
10:49 <iqubic> right.
10:49 <iqubic> But that's a super simple example.
10:49 <dmwit> Or don't even define anything, and just use the original name. =)
10:49 <iqubic> Yeah, I know that.
10:50 <iqubic> This is a simple function.
10:50 <iqubic> But I'll be doing something a bit more complex.
10:50 <klottie> print $ content :: CustomType gives me an error while print (content :: CustomType) doesn't. Doesn't '$' have the highest precedence?
10:50 MindlessDrone joined
10:51 <cocreature> klottie: :: is not an ordinary operator with precedence
10:51 <merijn> klottie: First of, you mean lowest precedence. And second, no, :: scopes over everything before it
10:51 <iqubic> What that does is trys to turn the output of "print $ content" into a CustomType.
10:52 <klottie> sorry, I meant lowest precedence.
10:52 LiaoTao joined
10:52 jennyrgb joined
10:52 Unhammer joined
10:52 <iqubic> Yeah, but :: uses everything in the entire line, or (), as it's input.
10:53 chbatey joined
10:53 <klottie> I got it. thanks for the answers.
10:54 <jennyrgb> are inclusion guards bad? :p
10:55 <dmwit> What is an inclusion guard?
10:55 wildlander joined
10:55 balor joined
10:55 JuanMiguel joined
10:56 madjestic joined
10:56 aglorei joined
10:57 jespada joined
10:58 <merijn> dmwit: I only know that term in context of C and header includes
10:58 <merijn> as in, the #ifndef MYHEADER; #define MYHEADER
10:58 <cocreature> #pragma once ftw :)
10:58 <dmwit> Don't write recursive modules ftw
10:59 <dmwit> The compiler just checks this for you without any effort on your part ftw
10:59 <dmwit> =P
10:59 <merijn> dmwit: I hate that lame as argument. Lack of recursive modules in GHC is my biggest annoyance with it's deviation of the report
10:59 mmachenry joined
10:59 <merijn> I find myself wanting recursive modules all the time :(
11:00 <dmwit> GHC allows recursive modules with only a modicum of effort.
11:00 <merijn> dmwit: It's a pretty substantial amount of effort, imho
11:00 <merijn> Which is why everyone has a Types.hs module that defines literally every ADT and typeclass...
11:02 coot joined
11:02 <jennyrgb> lol.. I mean regular haskell guards. Are they bad, should they be avoided?
11:03 <merijn> eh, no? it depends on what you're doing with them :p
11:03 mohsen_ joined
11:04 wroathe joined
11:04 klottie left
11:07 <dmwit> Often where you would use guard-like things in other languages you use pattern matching in Haskell.
11:08 <dmwit> But there are plenty of idiomatic uses of guards, and they are by no means "to be avoided".
11:08 orbifx joined
11:09 <iqubic> So what does it mean for a function to be "Point-Free"
11:09 <iqubic> ???
11:09 <merijn> iqubic: Not binding variable names
11:10 <pacak> foo x = x + 1 -- x is point in this case.
11:10 tomboy64 joined
11:10 <iqubic> Right.
11:10 <pacak> foo = (+1) -- this one is point free
11:10 <pacak> bar = show . (+1) -- this one is also point free
11:11 <iqubic> Why do you need function composition there?
11:11 <merijn> iqubic: It's a term originating from geometry, where you transform one point into another using functions. So if the function doesn't mention a specific point (i.e. no variable) it was "point free"
11:11 <iqubic> Ah. I see.
11:11 <iqubic> Still, why is fuctional composition needed in "bar = show. (+1)"?
11:12 jespada joined
11:12 <iqubic> Is that because the un-named variable(s) need to be last argument?
11:12 <merijn> iqubic: Well, you could write "show (+1)", but it'd mean something very different :)
11:13 <merijn> :t (.)
11:13 <lambdabot> (b -> c) -> (a -> b) -> a -> c
11:13 <merijn> @src (.)
11:13 <lambdabot> (f . g) x = f (g x)
11:13 <iqubic> right.
11:14 <merijn> iqubic: If you'd write "show (+1)" you would instead be applying "show" to the function "(+1)" (and get a messages that you can't show functions)
11:14 <iqubic> And you can't just write "foo x = show (x + 1) because this should be point-free.
11:14 <iqubic> Should one strive to make all functions point-free?
11:14 <jennyrgb> what's an easier definition of tail recursion for retards?
11:14 <merijn> iqubic: Right, writing foo like that wouldn't be point-free
11:14 Ferdirand joined
11:15 <merijn> iqubic: No, almost certainly not, pointfree often makes stuff way less readable :)
11:15 hdeshev joined
11:15 <merijn> jennyrgb: Honestly, tail recursion isn't that relevant for Haskell :)
11:15 <iqubic> jennyrgb: The recursive call should be the last statement in the function.
11:15 <pacak> @pl foo x y z = bar z y y x
11:15 <lambdabot> foo = flip (flip . (flip =<< flip bar))
11:15 <merijn> iqubic: It's basically a matter of "what's more readable?"
11:15 <iqubic> What does pl stand for?
11:15 <pacak> First version is a bit more readable compared to whatever lambdabot suggested.
11:15 <pacak> pointless I belive
11:16 <iqubic> Also, that is quit a bit worse
11:16 <iqubic> @pl foo x = show (x + 1)
11:16 <lambdabot> foo = show . (1 +)
11:16 Nycatelos joined
11:17 <merijn> iqubic: Often you find yourself wanting to apply a bunch of stuff in a row, like "map (foo . bar . baz)" where pointfree is nice, but it's certainly not universally nicer or better :)
11:17 <iqubic> Yeah, it is not needed.
11:18 <iqubic> Is it better to always write functions to be tail-recursive?
11:18 <merijn> iqubic: In Haskell it mostly doesn't matte
11:18 hdeshev joined
11:18 <pacak> iqubic: First write something that works, profile stuff if you have performance issues.
11:19 <merijn> iqubic: Tail-recursion, combined with tail-call optimisation is used to avoid function call stack growth (and thus memory leaks)
11:19 <merijn> iqubic: However, (GHC) Haskell doesn't *have* a function call stack, so there's no point in "avoiding to grow it" :)
11:19 <jennyrgb> I still don't get it. The last statement.. what? in a tail recursion
11:19 <merijn> iqubic: Depending on your point of view, either every haskell function call is a tail call or none are
11:20 chbatey joined
11:20 hdeshev joined
11:20 <pacak> jennyrgb: When last action in function is a recursive call to the same function recursion can be optimized away into a loop
11:20 <iqubic> I would like to create a functional programming language that only supports tail-recursion. Would that be a good idea?
11:20 <iqubic> Or would that be rather stupid?
11:20 <pacak> sum [] = 0
11:20 <pacak> sum (x:xs) = x + sum xs
11:20 dcoutts_ joined
11:20 <pacak> this one is not tail recursion because last operations +
11:21 <Myrl-saki> pacak: You'll be losing map and whatnots.
11:21 <jennyrgb> pacak: oh, ok, excellent, thanks
11:21 <iqubic> But you can make it tail recursive.
11:21 <pacak> sum = sum' 0
11:21 <pacak> where
11:21 <pacak> sum' p [] = pred
11:21 <pacak> sum' p (x:xs) = sum' (p+x) xs
11:21 <Myrl-saki> iqubic: fooo = map ...
11:22 <iqubic> What does pred do?
11:22 <pacak> mmmm
11:22 <pacak> pred = p
11:22 <pacak> my bad
11:22 <jennyrgb> but all self referenting recursions can be optimized to loops
11:22 <iqubic> What does self referenting mean?
11:23 <Myrl-saki> self referencing.
11:23 GodNeuron joined
11:23 <iqubic> Ah.
11:24 <iqubic> jennyrgb: all recursion is self referencing. That's the definition of recursion.
11:24 lordcirth joined
11:24 wroathe joined
11:25 <pacak> iqubic: There's also mutual recursion when you have several functions calling each other
11:26 <iqubic> Sure, but that eventually gets around to referencing itself.
11:26 <iqubic> I have a qustion. What if I define these two functions:
11:26 <iqubic> foo x = x + 1
11:27 <iqubic> and bar x = x + 1
11:27 <iqubic> what would happen with a call of "foo 1"?
11:27 <cocreature> it will evaluate to 1 + 1?
11:28 <iqubic> Sorry what I meant was:
11:28 <iqubic> foo x = bar x + 1
11:28 <iqubic> bar x = foo + 1
11:28 <iqubic> well, you get the idea.
11:28 <cocreature> that’s a type error. did you mean bar x = foo x + 1?
11:28 <iqubic> yeah
11:28 <iqubic> I did.
11:28 <iqubic> foo x = bar x + 1
11:29 prkc joined
11:29 <iqubic> bar x = foo x + 1
11:29 <iqubic> what would that do?
11:29 <cocreature> that’s an infinite loop (at least for almost the usual instances of Num)
11:29 <cocreature> -almost
11:29 <iqubic> Wait, you'd never get a StackOverFlow error ever?
11:30 <Myrl-saki> iqubic: Technically, you can have mutual recursion, which is not directly self-referencing.
11:30 mmhat joined
11:30 <Adeon> I think ghc might detect that loop
11:31 <Adeon> but if it doesn't you might eventually run out of memory
11:31 <pacak> > let ones = 1:ones in ones
11:31 <lambdabot> [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1...
11:31 <iqubic> Yeah, that's an infinite list.
11:32 <ClaudiusMaximus> with lazy Peano naturals you'll get S(S(S(S... , equivalent to infinity = S infinity, which might be useful as it can be evaluated only as far as necessary to know that it's bigger than another nat
11:32 <iqubic> listOfXs x = x:listOfXs
11:32 <Myrl-saki> pacak: Oh whoops. Didn't realize that you mentioned mutual recursion. :(
11:32 <Adeon> yeah, I tried that foobar program, with -O2 you get <<loop>> exception, anything lower and you recurse infinitely until memory runs out
11:33 <iqubic> listOfXs x = x:(listOfXs x)
11:33 <iqubic> is what I mean to type
11:33 <iqubic> gets you an infinite list of x
11:33 <iqubic> At least I think. Not too sure.
11:34 wroathe joined
11:34 <Myrl-saki> iqubic: That's correct.
11:34 <iqubic> cool.
11:35 <Myrl-saki> iqubic: You also dont need the parentheses.
11:35 <iqubic> why not?
11:35 <pacak> > [1..] :: [Integer]
11:35 <lambdabot> [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,...
11:35 <pacak> This one is also kind of infinite
11:35 <iqubic> What are the other kinds of infinite?
11:36 <bjs> iqubic: because function application binds tighter than (:)
11:36 GodNeuron joined
11:36 <iqubic> foo x = foo x + 1
11:36 GodNeuron left
11:36 <Myrl-saki> > let repeat' x = x:repeat' x
11:36 <lambdabot> <no location info>: error:
11:36 <lambdabot> not an expression: ‘let repeat' x = x:repeat' x’
11:36 <bjs> @src repeat
11:36 <lambdabot> repeat x = xs where xs = x : xs
11:36 GodNeuron joined
11:37 <pacak> > fix ((0:) . scanl (+) 1)
11:37 <lambdabot> [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,...
11:37 <iqubic> > let foo x = foo x + 1 in foo 1
11:37 <lambdabot> *Exception: stack overflow
11:37 <Myrl-saki> @let repeat' x = x:repeat' x
11:37 <lambdabot> Defined.
11:37 <iqubic> What does fix do?
11:37 <pacak> @src fix
11:37 <lambdabot> fix f = let x = f x in x
11:37 <pacak> :t fix
11:37 <Myrl-saki> pacak: What the hell lmao
11:37 <lambdabot> (a -> a) -> a
11:38 <bjs> Myrl-saki: what's wrong
11:38 <Myrl-saki> :t canl
11:38 <lambdabot> error:
11:38 <lambdabot> • Variable not in scope: canl
11:38 <lambdabot> • Perhaps you meant one of these:
11:38 <Myrl-saki> :t scanl
11:38 <lambdabot> (b -> a -> b) -> b -> [a] -> [b]
11:38 sdothum joined
11:38 <Myrl-saki> Oh okay. Makes sense now.
11:39 <pacak> Myrl-saki: Recursion without recursion :)
11:39 <pacak> > fix error
11:39 <lambdabot> "*Exception: *Exception: *Exception: *Exception: *Exception: *Exception: *Ex...
11:39 <iqubic> Wait, so fix returns and infinite list?
11:39 <bjs> iqubic: no
11:39 <iqubic> > fix (1 +)
11:39 <bjs> iqubic: look at its type (a -> a) -> a
11:39 <lambdabot> mueval-core: Time limit exceeded
11:39 <pacak> fix can do lots of stuff
11:39 <iqubic> Right.
11:40 <bjs> iqubic: it repeatedly applies f to itself, look at the source
11:40 <Myrl-saki> pacak: Recursion without recursion with fix tendsto be written as `fix (\f x -> f x) though. :P
11:40 <pacak> :t fixM
11:40 <lambdabot> error:
11:40 <lambdabot> • Variable not in scope: fixM
11:40 <lambdabot> • Perhaps you meant ‘fix’ (imported from Data.Function)
11:41 <bjs> iqubic: or think of this: fix' f = f (fix' f)
11:41 GodNeuron joined
11:41 <bjs> it's a kind of fixed point of the function :)
11:41 <abhiroop> Question bump: http://lpaste.net/354450
11:41 <iqubic> fix finds the fixed point of the function.
11:41 KongWubba joined
11:41 <iqubic> > fix 1
11:41 <lambdabot> error:
11:41 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M353276782070...
11:41 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
11:42 <iqubic> > fix 1 :: int
11:42 <lambdabot> error:
11:42 <lambdabot> • No instance for (Num (int1 -> int1)) arising from the literal ‘1’
11:42 <lambdabot> (maybe you haven't applied a function to enough arguments?)
11:42 <Myrl-saki> bjs: No. (* -> *) -> * is a kind of a fixed point.
11:42 <bjs> Myrl-saki: haha
11:42 <iqubic> > fix (id 1) :: int
11:42 <lambdabot> error:
11:42 <lambdabot> • No instance for (Num (int1 -> int1)) arising from the literal ‘1’
11:42 <lambdabot> (maybe you haven't applied a function to enough arguments?)
11:42 <iqubic> > fix (id x) :: int
11:42 <lambdabot> error:
11:42 <lambdabot> • Couldn't match expected type ‘int1 -> int1’
11:42 <lambdabot> with actual type ‘Expr’
11:42 <iqubic> > fix (id x)
11:42 <lambdabot> error:
11:42 <lambdabot> • Couldn't match expected type ‘a -> a’ with actual type ‘Expr’
11:42 <lambdabot> • Possible cause: ‘id’ is applied to too many arguments
11:42 <pacak> You can experiment with lambdabot in private conversation
11:42 cyborg-one joined
11:42 silver joined
11:42 <iqubic> > fix id
11:43 <lambdabot> mueval-core: Time limit exceeded
11:43 <iqubic> Why does that last thing fail?
11:43 <Myrl-saki> > fix (0*)
11:43 <lambdabot> mueval-core: Time limit exceeded
11:43 <pacak> iqubic: What kind of answer do you expect?
11:43 <Myrl-saki> iqubic: Because id doesn't 'short circuit'
11:43 <iqubic> fix (2*)
11:43 <iqubic> > fix (2*)
11:43 <lambdabot> mueval-core: Time limit exceeded
11:43 <pacak> > fix (const "Hello world")
11:43 <lambdabot> "Hello world"
11:44 <iqubic> Shouldn't "fix (2*)" return 1?
11:44 <Myrl-saki> > fix (False &&)
11:44 <lambdabot> False
11:44 <iqubic> > fix (2*)
11:44 <lambdabot> mueval-core: Time limit exceeded
11:44 <bjs> iqubic: why should it return 1?
11:44 <iqubic> > fix (1*)
11:44 <lambdabot> mueval-core: Time limit exceeded
11:44 <pacak> > let fib = fix (\f -> \n -> if n < 2 then n else f (n-1) + f (n-2)) in fib 5
11:45 <lambdabot> 5
11:45 <pacak> > let fib = fix (\f -> \n -> if n < 2 then n else f (n-1) + f (n-2)) in fib 9
11:45 <lambdabot> 34
11:45 <iqubic> Alright, that last one should have returned 1. fix (1*) = 1
11:45 <pacak> :t fix (1*)
11:45 <lambdabot> Num a => a
11:46 <Myrl-saki> iqubic: Technically should.
11:46 <pacak> It is 1 from math point of view, but not from ghc.
11:46 <iqubic> Why doesn't it return 1?
11:46 ruuns joined
11:46 <iqubic> Why doesn't ghc find out that the answer is one?
11:46 <Myrl-saki> pacak: How does math get 1?
11:47 <iqubic> 1 * 1 = 1
11:47 <Myrl-saki> pacak: Asking this from a Haskeller point of view. :P
11:47 <iqubic> fixed point of 1* = 1
11:47 <iqubic> 1 * 1 = 1
11:47 <pacak> I belive product of infinite list of ones is 1, at least a limit
11:47 <pacak> You can proove it by induction
11:48 <iqubic> So.
11:49 <bjs> iqubic: there are multiple fixed point functions you can implement, the Data.Function.fix one relies on lazy evaluation
11:49 <iqubic> Why doesn't GHC find an answer to fix (1*)
11:49 wroathe joined
11:49 leah2 joined
11:49 <bjs> iqubic: because (1*) is strict in its other argument
11:50 <pacak> let 1 * 1 = 2 in 1 * 1
11:50 <Myrl-saki> iqubic: Because Haskell is programming.
11:50 <pacak> > let 1 * 1 = 2 in 1 * 1
11:50 <lambdabot> 2
11:50 <pacak> Because 1 * 1 can be 2
11:50 <iqubic> what the heck???
11:50 <pacak> > let 2 + 2 = 5 in 2 + 2
11:50 <bjs> iqubic: so fix (1*) is like (1*) (fix (1*)), which is like (1* (1* (fix (1*)))
11:50 <lambdabot> 5
11:50 <Myrl-saki> 3 different answers lmao
11:50 <bjs> iqubic: can you see how this unrolling is never gonna end
11:51 <bjs> iqubic: ghc is going to try execute (1* (1* (1* (1* ...
11:51 <iqubic> > let false && false = true in false && false
11:51 <lambdabot> error:
11:51 <lambdabot> • Conflicting definitions for ‘false’
11:51 <lambdabot> Bound at: <interactive>:1:5-9
11:51 <Myrl-saki> And the reason why ` False &&` works is because it forgets its right argumentn.
11:51 <pacak> > let False && False = True in False && False
11:51 <lambdabot> True
11:51 <bjs> iqubic: whereas (False &&), (const 1) etc are lazy in their second argument
11:51 <Myrl-saki> bjs: I don't think strict/lazy is the proper term.
11:51 <iqubic> Right, they leave the second argument as thunks
11:52 <pacak> iqubic: The trick is in all those examples we override existing functions
11:52 <iqubic> You do?
11:52 <pacak> > let 2 + 2 = 5 in 3 + 3
11:52 <lambdabot> *Exception: <interactive>:3:5-13: Non-exhaustive patterns in function +
11:52 <iqubic> Ah.
11:52 <bjs> Myrl-saki: it's not, but it's easier to explain that way
11:52 <Myrl-saki> pacak: I also don't think overloading makes a difference.
11:52 shafox joined
11:52 <iqubic> I understand the concepts of Thunks and Weak Head Normal Form.
11:53 <Myrl-saki> > let False && x = x in fix (False &&)
11:53 <lambdabot> mueval-core: Time limit exceeded
11:53 <Myrl-saki> > let False && False = x in fix (False &&)
11:53 <lambdabot> error:
11:53 <lambdabot> • Couldn't match type ‘Expr’ with ‘Bool’
11:53 <lambdabot> Expected type: Expr -> Expr
11:54 <iqubic> Right, that forces the second argument to be evaluated. The first one does.
11:54 <pacak> Myrl-saki: Overloading is only to illustrate why ghc can't figure out 1 * 1 * 1 by itself.
11:54 <iqubic> I see.
11:54 <Myrl-saki> iqubic: Exactly.
11:54 daniel-s joined
11:54 <iqubic> I see now.
11:55 <pacak> > let 0 * x = 0 in fix (0*)
11:55 <lambdabot> 0
11:55 <pacak> this works because it ignores x
11:55 <iqubic> > let 1 * x = 1 in fix (1*)
11:55 <lambdabot> 1
11:55 <Myrl-saki> pacak: Exactly.
11:55 <iqubic> And there is ignores x again,
11:55 <pacak> iqubic: But that's false from math point of view
11:56 <iqubic> what is?
11:56 <iqubic> What's false from math's point of view?
11:56 <pacak> 1 * x =1
11:56 <Myrl-saki> pacak: 1 * x = 1, I guess.
11:56 <iqubic> right. But haskell seems to like it.
11:57 <bjs> iqubic: this is a fixed point of the function
11:57 <Myrl-saki> Sorry for late sends.. Such lag, very delay.
11:57 <iqubic> I don't like operator overloading at all.
11:57 <iqubic> It leads to weird stuff
11:57 <bjs> iqubic: forget the rebinding then and think, let f 1 y = 1; f x y = x * y;
11:58 <iqubic> right. that makes more sense
11:59 <iqubic> > let f 1 y = 1; f x y = x * y; in fix (f 1)
11:59 <lambdabot> 1
11:59 <iqubic> So that's a simpler way for me to think of that.
11:59 wroathe joined
12:00 <Myrl-saki> (1 *) == id, right?
12:00 <Myrl-saki> Actually, ignore what I said. lmao.
12:01 <bjs> Myrl-saki: no
12:01 <iqubic> No.
12:01 <iqubic> id x = x
12:01 <bjs> (1*) == const 1 in that example
12:01 <iqubic> right.
12:01 <Myrl-saki> bjs: I meant in actuality.
12:03 <Myrl-saki> Wait. Isn't `fix (1*)` R?
12:03 ragepanda joined
12:03 <Myrl-saki> Like, in math.
12:03 zymurgy joined
12:03 <bjs> Myrl-saki: i'm not following
12:04 <pacak> Myrl-saki: It's id in math, but in haskell it's a call to addq processor command. There are no extra checks
12:04 <Myrl-saki> bjs: Since we got to a math discussion of fixpoints. Then wouldn't fix(1*) be everything?
12:04 <bjs> Myrl-saki: it doesn't really make sense to assign multiple values to a fixed point
12:04 <bjs> but ... i guess?
12:05 greister joined
12:05 Mysterious_Light joined
12:05 <Myrl-saki> bjs: A fixpoint is where f(x) = x, right?
12:05 robotroll joined
12:06 <bjs> Myrl-saki: yeah, but Data.Function.fix is a special fixed point :)
12:06 <bjs> that doesn't even require EQ
12:06 <bjs> which is sort of strange when you think about it
12:06 athan joined
12:06 <iqubic> Yeah, but haskell has a different way of finding the fixed point.
12:07 <Myrl-saki> I said in math. :|
12:09 <Myrl-saki> @t get
12:09 <lambdabot> Maybe you meant: tell thank you thanks thesaurus thx tic-tac-toe ticker time todo todo-add todo-delete type v @ ? .
12:09 <Myrl-saki> > get
12:09 <lambdabot> error:
12:09 <lambdabot> • Ambiguous type variables ‘m0’, ‘s0’ arising from a use of ‘show_M34462...
12:09 <lambdabot> prevents the constraint ‘(Show (m0 s0))’ from being solved.
12:11 <bjs> Myrl-saki: oh okay, then yeah you could say any inputs are fixed point of id, and (1*) is just id
12:11 Gurkenglas_ joined
12:12 slacker joined
12:12 Itkovian joined
12:12 <Myrl-saki> Also, anyone else here read Clowns and Jokers? How are positions determined.
12:12 stoopkid joined
12:13 jbiesnecker joined
12:14 revprez_atlanta joined
12:15 eklavya joined
12:17 eklavya joined
12:18 oish joined
12:22 Lord_of_Life joined
12:23 dsantiago joined
12:24 prophile joined
12:27 <seequ_> So, I was battling with a timeout problem in codingame (The mimetype challenge). In this, the commented out snippet (line 36) times out, but the longer version (line 39) doesn't. Why?
12:27 <seequ_> http://lpaste.net/266436500911030272
12:27 Micamo joined
12:30 wroathe joined
12:33 static-whatever joined
12:34 HugoDaniel joined
12:35 wagle joined
12:40 oisdk joined
12:41 mojjo joined
12:42 merijn joined
12:42 <lyxia> seequ_: what is the input like
12:43 <lyxia> I don't see any obvious issue
12:43 egis joined
12:44 <seequ_> lyxia: "html text/html\npng image/png\n<ext> <mimetype>" ~1000x
12:46 boombanana joined
12:48 <jasondockers_> what is the "in" keyword for?
12:48 free_beard joined
12:48 leah2 joined
12:49 <lyxia> It's part of "let ... in ..." expressions
12:49 <lyxia> it delimits local definitions
12:49 <jasondockers_> you have to use the "in" keyword to specify you're in the lexical scope of the let?
12:49 <jasondockers_> ok
12:50 gawen joined
12:50 henriksod joined
12:52 Mysterious_Light joined
12:55 bbear joined
12:55 a3Dman joined
12:58 <bbear> hello
12:58 <bbear> I want to define a composite data type
12:58 <bbear> let say I have a type data Coord = C Int Int
12:59 xall joined
12:59 <bbear> how can I do something like
12:59 <bbear> data Move = Stay | C Int Int
12:59 <bbear> or data Move = Stay | Coord ?
13:00 <bbear> what If want to define a type like : data Foo = a|b|c
13:00 <pacak> data Move = Stay | C Coord
13:00 <bbear> and then data Bar = B d | Foo
13:00 <pacak> data Move = Stay | Co Coord
13:00 wroathe joined
13:01 <bbear> and I want my Bar type object taking values in a,b,c or d ?
13:01 <bbear> is that possble ?
13:01 <bbear> data Foo = a|b|c
13:01 <bbear> data Bar = d|Foo
13:01 <pacak> If you want to declare it as data - things around | must be constructors
13:02 gmhafiz joined
13:02 <pacak> You can define them as type and use sum and product types - but that will make code more messy
13:02 <bbear> data Foo=A|B|C
13:02 <bbear> dat Bar = D|Foo
13:02 <pacak> type Foo = Either () Coord
13:03 <pacak> Left () will be "Stay", Right (C Int Int) will be move
13:03 miklcct joined
13:04 <bbear> well Either works with two stuff
13:04 <bbear> I don't want that
13:05 <bbear> I want to be able to compile functions that take arguments of type Bar or Foo but type signature as written like it take types Bar only
13:06 <merijn> bbear: Yeah, that's not really possible in Haskell
13:06 <ongy> bbear: so you want the types to tell a lie?
13:06 <merijn> You basically seem to want anonymous sum types, but Haskell doesn't have those
13:07 <merijn> ongy: Naah, I think he wants like structural subtyping
13:07 <bbear> kind of overloading actually
13:07 <bbear> what is data Bar=D|Foo in data Foo =A|B|C anyway ?
13:07 <bbear> because I want to use enum
13:08 <bbear> messy
13:08 bl0w3d_0ut joined
13:08 <bbear> :t Either
13:08 <lambdabot> error:
13:08 <lambdabot> • Data constructor not in scope: Either
13:08 <lambdabot> • Perhaps you meant variable ‘either’ (imported from Data.Either)
13:08 <ongy> :k Either
13:08 <lambdabot> * -> * -> *
13:09 <ongy> Either is the type constructor, value constructers are Left and Right (data Either a b = Left a | Right b)
13:10 <bbear> say I have data Alphabet = a|b|c|d|e|f|g|h|[...]|z
13:10 presiden joined
13:10 <bbear> how could I do something like [a..z] ?
13:10 epsilonhalbe left
13:11 wroathe joined
13:11 <Myrl-saki> "The best editor is neither Emacs nor Vim, it's Emacs+Vim" Shouldn't it be Emacs*Vim?
13:12 <Myrl-saki> bbear: In a `data` constructor? I don't think you can do that. Maybe with TH.
13:12 <bbear> not in Data constructor
13:12 <bbear> to construct the list of all possible value that's all.
13:12 <bbear> to avoid boiler plate code
13:12 <ongy> :t \x y -> [x .. y]
13:12 <lambdabot> Enum t => t -> t -> [t]
13:13 <Myrl-saki> bbear: deriving Ord?
13:13 <bbear> yes
13:13 <ongy> bbear: you could do an instance Enum Alphabet for this
13:13 <bbear> ok
13:13 <bbear> deriving Ord should suffice
13:13 <bbear> I forgot
13:13 <bbear> I thought it was deriving Enum
13:13 jbiesnecker_ joined
13:14 <Myrl-saki> ongy: deriving Enum.
13:14 <ongy> if that's a thing, then it's even easier
13:15 <bbear> thanks I got my answer
13:15 <bbear> it was nice
13:15 cchalmers joined
13:15 <bbear> wow
13:16 <bbear> sometimes all this function composition is giving me kind of a seasickness
13:16 <bbear> I write all my functions as one-liners for a specific task and then combine them all
13:16 <bbear> is that a good idea ?
13:17 <bbear> I end up a
13:17 <bbear> with a lot and a lot of functions.
13:17 ner0x652 joined
13:18 <ongy> there's no universal truth. but *everything* as oneliner sounds a bit overdone to me.
13:19 kuribas joined
13:20 <bbear> eventually if you don't one liners then you need to break lines
13:20 yezariaely joined
13:20 <bbear> So basically you start using (where, let)
13:21 wroathe joined
13:21 mkoenig joined
13:21 <bbear> That's the alternative, right ?
13:21 <bbear> so if you forbid the use of where and let, you pretty much end up with a bunch of oneliners ?
13:22 <lordcirth> bbear, if a given line will only be used by 1 function, then I put it in "where". If I think it might be used by other functions, it becomes a function.
13:22 JuanDaugherty joined
13:23 <bbear> yes, but you don't have a priori knowledge that it won't need to be used elsewhere.
13:23 <ongy> why would you forbid let and where? I think it makes for a better spacial concentration of related code, which makes reading a bit nicer
13:23 Xanather joined
13:23 JuanDaugherty joined
13:23 <bbear> in fact if your code is truly reusable, any line of code you write could be reused anywhere.
13:23 <lordcirth> bbear, refactoring haskell is easy, tho.
13:23 <bbear> Yes
13:23 sepp2k1 joined
13:23 <bbear> I'm considering tradeoffs
13:23 <ongy> so? hlint even tells you when you have duplicated code blocks (and imo it's not much easier to search for functions than code snippets)
13:24 <bbear> I'm still a young Haskeller, i'm looking for a good style.
13:24 <bbear> how can you combine map applications ?
13:24 <bbear> map (otherFunc) $ map (func) myList
13:24 <bbear> <- it's ugly isn't it ?
13:25 wei2912 joined
13:25 <bbear> map (otherFunc. func) myList ?
13:25 <tobiasBora> Hello,
13:25 <hydraz> bbear: yep
13:25 <hc_> bbear: map (otherFunc . func) myList?
13:25 <hc_> jup
13:26 <hc_> I've got a question; is there an easy way to convert a ByteArrayAccess to a ByteString?
13:26 <hc_> ByteString.pack . ByteArray.unpack works, but sounds inefficient
13:26 <tobiasBora> I'm trying to send cookies using conduit, but it does not work...
13:26 <bbear> oky
13:27 <tobiasBora> I'm using:
13:27 <tobiasBora> requestWithProxy {cookieJar = cookieJarM}
13:28 <tobiasBora> where cookieJar is get from "cookieJar = Just $ responseCookieJar resp"
13:29 <tobiasBora> show cookieJarM gives me the good cookie
13:30 cfricke joined
13:30 <tobiasBora> But when I show the "requestWithCookie", the requestHeaders are empty,
13:31 <tobiasBora> and nothing is shown in the request about cookieJar
13:31 Gurkenglas joined
13:31 jbiesnecker joined
13:31 <tobiasBora> And, I'm sniffing the request with Wireshark
13:31 wroathe joined
13:31 <bbear> any idea about a function minWith ?
13:31 <bbear> should define an ordering on an indicator
13:31 <tobiasBora> and I can't find anything
13:32 <bbear> :t compare
13:32 <lambdabot> Ord a => a -> a -> Ordering
13:32 <tobiasBora> bbear: compare `on` ... ?
13:32 <tobiasBora> :t compare `on`
13:32 <lambdabot> error:
13:32 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
13:32 <bbear> yes
13:32 <bbear> :t on
13:32 <lambdabot> (b -> b -> c) -> (a -> b) -> a -> a -> c
13:32 <bbear> :t compare
13:32 <lambdabot> Ord a => a -> a -> Ordering
13:33 <bbear> :t (on compare)
13:33 <lambdabot> Ord a => (a1 -> a) -> a1 -> a1 -> Ordering
13:33 biglama joined
13:33 <lep-delete> :t comparing
13:33 <lambdabot> Ord a => (b -> a) -> b -> b -> Ordering
13:34 Itkovian joined
13:34 <bbear> comparing ?
13:34 theelous3 joined
13:35 gabluc joined
13:35 <bbear> is that valid to take head (sortBy ..) rather than min(something) ?
13:35 <bbear> preferred method in Haskell ?
13:35 meck joined
13:35 <bbear> :t min
13:35 <lambdabot> Ord a => a -> a -> a
13:36 <abhiroop> I am stuck with this issue in parsing using ReadP http://lpaste.net/354450
13:36 <abhiroop> Any help?
13:36 joneshf-laptop joined
13:37 <bbear> the Prelude is kind of limited isn't it ?
13:37 <bbear> How can you have a more extended std library loaded in ghci by default ?
13:38 meoblast001 joined
13:39 <yushyin> :set -XNoImplicitPrelude\n:module YourBetterPrelude in ~/.ghci
13:40 abhiroop joined
13:41 <abhiroop> I am trying to solve this problem in parsing using ReadP http://lpaste.net/354450 Any help?
13:41 wroathe joined
13:42 <bbear> :t readP
13:42 <lambdabot> error:
13:42 <lambdabot> • Variable not in scope: readP
13:42 <lambdabot> • Perhaps you meant one of these:
13:46 nomicflux joined
13:47 <bbear> heya
13:48 <bbear> I'm kinda stuck with the interpreter.
13:48 <bbear> loading :m Data.List erase `on` and loading :m Data.Function erases `sortBy`
13:48 <bbear> what do I do ?
13:49 <pavonia> bbear: :m + Data.List Data.Function
13:49 kuribas joined
13:53 Ferdirand joined
13:53 jmcarthur joined
13:54 meck joined
13:54 Jackneill_ joined
13:56 abhiroop joined
13:56 jgt1 joined
13:56 mstruebing joined
13:56 <bbear> distanceTo (x,y) (v,w) = sqrt((x-v)**2 + (y-w)**2)
13:57 <bbear> distanceTo (C x1 x2) (C y1 y2) = sqrt( (x1 - y1)**2 + (x2 - y2)**2 )
13:57 <bbear> No instance for (Floating Int) arising from a use of ‘sqrt’
13:57 <bbear> why the second is not working ?
13:57 <bbear> ha yes
13:57 <bbear> still syntax problem
13:58 <bbear> ha no
13:58 <bbear> so what's the problem ?
13:58 <bbear> where data Coord = C Int Int
13:59 <bbear> :t fromIntegral
13:59 <lambdabot> (Num b, Integral a) => a -> b
14:00 JuanMiguel joined
14:00 howdoi joined
14:01 eizua joined
14:02 wroathe joined
14:02 abhiroop joined
14:03 filterfish joined
14:04 cpape` joined
14:05 <bbear> is that fair to let the compiler infer the type from time to time ?
14:05 e14 joined
14:07 <peddie> :t sqrt -- bbear
14:07 <lambdabot> Floating a => a -> a
14:08 <bbear> what does that mean ?
14:08 <bbear> I'm kinda stuck
14:08 <bbear> distanceTo :: Coord -> Coord -> Float
14:08 <bbear> distanceTo (C a b) (C c d) = sqrt( (x - v)**2 + (y-w)**2 ) where [x,y,v,w]=map fromIntegral [a,b,c,d]
14:08 <bbear> that doesnt compile
14:08 <peddie> it means you can take the square root of something that's an instance of the Floating type class
14:08 <peddie> oh, OK, you got that part then
14:08 <bbear> distanceTo (C a b) (C c d) = sqrt( (x - v)**2 + (y-w)**2 ) where [x,y,v,w]=map fromIntegral [a,b,c,d]
14:08 <peddie> what error do you get now?
14:08 <bbear> it compiles but I can't get teh type signature right
14:09 <bbear> GHCI gives me : `distanceTo :: Floating a => Coord -> Coord -> a `
14:09 <peddie> makes sense
14:09 <bbear> copy pasting that solved my problem
14:10 <bbear> so the first part before => is just the constraint on the class.
14:10 <peddie> yes
14:10 <bbear> ok
14:10 <bbear> easier now
14:11 <bbear> working with type is so much harder but then your code is so much cleaner.
14:11 <peddie> bbear: it definitely gets easier with practice :)
14:11 <bbear> i'm wondering
14:12 <bbear> I don't think haskell will have widespread adoption
14:12 bl0w3d_0ut joined
14:12 <bbear> learning curve is quite steep compared to other languages.
14:12 <bbear> not as much actually
14:12 <bbear> w
14:12 <bbear> wondering
14:12 <bbear> javascript is quite complicated also
14:12 <bbear> and Java as well
14:12 azahi joined
14:13 <ongy> haskell isn't super new, so for any major change in adoption something weird would have to happen. But I think concepts tested out in/around haskell get adoption into other languages. Which is pretty nice aswell
14:13 <peddie> bbear: what exactly are you wondering?
14:13 MindlessDrone joined
14:14 whiteline joined
14:14 takle joined
14:14 <peddie> bbear: if you only knew haskell, you'd probably find the Java learning curve pretty steep ;)
14:15 cpape`` joined
14:15 <ongy> it's not necessarily hard, but different
14:15 Argue_ joined
14:15 <bbear> yes different
14:15 <bbear> I like t
14:15 <bbear> reasoning is much easier and programs are much more cleaner.
14:16 <bbear> You don't end up stuck in some mess you created.
14:16 static-whatever joined
14:18 <bbear> need to write a where clause
14:18 <bbear> complicated
14:19 static-whatever joined
14:19 Marumarsu joined
14:19 Zialus joined
14:22 oconnorct1 joined
14:22 _sras_ joined
14:22 static-whatever joined
14:23 <_sras_> Is there any way to parse json passing an explict parser at run time?
14:23 abhiroop joined
14:25 chbatey joined
14:25 <cocreature> :t Data.Aeson.Types.parse
14:25 <lambdabot> (a -> aeson- b) -> a -> aeson- b
14:25 <cocreature> ^ _sras_
14:25 <abhiroop> Can anybody help with this? http://stackoverflow.com/questions/43306945/parse-multiple-instances-of-a-string-using-readp
14:25 zero_byte joined
14:26 <_sras_> cocreature: Yes.
14:26 cpape``` joined
14:29 <abhiroop> Is it possible to use ReadP to parse multiple instances of a string inside a larger string
14:29 suppi joined
14:30 <abhiroop> I used a combinator which I found on stackoverflow
14:30 jrajav joined
14:30 static-whatever joined
14:30 <bbear> Kind of find it weird when my code compile at the first trial
14:30 <abhiroop> which looks like this http://lpaste.net/354456
14:30 marr joined
14:31 raichoo joined
14:31 Argue__ joined
14:31 Ferdirand joined
14:32 coltfred joined
14:32 wroathe joined
14:32 supki joined
14:33 {emptyset} joined
14:33 <_sras_> cocreature: Is there anyway to use this with the Yaml parser from Yaml library?
14:33 nh2 joined
14:35 alx741 joined
14:35 suppi joined
14:35 kuribas joined
14:36 <cocreature> _sras_: use a yaml parser to parse json or have a similar function that allows you to parse yaml without relying on a parser provided by a typeclass instance?
14:36 <cocreature> the yaml library just reexports the parser type from aeson
14:36 <cocreature> and it provides parseMaybe and parseEither functions
14:37 osa1 joined
14:37 jbiesnecker joined
14:37 mda1 joined
14:38 tristanp joined
14:38 Marumarsu joined
14:38 tristanp joined
14:40 Marumarsu left
14:41 jbiesnecker_ joined
14:43 abhiroop joined
14:44 abhiroop joined
14:46 path[l] joined
14:46 <lyxia> abhiroop: what is get
14:47 mudri joined
14:47 tristanp joined
14:48 <abhiroop> @hoogle get
14:48 <lambdabot> Text.ParserCombinators.ReadP get :: ReadP Char
14:48 <lambdabot> Text.ParserCombinators.ReadPrec get :: ReadPrec Char
14:48 <lambdabot> Control.Monad.State.Class get :: MonadState s m => m s
14:48 <abhiroop> The first one
14:48 <abhiroop> Basically I want to parse past the first character
14:49 <lyxia> Do you want the result to only contain (["AB", "AB", "AB"], "GHA") and no other outcomes?
14:49 <abhiroop> Yes exactly
14:50 steeze joined
14:50 <lyxia> in other words, "AB" should not occur in whatever is left?
14:50 <abhiroop> I state the entir problem here http://lpaste.net/354450
14:50 cpape```` joined
14:50 <abhiroop> Yes
14:50 mkoenig joined
14:50 <lyxia> I found your statement a bit ambiguous but now it's clear.
14:51 <abhiroop> I posted the same in SO as well http://stackoverflow.com/questions/43306945/parse-multiple-instances-of-a-string-using-readp
14:52 systemfault joined
14:52 cfricke joined
14:52 wroathe joined
14:53 <bbear> can you compute several values in a where clause ?
14:53 <lyxia> abhiroop: use asymmetric choice (<++) rather than <|>
14:53 takle joined
14:54 <lyxia> abhiroop: you don't want to try the second alternative if p succeeds.
14:54 mtesseract joined
14:54 <abhiroop> lyxia that worked like a charm :)
14:54 <lyxia> bbear: sure
14:54 takle_ joined
14:55 steeze joined
14:56 <lyxia> > let a = b where b = c ; d = 42 ; c = d in a
14:56 <lambdabot> 42
14:56 jgt1 joined
14:58 Neomex joined
14:58 Neomex left
15:00 <bbear> is that ok to gov with Data.Tree to use trees ?
15:00 <mtesseract> Hello
15:01 <hc> oh wow, there is even a pdf generator lib for haskell. :)
15:04 <abhiroop> lyxia: I am thinking about the semantics of `<++`
15:04 <abhiroop> Is it sequential in nature
15:04 <abhiroop> whereas <|> is parallelizable
15:05 <lyxia> you could run the two arguments of <++ in parallel and throw away the second one if you don't need it.
15:07 <bbear> how many time to be good at haskell ?
15:07 <bbear> 1 year ?
15:07 <dysfun> a lifetime?
15:08 <dysfun> how good do you want to be? how much time will you put into it?
15:08 abhiroop joined
15:10 capuk joined
15:11 mmachenry joined
15:12 SimpleL joined
15:13 wroathe joined
15:14 skeuomorf joined
15:14 <bbear> I wonder
15:14 cpup joined
15:14 <bbear> ultimately I think it is kind of a quest to be a good programmer
15:14 <bbear> But right now I notice I am really slow at abstracting problems.
15:14 <bbear> I mean really really slow.
15:15 abhiroop joined
15:15 <dysfun> well you can probably fix that in a few months of practice
15:15 <bbear> Like coding a proper minimax IA is taking me probably 3 full days of work for a simple game..
15:15 shayan_ joined
15:15 <bbear> I don't know what is the standard though.
15:15 <bbear> But I feel myself slow.
15:15 <ongy> I would have to start with 1-2 Days of research, so 3 days isn't that bad :)
15:16 <dysfun> it depends what you're doing
15:16 <dysfun> i'm quite slow to start in areas where i don't know the concepts or libraries
15:16 <ertes> @let class Boolsheet a where { boolsheet :: a -> [Bool] }; instance Boolsheet Bool where { boolsheet = pure }; instance (Boolsheet a) => Boolsheet (Bool -> a) where boolsheet f = [False, True] >>= boolsheet . f
15:16 <lambdabot> Defined.
15:16 <ertes> > boolsheet not
15:16 <lambdabot> [True,False]
15:16 <ertes> > boolsheet (&&)
15:16 <lambdabot> [False,False,False,True]
15:17 orbifx joined
15:20 abhiroop joined
15:20 <bbear> how can you define a Tree in Haskell ?
15:20 <cocreature> data Tree = Empty | Node a (Tree a) (Tree a)
15:20 <bbear> that's a binary tree
15:20 <bbear> I need a rose tree
15:21 <bbear> no idea ?
15:21 <cocreature> data Tree = Tree a [Tree a]
15:21 <bbear> good
15:21 <bbear> I suppose it will be sufficient.
15:21 <cocreature> eh I forgot an "a" on the left hand side
15:22 marcopullo joined
15:22 <cocreature> the containers package has rosetrees in Data.Tree
15:23 wroathe joined
15:24 significance joined
15:24 mda1 joined
15:25 abhiroop joined
15:25 <Zemyla> bbear: data Tree a = forall s. Tree (s -> (a, [s])) s
15:26 <bbear> is that using the Data.Tree ?
15:26 <bbear> I'm not sure if building my own data structure would be better for a beginner.
15:26 <Zemyla> bbear: Yeah, it's probably not better for a beginner, because it uses ExistentialQuantification, and writing a monad for it isn't obvious.
15:27 <significance> Is `[1,2] >>= \n -> ['a','b'] >>= \ch -> return (n,ch)` evaluated as `[1, 2] >>= (\n -> ['a', 'b']) >>= (\ch -> return (n, ch))`, or as `[1, 2] >>= (\n -> ['a', 'b'] >>= (\ch -> return (n, ch)))`?
15:27 <bbear> ich
15:27 Fendor joined
15:27 marcopullo joined
15:27 mbw joined
15:27 <joe9> I want to see the Rep of a data type. Is it possible to do that from the ghci after loading that module (which has the datatype)?
15:29 <mbw> Can anybody confirm that the memoize_fib function found here https://wiki.haskell.org/Memoization and also in the book "Haskell High-Performance Programming" is as fast as people seem to claim? I can't reproduce this at all.
15:29 <mbw> Using GHC 8.0.1 that is.
15:29 <lyxia> joe9: :kind! Rep MyType
15:29 Berra joined
15:29 <joe9> Thanks.
15:30 Zialus joined
15:30 <lyxia> mbw: how fast do you want it to go
15:31 <mbw> lyxia: I know there's an O(n) algorithm. It's just that people claim that the function "memoized_fib" should be able to calculate the 10000th fib quickly...
15:31 des_ joined
15:32 takle joined
15:32 <mbw> If I can't reproduce what I presume is a prototypical memoization example, something is off.
15:32 <mbw> I tried with and without -O2.
15:32 <lyxia> and what did you get?
15:33 <mbw> The 42th takes about 5 sec.
15:33 <mbw> Using Int as result type, that is. With Integer you can just forget about it
15:33 <lyxia> > let mfib :: Int -> Integer ; mfib = (map fib [0 ..] !!) ; fib 0 = 0 ; fib 1 = 1 ; fib n = mfib (n-1) + mfib (n-2) in mfib 10000
15:33 <lambdabot> 3364476487643178326662161200510754331030214846068006390656476997468008144216...
15:33 <cocreature> I get the 10000th in 0.76 seconds
15:33 wroathe joined
15:33 iomonad joined
15:33 <cocreature> without any changes
15:33 <mbw> huh....
15:34 <bbear> wait
15:34 <significance> Why does `guard` return `mzero` for false instead of `fail`?
15:34 <lyxia> looks like you're still testing the slow_fib somehow
15:34 takle_ joined
15:34 HugoDaniel joined
15:36 <mbw> This is the way I tested it: http://lpaste.net/354457 . Maybe it's because of the way I'm calling it?
15:36 <joe9> need some help, please? I used generics before and when defining a default method (Rep a) was good enough. But, this time, it says Rep a is a kind. code: http://dpaste.com/2TW6W5A error :
15:36 <joe9> http://codepad.org/emlUalSo
15:36 <joe9> I can hack around and change Rep a to Rep a Builder and it does not error at that line.
15:36 eazar001 joined
15:37 <joe9> but, I want to know why or understand why I would need that.
15:37 <lyxia> significance: fail is yucky because not all monads have a concept of failure and guard doesn't have a good string to pass to fail anyway
15:37 <significance> lyxia: ahh, thank you! any reason we use mzero?
15:37 <significance> > fail :: [a]
15:37 <lambdabot> error:
15:37 <lambdabot> • Couldn't match expected type ‘[a1]’
15:37 <lambdabot> with actual type ‘String -> m0 a0’
15:37 <lyxia> mbw: fibLoc is supposed to call fibmem
15:37 <joe9> When I do :Kind! Rep Builder , I get the same info as :kind! Rep Doc (which was a module that I defined earlier and that worked with just Rep a
15:37 <mbw> argh
15:37 <glguy> joe9: :kind! Rep Doc ()
15:37 marcopullo joined
15:38 <mbw> Now I feel stupid lol
15:38 <nshepperd> significance: in recent ghc it returns 'empty', which is from Alternative typeclass. so you can use it on some things that aren't even monads
15:38 <significance> nshepperd: ahh, awesome -- thank you!
15:39 trism joined
15:39 <joe9> glguy: for builder http://codepad.org/5BzVwzDH for Doc: http://codepad.org/wwaRUXtf
15:39 <lyxia> joe9: In GIBFormat a must have kind * -> *
15:39 fizruk joined
15:40 <joe9> for builder info is http://codepad.org/lzBLzgyJ
15:40 abhiroop joined
15:40 <nshepperd> but yeah, either mzero or empty is better than fail, because that way you get a type error if your monad doesn't support failure
15:40 <nshepperd> instead of a run time exception
15:40 <mbw> lyxia: Thanks for your help.
15:40 <glguy> joe9: then they aren't instances of Generic
15:40 <lyxia> joe9: class GIBFormat f where gbuildIBFormat :: f p -> Builder ; gparseIBFormat :: Parser (f p)
15:41 Boomerang joined
15:41 xall joined
15:41 <joe9> lyxia: got it. Thanks a lot.
15:41 jbiesnecker joined
15:43 t0by joined
15:43 Wuzzy joined
15:43 wroathe joined
15:43 cfricke joined
15:44 sleffy joined
15:45 cfricke joined
15:46 DataComputist joined
15:47 Goplat joined
15:47 <bbear> will it work ?
15:47 <bbear> http://vpaste.net/wzjLD
15:49 hamishmack joined
15:50 <bbear> build a tree from a seed
15:50 <bbear> do you know how to do it ?
15:50 Fusionnex joined
15:50 Welkin joined
15:51 <bbear> oh my
15:51 <bbear> http://haskell.1045720.n5.nabble.com/Building-a-tree-td3134095.html <- will I ever be able to code in Haskell
15:52 vektorweg1 joined
15:52 <Welkin> bbear: http://www.willamette.edu/~fruehr/haskell/evolution.html
15:53 raycoll joined
15:53 jbiesnecker joined
15:54 pera joined
15:54 richi235 joined
15:54 abhiroop joined
15:55 moth joined
15:57 revprez_atlanta joined
15:57 jgt1 joined
15:58 Mutter joined
16:00 takle joined
16:01 marcopullo joined
16:01 raichoo joined
16:01 user__ joined
16:02 Ferdirand joined
16:02 {emptyset} joined
16:02 gugah joined
16:03 urodna joined
16:04 wroathe joined
16:04 joneshf-laptop joined
16:04 nilof joined
16:05 <joneshf-laptop> If I have `newtype Foo = Foo Text deriving (ToJSON)` what will the `toEncoding` implementation look like?
16:06 <joneshf-laptop> Will it detour through `Value` land, or will it use the `toEncoding` of `Text`?
16:06 abhiroop joined
16:06 carlosda1 joined
16:06 <MitchellSalad> it will use the `toEncoding` of `Text`
16:06 <joneshf-laptop> Great!
16:06 <joneshf-laptop> Thanks
16:06 madsa joined
16:07 <MitchellSalad> GeneralizedNewtypeDeriving just gives you the instances of the underlying type. How could it do any different?
16:07 <MitchellSalad> =P
16:07 <joneshf-laptop> more generally, is that a property of...just what I was going to ask :)
16:07 <joneshf-laptop> Thanks again.
16:07 codesoup joined
16:07 <MitchellSalad> of course
16:08 <jennyrgb> what's {stuff} for?
16:09 peterbecich joined
16:09 <cocreature> jennyrgb: I think you need to provide a bit more context
16:10 <cocreature> maybe it’s NamedFieldPuns https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html?highlight=namedfieldpuns#ghc-flag--XNamedFieldPuns
16:11 <MitchellSalad> {stuff} is a pattern that assigns variable name 'stuff' to what otherwise would be 'stuff record'
16:11 <MitchellSalad> i.e. normally with 'data User = User { name :: String }', name :: User -> String
16:11 MindlessDrone joined
16:11 <MitchellSalad> but using a 'User{name}' pattern, in that context, name :: String
16:14 dfeuer joined
16:14 wroathe joined
16:15 <joneshf-laptop> Speaking of records
16:15 nick_h joined
16:15 <joneshf-laptop> It feels like thelast few extensions really made most of the problems go away in day to day use.
16:16 <joneshf-laptop> particularly: `DuplicateRecordFields` and `RecordWildCards`
16:18 MindlessDrone joined
16:18 sigmundv joined
16:19 Micamo joined
16:19 <tsahyt> RecordWildCards is not that new, is it?
16:19 redwater joined
16:19 jgt1 joined
16:20 <geekosaur> no
16:20 moth joined
16:21 oneeman joined
16:21 redwater joined
16:22 coot joined
16:22 jennyrgb joined
16:23 <jennyrgb> MitchellSalad: what's that doing? data User = User { name :: String }?
16:24 jbiesnecker joined
16:25 jsgrant-_ joined
16:26 tathougies joined
16:27 redwater left
16:29 <geekosaur> it's the same as `data User = User String; name :: User -> String; name (User s) = s` except you can also use it in pattern matching
16:29 <geekosaur> and record update syntax
16:29 <geekosaur> named fields instead of just positional
16:31 wroathe joined
16:33 pent joined
16:35 jbiesnecker joined
16:36 augur joined
16:36 wroathe joined
16:37 mada joined
16:39 aglorei joined
16:40 gcross_ joined
16:40 hamishmack joined
16:45 feynhat joined
16:45 coltfred joined
16:48 jbiesnecker joined
16:48 cdg joined
16:52 slacker joined
16:53 GodNeuron joined
16:53 migge joined
16:54 jbiesnecker joined
16:58 mstruebing joined
17:00 dan_f joined
17:01 acidjnk joined
17:02 albertus1 joined
17:02 azahi joined
17:03 dsh joined
17:04 mtesseract joined
17:04 e_svedang joined
17:05 abhiroop joined
17:05 <joe9> error http://codepad.org/Ocrz5UxJ , code http://dpaste.com/29FDY29 . I am missing something here. I can change the parseIBFormat definition in line 27: to be ByteString -> (a, ByteString). But, I want to figure out why I cannot use Parser a instead.
17:05 Ferdirand joined
17:06 <joe9> any kind suggestions, please?
17:07 jeltsch joined
17:07 <cocreature> joe9: gparseIBFormat gives you a Parser (f x). but what you need is a Parser a
17:07 _sg joined
17:08 <joneshf-laptop> I'm writing a wai middleware that catches exceptions and dishes them off to an external server. Is it better to create my own `Manager` or use the global `Manager`? The recommended reading (https://haskell-lang.org/library/http-client) doesn't really talk about this case.
17:09 <joe9> cocreature: I cannot make it just Parser f
17:10 <joneshf-laptop> Am I overthinking it?
17:10 <joneshf-laptop> Feels like it
17:11 <cocreature> joe9: maybe you’re looking for parseIBFormat x = gparseIBFormat (from x)?
17:11 bl4z3r21 joined
17:11 <Fusionnex> i feel like it is rather challenging to structure programs because of the number of things I have to think about being a novice haskeller
17:12 <joe9> cocreature: Thanks a lot. I feel brain dead that I cannot think it up.
17:12 <Fusionnex> i feel like my brain just doesnt think like a functional programmer so its hard to get useful things done
17:12 <Fusionnex> slowly shifting there
17:12 tel joined
17:12 <joneshf-laptop> Fusionnex, then don't think about them :)
17:12 <cocreature> Fusionnex: practice helps :)
17:12 <joe9> Fusionnex: same here. I just feel that my brain cannot think this through. feel like a sheep.
17:12 TotallyNotNeomex joined
17:12 <joneshf-laptop> A fairly huge benefit of Haskell is that you can make large changes with much confidence.
17:12 <Fusionnex> im working through practical haskell and learn u a haskell for great good
17:13 <Fusionnex> i frekaing love the compiler and the type safety is amazing compared to other languages
17:13 <TotallyNotNeomex> i dont care about haskell but ive heard there are cool people here
17:13 <joneshf-laptop> So if realize you're doing something wrong, just make changes.
17:13 <Fusionnex> change it till it compiles and then it works
17:13 <Fusionnex> :-D
17:14 <joe9> cocreature: I cannot use: parseIBFormat x = parseIBFormat (from x) -- as the x input is a bytestring. not the actual structure that is being parsed to. Is this where Proxy helps?
17:14 <joneshf-laptop> At least, that's the conventional wisdom
17:14 <cocreature> Fusionnex: just make sure that you are also actually writing code and not only reading books
17:14 <Fusionnex> im looking to contribute to some open source libraries, like possibly datascience for haskell
17:15 takle joined
17:15 <joneshf-laptop> The problem is, when first starting out, most people don't think much in types, so the compiler isn't quite as helpful for large changes like that.
17:15 <Fusionnex> im a bioinformatician who happens to find functional programming fascinating
17:15 <Fusionnex> types and typed composition makes sense to me to some extent, and i've got map and fold down
17:16 <joneshf-laptop> Like, if every invariant is at the value level, type checking will not help much.
17:16 mightyby1e joined
17:16 <joneshf-laptop> If you move invariants up to the type level, type checking is more useful
17:16 <Fusionnex> that makes sense
17:17 <joneshf-laptop> data science eh?
17:17 mtesseract joined
17:17 takle_ joined
17:17 mightyby1e left
17:18 <Fusionnex> well i feel that haskell may have advantages in writing software for distributed concurrent systems in a more st ructured typesafe way
17:18 <cocreature> joe9: oh right sorry. I don’t think proxy is going to save you here. let me think about it
17:18 <Fusionnex> but i don't know enough haskell to really make it happen at the moment. i write in c#, R, and python, and have contributed to open source libraries before, just need a better practical handle on haskell
17:19 <Fusionnex> i'm really learning it to make myself a better programmer in general, and to learn a new way to approach problems
17:19 <cocreature> joe9: parseIBFormat = fmap to gparseIBFormat
17:19 <joe9> cocreature: found something here https://jeltsch.wordpress.com/2016/02/22/generic-programming-in-haskell/
17:19 TotallyNotNeomex joined
17:19 <joneshf-laptop> Fusionnex, I don't want to send you down a rabbit hole this early, but there's some really interesting ideas here: https://izbicki.me/#haskell
17:19 <joe9> cocreature: good idea. Thanks.
17:19 <joneshf-laptop> Fusionnex, unfortunately, it looks like it's mostly bit rotted.
17:19 safe joined
17:19 <joe9> cocreature: that helped. Thanks again.
17:20 <Fusionnex> joneshf-laptop: hmm, looks interesting
17:20 <Fusionnex> joneshf-laptop: i know there are tensorflow bindings for haskell which is kind of interesting
17:20 TotallyNotNeomex left
17:20 <Fusionnex> joneshf-laptop: although they are not a first class citizen like python
17:20 <joneshf-laptop> Fusionnex, I especially like this post: https://izbicki.me/blog/hlearn-cross-validates-400x-faster-than-weka.html even if I can't verify whether it's accurate or not.
17:21 <Fusionnex> joneshf-laptop: that's where i've seen his face!
17:21 <Fusionnex> joneshf-laptop: i've used weka, and i think its entirely possible to be true, but i haven't verified it
17:22 <joneshf-laptop> Fusionnex, cool
17:22 jsgrant-_ left
17:22 <joneshf-laptop> Fusionnex, in any case, I'd love to see what you end up doing.
17:23 <joneshf-laptop> Fusionnex, even if what you end up doing is not continuing with Haskell
17:23 logicmoo joined
17:23 <Fusionnex> joneshf-laptop: bleh, im such a novice at haskell it is going to take me a while to become productive
17:24 <Fusionnex> joneshf-laptop: even if i don't become super proficient at haskell, it has helped me learn a lot of functional programming paradigms in R which has absolutely been useful
17:25 jsgrant-_ joined
17:27 <Fusionnex> joneshf-laptop: what projects are you working on at the moment?
17:27 jmiven joined
17:30 <joneshf-laptop> Fusionnex, wrapping some APIs at the moment.
17:31 <joneshf-laptop> Fusionnex, Rollbar currently, and maybe Datadog later.
17:32 miamia joined
17:33 <Fusionnex> joneshf-laptop: error logging always a good contribution :)
17:34 des_ joined
17:38 JuanMiguel joined
17:40 armyriad joined
17:41 jennyrgb joined
17:41 <jennyrgb> what are monads? I don't get it
17:42 <Fusionnex> http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
17:42 <Fusionnex> jennyrgb: this helped me
17:42 <benzrf> nooooooo
17:42 <benzrf> Fusionnex: stop linking that!
17:42 <benzrf> it's not helpful!
17:42 <Fusionnex> :(
17:42 <Fusionnex> why not?
17:43 <maerwald> benzrf: yes it is
17:43 <cocreature> jennyrgb: are you familiar with Functor and Applicative?
17:43 <benzrf> maerwald: ??
17:43 <qmm> glguy: i didn't know you could run "cabal get package_name" to fetch sources. that's quite handy. i'm guessing you gave up at malformed mach-o?
17:43 <Fusionnex> i mean you could explain straight lambda calculus and tell them to read alonzo church's papers and come back after a graduate course in mathematics
17:43 <monochrom> I find that picture inaccurate, too.
17:43 <jennyrgb> cocreature: what's applicative?
17:44 <jennyrgb> I'll just read that page :p
17:44 <cocreature> jennyrgb: https://hackage.haskell.org/package/base-
17:44 <* benzrf> sighs
17:44 <maerwald> benzrf: if people want a completely correct definition, they can read the maths. That link tries to give an intuition that works in a lot of cases, not in ALL.
17:44 <maerwald> over-nitpicking rarely helps with building up an intuition
17:44 <benzrf> maerwald: im not convinced it's actually a helpful intuition
17:44 <maerwald> I disagree then
17:44 <joe9> cocreature: one quick question, please? How do I parse the :+: types. I cannot know if they are the L1 or the R1 ? code http://dpaste.com/252GQBT line 113
17:44 <Fusionnex> benzrf: it's entirely possible that there could be inaccuracies in that, and it may not be pure enough for some, but it seems helpful for beginners
17:45 <benzrf> maerwald: well, i guess it's a good illustration _of certain specific monads_
17:45 <cocreature> joe9: just take a look at the constructors https://hackage.haskell.org/package/base-
17:45 <cocreature> joe9: it’s somewhat similar to Either
17:45 <maerwald> benzrf: and that's already helpful
17:45 <benzrf> maerwald: i just take issue with presenting it as though it's a _pattern for monads in general_
17:45 <benzrf> yeah, ok
17:45 <Fusionnex> benzrf: there are much better youtube vidoes for explaining monads i think as well
17:45 <Fusionnex> benzrf: i understand why you would take issue with _pattern_ for monads
17:46 <joe9> jennyrgb: monad is a mechanism to join 2 functions together. It helps avoid boilerplate code such as checks for correct argument value , etc.
17:46 takle joined
17:46 <benzrf> joe9: that's not really a good way of thinking aobut it
17:47 <benzrf> Fusionnex: mostly i just get pissy about trying to approach monads as something to understand before you can use them
17:47 <benzrf> Fusionnex: because ultimately the only way to understand them is to use them
17:47 <joe9> cocreature: I understand how the constructors work. but, when parsing a value, I would not know whether that value is on the Left side or the Right side. Does that make sense?
17:48 caumeslasal joined
17:48 <cocreature> joe9: well you need to pattern match to figure that out. just like you do for Either
17:48 <Fusionnex> benzrf: I agree, and i dont think i fully grasp monads yet considering I havent used them enough. reader and writer were somewhat enlightening though
17:48 <maerwald> benzrf: that's not really a good approach to teaching though. You could say that about anything. When programmers look at the maths of monads, it's mostly unhelpful. Saying "just use them" is also unhelpful
17:48 <EvanR> a way to "join" two arrows together is a category not a monad
17:48 <benzrf> maerwald: i don't think it is, as long as you point to some explanations of individual monads
17:48 <benzrf> jennyrgb: basically heres the deal with monads:
17:49 <maerwald> benzrf: that doesn't really help imo
17:49 <Fusionnex> benzrf: thanks for giving your understanding of monads, looking at several ways to conceptualize them is important I think
17:49 <EvanR> just use them
17:49 <EvanR> later you can delve into a more sophisticated understanding
17:50 <benzrf> jennyrgb: it turns out that there's this particular pattern that crops up across many types, where you have a pair of functions that you tend to use in particular ways that look structurally similar even though they're doing different things in each type
17:50 <EvanR> you will get into the habit of going back and trying to understand what you did in some rigorous way
17:50 <maerwald> there're a few "fuzzy" explanations about properties and intuition of monads that are helpful and they must be fuzzy, otherwise you can't explain what they mean to you as a programmer
17:50 <monochrom> The picture could have saved itself by stating what it actually works for. When one makes a sentence "a monad is ___" then it has an implicit "all" and one can't just weasel out of it with "I don't mean all".
17:50 <maerwald> just saying "look at 500 monad instances" doesn't help
17:51 <benzrf> jennyrgb: so people call a particular case of a type and two functions related to it a "monad", so that you can write code which captures particular structures that you might want to do for any given monad
17:51 <benzrf> jennyrgb: however, it is very hard to explain exactly what it is that all monads have in common, except that you tend to use them in similar patterns of code
17:51 holla joined
17:51 <benzrf> therefore, to understand monads, you just need to use enough different monads until you begin to recognize the pattern
17:51 <maerwald> no
17:51 <benzrf> then you can start thinking about writing code that captures these patterns
17:51 <maerwald> doubt it
17:52 <jennyrgb> brb
17:52 <Fusionnex> LOL
17:52 vektorweg1 joined
17:52 <EvanR> dont stop what you do maerwald
17:52 <maerwald> https://stackoverflow.com/questions/17409260/what-advantage-does-monad-give-us-over-an-applicative
17:52 <maerwald> the accepted answer is very nice
17:52 <maerwald> and it uses fuzzy terms
17:52 <maerwald> but that's fine
17:53 slacker joined
17:53 <maerwald> you can't explain that when all you want to do is be correct and catch all cases
17:53 caumeslasal joined
17:53 <maerwald> that's not how you teach and build intuition
17:54 <benzrf> maerwald: i read a *lot* of monad intuition posts and i am not convinced that any of them actually helped me
17:54 <benzrf> well, ok, now that i'm reading the linked post -
17:54 <benzrf> i guess this may be helpful
17:54 <maerwald> that's basically the only post that helped me ;)
17:54 <EvanR> theres something to be said for building wrong intuition fast and going back later to fix it
17:54 abhiroop joined
17:54 <EvanR> if it gets the job done
17:54 <benzrf> but you'll notice that it's talking about how you can use a monad, not "what a monad is"!
17:55 <maerwald> EvanR: yeah
17:55 <benzrf> that is, what patterns of use are possible to implement with a monad
17:55 <benzrf> which is what i was talking about :)
17:55 zariuq joined
17:55 <qmm> lambdabot; cd lambdabot-; cabal new-build
17:55 <benzrf> i guess i can concede that i may have hyperfocused on ONLY learning-by-using
17:55 <EvanR> however wrong intuition about monads might end up being the basis of a world wide undeletable javascript framework
17:55 <maerwald> benzrf: but I doubt that just by looking at 20 different monad instances... most people would still not find those patterns
17:55 <EvanR> that would be silly
17:55 splanch joined
17:55 <benzrf> yeah ok, i guess there's value in explanations when they focus on usage patterns
17:55 <Fusionnex> EvanR: oh goodness, javascript makes me cry
17:56 gugah joined
17:56 <cocreature> maybe we should just accept that different people have different ways of learning things
17:56 <benzrf> i guess i just got so used to monad explanations trying to explain "what a monad is" rather than presenting patterns that arise with monads
17:56 mudri joined
17:56 <benzrf> that i started to habitually reject monad explanations entirely :>
17:56 marr joined
17:56 gugah joined
17:56 <maerwald> we're making a pretty good case why learning haskell is hard btw :)
17:56 <MarcelineVQ> talking about learning haskell is hard
17:56 <EvanR> both of you are analyzing it from the perspective of already knowing all this
17:56 <maerwald> (not because it's different)
17:57 <maerwald> EvanR: well, I also tried to explain it to others, so I have some experience there too
17:57 <EvanR> i never have, i only ever explained algebraic data types and type classes
17:57 <EvanR> and then monads were just another thing
17:57 <maerwald> it's easier to teach python, java or whatever :P
17:57 <joneshf-laptop> maerwald, is it hard because there's years of bad information floating around?
17:58 <benzrf> maerwald: my opinion is generally that learning haskell is hard, but it's not much harder than learning python
17:58 <maerwald> joneshf-laptop: no, it's hard because the concepts in haskell are more abstract and advanced
17:58 <EvanR> you can use python without knowing anything about it
17:58 <maerwald> yep
17:58 <EvanR> haskell, not so much
17:58 <benzrf> maerwald: the problem is that people who are learning python very often already know javascript or something, so they got the difficulty out of the way, and they perceive python as easier than it is
17:58 <maerwald> benzrf: that's what I disagree with. I don't think the paradigm per-se or the previous knowledge is the big difference
17:58 <benzrf> whereas few people have a pre-existing base for haskell concepts, so it's almost always as hard as it really is
17:59 <maerwald> it's the abstraction and the kind of concepts haskell is promoting
17:59 <joe9> cocreature: I am not talking about pattern matching but while parsing http://codepad.org/89lpHzS1 (this is not valid), how would I know if it is a L1 constructor or R1 constructor.
17:59 <EvanR> speaking of which
17:59 <EvanR> why is haskell catching on more than scheme?
17:59 harfangk joined
17:59 <benzrf> well, i can acknowledge that it's harder to get to a level of haskell expertise where you can use it for programs than it is to get to a level of python expertise where you can use it for programs
17:59 <hpc> EvanR: i think i would argue it the other way around
17:59 <EvanR> seems like scheme has the "easy" factor like python and is older
17:59 <benzrf> but like EvanR said, that's just because you can use python without knowing anything about it :P
17:59 <hpc> EvanR: it's a struggle sometimes just to figure out what the right import syntax is in python
17:59 <Fusionnex> EvanR: you may not want to hear this, but I think it is due to some larger instuitional support through stack etc
18:00 <joe9> I can try a case statement
18:00 <EvanR> stack? really?
18:00 <Fusionnex> EvanR: resulting in increased popularity
18:00 <hpc> and all those __magic_identifiers__ for basic functionality get on my nerves
18:00 redwater joined
18:00 <hpc> while haskell gives you instant feedback on everything via the compiler
18:00 <cocreature> joe9: well that’s a type error. you need a "Parser (a :+: b)" but your definition is constructing some sort of function
18:00 <Fusionnex> im not saying stack is driving it, but i am saying that larger corporate sponsorship seems to result in increased popularity of haskell
18:01 <joe9> cocreature: http://codepad.org/hJJH1rCP
18:01 <maerwald> benzrf: doing proper C is harder than haskell, but the only really complicated "concept" are pointers. Everything else is just pitfalls, compiler details and whatnot. In haskell it's about the primary concepts used everywhere. And there are a LOT of them. Monads just being the most popular one, that's already fairly problematic for a wide audience.
18:01 <joe9> but the :+: is not exported by Generics. maybe I can use a Parser.try?
18:01 <EvanR> monads are not that different from + in terms of languages features
18:01 <benzrf> maerwald: i think if you look at the fundamental language semantics, haskell is really approximately on the same level as C
18:02 <maerwald> http://dev.stephendiehl.com/hask/
18:02 <benzrf> maerwald: it's just that C doesn't do as much abstraction-building
18:02 <EvanR> these features are going to be just as alien to somebody who doesnt know monads as monads
18:02 <maerwald> haskell is so full of concepts, there are very few languages that can keep up
18:02 <benzrf> maerwald: yes, those are all idioms or libraries, not fundamental language semantics
18:02 <maerwald> benzrf: doesn't matter when half of the ecosystems uses them
18:02 <benzrf> and if you want to write real C, you also have to learn all kinds of idioms and libraries
18:03 <tsahyt> benzrf: at least as long as we're talking about about haskell98. once you bring in GHC extensions, this is no longer the case I think
18:03 d34df00d left
18:03 <Fusionnex> what are the most helpful libraries for writing practical haskell ?
18:03 <benzrf> tsahyt: ...well, ok :)
18:03 jaguar joined
18:03 <maerwald> most people only use libc when they write C. It's pretty common to reimplement everything you need
18:03 <benzrf> then doesnt that make it HARDER, since you have to know how to implement everything you need?
18:03 <EvanR> Fusionnex: parsec, optparse-applicative,
18:03 <monochrom> I happen to think that Haskell has to be harder than imperative languages and other functional languages (SML for example) too.
18:03 <EvanR> text, bytestring
18:04 <maerwald> benzrf: I thought my argument was obvious: different CONCEPTS are widely used in the haskell ecosystem
18:04 <tsahyt> Fusionnex: containers
18:04 <maerwald> that's not really true for C
18:04 <benzrf> maerwald: btw, if you think python is easier than haskell - please try explaining to a beginner why this code is wrong: "grid = [[True] * 10] * 10"
18:04 <benzrf> ;)
18:04 <monochrom> In all other languages both "xxx" and getLine() have type String. In Haskell they have different types.
18:04 <joneshf-laptop> I dunno, don't you think that most of these problems stem from people starting with bad resources and having to relearn properly?
18:04 <tsahyt> Fusionnex: as well as unordered-containers and vector. those are probably the ones I find myself depending on most often
18:04 <joneshf-laptop> LYAH is like the top result for haskell stuff
18:04 <benzrf> maerwald: well, i mean - there's all kinds of algorithms and data structures in C
18:04 <maerwald> benzrf: C doesn't have nearly the amount of abstract concepts like haskell does
18:04 <joneshf-laptop> But it's definitely not the first resource you should try and consume.
18:05 <benzrf> maerwald: that's fair, yeah
18:05 <cocreature> joe9: using :+: as a data constructor with two arguments makes about as much sense as using Either as a data constructor and passing it both the Left case _and_ the Right case. you probably want something like "gparseIBFormat = fmap L1 gparseIBFormat <|> fmap R1 gparseIBFormat"
18:05 <Fusionnex> are containers like generic lists ?
18:05 <monochrom> If you try to learn a language just enough to write "input a line from the user, then echo it back", Haskell already needs you one or two more concepts than other languages.
18:05 fizbin joined
18:05 mda1 joined
18:05 <maerwald> benzrf: neither does python. Java is a different situation, you could argue that design patterns are a similar beast
18:05 <joe9> cocreature: thanks. makes sense.
18:05 <tsahyt> Fusionnex: containers is the package implementing things like Data.Map
18:06 <benzrf> maerwald: "neither does python"?
18:06 <benzrf> oh wait
18:06 <monochrom> OTOH "xxx" vs getLine() is also why I think that other languages are philosophically wrong and Haskell got it right (one way of being right anyway).
18:06 <tsahyt> Fusionnex: basically a bunch of container data structures that I personally end up requiring very often, since base doesn't provide much in that regard
18:06 <benzrf> ok, didnt connect which sentence you were continuing
18:06 <benzrf> 14:04 <benzrf> maerwald: btw, if you think python is easier than haskell - please try explaining to a beginner why this code is wrong: "grid = [[True] * 10] * 10"
18:06 <benzrf> :P
18:06 <Fusionnex> tsahyt: cool, ill check it out.thanks for the recommendations
18:06 <cocreature> Fusionnex: "containers" is the name of a package. not the name of some generic abstraction or data type
18:07 <EvanR> ok
18:07 <joneshf-laptop> Whereas a meaningful book like haskellbook is harder to find.
18:07 <joneshf-laptop> Like, there's years of stuff we can't erase from the internet
18:07 <maerwald> benzrf: that's just obfuscation and details, not really "concepts"
18:08 <monochrom> But when it comes to ease, apparently the wrong one is also the easier one.
18:08 <joneshf-laptop> It's not even on https://wiki.haskell.org/Books for instance
18:08 <benzrf> maerwald: are you kidding me?
18:08 <maerwald> benzrf: python hardly has a lot of abstraction
18:08 <tsahyt> joneshf-laptop: I still don't think the haskellbook is the best way to first dive into the language. it just progresses very very slowly
18:08 <maerwald> benzrf: how often do you see people write that code?
18:08 <benzrf> maerwald: object identity and mutation is one of the most fundamental concepts in python
18:08 <maerwald> you're coming up with a pathological example
18:08 <tsahyt> joneshf-laptop: I feel that for a lot of people they might lose interest before even coming to the interesting bits
18:08 <benzrf> i am not
18:08 <benzrf> ive personally made that mistake multiple times
18:08 <maerwald> I've never seen such python code
18:08 <tsahyt> that said, it's great for a second exposure
18:09 <joe9> Fusionnex: that is a good article about monads with pictures, etc.
18:09 <benzrf> maerwald: you've never seen python code where you accidentally mutate a list that you're also holding a reference to elsewhere?
18:09 <joneshf-laptop> tsahyt, I'm not saying that it's the best way either.
18:09 <benzrf> because you forgot to copy your argument?
18:09 fkurkowski joined
18:10 <monochrom> EvanR: The thing to be said about wrong intuition fast first and fix it later is that you need to be aware that you are doing that.
18:10 <tsahyt> I'm waiting for the joy of haskell book. I've been waiting for a non-beginner book on Haskell for a long time now
18:10 <Fusionnex> cocreature: thanks for the clarification
18:10 <joneshf-laptop> tsahyt, but it's tons better than LYAH for a beginner
18:11 <EvanR> monochrom: good point, monad explanations are doing that obliviously
18:11 <tsahyt> joneshf-laptop: I'd say that depends a lot on the particular beginner. LYAH is much shorter and serves better as a whirlwind exposure. but because of that it also doesn't go in depth with anything
18:11 <EvanR> like whoever is explaining it never went back and fixed it personally
18:12 <maerwald> benzrf: I find your example even fairly inutitive
18:12 <tsahyt> I think the first few chapters of LYAH was also the first resource I used when starting to learn haskell. I then quickly switched over to RWH.
18:12 <benzrf> maerwald: huh?
18:12 <maerwald> but that's when I don't think functionally
18:12 Mysterious_Light joined
18:12 <benzrf> no, it's very intuitive if you're acclimated to python
18:12 <benzrf> but again - try explaining the problem to a beginner!
18:12 <maerwald> you mean a haskell beginner? ;)
18:12 <benzrf> i mean a programming beginner
18:12 <joe9> any good books to learn the basics of haskell concepts (functor, applicative, alternative) well?
18:12 <joneshf-laptop> tsahyt, I also think RWH is much better than LYAH
18:13 ertesx joined
18:13 <maerwald> I think it's rather intuitive for a general programmer beginner, but I don't know about that
18:13 <benzrf> i've been comparing "haskell to a programming beginner" and "python to a programming beginner" all along
18:13 <maerwald> that's guessing
18:13 <maerwald> I might be wrong
18:13 <benzrf> maerwald: the list still prints as [[True, True, True], [True, True, True], [True, True, True]] regardless of whether you've constructed it correctly or not
18:13 <tsahyt> joneshf-laptop: unfortunately it's outdated by now
18:13 <maerwald> I've never teached absolute programming beginners
18:13 <tsahyt> a RWH 2e would be great
18:13 <benzrf> maerwald: it is very natural to think of lists as "values", like something you've written down on a piece of paper
18:14 <benzrf> and if i change what i've written down, i just change what i change
18:14 <maerwald> you'll have to ask someone else, who has experience with absolute programming beginners
18:14 <benzrf> i don't have 3 rows that are magically the same row
18:14 <MarcelineVQ> benzrf: interesting, that's certainly not the list I guessed
18:14 <tsahyt> oh nice I just saw that with GHC 8.2, Bi{fold,travers}able will be in base
18:14 <benzrf> MarcelineVQ: er, i was contracting it to as if i did [[True] * 3] * 3
18:14 <benzrf> :p
18:14 <qmm> glguy: where did you specify dependent-sum-0.4 as a dependency? i don't see dependent-sum in the cabal file
18:14 <MarcelineVQ> o oops
18:14 <maerwald> MarcelineVQ: it's totally what you would expect in python
18:14 <MarcelineVQ> ehe
18:14 <benzrf> maerwald: _if you know python_
18:15 fresheyeball joined
18:15 <maerwald> as I said: I have no idea how a total program beginner thinks
18:15 <maerwald> my first language was pascal
18:15 <benzrf> well, ok
18:15 <benzrf> heh
18:15 <benzrf> i do agree that haskell is more abstract
18:15 <benzrf> but im not convinced that this means more effort overall
18:15 <EvanR> people like abstract stuff
18:16 <EvanR> so haskell should be very popular
18:16 <glguy> qmm: I didn't
18:16 <monochrom> benzrf: Java has a similar disparity. Suppose I have two state variables, int x and Vector y. Then when I pass them to some method f(x, y), f can't mutate my x but it can mutate my y. Eventually we just got used to it and say "ah the difference between primitive types and classes"
18:16 <benzrf> if you learn something like python, you don't have to deal with such abstract concepts, but you do have to deal with mechanics that aren't clear up front such as object identity and scoping and closures
18:16 <glguy> qmm: I just allowed cabal to pick a newer version with --allow-newer=dependent-sum
18:16 <benzrf> so it's not clear to me that the extra effort for the abstractions isn't counterbalanced by the extra effort for the subtleties in python's semantics
18:16 <benzrf> haskell's semantics are almost entirely exactly what they seem to be the first time you learn them, i think
18:17 <EvanR> python has plenty of abstract concepts, the idea of an invisible mutable runtime system?
18:17 <benzrf> :)
18:17 <maerwald> EvanR: I recently talked to someone who made a proposal to write a compiler that sounded to me like a weird imperative version of what Idris, F* etc do... then I gave him a few references and this is what I got back: "I looked at haskell and now I don't understand why imperative programming is still so popular" xD
18:17 <maerwald> I laughed hard
18:17 <monochrom> Whereas C++ avoids this problem by having call-by-value vs &'s call-by-reference. (And Pascal too.)
18:17 <benzrf> there might be a case for C being simpler than both since its semantics are mostly what they seem and it doesn't have such abstractions
18:17 <benzrf> but idk
18:17 <EvanR> F*?
18:17 <maerwald> EvanR: yep, amazing language
18:17 <maerwald> have a look at it
18:17 <benzrf> oh damn
18:17 <benzrf> i used to have a tab about F* open
18:17 warlock joined
18:17 <benzrf> for like a month
18:18 <benzrf> then my session crashed
18:18 <maerwald> there's a channel, we're just 8 people though or so
18:18 <Fusionnex> benzrf: I think what you are saying is there will be less "gotchas" in haskell than in python?
18:18 <qmm> glguy: thanks, trying that now
18:18 <benzrf> Fusionnex: yeah, that's not a bad way of putting it
18:18 <benzrf> Fusionnex: except that i think "gotcha" may be a slightly trivializing way of putting it, because the "gotchas" are actually the core language semantics
18:19 <EvanR> hmm. "gotchas" ....
18:19 <benzrf> e.g., the problem with "[[True] * 3] * 3"
18:19 <Fusionnex> benzrf: for sure they are core languages features, but they definitely don't behave like you would expect
18:19 <benzrf> yeah :) i just mean that "gotchas" has kind of a connotation of bumps in the road, not the overall road's direction
18:19 <maerwald> I think ruby is more "wtf, how did this..."... but python is mostly intuitive imo
18:19 snowalpaca joined
18:19 <Fusionnex> I'm a self taught programmer, and the first time I encountered mutability issues it was so challenging
18:20 <benzrf> maerwald: ruby is to python as python is to haskell, in that respect
18:20 <EvanR> beyond the initial grocery basket of gotchas that haskell isnt anything like any other mainstream language... you have performance gotchas
18:20 <benzrf> maerwald: you've just internalized python's weirdness :)
18:20 <Fusionnex> EvanR: performance gotchas are just not understanding the compiler ?
18:20 <maerwald> I use python for prototyping and I don't even care what half of the stuff does what I do. I use a subset of the language.
18:20 <EvanR> good question
18:20 mmachenry joined
18:20 <ggVGc> haskell also has the gotcha of starting to write a program and ending up with a ultra-generic library for some new type theory concepts you just learnt
18:21 <benzrf> ggVGc: huehuehuehuehue
18:21 ragepandemic joined
18:21 <EvanR> at what point does performance factor in, language level, implementation level, emotional level
18:21 <maerwald> xD
18:21 <Fusionnex> EvanR: performance issues are definitely more difficult to reason about I think in haskell
18:21 erisco joined
18:21 <Fusionnex> EvanR: I firmly agree. Who cares about performance if your productivity goes through the roof XD
18:21 <benzrf> imo, in practice ggVGc usually ends up more like VggoGc
18:21 <erisco> :t traverse
18:21 <lambdabot> (Applicative f, Traversable t) => (a -> f b) -> t a -> f (t b)
18:21 <erisco> :t traverse (>>=)
18:21 <lambdabot> (Monad m, Traversable t) => t (m a) -> (a -> m b) -> t (m b)
18:22 <maerwald> EvanR: oh man, emotional level... now you've said something =D
18:22 zero_byte joined
18:22 <EvanR> Fusionnex: haskell = productivity going through the roof, ill have some of what youre smoking
18:22 <monochrom> What does "performance" mean at the emotional level? Like winning an Oscar?
18:22 <EvanR> performance reasoning is often driven by mysticism
18:22 <Fusionnex> EvanR: I think that my productivity in all languages has improved after learning some haskell :-D
18:23 <EvanR> is there anything in the language standard that you can logically use to reason about performance, seq ?
18:23 <ggVGc> I've had very few times in my life where performance became an actual issue, and it's always been just a matter of doing some extra work. All you need is a decent profiler, and I think GHC has good enough tools
18:23 <maerwald> EvanR: for prototyping, haskell is just pooooor. You have too much up-front design decisions and stuff you think about. Where in python you just fire up stuff and then realize it works, but also sucks in the end. Which is good for prototyping.
18:23 <ggVGc> at least so far in my use cases
18:23 redwater joined
18:23 <monochrom> Actually no for Haskell Report. But if you assume lazy evaluation and that seq is eager evaluation then you can do it.
18:24 <EvanR> heh
18:24 <EvanR> you cant legally reason about performance
18:24 <ggVGc> I think the main lesson haskell gave me is the value of composition
18:24 <monochrom> But both assumptions are good only 99.9% of the time.
18:24 <ggVGc> e.g composable types
18:24 <ggVGc> now I make composable types wherever I go
18:24 <benzrf> maerwald: well, why not think about how it should work in the first place o=
18:24 <glguy> For my work Haskell is excellent for prototyping. As the project changes the type system helps support making sweeping refactorings
18:24 <benzrf> maerwald: (but no i get what you mean :P)
18:25 <maerwald> benzrf: well, for Prototyping... I want to a) get VERY fast results and b) want to think about what sucked and what is problematic AFTERWARDS
18:25 <maerwald> so I can do the real thing properly
18:25 <maerwald> haskell doesn't let me do this
18:25 <monochrom> To be fair I actually doubt that any language standard is any better.
18:26 <maerwald> benzrf: which is fine btw. I'm not saying it should let me do that
18:26 <maerwald> it's a conflict of interest
18:26 <EvanR> people use C++ for performance, is there any logical basis for that? or is it mystic
18:26 nomicflux joined
18:26 <ggVGc> in my experience I've had way faster development and pretty much same performance with C and Lua, compared to C++
18:26 <joe9> code: http://dpaste.com/0NJBEPD error: http://codepad.org/kUbEicjE . any suggestions on how to fix it, please?
18:26 <monochrom> It is half empirical and half extrapolation.
18:26 <benzrf> maerwald: yeah, i can see that
18:27 <EvanR> i like C better too but this is just a standalone question
18:27 <monochrom> There is empirical fact that you can write fast programs in C. Then people extrapolate that to C++.
18:27 <monochrom> And all the while forgetting that Fortran is even better. But meh, people want OOP too.
18:27 <ggVGc> monochrom: people also want to compile for all platforms
18:27 <ggVGc> I guess fortran support is more limited
18:27 <ggVGc> maybe I'm wrong
18:28 <EvanR> well youre not getting fortran or C++ on a phone
18:28 <monochrom> No, Fortran support is wider.
18:28 <ggVGc> really?
18:28 <joe9> I am trying to write a simple function that I can use for debugging how the serialization or deserialization works.
18:28 abhiroop joined
18:28 lifter joined
18:28 <ggVGc> could I get fortran onto some random microcontroller I pick up from aliexpress?
18:28 <monochrom> It has been around longer, and more scientists with less known hardware use Fortran.
18:29 <ggVGc> EvanR: pretty sure you can get C++ onto most phones?
18:29 <EvanR> i dont think its popular
18:29 fkurkowski joined
18:30 <monochrom> No, not for microcontrollers.
18:30 jbiesnecker joined
18:30 cyborg-one joined
18:30 <cocreature> joe9: you probably want to use ScopedTypeVariables
18:32 abhiroop joined
18:32 <tsahyt> Has anyone here been reading Type-Driven Development with Idris?
18:32 orbifx joined
18:32 <Fusionnex> as a personal preference question. does anyone use haskell and visual studio code?
18:32 <Fusionnex> tsahyt: type driven development sounds so sexy
18:32 <joe9> cocreature: no, that does not seem to help. http://dpaste.com/2THGC6E error http://codepad.org/TI9VJKxi
18:32 <EvanR> tsahyt: i read the first few chapters
18:33 <joe9> Is the book online?
18:33 <monochrom> Someone did. Someone actually wrote a Visual Studio plugin for Haskell.
18:33 Tuplanolla joined
18:33 <tsahyt> EvanR: would the book be useful for a haskell programmer with no intentions of switching to idris?
18:33 <monochrom> Then they finished their PhD and stopped.
18:33 <EvanR> yes
18:33 <tsahyt> okay thanks. I guess I'll put it on my wishlist
18:33 <cocreature> joe9: scopedtypevariables have no effect without explicit forall
18:33 <Fusionnex> monochrom: :( that is rather unfortunate so development is stalled on the plugin?
18:33 <EvanR> its useful for making you jealous of dependent types
18:34 <monochrom> Yes. No one uses it now.
18:34 <EvanR> more seriously, some of the techniques in there can technically be done in haskell, at some expense
18:34 <monochrom> I don't even know whether it is usable or not.
18:34 <Fusionnex> monochrom: i'm going to give it a try right now and see what happens :-P
18:34 <EvanR> with GADTs, DataKinds
18:34 <tsahyt> EvanR: that's exactly what I wanted to hear :)
18:34 <tsahyt> I'll buy it then
18:35 <Tuplanolla> I was gone for two weeks due to hard drive failure. Did I miss anything important?
18:35 <Fusionnex> GADTs generalized algabraic data types?
18:35 abhiroop joined
18:35 <EvanR> thats what it expands to
18:35 <benzrf> bbl
18:36 <Fusionnex> monochrom: it seems functional at the moment
18:38 <joe9> cocreature: got it. just broke up the function into smaller pieces.
18:42 oish joined
18:43 hybrid joined
18:43 ChaiTRex joined
18:44 oisdk joined
18:45 Guest81707 joined
18:45 <joe9> instance QC.Arbitrary ClientVersion where arbitrary = return . ClientVersion =<< QC.arbitrary; I am doing this currently. Is there a generic way of doriving this?
18:45 <joe9> Is that what CoArbitrary does?
18:45 iqubic joined
18:46 <iqubic> Hello World
18:47 abhiroop joined
18:48 marfoldi joined
18:48 <joe9> found it, generic-random
18:49 <iqubic> What does that do??
18:49 <ski> joe9 : `arbitrary = ClientVersion <$> QC.arbitrary'
18:50 <ski> joe9 : if it's a `newtype', try deriving it
18:50 <joe9> ski, thanks. I need to read up on Control.Applicative.
18:50 <ski> `(<$>)' is an alias for `fmap', belonging to `Functor', not `Applicative', btw
18:50 <ski> (and `CoArbitrary' is something else)
18:50 <joe9> ski, http://dpaste.com/2J8Z17B is the data definition line 22
18:51 <joe9> ski, Thanks.
18:51 wroathe joined
18:51 <ski> if you change `data' to `newtype', you should be able to derive `QC.Arbitrary' (assuming you turn on extension `GeneralizedNewtypeDeriving')
18:51 ner0x652 joined
18:52 <ski> .. oh, you're already deriving it ?
18:52 nagyf joined
18:52 <joe9> ski, I was trying it. but, it does not work though.
18:52 <ski> (or do you have two different classes `Arbitrary' in scope ?)
18:52 <joe9> ski, https://byorgey.wordpress.com/2016/09/20/the-generic-random-library-part-1-simple-generic-arbitrary-instances/ found this that helps.
18:53 <ski> well .. try what i suggested
18:53 <joe9> ski, ok, will do. Thanks.
18:53 <ski> since presumably you'll never add another data constructor to `ClientVersion', nor add another component to the data constructor you have
18:54 <joe9> http://hackage.haskell.org/package/generic-random
18:54 systemfault joined
18:55 meck joined
18:56 stef204 joined
18:56 chaosmasttter joined
18:57 cchalmers joined
18:57 <iqubic> What does generic random do?
18:57 <joe9> iqubic: https://byorgey.wordpress.com/2016/09/20/the-generic-random-library-part-1-simple-generic-arbitrary-instances/
18:57 robotrolll joined
18:58 t0by joined
18:58 t0by joined
18:59 revprez_atlanta joined
18:59 HugoDaniel joined
19:00 <lyxia> joe9: what you wrote is done by GeneralizedNewtypeDeriving
19:00 <lyxia> generic-random is actually useful if you have large types
19:01 stef204 joined
19:01 <lyxia> what's wrong with "arbitrary = ClientVersion <$> arbitrary" or deriving Arbitrary
19:01 <joe9> lyxia: yes, thanks. I am testing it. I have bigger data types that I want to usi it on.
19:01 wroathe joined
19:01 <joe9> s/usi/use/
19:02 <joe9> lyxia: it works. no issues. I am building up to bigger data types and I do not fancy writing that http://codepad.org/7ufJkeJD code over and over
19:02 <lyxia> ok sure
19:03 blocus joined
19:04 takle joined
19:04 fizruk joined
19:04 augur joined
19:04 jeltsch joined
19:05 iomonad joined
19:06 darjeeling_ joined
19:06 <joneshf-laptop> Is there a simple https library like `http-conduit` that doesn't throw a crapton of exceptions?
19:07 emanuel joined
19:07 <emanuel> Hi there :)
19:08 ragepanda joined
19:08 eacamero_ joined
19:08 e14 joined
19:09 <ggVGc> I would hope most haskell code doesn't throw much exceptions
19:09 <ggVGc> :(
19:09 <iqubic> Is there a library for playing solid tones?
19:10 <Fusionnex> iqubic: I think there are some music libraries that may do some thing like that?
19:10 <iqubic> Not audio files, just tones
19:10 <iqubic> Like I want to be able to play the tone of C for 10 seconds.
19:11 <Fusionnex> iqubic: maybe check here: https://wiki.haskell.org/Applications_and_libraries/Music_and_sound
19:11 <joneshf-laptop> ggVGc, unfortunately, `http-conduit` throws exceptions like nobody's business
19:11 <Boomerang> iqubic: Do you want to play it from Haskell itself or create a file with the audio on it (e.g. .wav)
19:12 abhiroop joined
19:12 splanch joined
19:13 <iqubic> I'd like to play it directly from haskell, as it is a really simple tone.
19:13 <ggVGc> I would suggest not haskell for this
19:13 <ggVGc> because it'll end up being C interaction anyway
19:13 <ggVGc> might as well use something like ChucK
19:14 <iqubic> Why not Haskell?
19:14 takle joined
19:14 Ferdirand joined
19:15 <Fusionnex> iqubic: how do you get bits of information into your speakers?
19:15 fizbin joined
19:15 <iqubic> Fusionnex: I think you'd have to use C.
19:16 <iqubic> or C++ or something/
19:16 meck joined
19:17 ichor joined
19:17 <Fusionnex> iqubic: device interfacing would be correct, usually has to go through your os to comunicate with your device
19:17 <Boomerang> There are wrappers around C libraries that could help you (sfml, sdl) but I'm not sure you can easily generate the sound for these libraries
19:17 <Tuplanolla> We have bindings to SDL mixer, no?
19:18 <iqubic> Yes, but I don't think there are any simple ways to generate tones for something like, say Morse Code.
19:19 pent joined
19:20 <Boomerang> I played around with generating tones to be serialized into a WAV file in Haskell a while ago. It's not great but maybe it can help you: https://gist.github.com/basile-henry/ac86f8bb8829e156d2041084bc6c3613#file-notes-hs
19:20 <tsahyt> We do have bindings to several ways in which we can get audio to the speakers
19:20 <tsahyt> SDL included
19:20 lifter joined
19:20 <tsahyt> there are also several alsa packages that I haven't looked at, as well as jack bindings
19:20 <erisco> how can you get ghci to expand aliases?
19:20 <iqubic> That may help, not sure.
19:20 <tsahyt> at least with the jack bindings I know that they work
19:21 <Boomerang> Or you could use haskell to generate MIDI and connected it to whatever instrument using jack
19:22 <tsahyt> oh yeah that's also a possibility
19:22 wroathe joined
19:22 <tsahyt> shameless plug for my barebones midi lib
19:22 <iqubic> How does MIDI work?
19:23 cchalmers joined
19:23 <tsahyt> iqubic: basically you send messages like NoteOn C4 64, where C4 is middle C and 64 is a velocity
19:23 <tsahyt> and NoteOff etc. there are a bunch of different messages that you can send
19:23 <tsahyt> a synthesizer can then interpret this
19:24 <iqubic> And how do I do this in Haskell?
19:24 <Boomerang> If it's for a small 5 min project you could do like in the gist I shared: have haskell generate WAV samples on stdout and then pipe stdout to aplay
19:24 cchalmers joined
19:24 fotonzade joined
19:25 <tsahyt> iqubic: by using alsa or jack, and some suitable midi library for creating those messages
19:25 <iqubic> Boomerang: It's Morse Code. Preferable the input could be text, as long as I like. And then the program would start playing the correct morse code.
19:26 Noldorin joined
19:26 abhiroop joined
19:26 <iqubic> Also, whould this program be cross-compatible with Windows, or no?
19:26 aarvar joined
19:26 JuanMiguel joined
19:27 <Tuplanolla> @hackage sdl2-mixer
19:27 <lambdabot> http://hackage.haskell.org/package/sdl2-mixer
19:27 <tsahyt> as soon as you start interfacing with things like alsa or jack, it's not cross platform anymore. SDL abstracts that away though
19:27 <Tuplanolla> I'd try this one, iqubic.
19:27 path[l] joined
19:27 <Tuplanolla> It's not a big mess like most things audio.
19:27 <iqubic> So if I use SDL, then it will work on other OSes besides Linux?
19:28 raycoll joined
19:28 <iqubic> Alright, SDL2-Mixer looks dead simplt
19:28 <iqubic> *simple
19:28 <tsahyt> it should, that's the point of sdl
19:28 <joe9> is ghc rts a big deal to port to a new platform?
19:28 <EvanR> tsahyt: jack is "cross platform"...
19:28 <EvanR> port audio is also a thing
19:28 <tsahyt> EvanR: jack is also absolutely awesome imo, but I've heard it can be a bit of a pain on Windows
19:29 <EvanR> are we just trying to play sound
19:29 <EvanR> port audio man
19:29 <iqubic> What I want to do is create an executable that will play sound on both Linux and Windows.
19:30 abhiroop joined
19:31 <tsahyt> iqubic: sdl should be a fine choice. it frees you of all the platform specific details and is not that complicated to use
19:32 <iqubic> So SDL is this:
19:32 <iqubic> @hackage SDL2
19:32 <lambdabot> http://hackage.haskell.org/package/SDL2
19:32 <tsahyt> @hackage sdl2
19:32 <lambdabot> http://hackage.haskell.org/package/sdl2
19:32 wroathe joined
19:32 <tsahyt> case sensitive
19:32 <iqubic> @hackage sdl2
19:32 <lambdabot> http://hackage.haskell.org/package/sdl2
19:32 <iqubic> Isn't this simpler to use: http://hackage.haskell.org/package/sdl2-mixer?
19:33 <Tuplanolla> It's a plugin, iqubic.
19:33 <iqubic> What is?
19:33 <iqubic> sdl2-mixer?
19:33 <sm> yes, it's a standard addon extending sdl2
19:33 <sm> and yes it will be easier. I didn't notice a tone-playing function specifically
19:34 <iqubic> And still cross-compatible with Windows?
19:34 robotroll joined
19:34 <sm> in theory
19:35 <Boomerang> I've been looking at SFML bindings and it looks pretty easy to play a pitch with "createSound", "setPitch", "pause", and "play": https://hackage.haskell.org/package/SFML-
19:35 psychicist__ joined
19:35 <EvanR> sdl mixer is an add on library based on SDL which lets you play samples and mix them together. it also has a music-specific API
19:35 jeltsch joined
19:35 <Boomerang> And I'm pretty sure SFML works on both Linux and Windows
19:35 systemfault joined
19:36 <EvanR> to play tones you need to use SDL audio directly and feed raw samples using the audio callback
19:36 <iqubic> Is that hard to do?
19:36 fizruk joined
19:36 <EvanR> not really once you get the hang of it
19:37 <iqubic> Is there a guide somewhere for that kind of thing?
19:37 <EvanR> however doing that from haskell will involve using the FFI to write to output buffers
19:37 chaosmasttter joined
19:37 <EvanR> the SDL documentation exists
19:37 <iqubic> What's FFI?
19:37 <mauke> @where ffi
19:37 <lambdabot> http://www.haskell.org/onlinereport/haskell2010/haskellch8.html
19:37 <EvanR> foreign function interface, its how haskell talks to C
19:38 Cthalupa joined
19:38 <sm> does not sound simple
19:38 <EvanR> if you dont want to do all this from scratch there are plenty of sound synth libraries
19:39 <EvanR> https://wiki.haskell.org/Applications_and_libraries/Music_and_sound
19:39 <iqubic> Do any of them support playing tones?
19:39 <iqubic> Or is that something I'll have to write myself?
19:39 <EvanR> that is a basic function of a synth library
19:40 <iqubic> Cool.
19:40 lifter joined
19:40 <iqubic> Are any of those compatible with both Linux and Windows?
19:41 simukis_ joined
19:41 TheLemonMan joined
19:41 <EvanR> good question
19:42 chbatey joined
19:42 wroathe joined
19:42 simukis_ joined
19:42 <sm> and simple ? I am starting to think no
19:43 <iqubic> Why do you think these aren't simple?
19:43 <EvanR> i recall one library from conal that was a nice synth dsl
19:43 <EvanR> cant remember its name or find it at the moment....
19:43 RonnieHolm joined
19:44 <sm> iqubic: quick research, I haven't found anything that looks simple to install/understand/use
19:44 <EvanR> heres one that has an example of exactly what youre asking https://github.com/spell-music/csound-expression
19:44 RonnieHolm left
19:44 simukis_ joined
19:44 <EvanR> https://hackage.haskell.org/package/csound-expression
19:44 <EvanR> dac (osc 440)
19:45 <EvanR> csound works on linux and windows
19:45 <iqubic> EvanR, what would that function do?
19:45 <* sm> gives that a try
19:45 <EvanR> play a 440Hz tone
19:46 <iqubic> Can I set a duration for a tone?
19:46 <wroathe> So I've been trying to wrap my head around functors and applicative functors... Would it be incorrect or overly simplistic to say that an applicative functor is just a functor that contains a function? And when describing it do you need to specify that that functor can be applied to other functors?
19:46 Gurkenglas_ joined
19:46 <iqubic> Or is that an infinitely long tone.
19:46 <ggVGc> in ChucK this is literally SinOsc s => dac;
19:47 <ggVGc> I think that's easier than using portaudio or something through haskell
19:47 ragepanda joined
19:47 Mysterious_Ligh1 joined
19:47 <iqubic> Can I have a link to chuck? the only thing I was able to find was an http processing library.
19:47 <EvanR> iqubic: yes, csound contains functionality to create many kinds of sounds and orchestrate scores
19:47 <ggVGc> iqubic: http://chuck.cs.princeton.edu/doc/learn/tutorial.html
19:48 pera joined
19:48 <iqubic> ggVGc: What backend does chuck use?
19:48 <ggVGc> JACK I think
19:48 <ggVGc> not sure if there are other options
19:49 <iqubic> Also, ggVGc is ChucK avalible on Hackage?
19:49 <ggVGc> iqubic: it's not a haskell package. It's a runtime and language of it's own
19:49 simukis__ joined
19:49 <iqubic> What the heck???
19:49 cpup joined
19:49 <ggVGc> I'm saying I don't think haskell is good for your task
19:49 <ggVGc> sorry
19:49 <iqubic> Oh. I see.
19:49 <EvanR> csound-expression works, i tried it before
19:49 <iqubic> I'll use that then.
19:49 <EvanR> its a DSL in haskell on top of csound
19:49 <Philonous> wroathe, Every functor can contain functions. The special thing about applicatives is that you can combine two. So you can have e.g. combine :: f a -> f b -> f (a,b)
19:49 <EvanR> csound has its own array of backends
19:50 Mysterious_Light joined
19:50 <sm> SDL or SFML should be the natural "easy" way to do cross platform sound, it's a pity if they don't do simple non-sampled tones
19:51 <EvanR> because SDL mixer is really just a mixer. SDL doesnt even do that for you
19:51 <EvanR> same with SFML
19:51 <EvanR> for just sound i wouldnt use SDL
19:51 <Boomerang> sm what do you mean by non-sampled tone?
19:52 zero_byte joined
19:52 <EvanR> he means doing DSP to synthesize sound programmatically
19:52 <iqubic> So I have to use csound-expression if I want to get tones?
19:52 <wroathe> Philonous: Thanks. That helps.
19:52 <sm> Boomerang: iqubic wants to play simple tones, eg a middle C, without having to make/load a sample
19:52 <Boomerang> I have not tested it but the link I gave to SFML Sound library seens to be able to do just that (without loading any files beforehand).
19:53 <EvanR> iqubic: its a library that exists and does that, youll have to learn to use it to get more complex songs out of it
19:53 <iqubic> I'm not trying to get complex songs.
19:53 <Boomerang> But SMFL is a pain to install... :/
19:53 <EvanR> i never understood the point of SFML
19:53 <iqubic> Why is it a pain?
19:53 HugoDaniel joined
19:53 m1dnight_ joined
19:54 <EvanR> somebody wanted to make an SDL-alike in C++
19:54 <EvanR> when SDL exists already
19:54 marcopullo joined
19:54 <iqubic> What the heck???
19:54 <wroathe> Philonous: So for that to be true either a or b in f a and f b needs to be a function, right?
19:54 <EvanR> no
19:54 <Philonous> wroathe, No
19:54 <EvanR> a and b are any type
19:54 <Boomerang> Right, the only reason I brought up SFML is because it's a little bit more high level and can generate a pitch
19:55 <sm> I was able to install csound expression but it requires a separate C package (csound)
19:55 <EvanR> yes
19:55 <sm> which brew doesn't know about
19:55 fizbin joined
19:56 <EvanR> theres a tap apparently
19:56 fizruk joined
19:57 <sm> it knows a bit more about SFML, trying that one
19:57 <Philonous> wroathe, The Definition of Applicative looks like this (<*>) :: Applicative f => f (a -> b) -> f a -> f b. So maybe that's why you think it has something to do with functions in Functors. But it doesn't. The idea is really just "we can combine the elements of the left applicative value with the elements of the right value). You could have combine :: Applicative f => f a -> f b -> f (a,b) instead and it would be equivalent.
19:57 <EvanR> actually im brew installing csound now without problems
19:57 jgertm_ joined
19:57 <sm> EvanR: strange, it doesn't find csound in formulae or taps here
19:58 <Philonous> wroathe, That is to say, you can define (<*>) using only fmap and combine and you can define combine using only fmap and (<*>).
19:58 <EvanR> yep installing version 6.07.0
19:58 <* EvanR> wonders if 0 in 07 is significant
19:58 iomonad joined
19:59 <Boomerang> sm if you manage to install SFML and the bindings to it before me, this is what I'm trying to run on it http://lpaste.net/354462
20:00 Lord_of_Life joined
20:00 cpup joined
20:01 <wroathe> Philonous: I'm writing this down. Thanks for the help.
20:01 <wroathe> Philonous: And yes, that's exactly what I thought that way.
20:01 <EvanR> Boomerang: createSound creates what, a sine wave?
20:02 PennyNeko joined
20:02 <sm> SFML fails to build with csfml 2.4 it seems
20:02 <Philonous> wroathe, Obvious exercise: Try to define combine in terms of <*> and fmap and <*> in terms of fmap and combine ;)
20:03 takle joined
20:03 <Boomerang> sm: Ah so it's not just me. SFML is probably not the right option at the moment then.
20:03 <EvanR> you also need to implement pure with unit :: f () and fmap
20:03 <wroathe> Philonous: To me it seemed like the difference was (\x -> x + 4) <$> Just 3 vs. Just (\x -> x + 4) <*> Just 3
20:03 <sm> Boomerang: it's very close... probably a one-line PR
20:03 augur joined
20:03 <sm> iqubic: not giving up yet, but I think you have identified an area for improvement in haskell
20:04 des_ joined
20:04 <EvanR> > Just (+4) <*> Just 3
20:04 <Boomerang> EvanR: I think createSound creates a sound with the default settings (whatever these are). So yes probably sin wave
20:04 <lambdabot> Just 7
20:04 <wroathe> EvanR: good call :P
20:04 <Philonous> wroathe, Maybe has a pretty boring Applicative instance. Try lists with at least 2 elements instead.
20:04 <Philonous> > [(+2), (*3)] <*> [1,5]
20:04 <lambdabot> [3,7,3,15]
20:05 fnurglewitz joined
20:05 <Philonous> > let combine = liftA2 (,) in combine [2,3] ['a', 'b']
20:05 <lambdabot> [(2,'a'),(2,'b'),(3,'a'),(3,'b')]
20:06 Welkin joined
20:06 <iqubic> Wait, making a tuple is an applicative function?
20:06 ragepanda joined
20:06 Welkin left
20:06 <iqubic> @src liftA@
20:06 <lambdabot> Source not found. Take a stress pill and think things over.
20:06 <iqubic> @src liftA2
20:06 <lambdabot> liftA2 f a b = f <$> a <*> b
20:06 <iqubic> Right, that looks good.
20:07 <EvanR> (,) is just another function
20:07 raycoll joined
20:07 <Philonous> The tuple constructor is a binary function, so you can apply it via fmap and <*>, yes
20:09 <sm> https://github.com/SFML-haskell/SFML/issues/23
20:09 bl4z3r21 joined
20:11 <Boomerang> +1 sm :)
20:11 monochrom joined
20:12 Bob8989|2 joined
20:12 Bob89893 joined
20:14 <sm> EvanR: I discovered brew tap csound/csound, but it fails to build here
20:15 <EvanR> whats the error?
20:15 <sm> oh maybe needs --HEAD
20:15 <iqubic> Makes sense
20:16 fizbin joined
20:16 takle joined
20:16 <iqubic> So, csound-expression requires a C Library? Which one?
20:17 <sm> csound
20:18 <* sm> feels using csound to play a tone is like using a battleship to cross a pond
20:18 <Fusionnex> this is great
20:18 <iqubic> Is there an easier way to play a tone?
20:18 <EvanR> yeah but iqubics requirements are pretty tough
20:18 <Fusionnex> i love how this all started with. can i play c for 15 seconds in haskell
20:18 <monochrom> But are you OK with using a battleship to ship cargo? :)
20:19 <EvanR> theres are 100 ways to do it and they dont like any of them
20:19 <iqubic> EvanR: What do you mean?
20:19 <iqubic> What are the ways that I can play a sound in Haskell?
20:19 <EvanR> this task is so simple
20:19 Mysterious_Light joined
20:19 <EvanR> install a sound library, write the code to output your desired sound
20:20 oisdk joined
20:20 <iqubic> what sound library should I use?
20:20 <sm> success: brew tap csound/csound; brew install csound --HEAD; stack install csound-expression csound-expression-dynamic csound-expression-opcodes csound-expression-typed temporal-media data-fix data-fix-cse; stack ghci, import Csound.Base, dac $ osc 440
20:20 augur joined
20:20 <iqubic> I'm fine with just about anything.
20:20 <EvanR> there you go
20:20 amartea joined
20:20 <EvanR> install csound, its its own rabbit hole
20:20 <EvanR> then install csound-expression
20:21 <iqubic> I'll do that.
20:21 <Fusionnex> is your sound function mathematically a pure c note though ?
20:21 <sm> where "success" means "attainable by a skilled developer in half an hour"
20:21 <sm> :)
20:22 <EvanR> in what tuning system?
20:22 <iqubic> Fusionnex, does that really matter. I'm not using this to play a whole range of sounds.
20:22 <iqubic> I'll just pick a tone I loike, and go with that.
20:22 strykerkkd joined
20:23 Guest81707 joined
20:23 <iqubic> *like.
20:23 akh joined
20:23 <Fusionnex> :-P i was just thinking of whether or not it was possible to express mathematically pure sounds
20:23 <Fusionnex> but i don't know enough about music theory to understand if that even makes sense
20:23 <* sm> . o O omg what is this piano keyboard thing
20:23 <iqubic> sm, what are you doing?
20:23 <Fusionnex> ratios all the way down
20:23 <cocreature> Fusionnex: well just a sine wave of a specific frequency
20:24 <EvanR> its not even ratios in the standard system
20:24 <EvanR> its irratios
20:24 <sm> running through the tutorial at https://github.com/spell-music/csound-expression/blob/master/tutorial/chapters/SynthTutorial.md, I just did "run osc" and did not expect a GUI to pop up :)
20:24 <Fusionnex> irratios all the way down ?
20:24 <EvanR> 12th root of two
20:24 shainer left
20:24 splanch joined
20:24 <EvanR> sm: o_O
20:24 <* sm> trying to play a tone of finite length
20:24 <iqubic> sm, that link gives me a 404 error.
20:24 <sm> remove the comma
20:24 <iqubic> I NEED that.
20:25 <iqubic> I NEED a way to play a sound of a certain length X.
20:26 <EvanR> forkIO (threadDelay X*1000000 >> exitSuccess)
20:26 <sm> ugh!
20:26 <iqubic> So is there no clean way to get a finite length?
20:27 <EvanR> there is, but i dont know csound
20:27 <iqubic> Oh.
20:27 <EvanR> so i cant tell you
20:27 <iqubic> I'll see if I can find something.
20:27 <iqubic> Why are you creating a new thread?
20:27 <sm> lol this thing is hours of fun
20:27 <sm> dac $ mul (usaw 4) white
20:27 <iqubic> What is? csound epression?
20:28 raycoll joined
20:28 Mysterious_Light joined
20:28 <sm> yup
20:28 <iqubic> What does that do?
20:28 <iqubic> The usaw 4 thing?
20:29 <EvanR> the docs man!
20:29 <EvanR> the docs!
20:29 <iqubic> I'll look at the docs.
20:29 <Fusionnex> sm: this tutorial looks like fun
20:29 <sm> sorry I meant that for GHCI window. Get it installed, then you'll hear it
20:29 <EvanR> https://hackage.haskell.org/package/csound-expression-5.2.0/docs/Csound-Air-Wave.html
20:29 <sm> it sure is!
20:30 zeroed joined
20:30 zeroed joined
20:31 oisdk_ joined
20:31 <Fusionnex> building csound !
20:31 <sm> lambdabot needs to learn to play csound snippets
20:31 <iqubic> But that wouldn't work.
20:33 filterfish joined
20:33 <sm> why wouldn't it ? simple matter of programming
20:34 <Boomerang> Wouldn't you need compatible IRC clients to play the sounds?
20:34 <iqubic> You would.
20:34 <iqubic> That was my point.
20:35 <EvanR> what in the world
20:35 caumeslasal joined
20:35 <iqubic> What???
20:35 <* sm> imagines IRC with per-channel ambient sounds
20:35 <EvanR> lol
20:35 <EvanR> yes and they are all playing at once as you idle in 30 channels
20:36 <Boomerang> What might be doable is for lambdabot to generate a sound file, post it on clyp.it and the send the link here
20:37 dan_f joined
20:39 bennofs joined
20:39 cpup joined
20:41 pera joined
20:43 <Fusionnex> csound-expression and csound installed, time to play
20:44 Swizec joined
20:46 <sm> https://github.com/spell-music/csound-expression/blob/master/tutorial/chapters/appendix/CsoundInstro.markdown#example-a-concert-a-with-scores seems about what's required to play a note
20:48 HugoDaniel joined
20:48 <Fusionnex> sm: omg that gui popup
20:48 <Fusionnex> sm: scared the shit outa me
20:49 Itkovian joined
20:49 <sm> GUIs! scary!
20:49 <Boomerang> Fusionnex: you can play with your keyboard too :D
20:50 revprez_atlanta joined
20:50 <Fusionnex> Boomerang: wut
20:51 <Boomerang> As in, instead of clicking on the keys in the GUI you can play on the keys of your keyboard. But maybe you're not talking about the same csound GUI?
20:51 <Fusionnex> oh god this is amazing
20:51 <Fusionnex> im following this tutorial that was posted by sm https://github.com/spell-music/csound-expression/blob/master/tutorial/chapters/SynthTutorial.md
20:52 <EvanR> sm: hahaha
20:52 zcourts joined
20:52 <EvanR> csound is the shit
20:53 <Fusionnex> if only there wasn't so much distortion :(
20:54 <Fusionnex> fml
20:54 <EvanR> hmm you might need to adjust some settings
20:54 <Fusionnex> make it stop
20:54 dan_f joined
20:54 <Fusionnex> dac $ mul (usqr 4) white
20:54 electrostat joined
20:55 AntiSpamMeta joined
20:55 <EvanR> now that we have ultimate synthesis of audio squared away, any ideas for programmatically generating vector graphics from haskell?
20:55 <Fusionnex> i get a bit of hissing and poping but i wonder if it is just my sound card misbehaving
20:55 <EvanR> diagrams? cairo?
20:56 <Fusionnex> u want to replace adobe illustrator w/ haskell?
20:56 <bennofs> EvanR: diagrams is pretty cool
20:56 <EvanR> hmm
20:57 <sm> lots of options there.. graphics seems easier than sound
20:58 <sm> Fusionnex: what kind of machine is that ?
20:58 <Fusionnex> custom built
20:59 <Fusionnex> sm: it has a soundblaster x-fi card in it, but it gives me some issues sometimes
20:59 cpup joined
20:59 <Fusionnex> ocassionally i straight have to kill pulseaudio for anything to work
21:00 <iqubic> Why???
21:00 <Fusionnex> iqubic: ?
21:01 <iqubic> Why do you have to kill pulse to get the sound to work.
21:01 <iqubic> ??
21:01 Guest81707 joined
21:01 <Fusionnex> honestly not sure. i am using arch linux with the vlc backend, after updating at some point my sound get's all distored, but a simple restart of pulseaudio fixes it
21:02 sigmundv joined
21:02 <Fusionnex> iqubic: it used to happen every boot, now it only happens occasionally. somebody is playing with something, im just assuming updates later will fix it
21:03 AntiSpamMeta joined
21:03 chbatey joined
21:04 AntiSpamMeta joined
21:05 bkboggy joined
21:07 <iqubic> So I'm having some issues with CSound-Expression.
21:07 soLucien joined
21:08 <lpaste> iqubic pasted “CSound-Expression errors” at http://lpaste.net/354464
21:08 <iqubic> Anyone know what's going on there?
21:09 <Fusionnex> not sure
21:09 <sm> not me.. which OS ?
21:09 <Fusionnex> mine worked fine
21:09 <iqubic> I'm using Gentoo Linux
21:10 <sm> maybe there's some more csound packages to install
21:11 <maerwald> nah, there's only one
21:11 <Fusionnex> i know i had to install gmm as a dependency
21:11 <maerwald> could rather be misconfiguration of USE flags, who knows
21:11 <Fusionnex> :-/
21:11 <Fusionnex> gentoo is so very hardcore
21:11 <sm> http://comments.gmane.org/gmane.comp.audio.csound.user/30349
21:11 <maerwald> gentoo often allows broken configuration
21:11 <Fusionnex> i don't want to take that leap just yet
21:12 <maerwald> Fusionnex: it really isn't
21:12 <iqubic> Gentoo's package manager pulls in all the depedencies when needed.
21:12 <iqubic> Fusionnex: What OS do you use?
21:12 <maerwald> iqubic: no, that depends on the correctness of ebuild definitions
21:12 <Fusionnex> arch currently
21:12 <iqubic> Ah.
21:12 <maerwald> which are more often incorrect than correct
21:12 <iqubic> so maerwald what should I do?
21:13 <Fusionnex> iqubic: i liked not having to compile everything, but i like rolling release
21:13 <maerwald> iqubic: I'd just enable all USE flags for the package and try again
21:13 <iqubic> maerwald: I'll do that.
21:13 <sm> yes ignore my link, install csound in such a way that it includes "virtual"
21:13 Lord_of_Life joined
21:14 <iqubic> I will do that.
21:15 significance joined
21:15 <maerwald> virtual keyboard?
21:16 <maerwald> that would be the "keyboard" USE flag https://github.com/gentoo/gentoo/blob/master/media-sound/csound/csound-9999.ebuild#L143
21:16 <maerwald> although I don't know how this is still haskell related
21:16 <iqubic> Why do I need the virtual keyboard?
21:16 <geekosaur> I think it's a midi emulation over a soundcard
21:16 <iqubic> Ah. I see.
21:18 <sm> this is not going to work for shipping christmas carols to my mom is it
21:18 <* maerwald> sees a mom joke incoming from a mile away
21:19 ziocroc joined
21:19 orbifx joined
21:19 <iqubic> Nope.
21:19 <sm> only because, my mom isn't going to be getting the csound flags right. No implication about other moms intended.
21:19 <maerwald> xD
21:20 <iqubic> Can't you send here an executable?
21:20 <iqubic> *her
21:20 <sm> iqubic: maybe! that is true
21:20 <iqubic> Because csound should work on all machines.
21:20 Ferdirand joined
21:20 <Fusionnex> iqubic: even embedded ones
21:20 <maerwald> package it in a docker container, which runs nix, which runs stack which runs cabal, which runs...err... haskell
21:22 <sm> yeah. It's going to be a lot of work
21:22 <iqubic> Wait, so making a Haskell executable is hard work?
21:22 ericdwhite joined
21:23 <iqubic> I mean so I have something that runs on Windows.
21:23 <monochrom> There was a time people sent Windows exes to each other by email. And the exes were merely Christmas cards.
21:23 <sm> not in general, iqubic
21:23 Edith joined
21:24 <maerwald> haskell is not cross-platform by default =)
21:24 <monochrom> If your program is just "hello world" it's pretty easy. In fact no deployment issue for the receiver either. No extra DLLs to ship, Haskell code is statically linked.
21:24 <sm> though, is that windows executable going to have csound libs embedded ?
21:25 <iqubic> Could I do that?
21:25 <maerwald> you'll have to go for java bro
21:25 <iqubic> Or would that be a pain in the butt.
21:25 <iqubic> Why is Java better?
21:25 mtesseract joined
21:25 <monochrom> But yeah if you will involve csound then csound is the dominator of how hard it gets.
21:25 <sm> if you're shipping to windows users and want it to just work, using any C libraries is basically a no no
21:25 <iqubic> How does one package CSound into a .exe?
21:26 <iqubic> Is there a way to do that?
21:26 <maerwald> docker container :P
21:26 <Fusionnex> docker ie. lets just ship linux with everything
21:26 <maerwald> everything else probably involves more pain
21:26 <monochrom> Java is not going to make the csound story any better.
21:27 <sm> an embedded web app that plays sounds is probably easier
21:27 <EvanR> classic zip files with exe and dlls in it
21:27 <maerwald> yes, let's go full web. Start learning yesod.
21:27 <maerwald> should be piece of cake
21:27 <sm> hmm.. docker, nix.. yesod..
21:28 <maerwald> only the simple stuff...
21:28 <EvanR> sm: unfortunately, theres no audio API like the ones weve been discussing, you cant use DSP to generate sound
21:28 <hpc> the container needs a web browser too
21:28 <EvanR> you can only play samples
21:28 <hpc> or several, so you can pick your favorite
21:28 <EvanR> or control individual oscillators
21:28 <hpc> :D
21:28 GsC_RuL3Z joined
21:28 <sm> EvanR: do you mean, in web land, too ?
21:28 <iqubic> Is yesod simple? or not?
21:28 <EvanR> in browsers
21:28 <maerwald> iqubic: no
21:28 <sm> arghhhh
21:29 <iqubic> sm, what is so agrivating?
21:29 <maerwald> we've just derailed somehow
21:29 <iqubic> From what?
21:29 <maerwald> I don't remember
21:29 <iqubic> to where.
21:29 <sm> iqubic: your stupid problem :)
21:29 <iqubic> sm, I have decided that my issue is as solved as it can be for now.
21:30 <EvanR> btw my program has been playing a tone since yesterday
21:30 <sm> just kidding, it's a great problem. How to play musical notes in haskell, simply
21:30 <EvanR> x seconds at a time
21:30 <EvanR> but its not in haskell
21:30 <iqubic> EvanR: What program are you refering to?
21:31 <EvanR> my program right here, ive been playing with tones for a couple days
21:31 <reactormonk[m]> I want to keep an updated map of the current network topology via pings - how would you achieve that with haskell? I considered nmap and parsing output, other ideas?
21:31 Deide joined
21:32 djapo_ joined
21:33 <monochrom> There is Haskore for music, isn't there?
21:33 <iqubic> I think so. But that's not really what I want.
21:34 e14 joined
21:35 Lord_of_Life joined
21:37 <sm> iqubic: not to keep beating on it, I'm just interested - I think the most pragmatic solution will involve either SFML or SDL
21:37 <EvanR> port audio
21:37 <sm> SFML requires a fix in the haskell lib. SDL requires that you include or generate some tone samples
21:38 <iqubic> I'm fine with what I have so far.
21:38 <sm> great
21:38 <sm> I'm planning ahead for my Simon game
21:38 zero_byte joined
21:39 <Boomerang> I just found this: http://charlieharvey.org.uk/page/audio_haskell_morse_code Which is exactly what I described with WAVE and aplay. Problably doesn't work on windows though
21:39 ragepanda joined
21:40 <sm> nice
21:43 <iqubic> Is that better than using CSound-Expression?
21:43 kirillow joined
21:44 <sm> iqubic: your call, depends on your need
21:44 plutoniix joined
21:44 <Boomerang> CSound is a lot more flexible but this post gives a much lighter solution (the only real dependency is aplay which is on most linux systems)
21:44 <iqubic> I'd like to try CSound.
21:44 louispan joined
21:46 ed1 joined
21:47 redwater left
21:49 aarvar joined
21:49 revprez_atlanta joined
21:52 eacameron joined
21:52 hiratara joined
21:53 bhiliyam joined
21:54 <iqubic> Goodbye guys. I have enough knowledge to do what I want with Haskell.
21:54 <iqubic> I'll be back later.
21:56 hrehf joined
21:57 Volt_ joined
21:59 louispan joined
22:07 des_ joined
22:10 Jesin joined
22:10 plutoniix joined
22:10 HoierM joined
22:12 <joneshf-laptop> How does `System.Info` work?
22:12 <joneshf-laptop> Is it just 100% magic?
22:12 eacameron joined
22:12 <joneshf-laptop> aside from https://hackage.haskell.org/package/base-
22:13 <joneshf-laptop> oh, maybe this: #include "ghcplatform.h"
22:13 <monochrom> Right, 100% compile-time hardcoding.
22:14 <joneshf-laptop> wait, compile-time?
22:14 <monochrom> Yes!
22:14 kay joined
22:14 <monochrom> Also, I mean GHC's own compile time, not your program's compile time.
22:15 <joneshf-laptop> I'm lost :)
22:15 <joneshf-laptop> If I put `System.Info.os` in a library, will the value be accurate for where the library is used?
22:15 <joneshf-laptop> Like if i develop on linux, will it say `"linux"` all the time?
22:15 justkhay left
22:15 <monochrom> Actually yes.
22:16 <monochrom> The exe you produce won't work on Windows, so the value is always right. Vacuously.
22:16 <monochrom> Or tautologically, I don't know which.
22:16 <joneshf-laptop> for the exe, sure
22:16 <monochrom> Similarly, the binary of your library
22:16 <joneshf-laptop> what about for a library?
22:17 <monochrom> If you wrote a library, and build its binary on linux, it still won't work on Windows, so no Windows user will observe a contradiction.
22:17 <joneshf-laptop> Correct
22:18 <joneshf-laptop> But if I develop a library on linux, and upload to hackage, what happens?
22:18 <joneshf-laptop> Will a windows user see "linux"?
22:18 <Tuplanolla> People compile it themselves.
22:18 <monochrom> A Windows user will have to take your source and compile it (or have someone else do the same). And then they will see the correct value "windows" because they are using a Windowized GHC.
22:18 <joneshf-laptop> Dope!
22:18 <joneshf-laptop> Thanks!
22:18 <monochrom> You can only upload source, you know that?
22:19 <monochrom> Or rather, yeah, the receivers will only honour the source code.
22:19 <joneshf-laptop> Yeah, but I don't know how magic works :)
22:20 <monochrom> It is no magic. (Unless the "magic number" kind where you just hardcode the answer.)
22:20 <Tuplanolla> It's called "magic" simply because "disgusting trickery" was too long.
22:21 <monochrom> It is just elimination of any falsfying experiment.
22:21 splanch joined
22:22 eacameron joined
22:23 <joneshf-laptop> monochrom, Tuplanolla in anycase, thanks very much for the explanation!
22:23 orbifx joined
22:24 <monochrom> In fact this scheme is already leaking a little bit of inconsistency on 64-bit Windows.
22:24 <monochrom> On 64-bit Windows you have the choice of 32-bit GHC and 64-bit GHC.
22:25 <monochrom> If you use 32-bit GHC to build an exe, then its arch will say "I see 32-bit" even though you are on 64-bit Windows.
22:25 Ferdirand joined
22:26 megaTherion joined
22:27 <monochrom> IIRC the exact strings are "i386" for 32-bit and "x86-64" for 64-bit.
22:28 louispan joined
22:28 tristanp joined
22:28 <monochrom> Probably magic in the sense of David Copperfield.
22:29 lifter joined
22:29 splanch joined
22:29 pandeiro joined
22:30 jmcarthur joined
22:31 Koterpillar joined
22:31 hiratara joined
22:31 freeside joined
22:36 dhruvio joined
22:36 LuckyRawApe joined
22:38 dhruvio joined
22:40 dhruvio joined
22:41 zymurgy joined
22:47 ludat joined
22:48 soLucien joined
22:48 anuxivm joined
22:49 bjz joined
22:51 lifter joined
22:52 splanch joined
22:54 bhiliyam joined
22:54 dan_f joined
22:56 ed3 joined
22:57 Ferdirand joined
22:58 martin3 joined
22:59 <martin3> hi. what is the prefered way of installing ghc under ubuntu? anything other than apt install ghc?
22:59 boxscape joined
22:59 oisdk joined
23:00 <Koterpillar> martin3: that's good enough. You might also want to look at Stack (haskellstack.org).
23:00 zcourts joined
23:01 hybrid joined
23:01 blocus joined
23:01 <martin3> is that prefered over cabal sandboxes these days?
23:01 wroathe joined
23:02 acarrico joined
23:02 <Koterpillar> over sandboxes, I'd say yes. There's cabal new-build which is also better than sandboxes, whether stack is better than that or not is debatable.
23:02 <Koterpillar> Stack can install and manage GHC for you though.
23:03 Jesin joined
23:03 Shatnerz0 joined
23:03 <martin3> manage it how?
23:05 <Koterpillar> in short, stack.yaml defines the precise version you'll get (7.10.3, 8.0.2, etc.), so you can be sure what you build with is what the author had
23:06 <martin3> interesting
23:06 <martin3> can it handle multiple ghc versions?
23:06 <boxscape> > (\4 | True -> 2) 4 -- can you not use guards in lambdas?
23:06 <Koterpillar> yes
23:06 <lambdabot> <hint>:1:5: error: parse error on input ‘|’
23:07 <martin3> nice
23:07 <Koterpillar> boxscape: do you want LambdaCase?
23:07 javjarfer joined
23:07 <centril> <3 LambdaCase
23:07 <boxscape> Koterpillar: no.. I'm just testing out random syntax things that come to my head :)
23:07 <centril> I'm having some trouble writing a function:
23:07 <centril> :: Traversal' s a -> [i] -> IndexedTraversal' i s a
23:08 pera joined
23:08 <centril> :t \t is -> partsOf t . to (zip is) . traverse . itraversed
23:08 <lambdabot> (Applicative f, Indexable i p, Contravariant f) => Traversing (->) f s t a a -> [i] -> p a (f a) -> s -> f t
23:08 <boxscape> > (\case 4 | True -> 2) 4 -- would be the same, I suppose, and admittedly, it's just one word longer
23:08 <lambdabot> 2
23:09 <centril> :t (\t is -> partsOf t . to (zip is) . traverse . itraversed) :: Traversal' s a -> [i] -> IndexedFold i s a
23:09 <lambdabot> (Applicative f, Contravariant f, Indexable i p) => Traversal' s a -> [i] -> p a (f a) -> s -> f s
23:09 <centril> I need to get rid of the constraint Contravariant f to make it an IndexedTraversal'
23:10 <centril> I can do a slower version atm:
23:10 <centril> :t (\t ds -> reindexed (ds !!) $ indexing t) :: Traversal' s a -> [i] -> IndexedTraversal' i s a
23:10 <lambdabot> (Applicative f, Indexable i p) => Traversal' s a -> [i] -> p a (f a) -> s -> f s
23:10 <centril> but that one has a quadratic complexity instead
23:11 <centril> anyone got any ideas ?
23:14 <martin3> Koterpillar so if I want to try sandboxes I guess I shouldn't install ghc manually, but let sandbox install it for me?
23:14 <martin3> s/sandboxes/stack
23:14 gmhafiz joined
23:14 <centril> martin3: just use stack, people should move away from cabal
23:14 <Koterpillar> martin3: Stack will not interfere with your system GHC
23:14 nakal joined
23:15 <Koterpillar> martin3: you _can_ tell it you have one, and it will reuse it if it's the right version
23:15 <centril> and if system GHC == stack project GHC, then the system GHC will be used
23:15 <martin3> ah
23:15 markus1189 joined
23:15 {emptyset} joined
23:15 <martin3> I'll definately give stack a go. sounds like it came a long way
23:15 markus1199 joined
23:16 <centril> Koterpillar: any ideas about my issue ? im kinda stuck :/
23:17 silver_ joined
23:17 <Koterpillar> centril: no, sorry
23:18 <centril> :/
23:18 ddere joined
23:18 gawen joined
23:18 theDon_ joined
23:20 <boxscape> > (\case x | x <- x -> x) x -- I like this
23:20 <lambdabot> x
23:25 <Gurkenglas_> centril, I assume that the obvious n*log n version from replacing [i] with a logarithmic-access data structure isn't enough?
23:25 gawen joined
23:25 raycoll joined
23:25 <lpaste> glguy pasted “adding indexes for centril” at http://lpaste.net/354467
23:25 lifter joined
23:26 louispan joined
23:26 splanch joined
23:27 <Gurkenglas_> glguy, whatcha think of "iso state evalState"?
23:27 e14 joined
23:27 <centril> Gurkenglas_: so what I have is a rose tree as the source of indices (decorations), corresponding 1:1 to an AST
23:27 mrowe joined
23:27 carlomagno joined
23:27 <centril> and then I want to do an indexed transformMOnOf
23:28 <glguy> Gurkenglas_: I think it's an invalid iso
23:29 Ferdirand joined
23:30 splanch_ joined
23:30 <glguy> but I get that in this case it saves the outside fst$
23:30 <boxscape> lambdabot doesn't have MultiWayIf :(
23:31 <monochrom> @query lambdabot
23:31 <lambdabot> Unknown command, try @list
23:31 <monochrom> oops hehe
23:31 acarrico joined
23:32 splanch joined
23:32 stef204 joined
23:34 <centril> glguy: oh man, thanks so much <3
23:35 splanch_ joined
23:36 zcourts joined
23:36 <centril> glguy: time to break it into pieces until i understand how it works ^^
23:38 obihann joined
23:39 wroathe joined
23:41 <michalrus> Hey, how can I do execv(3) syscall as in <unistd.h>? I.e. substitute the current Haskell process image with another one. I can’t find that in System.Process. :o
23:41 lambda-11235 joined
23:42 <centril> michalrus: how does that play with GC ?
23:43 <michalrus> Hmmm, I don’t know if that (and anything really) matters at all with exec(). (:
23:44 <centril> right, each process has its own GC heap, so it shouldnt be a problem
23:44 <geekosaur> michalrus, System.Posix.Process.execProcess
23:45 <michalrus> Wheee! Thank you, geekosaur!
23:45 <centril> haha, 1 sec too late
23:45 <centril> michalrus: obviously, it won't work on Windows, which is why you didnt find it in System.Process
23:45 <geekosaur> sorry, executeFile
23:45 <geekosaur> pheh
23:45 <geekosaur> and yes. System.Process is the portable stuff only. so no form or exec
23:46 erisco_ joined
23:46 <geekosaur> *fork
23:46 <centril> which is a bit sad
23:46 <centril> or more like: a lot sad
23:46 <michalrus> Ahh. Hmm, it’s a NixOS util, so whatevs.
23:46 <geekosaur> (fork() is problematic, btw, but not with gc)
23:46 <centril> geekosaur: do tell ?
23:46 <michalrus> +1!
23:47 <geekosaur> the docuimented one is "forkProcess comes with a giant warning: since any other running threads are not copied into the child process, it's easy to go wrong: e.g. by accessing some shared resource that was held by another thread in the parent."
23:47 erisco_ joined
23:47 wr3n[m] joined
23:47 <geekosaur> there's also some issues with the I/O manager becoming confused because of mutexes which might not be held any more, due to those other threads going away
23:47 <geekosaur> iirc
23:48 <centril> geekosaur: iirc haskell has a shared GC heap, so problems...
23:48 <geekosaur> (every Handle has a mutex, for example)
23:48 <centril> erlang has a GC heap per thread, so no problems
23:48 <EvanR> yeah erlang sends copies of data through the pipes
23:48 <EvanR> simplifies a lot
23:48 <Sornaensis> haskell should absorb erlang semantics
23:48 <centril> at least this is what we were told @ the Parallel Functional Programming course at Chalmers
23:48 <EvanR> but haskell is concerned with performance
23:49 <geekosaur> afaik it just reaps the no-longer-extant thread data including heap allocations on the next gc.
23:49 <centril> EvanR: what is "performance"? latency, or throughput ?
23:49 <EvanR> communication overhead between threads is very low in ghc
23:49 <geekosaur> forkProcess does know that the other threads went away, and frees the thread data structures appropriately
23:49 <centril> erlang is latency centric
23:50 <EvanR> low latency, high throughput
23:50 YongJoon joined
23:50 <geekosaur> but user code has to know that as well
23:50 <EvanR> so van full of mag tapes strapped to a spaceshuttle
23:50 <centril> EvanR: tho, i did find it really hard to get good speedups in haskell for an embarasingly parallel function such as map
23:51 <EvanR> map is not embarassingly parallel
23:51 <EvanR> specifically because its processes linked lists
23:51 louispan joined
23:51 <EvanR> lists are a middle finger to parallelism
23:51 <centril> EvanR: oh, so the cons:ing is the culprit ?
23:52 <centril> so an Array or Vector instead would give me good speedups ?
23:52 <EvanR> if you use a parallel map operation
23:52 <centril> I should try this sometime later
23:52 <geekosaur> given ghc's tendency toward glaswegian, shouldn't that be two-fingers? :p
23:53 <centril> geekosaur: glaswegian? is that a word?
23:53 <geekosaur> yep
23:53 <geekosaur> blame scots gaelic
23:54 <centril> geekosaur: oh well, Chalmers is overtaking everything FP anyways, so :P
23:54 <centril> I guess we only need to steal Simon Peyton Jones now and we're complete - maybe Simon Marlow too
23:55 bhiliyam joined
23:55 louispan joined
23:55 zv joined
23:56 oisdk joined
23:57 _significance joined
23:58 splanch joined