<    April 2017    >
Su Mo Tu We Th Fr Sa  
                   1  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
30
00:08 __rgn joined
00:13 NeverDie joined
00:17 newhoggy joined
00:20 vaibhavsagar joined
00:24 Rodya_ joined
00:25 texasmynsted joined
00:28 Pupnik joined
00:39 aarvar joined
00:40 baweaver joined
00:55 vaibhavsagar joined
01:08 Rodya_ joined
01:28 roboguy` joined
01:36 roboguy`_ joined
01:37 newhoggy joined
01:39 cschneid_ joined
01:41 Youmu joined
01:46 Pupnik_ joined
01:53 newhoggy joined
01:59 peterson joined
02:01 taksuyu joined
02:02 newhoggy joined
02:08 newhoggy joined
02:16 Irishluck83 joined
02:22 godfreygyz joined
02:23 conal joined
02:34 qu1j0t3 joined
02:41 geekosaur joined
02:42 vicfred joined
02:47 yuze joined
02:47 permagreen joined
02:49 exferenceBot joined
02:53 hexagoxel joined
03:18 EricPoe joined
03:20 Rodya_ joined
03:22 systemfault joined
03:37 conal joined
03:51 peterson joined
03:54 conal joined
03:58 cschneid_ joined
03:58 mengu joined
04:21 Rodya_ joined
04:38 Pupnik joined
04:48 vaibhavsagar joined
04:49 Levex joined
04:51 vito_swiss joined
04:52 pixelfog_ joined
04:54 Levex joined
05:09 alqatari joined
05:20 abhiroop joined
05:23 Rodya_ joined
05:28 ploop joined
05:32 pungi-man joined
05:32 nickager joined
05:36 abhiroop joined
05:37 abhiroop joined
05:42 Levex joined
05:46 shawn_lu_ joined
05:47 mstruebing joined
05:48 <shawn_lu_> Friends, got a question, I have a function with the following type signature:
05:48 <shawn_lu_> addResult :: Integer -> State (DL.DList String)
05:49 <shawn_lu_> For some reason, GHC is giving me “Expecting one more argument to ‘State (DL.DList String)’
05:49 <shawn_lu_> Expected a type, but ‘State (DL.DList String)’ has kind ‘* -> *’”
05:49 <shawn_lu_> Here are my imports:
05:49 <shawn_lu_> import Control.Monad
05:49 <shawn_lu_> import Control.Monad.Trans.State
05:49 <shawn_lu_> import qualified Data.DList as DL
05:50 <jle`> shawn_lu_: yes, that's because State (DL.DList String) expects another parameter
05:50 <jle`> the result value
05:50 <jle`> do you have an implementation for addResult?
05:51 <shawn_lu_> @jie Thanks. Yeah, after you said it, I wanna double check my implementation
05:51 <lambdabot> Maybe you meant: time join id dice cide bid
05:52 <jle`> shawn_lu_: state involves values of type 'State s a'
05:52 <jle`> which contains instructions on how to produce an 'a', while manipulating a state of type 's
05:53 <shawn_lu_> @jie`, it’s the fizzbuzz problem
05:54 <lambdabot> Unknown command, try @list
05:54 <shawn_lu_> addResult :: Integer -> State (DL.DList String)
05:54 <shawn_lu_> addResult n = do
05:54 <shawn_lu_> xs <- get
05:54 <shawn_lu_> let result = fizzBuzz n
05:54 <shawn_lu_> put (DL.snoc xs result)
05:54 <jle`> check out he type of 'put'
05:54 <MarcelineVQ> oh that example is a typo, think it used to be addResult :: Integer -> State (DL.DList String) ()
05:54 <MarcelineVQ> not sure why it got broken
05:55 ThomasLocke joined
05:55 <jle`> put :: s -> State s ()
05:55 <jle`> so yeah, in this case, it's put :: DList String -> State (DList String) ()
05:55 <shawn_lu_> yeah it type checks
05:56 <shawn_lu_> @jle` @MarcelineVQ Thanks a lot
05:56 <lambdabot> Parse failed: Parse error: @
05:56 <shawn_lu_> jle` MarcelineVQ Thanks a lot
05:56 <jle`> no problem!
05:59 hazyPurple joined
06:02 Gurkenglas joined
06:06 abinr joined
06:07 delexi joined
06:12 seangrove joined
06:16 ploop joined
06:18 seangrove joined
06:19 eatman joined
06:19 <eatman> Hi!
06:21 nepiktaz joined
06:23 <eatman> It might not be the best place to ask but : I've many sorted-lists and I want to put them in a Set-like structure.
06:24 <eatman> I guess it's pretty inefficient to build a set over a sorted list.
06:24 <kadoban> Could be. If they share long prefixes, each comparison could take a while, comparatively.
06:25 <kadoban> Are they big enough and/or are there enough of them for it to matter?
06:25 <kadoban> If they don't share long prefixes it won't matter either.
06:26 seangrove joined
06:27 <eatman> Hi kadoban. It's for a "Conway's game of life" so there wont be much of them in the beginning but the number can grow "fast".
06:28 <geekosaur> @index fromAscList
06:28 <lambdabot> Data.IntMap.Strict, Data.IntMap.Lazy, Data.IntMap, Data.IntSet, Data.Map.Strict, Data.Map.Lazy, Data.Map, Data.Set
06:28 <kadoban> Hmmm. I'm not familiar with how sorted lists fit into the implementation of game of life. Is it obvious and I'm missing it?
06:29 <eatman> Well, neighbors p@(x, y) = filter (/= p) $ range ((x-1, y-1), (x+1, y+1))
06:30 <eatman> So every cell neighbors is a list of "sorted" cells.
06:30 <eatman> Assuming (Ix x, Ix y) of course.
06:31 <eatman> But.. the fromAscList looks awesome to me.
06:31 <kadoban> Oh, so they're lists of length about 8?
06:32 <eatman> In 2D yes, 26 in 3D.
06:32 <eatman> And there is a lot of 8-lenght lists.
06:32 yellowj joined
06:34 <kadoban> Any kind of set seems probably fine then
06:36 yuze joined
06:36 <eatman> And, do you know if the set-monad is just like regular set but with monadic behavior?
06:37 <kadoban> Never used it. I'd probably avoid it unless you really need something it provides, if it were me.
06:37 <eatman> Well, I'd love to have the >>= operator.
06:37 <eatman> But I can fake it, indeed.
06:39 alqatari joined
06:39 cschneid_ joined
06:41 Pupnik_ joined
06:50 govg joined
06:51 ploop joined
06:51 monochrom joined
06:58 bvad joined
07:00 crave joined
07:03 Durz0 joined
07:08 c0smo joined
07:25 Rodya_ joined
07:26 aarvar joined
07:28 govg joined
07:33 thc202 joined
07:33 crave joined
07:34 dni- joined
07:37 <mstruebing> hey guys, I started haskell with haskell as a hobby a while ago and already know some basic stuff, I have written a terminal-todolist a while ago(which basically includes all I know about haskell I would say) and wanted to know how I should and could improve next. for referecne the todolist is here: https://github.com/mstruebing/todo.hs
07:37 <mstruebing> anyone have some suggestions? maybe cool tutorials or something?
07:39 mattyw joined
07:40 adarqui joined
07:41 heath_ joined
07:41 <thang1> Most of your comments seem pretty useless
07:41 Sornaensis joined
07:41 <thang1> "todoFileAvailable :: IO Bool"
07:41 <thang1> gee, wonder what that does.
07:42 ploop_ joined
07:42 <thang1> "checks if the todo file is available" well duh. There's literally only two things it could do and the name of the function already told me which one it was
07:43 <MarcelineVQ> You can't have too much comments
07:43 <thang1> Also you can delete any commented out code. That's what git is for. Version control is a time machine
07:43 <jle`> s/can/can't
07:43 <jle`> er, i mean, s/can't/can
07:43 geekosaur joined
07:43 <jle`> :)
07:43 <thang1> MarcelineVQ: you can definitely have too many comments :p
07:44 <jle`> but in this case it's a reasonable amount of comments
07:44 <jle`> documenting all of your top-level functions is reasonable
07:44 <jle`> especially for library code
07:44 <jle`> i'd use haddock style, -- | Checks if the todo file is available
07:45 <thang1> https://www.cs.princeton.edu/courses/archive/spring17/cos333/knuth-mcilroy.pdf
07:46 <thang1> This is my favorite example of too much comments vs too little comments
07:46 <jle`> i woudln't comment everything you name, but, if your module exports anything, you should document the things that it exports
07:46 <jle`> there's a reason why haddock gives coverage reports/scores :)
07:48 <thang1> Also, nice testing suite :p
07:49 <mstruebing> thx :P
07:50 hvr joined
07:50 hvr joined
07:50 nickolay joined
07:52 <thang1> QuickCheck or whatever it's called is pretty nice and easy to use. Might be a good next step?
07:58 abinr joined
08:07 colt44 joined
08:22 mattyw joined
08:26 Rodya_ joined
08:30 nacon joined
08:32 govg joined
08:32 grdryn joined
08:36 Tomatosoup- joined
08:37 cschneid_ joined
08:56 andyhoang joined
08:58 binaryplease joined
08:59 Iceland_jack joined
09:04 zero_byte joined
09:04 mattyw joined
09:07 merijn joined
09:08 alqatari joined
09:11 Pupnik joined
09:26 yellowj joined
09:27 Rodya_ joined
09:29 nickager joined
09:32 <lpaste> nickager pasted “confusion constructors with types” at http://lpaste.net/354916
09:33 <nickager> I think I understand the error message, I’d love help with the best solution. Thanks
09:34 <kadoban> nickager: The things there have to be types, but OnePair isn't a type. That's a value of type PokerResult
09:37 <nickager> kadoban: indeed, it seems a shame to define `TwoPairs [Card] [Card]` and `FullHouse [Card] [Card]`
09:37 <nickager> or less explicit
09:37 <nickager> is there a better way
09:38 <LiaoTao> Does [x] mean the same thing as (x:[]) in pattern matching?
09:38 <kadoban> LiaoTao: Yes
09:38 <LiaoTao> kadoban: Thanks!
09:39 <kadoban> nickager: Nothing comes to mind. Does this PokerResult type actually make sense? It doesn't seem like it gives you enough information to compare hands. Or do you not have to?
09:40 newhoggy joined
09:40 <kadoban> If you have highcard, AK is better than AQ, isn't it, for example? Or even more common cases of kickers with pairs. Or is a real result a ... list of PokerResults for each hand with each thing in descending order or something?
09:41 govg joined
09:42 <nickager> two players then RoyalFlush beats StraightFlush, FourOfAKind … etc
09:44 <nickager> if two players don’t have anything other than HighCard and the value is the same then its the next highest card that wins
09:44 <nickager> https://projecteuler.net/problem=54
09:44 <kadoban> But PokerResult doesn't give you the information of what the next highest card is, right?
09:45 <nickager> true, but its a start!
09:45 <nickager> perhaps I should call it `PokerIntermediateResult` or something
09:46 <kadoban> Ah okay, fair enough
09:46 <nickager> or `PokerHandGrouping`
09:47 <kadoban> I guess at that point you could just sort the cards in the hard, descending and then compare lexicographically after that.
09:47 <nickager> indeed
09:47 <nickager> OK I’ll crack on with `TwoPairs [Card] [Card]` and `FullHouse [Card] [Card]`
09:47 <nickager> thanks
09:48 nobodyzxc joined
09:48 <merijn> nickager: I would argue that you should probably use "(Card, Card)" and "(Card, Card, Card)" for those constructors
09:48 <kadoban> If you don't care what the actual cards are, which I don't think you do, you could do uhm ... OnePair Value TwoPairs Value Value, etc.
09:48 <merijn> nickager: Since [Card] might have the wrong number of cards
09:50 <nickager> merijn: I started using tuples, but I found it a pain to convert from arrays to tuples as I’m using `groupBy (\card1 card2 -> value card1 == value card2) cards`
09:51 <nickager> do find pairs, three of a kind, four of a kind etc
09:51 <nickager> perhaps I was just being lazy
09:51 <merijn> nickager: It's a trade-off
09:51 <merijn> nickager: In general I prefer making illegal states unrepresentable
09:51 <nickager> agreed
09:52 <nickager> OK, good suggestion I’ll have a go at the implementation and see how it works out
09:52 <merijn> nickager: You could write it the [Card] way to get everything working and then refactor to use something else afterwards
09:53 <merijn> That way you can at least get something working without too much hassle and fix it permanently later. Refactoring it should be fairly trivial. Just change the datatypes and fix the compile errors ;)
09:54 <nickager> hoogle didn’t seem to have functions for [a,a] -> (a,a) and [a,a,a] -> (a,a,a)
09:54 <merijn> Yeah, I doubt those exists
09:54 <nickager> easy to write I guess or is there a standard solution
09:54 <merijn> Some lens voodoo could work, but that's...not going to make things easier :p
09:54 <nickager> OK thanks all
09:55 kritzcreek joined
09:57 binaryplease1 joined
09:58 Tomatosoup- joined
10:05 mengu joined
10:10 <Akii> > (,,) <$> (!! 0) <*> (!! 1) <*> (!! 2) $ [1,2,3 :: Int]
10:11 <lambdabot> (1,2,3)
10:11 <Akii> np :D
10:12 <Akii> of course that's a partial function
10:12 <Iceland_jack> There we go!
10:12 <Iceland_jack> > (,,) <$> view _1 <*> view _2 <*> view _3 $ (1,2,3)
10:12 <Iceland_jack> > (,,) <$> view _1 <*> view _2 <*> view _3 $ (1,2,3,4)
10:12 <lambdabot> (1,2,3)
10:13 <lambdabot> (1,2,3)
10:13 <Iceland_jack> > (,,) <$> view _1 <*> view _2 <*> view _3 $ (1,2,3,4,5)
10:13 <lambdabot> (1,2,3)
10:13 <Iceland_jack> Fails on tuples
10:13 <Iceland_jack> > (,,) <$> view _1 <*> view _2 <*> view _3 $ (1,2)
10:13 <lambdabot> error:
10:13 <lambdabot> • Ambiguous type variable ‘t0’ arising from a use of ‘show_M896129003090...
10:13 <lambdabot> prevents the constraint ‘(Show t0)’ from being solved.
10:16 <Akii> I thought the goal was to convert a list to tuple
10:18 <Iceland_jack> oh it is? toListOf each
10:19 <Iceland_jack> I was swanning off
10:19 <Iceland_jack> > toListOf each (1,2,3)
10:19 <lambdabot> [1,2,3]
10:19 <Iceland_jack> > toListOf each (1,2,3,4,5)
10:19 <lambdabot> [1,2,3,4,5]
10:19 <Akii> that converts a tuple to list
10:19 <Akii> >_>
10:20 <Akii> > toListOf each (1,2,3,4,"foo")
10:20 <lambdabot> error:
10:20 <lambdabot> • No instance for (Num [Char]) arising from the literal ‘1’
10:20 <lambdabot> • In the expression: 1
10:20 <Akii> :D
10:20 <Iceland_jack> I need to read more carefully
10:20 <Iceland_jack> A list to a tuple is possible with lens, unsafely
10:21 <Iceland_jack> > set (partsOf each) [1,2,3] (undefined, undefined, undefined)+
10:21 <Iceland_jack> > set (partsOf each) [1,2,3] (undefined, undefined, undefined)
10:21 <lambdabot> <hint>:1:62: error:
10:21 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
10:21 <lambdabot> (1,2,3)
10:21 <Iceland_jack> > set (partsOf each) [1..4] (undefined, undefined, undefined, undefined)
10:21 <lambdabot> (1,2,3,4)
10:22 vaibhavsagar joined
10:22 <Akii> :t partsOf each
10:22 <lambdabot> (Each s t b b, Functor f) => LensLike f s t [b] [b]
10:23 <Iceland_jack> > (,,,){} & partsOf each .~ [1..4]
10:23 <lambdabot> (1,2,3,4)
10:23 <Iceland_jack> > (,,){} & partsOf each .~ [1..3]
10:23 <lambdabot> (1,2,3)
10:24 <eatman> Akii: were you the one who gave me this link https://samtay.github.io/posts/comonadic-game-of-life.html about the Conway's game of life?
10:24 <Akii> nope
10:24 <eatman> Arf...
10:24 <Akii> but I met conway in person
10:24 <eatman> Ho yeah?
10:24 <Akii> nice guy
10:25 <Akii> if that's the same conway from conways law anyway
10:25 <eatman> Looks like it.
10:26 <eatman> https://en.wikipedia.org/wiki/John_Horton_Conway
10:26 <Akii> nope not that one
10:26 <Akii> xD
10:27 <Akii> https://en.wikipedia.org/wiki/Melvin_Conway
10:27 <eatman> Ah, well that does not change my associated question: a lot of website implement the "game Of Life" using zippers and comonads.
10:27 Rodya_ joined
10:28 <eatman> But, doing so implies keeping a record of the whole universe.
10:28 <eatman> I find it really heavy.
10:28 <eatman> In term of memory of course.
10:29 <eatman> I would have prefererd something that behave like a Hash Map of living cells only.
10:35 <eatman> And then I find something called HashLife that could be a good approach.
10:36 <eatman> Funny how a "simple" topic can become a broad field of research.
10:38 newhoggy joined
10:51 peterson joined
10:56 netheranthem joined
10:58 <LiaoTao> So I'm doing Project Euler problem 5 (https://projecteuler.net/problem=5) and I've already sort of brute forced it by using iterated comparison
11:00 <LiaoTao> I'd like to solve it by prime factorization but keep getting stuck on finding a representation of the unique factorization
11:00 <reptar_> why can't i do this? https://pastebin.com/8wdQb41L
11:02 <LiaoTao> http://lpaste.net/354923
11:02 <Akii> reptar_: wrong indentation?
11:03 <LiaoTao> This is what I have so far, but am stuck on how to get the maximum number of repeated factors for each of the numbers
11:03 <merijn> LiaoTao: Somewhat relevant side note: I tend to advise people not to use Project Euler as practice. Because 1) Project Euler is really more about number theory than programming and 2) it forces you to work with the less elegant parts of Haskell
11:03 <reptar_> Akii: what's wrong about it?
11:04 <LiaoTao> merijn: Noted!
11:04 <merijn> reptar_: where being indented further than the in
11:04 <Akii> reptar_: hm didn't know that was possible
11:04 <merijn> Not sure if that's it
11:04 <merijn> But it certainly looks weird
11:04 <merijn> @where exercises
11:04 <lambdabot> http://www.haskell.org/haskellwiki/H-99:_Ninety-Nine_Haskell_Problems https://github.com/bitemyapp/learnhaskell http://www.reddit.com/r/dailyprogrammer/ http://www.reddit.com/r/programmingchallenges/
11:04 <Akii> actual error is Couldn't match type ‘[Char]’ with ‘Char’
11:05 <reptar_> ^
11:05 <Akii> result is [String], maybe you need unlines?
11:05 <merijn> oh, easy
11:05 <merijn> Akii++
11:05 <Akii> \o/
11:05 <reptar_> oh, so that's why
11:06 <merijn> LiaoTao: As for your actual question, maybe use "Map Int Int" where the key is the prime and the value is the power of said prime?
11:06 <reptar_> i thought it complained because checkColors got a list of strings and couldn't understand why
11:07 <merijn> LiaoTao: So the prime factorisation "2^3 * 5^2 * 7" would be "fromList [(2, 3), (5, 2), (7, 1)]"
11:07 miguel_fontes__ joined
11:08 <reptar_> thanks, Akii
11:08 <LiaoTao> merijn: But how do I extract that from the list of lists of factors?
11:08 <Akii> reptar_: np!
11:08 <reptar_> is hackerrank also more about number theory than programming?
11:09 <merijn> LiaoTao: Your list of prime factors is simply the flat list of factors? i.e. my example would be some permutation of [2, 5, 2, 7, 2, 5]?
11:10 <merijn> reptar_: I'm not really familiar with hackerrank
11:10 <LiaoTao> merijn: 14 would be [2,7], but I'm mapping over the range [2..20], so it's a list of lists
11:11 <merijn> LiaoTao: And 4 would be [2,2]?
11:11 <LiaoTao> Yeah
11:11 <LiaoTao> So I need to count the maximum number of repeats per factor for the list of lists
11:13 <merijn> LiaoTao: Should be straightforward, you can do "zip (,1) factors" to turn the list of factors into a list of "prime + power" pairs (which may have duplicates primes, all with count 1), and then you could construct your Map by folding over the list, adding duplicates
11:13 <LiaoTao> [[2],[3],[2,2],[5],[2,3],[7],[2,2,2],[3,3],[2,5],[11],[2,2,3],[13],[2,7],[3,5],[2,2,2,2],[17],[2,3,3],[19],[2,2,5]]
11:13 <merijn> In fact, that already exists:
11:13 <merijn> :t fromListWith
11:13 <lambdabot> error:
11:13 <lambdabot> • Variable not in scope: fromListWith
11:13 <lambdabot> • Perhaps you meant one of these:
11:13 <merijn> eh
11:13 <merijn> :t M.fromListWith
11:13 <lambdabot> Ord k => (a -> a -> a) -> [(k, a)] -> M.Map k a
11:14 <merijn> > M.fromListWith (+) . zip (,1) $ [2,3,2,5]
11:14 <lambdabot> error:
11:14 <lambdabot> • Couldn't match expected type ‘[k]’
11:14 <lambdabot> with actual type ‘t0 -> (t0, Integer)’
11:14 <merijn> wut?
11:14 <merijn> oh
11:14 <merijn> > M.fromListWith (+) . zip (,1) $ ([2,3,2,5] :: [Integer])
11:14 <lambdabot> error:
11:14 <lambdabot> • Couldn't match expected type ‘[k]’
11:14 <lambdabot> with actual type ‘t0 -> (t0, Integer)’
11:16 <merijn> oh, wait, brainfart
11:16 <merijn> That should be map
11:16 <merijn> > M.fromListWith (+) . map (,1) $ [2,3,2,5]
11:16 nepiktaz joined
11:16 <lambdabot> fromList [(2,2),(3,1),(5,1)]
11:16 <merijn> boom
11:16 <LiaoTao> merijn: I'm having some connection problems
11:17 <LiaoTao> Can you hold off on the explanation for a bit?
11:17 <LiaoTao> ZNC is dropping messages
11:17 <merijn> tbh, that last line was pretty much the entire explanation, but sure ;)
11:26 newhoggy joined
11:28 Rodya_ joined
11:35 stianhj joined
11:37 peterson joined
11:49 newhoggy joined
11:50 nepiktaz joined
11:52 madjestic joined
11:57 newhoggy joined
11:58 Levex joined
12:01 mattyw joined
12:01 mattyw joined
12:06 newhoggy joined
12:11 <nickager> is there an operator that allows: m (a -> b) -> a -> m b
12:11 <nickager> eg (Just (+1)) ???? 4::Int
12:12 <merijn> ap and <*>
12:12 <merijn> :t (<*>)
12:12 <lambdabot> Applicative f => f (a -> b) -> f a -> f b
12:12 <merijn> You'll want pure to turn "4 :: Int" into "m Int"
12:12 <merijn> > Just (+1) <*> pure 4
12:12 <lambdabot> Just 5
12:12 <merijn> > Nothing <*> pure 4
12:12 <lambdabot> Nothing
12:12 <nickager> of course
12:13 <nickager> it was the `pure` I was missing
12:13 <merijn> :)
12:13 <nickager> thanks
12:14 newhoggy joined
12:14 govg joined
12:15 <nickager> is there a neater way of writing: if isRoyalFlush then Just $ RoyalFlush cards else Nothing
12:16 <nickager> eg Bool -> Maybe
12:16 <nickager> I guess I can write my own ...
12:16 <merijn> guard?
12:16 vaibhavsagar joined
12:16 <Iceland_jack> guard or monad comprehension
12:17 <merijn> :t \b -> () <$ guard b
12:17 <lambdabot> Alternative f => Bool -> f ()
12:17 <Iceland_jack> do guard isRoyalFlush; pure (RoyalFlush cards)
12:17 <merijn> > \b -> () <$ guard b $ True :: Maybe ()
12:17 <lambdabot> error:
12:17 <lambdabot> • Couldn't match type ‘()’ with ‘Maybe ()’
12:17 <lambdabot> Expected type: Bool -> Maybe ()
12:17 <merijn> oh
12:17 <merijn> > (\b -> () <$ guard b) True :: Maybe ()
12:17 <lambdabot> Just ()
12:17 <merijn> > (\b -> () <$ guard b) False :: Maybe ()
12:17 <lambdabot> Nothing
12:18 <merijn> Replace () with whatever you want
12:19 <nickager> that looks more complex than: “if Bool then Just x else Nothing”
12:20 <merijn> :t (<$)
12:20 <lambdabot> Functor f => a -> f b -> f a
12:20 <merijn> <$ is basically just "replace a value inside a Functor"
12:20 <merijn> :t guard
12:20 <lambdabot> Alternative f => Bool -> f ()
12:20 <Iceland_jack> > 'a' <$ [1..10]
12:20 <lambdabot> "aaaaaaaaaa"
12:21 pbrant joined
12:21 <merijn> And guard produces either 'empty :: Alternative f => f a' (which is specific to 'f' but usually conforms to 'failure', like Nothing. Or it produces 'f ()')
12:22 pungi-man joined
12:22 <nickager> Ok, I was with you until Iceland_jack pulled 'a' <$ [1..10]
12:23 <merijn> nickager: Well, [1..10] is [Int]? yes
12:23 <merijn> :t (<$)
12:23 <lambdabot> Functor f => a -> f b -> f a
12:23 <nickager> yes
12:23 <merijn> <$ takes an 'a' and an 'f b' and turns it into 'f a', and there's really only one way to do that
12:23 <nickager> OK
12:23 <merijn> Replace all b's with a's, i.e. replace all Int with Char in his example
12:24 <merijn> Since <$ only has one Char (the one you give it) it replaces all Int with that one Char
12:24 <merijn> nickager: It's basically just "fmap (const 'a')"
12:24 <merijn> Where "const a b = b"
12:24 <nickager> OK
12:24 <merijn> For lists it's generally not very useful, but <$ is nice for things like guard and parsers
12:25 <Iceland_jack> :t (<$) :: Char -> [Int] -> String
12:25 <lambdabot> Char -> [Int] -> String
12:25 <merijn> Where you want to use something for it's side-effects (parsing, failing, etc.) but want to replace the "success" result
12:25 <merijn> > True <$ Just 'c'
12:25 <lambdabot> Just True
12:25 <merijn> > True <$ Nothing
12:25 <lambdabot> Nothing
12:26 mattyw joined
12:29 Rodya_ joined
12:29 newhoggy joined
12:29 <nickager> So: “RoyalFlush cards <$ guard isRoyalFlush” is the applicative form of do guard isRoyalFlush; pure $ RoyalFlush cards
12:30 <merijn> nickager: Right
12:31 <merijn> nickager: I just dislike the "do { ...; pure something }" in do notation :)
12:31 <Iceland_jack> Or MonadComprehensions [ RoyalFlush cards | isRoyalFlush ]
12:32 <Iceland_jack> does the same
12:32 <Iceland_jack> not supported by lambdabot tho
12:32 <nickager> OK
12:33 <nickager> I understand you dislike the “do ..” formulation but is there a reason why you use “pure” and not “return"
12:34 <Iceland_jack> pure is more modern, now that Applicative is a superclass of Monad
12:34 <Iceland_jack> more general than 'return'
12:34 <merijn> nickager: pure is more general
12:35 <nickager> OK - I’d hate for people to look at my code and think that it was antiquated when I used ‘return’ rather than ‘pure’ ;)
12:35 <Iceland_jack> It's not a big deal either way :)
12:37 <Iceland_jack> At work we use 7.8 where Monad has no superclasses
12:39 <nickager> thanks both
12:44 geekosaur joined
12:51 hazyPurple joined
12:54 cschneid_ joined
12:57 Levex joined
12:58 conal joined
13:09 des_ joined
13:09 iAmerikan joined
13:14 kuznero joined
13:16 des_ joined
13:21 jathan joined
13:25 mizu_no_oto_work joined
13:26 FKlama joined
13:27 jmiven joined
13:29 Rodya_ joined
13:33 jship joined
13:34 des_ joined
13:35 Rodya_ joined
13:40 Zialus joined
13:40 Boarders joined
13:40 cschneid_ joined
13:40 chlong joined
13:42 <Boarders> I was running a simple example to get used to quick check so I wrote the following:
13:42 <Boarders> import Test.QuickCheck
13:42 <Boarders> add3 :: Int -> Int add3 x = x+3
13:42 <Boarders> add3':: Int-> Int
13:43 <Boarders> add3' n | n>100 = 103
13:43 <Boarders> | otherwise = 3+n
13:43 <Boarders> add3prop :: Int -> Bool
13:43 <Boarders> add3prop n = add3 n == add3' n
13:43 <Akii> please use lpaste
13:43 <Boarders> (sorry for copying it out here)
13:44 <Boarders> in any case the functions seem to work as expected in ghci but quickcheck tells me add3prop passes all tests
13:44 <Boarders> I'll just put it in lpaste
13:45 <Boarders> http://lpaste.net/3013440447482691584
13:45 <Boarders> if I write quickCheck (add3prop) in ghci it gives me 100 tests passed
13:50 <Akii> seems like it doesn't generate values greater than 100
13:52 <Boarders> oh ok, it worked when I changed to >50
13:52 <Boarders> weird
13:52 <Akii> sample (arbitrary :: Gen Int)
13:52 <Akii> will give you a bunch of ints
13:52 <Akii> but nothing too big
13:52 <Akii> or too small
13:54 <Iceland_jack> quickCheck (< 100) should pass
13:55 <Iceland_jack> but you can change the size parameter, one way is: quickCheck (mapSize (+ 44) (< 100)) which will fail
13:55 mizu_no_oto_work joined
14:00 salva joined
14:04 douglascorrea joined
14:14 <benzrf> :t mapSize
14:14 <lambdabot> STestable prop => (Int -> Int) -> prop -> Test.QuickCheck.Safe.SProperty
14:14 <benzrf> heuh
14:18 vmeson joined
14:18 Tomatosoup- joined
14:20 carlomagno1 joined
14:22 newhoggy joined
14:22 filostrato joined
14:23 nil_ joined
14:24 des_ joined
14:25 nitrix joined
14:29 zaphyr joined
14:35 zaphyr_ joined
14:38 newhoggy joined
14:43 newhoggy joined
14:47 kritzcreek joined
14:49 eacameron joined
14:49 <zaphyr_> Hi there, complete newbie here. I installed stack under windows 10, and ran into ghc.exe sanity check errors
14:50 <zaphyr_> I think I ran into https://github.com/commercialhaskell/stack/issues/3117 and replaced my gcc.exe as explained and things seem to be working but I'm scared, is that all I'll need to work through the book?
14:51 <zaphyr_> (In particular will 8.2.1 cause me any grief since the book is for 7.x?)
14:51 ysgard joined
14:51 newhoggy joined
14:54 <nitrix> zaphyr_: The major differences are some API changes in `base`, mostly the GHC.* modules.
14:54 <nitrix> zaphyr_: Since you haven't been exposed to Haskell too much, that shouldn't interfere much with your learnings.
14:55 <zaphyr_> nitrix: okay, that's good to know, thanks!
14:55 <nitrix> Intriguing that you had to go this far to get stack to work though, apologies for that.
14:56 <nitrix> Seems like they figured it out quickly though. It's a pretty massive update from Microsoft.
14:56 Tomatosoup- joined
14:57 newhoggy joined
14:58 <nitrix> zaphyr_: It's temporary, they'll roll out an update for stack soon. Next milestone here: https://github.com/commercialhaskell/stack/milestone/8
14:59 <zaphyr_> Oh, thanks. I'll try and update when it's out. Looks like stack is far easier to manage than platform for a beginner
15:01 <nitrix> Kinda yeah. I like that it is able to manage multiple GHC versions sandboxed for each projects.
15:01 <nitrix> The "reproducible build" idea has its heart in the right place :)
15:03 ysgard joined
15:05 <zaphyr_> Last attempt at learning haskell involved a nasty car accident with my global setup and cabal :)
15:05 cschneid_ joined
15:05 newhoggy joined
15:09 zaphyr joined
15:10 __rgn joined
15:10 corintho[m] joined
15:11 newhoggy joined
15:15 razvanc-r[m] joined
15:15 sirius[m] joined
15:15 unclechu joined
15:15 sudoreboot[m] joined
15:15 agates joined
15:15 dyce[m] joined
15:15 curry[m] joined
15:15 korayal[m] joined
15:15 hazyPurple joined
15:25 uglyfigurine joined
15:32 Tomatosoup- joined
15:42 newhoggy joined
15:45 nicknovi1 joined
15:49 des_ joined
15:49 binaryplease joined
15:53 hazyPurple joined
15:58 newhoggy joined
15:58 nicknovi1 joined
16:07 newhoggy joined
16:08 ElTOTO joined
16:09 <ElTOTO> Hi!
16:09 <ElTOTO> I'm new to both haskell and stack and I'd like to use Data.QuadTree
16:09 <Iceland_jack> Hi ElTOTO!
16:09 <ElTOTO> What do I need to install?
16:10 <ElTOTO> Because :m + Data/QuadTree does not work here.
16:10 <ElTOTO> s/\//./
16:10 <Iceland_jack> Do you have 'cabal' installed?
16:10 <Iceland_jack> You can try 'cabal install QuadTree'
16:11 <ElTOTO> But this will not be really stack friendly?
16:11 <Iceland_jack> I'm not sure QuadTree is on Stackage, if you are using stack someone else can help you better
16:11 <ElTOTO> I don't even have cabal on this computer.
16:12 <ElTOTO> Iceland_jack: ok, thanks for the info.
16:12 meandi_2 joined
16:12 <Iceland_jack> I have never used that package either
16:12 <ElTOTO> Ho, I thought it was pretty common.
16:13 <Iceland_jack> 7 people have downloaded it in the last 30 days and it hasn't been updated in a few years
16:13 <Iceland_jack> If you are talking about https://hackage.haskell.org/package/QuadTree
16:15 <ElTOTO> Indeed.
16:15 <ElTOTO> Ok, I'll code mine :-)
16:15 <Iceland_jack> heh :)
16:15 <ElTOTO> Thanks for the info, I came accross it directly to the functions signatures pages.
16:16 <Iceland_jack> I'm not much help but you're welcome
16:17 jship joined
16:17 vmeson joined
16:18 mizu_no_oto_work joined
16:21 baweaver left
16:24 newhoggy joined
16:24 chlong joined
16:28 hazyPurple joined
16:40 newhoggy joined
16:40 delexi joined
16:40 geekosaur joined
16:45 newhoggy joined
16:45 abinr joined
16:50 newhoggy joined
16:55 nicknovi1 joined
16:59 newhoggy joined
16:59 pilne joined
17:05 newhoggy joined
17:09 malaclyps joined
17:13 newhoggy joined
17:20 initiumdoeslinux joined
17:22 newhoggy joined
17:24 hazyPurple joined
17:30 newhoggy joined
17:36 newhoggy joined
17:37 mizu_no_oto_work joined
17:41 newhoggy joined
17:50 newhoggy joined
17:53 chlong joined
17:54 newhoggy_ joined
17:56 ralu joined
18:01 mac10688 joined
18:04 newhoggy joined
18:05 bvad joined
18:08 Gurkenglas joined
18:08 conal joined
18:13 newhoggy joined
18:18 newhoggy joined
18:24 newhoggy joined
18:25 mengu joined
18:30 dni- joined
18:33 newhoggy joined
18:36 Levex joined
18:39 newhoggy joined
18:40 drw77 joined
18:42 <drw77> I have a String variable that I'd like to change at compile-time with a switch (or something like that). Is it possible to make something like `stack build -DEV` vs `stack build -PROD` ?
18:44 Levex joined
18:44 newhoggy joined
18:49 <geekosaur> see --flag
18:49 <geekosaur> and cabal configuration flags at https://www.haskell.org/cabal/users-guide/developing-packages.html#configurations
18:49 NeverDie_ joined
18:52 newhoggy joined
18:52 mengu_ joined
18:58 newhoggy joined
18:59 <drw77> geekasour thanks. Is there a way to check the value of a flag from code within a module? The only opportunity I can see is to write one module that has the value I want for `Prod` and another that has the value I want for `Dev` is that how these things are typically done?
18:59 meandi joined
19:00 <geekosaur> you can also use LANGUAGE CPP and gcc-options: -DFOR_DEVEL, then test #ifdef FOR_DEVEL in the module
19:01 bvad joined
19:01 <geekosaur> (I think you can even specify the string as the value of the preprocessor macro, but I'd have to see how quoting works before saying how to use it...)
19:03 newhoggy joined
19:09 newhoggy joined
19:11 nickager joined
19:17 <drw77> geekosaur: the combination you described works just as I'd hoped. Thanks for the help.
19:25 newhoggy joined
19:37 davenpcm joined
19:41 newhoggy joined
19:57 newhoggy joined
19:57 chlong joined
20:02 xificurC joined
20:03 newhoggy joined
20:08 Levex joined
20:08 newhoggy joined
20:13 carlomagno joined
20:17 newhoggy joined
20:19 dni- joined
20:23 newhoggy joined
20:23 Deide joined
20:28 newhoggy joined
20:34 newhoggy joined
20:45 newhoggy joined
20:50 malaclyps joined
20:50 carlomagno1 joined
20:51 crave joined
20:54 newhoggy joined
20:55 sudoreboot joined
21:01 Prutheus joined
21:02 NeverDie joined
21:02 nicknovi1 joined
21:05 newhoggy joined
21:10 newhoggy joined
21:16 justicefries left
21:17 pdgwien joined
21:19 Rodya_ joined
21:22 Durbley_ joined
21:33 pdgwien joined
21:47 sigmundv joined
21:53 hiratara joined
21:53 newhoggy joined
21:54 mizu_no_oto_work joined
21:56 jship joined
22:08 dni- joined
22:11 Orion3k joined
22:17 dni- joined
22:21 sigmundv joined
22:21 Durbley joined
22:27 malaclyps joined
22:31 hiratara joined
22:51 newhoggy joined
23:03 nicknovi1 joined
23:09 seanparsons_ joined
23:09 sigmundv joined
23:10 takle joined
23:15 cschneid_ joined
23:36 conal joined
23:46 leothrix joined
23:53 eacameron joined
23:55 leothrix joined
23:56 cschneid_ joined
23:57 geekosaur joined
23:58 sigmundv joined