<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30 31
00:02 mengu joined
00:03 m1dnight_ joined
00:03 m1dnight1 joined
00:03 Elsi joined
00:08 louispan joined
00:10 tom7942 joined
00:11 yellowj joined
00:16 louispan joined
00:24 ebw joined
00:28 uglyfigurine joined
00:30 abhiroop joined
00:40 acarrico joined
00:43 newhoggy joined
00:47 newhoggy_ joined
00:48 Atrumx joined
00:51 <saylu> Hey folks -- I'm testing some code with Hspec and to avoid tediously writing out hundreds of tests (actually...I already did and am now refactoring) I've decided to provide a list of inputs and a list of expected outputs and use `zipWith` with `shouldBe` to produce a list of expectations that should hold.
00:51 <saylu> Instead of .. func x `shouldBe` 10 .. I now have .. zipWith shouldBe [func x, func y] [10, 11]
00:52 <saylu> which produces a list of expectations, or variable :: [Expectation]
00:52 <saylu> What I don't know is how to actually evaluate this!
00:57 takle joined
01:00 ridho joined
01:00 <benzrf> saylu: well, how were you combining them before?
01:01 <saylu> I wasn't. I just had a list of `shouldBe` within an 'it' block
01:01 <saylu> ie.
01:01 <saylu> it "should do something" $ do
01:01 <saylu> f x `shouldBe` 10
01:01 <saylu> f y `shouldBe` 11
01:01 <saylu> now, i've got
01:01 <saylu> it "should do something" $ do
01:02 <saylu> zipWith shouldBe [f x, f y] [10, 11]
01:02 <geekosaur> :t sequence_
01:02 <lambdabot> (Monad m, Foldable t) => t (m a) -> m ()
01:04 <saylu> ugh the amount of times I've forgotten sequence...
01:05 <saylu> just found zipWithM_ in Control.Monad, which does the same as sequence_ . zipWith
01:05 vaibhavsagar_ joined
01:06 <benzrf> saylu: the key thing to remember: you *are* combining them - the do block combines them with (>>)
01:06 <benzrf> remember, that's what a do block does
01:06 <saylu> of course. f x `shouldBe` 10 >>= \_ -> f y `shouldBe` .....
01:07 ridho joined
01:07 <benzrf> so what you want is then something like "foldr1 (>>)"
01:08 <benzrf> which is precisely what sequence_ does (except not foldr1, but foldr, so it doesnt blow up on empty lsits)
01:11 abhiroop joined
01:12 carlomagno joined
01:14 takle joined
01:22 uglyfigurine joined
01:22 aarvar joined
01:23 takle joined
01:30 louispan joined
01:30 dni- joined
01:31 takle joined
01:32 malaclyps joined
01:33 reverse_light joined
01:46 takle joined
01:52 carlomagno joined
01:54 abhiroop joined
01:58 rstefanic joined
02:03 mengu joined
02:06 takle joined
02:07 abhiroop joined
02:13 uglyfigurine joined
02:13 takle joined
02:13 pixelfog_ joined
02:22 kritzcreek joined
02:26 louispan joined
02:30 birdgg joined
02:32 malaclyps joined
02:32 takle joined
02:40 <Squarism> Im using a monad transformer! I think im gathering some intuition on how to use them. What would be a next step after beeing down with this chapter? On the path to apprentice haskeller i mean?
02:40 exferenceBot joined
02:42 abhiroop joined
02:44 hexagoxel joined
02:45 louispan joined
02:45 ysgard joined
02:58 systemfault joined
02:59 systemfault joined
02:59 abhiroop joined
03:02 cschneid_ joined
03:04 mengu joined
03:06 mac10688 joined
03:06 bengt_ joined
03:09 systemfault joined
03:13 takle joined
03:19 dni- joined
03:21 takle joined
03:30 abhiroop joined
03:31 michbad joined
03:34 takle joined
03:34 louispan joined
03:40 myrkraverk joined
04:00 <dmj`> Squarism: work on projects probably.
04:04 <Squarism> dmj`, Thats what ive done to learn. I thought if there were functional concepts one should have atleast tried or special problems catering to haskell so to speak. Been hearing about Arrows? GADT's? Comonads/Cofree/xyz
04:04 takle joined
04:05 <glguy> You don't need Arrows, GADTs, Comonads, or Cofree to start working on a project
04:05 <glguy> You won't even need them to finish working on a project
04:07 <Squarism> i know that. But i already have project running. And i find myself solving imperative stuff with just functions + some monad trickery. So i wanted to expand my view in FP land so to speak.
04:10 <dmj`> Squarism: probably useful to learn those things so you can see where / if it fits into your project
04:12 takle joined
04:13 louispan joined
04:15 abhiroop joined
04:16 <Squarism> are there any texts on FP concepts ranked from crucial to merely interesting?
04:19 <dmj`> Squarism: there is this SO post, http://stackoverflow.com/a/1016986/453261
04:23 chlong joined
04:23 takle joined
04:24 <Squarism> dmj`, thanks - perfect
04:26 <dmj`> Squarism: When you say ‘imperative stuff’, to what are you referring? Others might offer insight into more functional approaches if you ask
04:31 takle joined
04:31 <Squarism> dmj`, I thought about the phrasing of that myself afterwards. I only meant that i solved problems I use to do imperatively with FP. Its not that i trick-mutate or spray mvars all over. Some areas like logging, message loops, UI differ completely - but other areas ofcourse similar to how its done imperatively.
04:34 ysgard joined
04:36 <dmj`> Squarism: sounds good :)
04:38 <Squarism> interacting with a database, REST/WEB, data transformations isnt THAT different to imperative land.
04:38 kritzcreek joined
04:45 <dmj`> Squarism: sure, if you’re using do syntax
04:48 aarvar joined
04:49 <Squarism> dmj`, are there better alteratives? Thought were no way around do/bind for IO atleast?
04:53 <dmj`> Squarism: don’t think so, you need sequencing for effects
04:55 takle joined
04:58 uglyfigurine joined
05:09 dni- joined
05:09 louispan joined
05:14 Big_G joined
05:24 abhiroop joined
05:35 nobodyzxc joined
05:36 abhiroop joined
05:39 Axman6 joined
05:44 pungi-man joined
05:54 yellowj joined
06:03 galderz joined
06:03 ysgard joined
06:05 JoelMcCracken joined
06:10 pbrant joined
06:11 takle joined
06:19 takle joined
06:20 ebw joined
06:22 uglyfigurine joined
06:25 ebw left
06:26 Denthir joined
06:27 uglyfigu_ joined
06:28 nicknovi1 joined
06:36 noumenon joined
06:37 takle joined
06:39 ysgard joined
06:45 takle joined
06:46 uglyfigurine joined
06:51 xificurC joined
06:55 nickolay joined
06:55 uglyfigurine joined
06:55 <xificurC> I have a small script I keep writing in different languages to learn the basics and test a few basic things I often do. It's a script that traverses a set of directories searching for git projects and running `git pull` in them. The focus of the implementation is to run the pulls concurrently, collect the exit codes and show a live progress of the
06:55 <xificurC> good/bad runs
06:55 <xificurC> now my question: where should I look for running those concurrent tasks?
06:56 louispan joined
06:56 <xificurC> I'm "OK" with a solution that runs concurrently on a single core but preferably I would like to try out one that runs on multiple CPUs as well
06:57 <geekosaur> @hackage async
06:57 <lambdabot> http://hackage.haskell.org/package/async
06:58 <xificurC> geekosaur: so this is preferred over Control.Parallel nowadays?
06:59 takle joined
07:01 Pupnik joined
07:03 <geekosaur> Control.Parallel is the low level interface. async is higher level / more convenient
07:04 <xificurC> geekosaur: I see. The docs for withAsync say "Spawn an asynchronous action in a separate thread". What thread, OS or userspace?
07:05 <geekosaur> "yes" --- if you use the non-threaded backend then it's a userspace thread, with the threaded backend Haskell does M:N threading
07:06 <geekosaur> if you *must* ensure specific OS level threads then you must use the lower level interface with forkOS. I don't recommend it; usually it's only worth the pain if you need thread local state in FFI calls
07:06 <xificurC> geekosaur: where is the threaded backend
07:07 <geekosaur> it's what you get if you link with ghc -threaded
07:07 <geekosaur> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/using-concurrent.html#using-smp-parallelism
07:07 <xificurC> geekosaur: I don't have such needs, I'm just curious about the options ghc has for parallelism and concurrency. I see Async is for IO, what about parallely running a CPU-intensive computation?
07:08 <xificurC> by such needs I'm referencing your comment on the need to have OS level threads
07:08 <geekosaur> async is not just about IO
07:08 Lokathor joined
07:09 <xificurC> the description says -- Run IO operations asynchronously and wait for their results
07:11 mengu joined
07:11 mattyw joined
07:13 <geekosaur> IO there refers to the IO monad
07:13 uglyfigurine joined
07:13 <geekosaur> which is not just about I/O but about anything that is not 100% pure/side-effect free
07:13 <geekosaur> threads are *always* in IO
07:14 <xificurC> so if I have a list of 1000 values and I need to run an expensive computation on them and want to run it in parallel over all my CPUs I *have to* use the IO monad?
07:14 <geekosaur> I suggest you start with http://www.vex.net/~trebla/haskell/IO.xhtml before learning threading, if this confuses you
07:14 <xificurC> a *pure* computation
07:15 <geekosaur> *foring a thread* is in IO, necessarily
07:15 takle joined
07:16 <xificurC> I guess you meant forking. While that makes sense it's not something the user has to know about when running a pure computation. pmap (+1) myBigList
07:16 zaphyr joined
07:18 <xificurC> isn't the IO part of that computation an implementation detail that doesn't necessarily need to leak in the types?
07:18 <geekosaur> no, because of locking/synchronization including that of resources used by the runtime
07:19 <glguy> xificurC: If you just want to evaluate a bunch of things in parallel, you can stay out of IO and use the parallel package
07:19 <glguy> https://github.com/glguy/kami-solver/blob/master/src/Kami.hs#L90
07:20 <glguy> That line evaluates an expensive computation on all the elements of a list across all the cores on my computer
07:22 uglyfigurine joined
07:23 <xificurC> alright, that's enough for me to know where to look for more answers if necessary. Thank you geekosaur, I will read the IO tutorial as well, and glguy
07:23 <xificurC> oh 1 last question
07:24 <xificurC> how can I check if the ghc I have was compiled with -threaded?
07:24 takle joined
07:24 Axman6 joined
07:27 Gurkenglas joined
07:31 <glguy> xificurC: It usually doesn't matter if your GHC was compiled with threaded
07:31 <glguy> That doesn't effect the programs that GHC produces
07:32 <glguy> But you can look at the output of: ghc +RTS --info
07:38 cschneid_ joined
07:38 Levex joined
07:38 conal joined
07:38 takle joined
07:44 uglyfigurine joined
07:46 thc202 joined
07:48 dni- joined
07:48 <xificurC> glguy: oh so it's not ghc's capability but of the compiled program. thanks
07:51 ysgard joined
07:52 Levex joined
07:56 mstruebing joined
07:58 uglyfigurine joined
08:08 uglyfigurine joined
08:11 madjestic joined
08:13 colt44 joined
08:15 grdryn joined
08:15 hphuoc25 joined
08:16 hphuoc25 joined
08:18 LiaoTao joined
08:19 Levex joined
08:24 galderz joined
08:26 uglyfigurine joined
08:29 takle joined
08:33 madjestic joined
08:35 takle joined
08:35 Denthir joined
08:39 noumenon joined
08:45 nacon joined
08:52 Iceland_jack joined
08:53 uglyfigurine joined
08:55 yellowj joined
09:02 uglyfigurine joined
09:03 zero_byte joined
09:06 BOOKBOOK joined
09:09 mengu joined
09:11 uglyfigurine joined
09:23 bno2 joined
09:23 ycheng joined
09:23 davenpcm__ joined
09:26 CuriousErnestBro joined
09:30 lambdabot joined
09:34 romank joined
09:34 uglyfigurine joined
09:38 ysgard joined
09:53 jarshwah joined
10:01 uglyfigurine joined
10:02 BOOKBOOK joined
10:07 salva joined
10:11 Gurkenglas joined
10:49 ysgard joined
11:04 brokenprogrammer joined
11:05 <brokenprogrammer> For a Haskell beginner whats a good project idea?
11:15 cur8or joined
11:41 hphuoc25 joined
11:42 netheranthem joined
11:48 hvr joined
11:54 Denthir joined
12:01 Prutheus joined
12:02 Levex joined
12:03 slomo joined
12:06 moei joined
12:07 watersoul joined
12:12 jrm joined
12:26 hphuoc25 joined
12:32 jship joined
12:33 cschneid_ joined
12:43 nacon joined
12:43 nacon joined
12:46 Nycatelos joined
12:49 pungi-man joined
12:51 galderz joined
12:57 <reptar_> any hints to how i can visualize a tree?
12:58 <reptar_> or other recursive data type
12:58 <reptar_> i was thinking to parse it to json and then use js to view it
12:58 bruschkov joined
12:58 <bruschkov> hi, quick stack question
13:00 <bruschkov> recently upgraded after some time off to newest stack version (1.3.2, resolver:8.13, ghc:8.02)
13:00 <bruschkov> for some reason my builds are not finding the executables anymore
13:01 <bruschkov> output of stack build: http://lpaste.net/355150
13:03 <Iceland_jack> reptar_: See Data.Tree (https://hackage.haskell.org/package/containers-
13:03 <Iceland_jack> It has a (drawTree :: Tree String -> String) function
13:04 <bruschkov> output of stack exec: http://lpaste.net/355152
13:08 iAmerikan joined
13:11 myrkraverk_ joined
13:13 <reptar_> Iceland_jack: oh, thanks :)
13:16 jathan joined
13:18 pungi-man left
13:18 pungi-man joined
13:23 lukesp joined
13:24 jmiven joined
13:31 lukesp joined
13:37 <Iceland_jack> reptar_: Check out "putStrLn $ drawTree $ unfoldTree (\n -> (show n, [1..n-1])) 5"
13:41 romanix joined
13:50 mizu_no_oto_work joined
13:56 <LiaoTao> So (->) x is a functor...
13:56 <LiaoTao> Brain is melting
13:58 <Akii> :D
13:58 <Iceland_jack> LiaoTao: and fmap @((->) _) = (.)
13:59 <Iceland_jack> There are so many ways of viewing (.)
14:00 <LiaoTao> @_@
14:00 <Iceland_jack> LiaoTao: It helps using a type synonym: type Arr = (->)
14:01 <Iceland_jack> Then fmap becomes: fmap :: (b -> b') -> (Arr a b -> Arr a b')
14:01 <Iceland_jack> (fmap f) uses 'f' to modify the output of a function
14:02 <LiaoTao> Iceland_jack: Thanks for the explanation
14:02 <Iceland_jack> (Arr a) is also an Applicative
14:02 <Iceland_jack> With: pure :: b -> Arr a b
14:03 <Iceland_jack> Which makes a function that returns a constant 'b'
14:03 <Iceland_jack> And it is a Monad with join :: Arr a (Arr a b) -> Arr a b
14:04 <LiaoTao> Iceland_jack: Baby steps
14:04 <Iceland_jack> :)
14:04 <Iceland_jack> Deep end
14:04 Prutheus joined
14:06 <Akii> what would be the quickest way to find out if (->) is also a contravariant functor?
14:06 <Akii> running :i Contravariant doesn't spit out a whole lot
14:06 <Iceland_jack> (->) is a contravariant functor, in its first argument
14:07 <Iceland_jack> this can't be formulated in Haskell so we use a newtype
14:07 <Iceland_jack> (it -can- be formulated, but not with the usual Functor / Contravariant)
14:07 <Akii> hm right since you'd need to modify the first argument, not the second
14:07 <Iceland_jack> newtype Op a b = Op (b -> a)
14:07 <Iceland_jack> that's why this exists
14:08 <Akii> (oh, and look what's being listed as an instance Op a)
14:08 <Akii> totally makes sense
14:08 <Iceland_jack> In reality, (->) is a contravariant functor from (->) to (cat of) natural transformations
14:10 <Iceland_jack> A functor from (<-) to (~>)
14:10 <Akii> I hate my IRC client for turning everything into smilies
14:10 <Akii> (and not only that but mutating the actual message)
14:10 <LiaoTao> instance Functor ((->) r) where fmap f g = (\x -> f (g x))
14:10 <LiaoTao> Is this correct?
14:11 <Iceland_jack> yes
14:11 <Iceland_jack> @src (.)
14:11 <lambdabot> (f . g) x = f (g x)
14:11 <Iceland_jack> I recommend enabling InstanceSigs LiaoTao
14:12 <Iceland_jack> fmap :: (b -> b') -> ((a -> b) -> (a -> b'))
14:13 <Iceland_jack> {-# Language InstanceSigs #-}
14:14 vaibhavsagar joined
14:15 <LiaoTao> Iceland_jack: That goes in the source files?
14:15 <Iceland_jack> Yeah, the Language pragma goes to the top of the file
14:15 <Iceland_jack> and then you can write signatures for methods of your type class instances
14:16 <Iceland_jack> for Maybe: fmap :: (a -> a') -> (Maybe a -> Maybe a')
14:18 <Iceland_jack> LiaoTao: When learning type classes, I make my own version of Functor
14:18 <Iceland_jack> class FUNCTOR f where myfmap :: (a -> a') -> (f a -> f a')
14:18 <Iceland_jack> and then define basic instances like FUNCTOR ((->) a), FUNCTOR Maybe, etc.
14:19 <LiaoTao> That sounds like a good way to learn the fundamentals
14:19 <Iceland_jack> Yeah, I make sure to write the signatures and I try to gain an intuition by using redundant parentheses
14:20 <Iceland_jack> For example (map :: (a -> a') -> [a] -> [a']) looks like a function of two arguments
14:20 <Iceland_jack> but a functional perspective is to view it as a function of a single argument (which technically in Haskell, it is)
14:20 <Iceland_jack> and viewing map as a *transformation* of functions: transforms (a -> a') into a function ([a] -> [a'])
14:21 <Iceland_jack> That's why it's difficult to think about Functor ((->) a), because you are transforming a function to a transformation of functions
14:21 <LiaoTao> That's probably it
14:22 lukesp joined
14:22 <Iceland_jack> That's why I like writing it as a type synonym, to distinguish between the type being mapped over
14:23 <Iceland_jack> You can even think of functions from a fixed type
14:23 <Iceland_jack> type FromInt a = Int -> a
14:23 <Iceland_jack> fmap :: (a -> a') -> (FromInt a -> FromInt a')
14:23 <Iceland_jack> </spam>
14:24 <Iceland_jack> <spam>
14:25 <Iceland_jack> For example, if you understand: data Pair a = P a a
14:25 <Iceland_jack> You understand (Bool -> a), because they are the same thing
14:25 <Iceland_jack> so if this makes sense:
14:25 <Iceland_jack> fmap :: (a -> a') -> (Pair a -> Pair a')
14:25 <Iceland_jack> fmap f (P a b) = P (f a) (f b)
14:26 noumenon joined
14:28 <Akii> love how you re-opened the tag
14:28 <Akii> should've been <example> though :P
14:30 <Iceland_jack> :)
14:37 alqatari joined
14:46 mizu_no_oto_work joined
15:02 uglyfigurine joined
15:07 cschneid_ joined
15:09 ysgard joined
15:16 chlong joined
15:20 vlnts joined
15:29 bruschkov joined
15:31 <bruschkov> can anybody see how I resolve this "Duplicat Type Declaration" in line 48: http://lpaste.net/3385429712472899584
15:31 <bruschkov> ?
15:32 vaibhavsagar joined
15:38 mengu joined
15:43 Gurkenglas joined
15:44 <Cale> @tell bruschkov There's already an instance Arbitrary a => Arbitrary (Sum a) defined in the QuickCheck library, you don't need to write one yourself.
15:44 <lambdabot> Consider it noted.
15:56 bcq joined
15:56 <bcq> how do you use :kind!
15:56 jathan joined
15:57 <Iceland_jack> bcq: You use to evaluate type families
15:57 <Iceland_jack> if you defined: >>> type family F a where F Int = [[Int]]
15:57 <Iceland_jack> You can write: >>> :kind! F Int
15:57 <Iceland_jack> and the output is [[Int]]
16:00 pungi-man joined
16:13 meandi_2 joined
16:16 <jle`> you can also use it to find the kind of things
16:18 deank joined
16:23 alqatari joined
16:30 nobodyzxc joined
16:31 aarvar joined
16:31 baweaver joined
16:36 alqatari joined
16:43 skeet70 joined
16:48 <bcq> there was a talk where the person was using GHC.Generics and they used :kind! forall a. Rep (Maybe a) to get a representation of Maybe and i'm wondering how they did that
16:57 jship joined
17:00 pilne joined
17:10 malaclyps joined
17:18 teqwve joined
17:25 romank joined
17:37 iAmerikan joined
17:39 mengu joined
17:44 sobol joined
17:46 baweaver left
17:48 nek0 joined
18:05 vlnts joined
18:08 bvad joined
18:10 uglyfigurine joined
18:16 ralu joined
18:20 jathan joined
18:32 peterbecich joined
18:32 NeverDie joined
18:37 Lokathor_ joined
18:40 mengu joined
18:40 myrkraverk_ joined
18:45 vlnts joined
18:56 peterbecich joined
18:56 colt44 joined
18:57 peterbec` joined
19:09 MotherFlojo joined
19:28 delexi joined
19:41 iAmerikan joined
19:42 yellowj joined
20:00 dni- joined
20:12 glguy joined
20:13 senorchang left
20:15 emmanuel_erc joined
20:19 jathan joined
20:30 iAmerikan joined
20:34 Prutheus joined
20:35 hvr joined
20:39 Gurkenglas joined
20:42 madjestic joined
20:42 hvr joined
20:42 hvr joined
20:42 acarrico joined
20:54 yellowj joined
20:57 peterbecich joined
20:59 mengu joined
21:01 dni- joined
21:02 cur8or joined
21:13 kritzcreek joined
21:20 pbrant joined
21:20 Uniaika joined
21:38 noumenon joined
21:40 haskelleksah joined
21:52 hiratara joined
21:54 romank joined
22:00 vmeson joined
22:05 Deide joined
22:06 iAmerikan joined
22:13 takle joined
22:14 Levex joined
22:15 takle joined
22:19 uglyfigurine joined
22:20 iAmerikan joined
22:23 blissdev_ joined
22:23 Youmu_ joined
22:26 mathu_ joined
22:26 __red___ joined
22:27 unsymbol_ joined
22:27 Levex joined
22:28 codehero joined
22:28 tjb0607_ joined
22:29 majoh joined
22:30 mathu joined
22:31 levex_ joined
22:31 hiratara joined
22:31 lambdabot joined
22:32 `micro joined
22:36 zero_byte joined
22:41 Levex joined
22:42 carlomagno joined
22:50 conal joined
22:50 ljc joined
22:51 dni- joined
22:52 jarshwah_ joined
22:53 Levex joined
22:54 iAmerikan joined
23:01 ysgard_ joined
23:07 romank joined
23:10 lgs joined
23:11 jship joined
23:14 cschneid_ joined
23:15 aarvar joined
23:18 conal joined
23:19 bytesighs joined
23:34 conal joined
23:39 Xion_ joined
23:41 Gurkenglas_ joined
23:46 cschneid_ joined
23:52 kadoban joined
23:57 jathan joined