<    March 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:00 Fairy joined
00:02 <michi7x7> parsnip: how is a Bytestring a time?
00:02 Claudius1aximus joined
00:03 <parsnip> michi7x7: the time is stored in a file, and then reading it in, i'd like to insert it in a record entry with type UTCTime
00:03 <michi7x7> parsnip: "stored" in what format?
00:03 <parsnip> i can do it if it's a string, but i can't find a `read` in Data.ByteString.Lazy
00:03 <parsnip> michi7x7: it's almost a json file, but not quite. i've massaged into json.
00:05 <michi7x7> parsnip: is it just an unix timestamp?
00:05 <parsnip> it's in POSIX format, yes
00:05 <parsnip> integer seconds from epoch
00:06 <parsnip> right now, my draft functions, do the following:
00:07 <parsnip> FilePath (contents are almost JSON) --(Parsec)--> [[(String, String)]] --> ByteString (JSON format) ...
00:07 <parsnip> er, the tuple maybe should be (ByteString, ByteString)
00:08 <parsnip> but maybe life is easier if i ignore efficiency and just read in the file as String, these aren't large datafiles.
00:09 <michi7x7> > parseTimeM True defaultTimeLocale "%s" "1234567890" :: Maybe UTCTime
00:09 <lambdabot> error:
00:09 <lambdabot> Not in scope: type constructor or class ‘UTCTime’
00:09 heedypo_ joined
00:10 MindlessDrone joined
00:10 arpl left
00:10 <parsnip> > "1489002497" :: POSIXTime
00:11 <lambdabot> error:
00:11 <lambdabot> Not in scope: type constructor or class ‘POSIXTime’
00:11 <parsnip> > "1489002497" :: ByteString
00:11 <lambdabot> error:
00:11 <lambdabot> Not in scope: type constructor or class ‘ByteString’
00:11 <lambdabot> Perhaps you meant one of these:
00:11 <michi7x7> hmm, parseTimeM just takes strings
00:12 <parsnip> :t unpack
00:12 <lambdabot> error:
00:12 <lambdabot> • Variable not in scope: unpack
00:12 <lambdabot> • Perhaps you meant one of these:
00:13 dddddd joined
00:14 <fred-fri> michi7x7, got it. for a beginner, doing things step by step makes it easier to understand what's going on. https://gist.github.com/androidfred/92994d8dc0503388c20797ac1071314e
00:15 <fred-fri> thanks again
00:18 Rodya_ joined
00:19 Qommand0r joined
00:21 SCHAAP137 joined
00:23 raycoll joined
00:23 <stevebash> join ##security
00:24 splanch joined
00:24 ryandevilla1 joined
00:25 eacameron joined
00:25 <parsnip> so Data.ByteString.Lazy converts to word8. do i have to use Data.ByteString.Lazy.Char8 to get conversion to string?
00:26 <parsnip> oh, nm, these functions work on the first bytestrings
00:26 <Jinxit> any ideas why earley would give me 4 identical parses?
00:27 Rodya__ joined
00:28 whiteline joined
00:34 <ertes> > B.pack [195, 164]
00:34 <lambdabot> error:
00:34 <lambdabot> Not in scope: ‘B.pack’
00:34 <lambdabot> Perhaps you meant one of these:
00:34 stevebash joined
00:34 <ertes> > BS.pack [195, 164]
00:34 <lambdabot> "\195\164"
00:34 <ertes> parsnip: what String would you convert that one into?
00:35 <parsnip> > map char [195, 164]
00:35 <lambdabot> error:
00:35 <lambdabot> • No instance for (Num Char) arising from the literal ‘195’
00:35 <lambdabot> • In the expression: 195
00:36 <parsnip> the value it's parsing will be a POSIXTime, that is, digits 0-9
00:36 oisdk joined
00:36 <ertes> parsnip: you need to pick an encoding anyway
00:36 stevebash joined
00:36 <parsnip> > map int > map ord ['0'..'9']
00:37 <lambdabot> error:
00:37 <lambdabot> • Couldn't match expected type ‘[Int] -> [Doc]’
00:37 <lambdabot> with actual type ‘[Int]’
00:37 <parsnip> > map ord ['0'..'9']
00:37 <lambdabot> [48,49,50,51,52,53,54,55,56,57]
00:37 <ertes> even if it's: "i'll assume it's ASCII, and i promise that i formally proved that it's going to be ASCII"
00:37 <ertes> if you assume that or latin-1, then you can use the unsafe .Char8
00:38 lambda-11235 joined
00:38 <ertes> > BSC.unpack (BS.pack [48..57])
00:38 <lambdabot> "0123456789"
00:39 Welkin joined
00:39 <parsnip> decodeDate bs = posixSecondsToUTCTime . (fromIntegral :: Int -> POSIXTime) . (read :: String -> Int) . BC.unpack $ bs
00:40 markus1189 joined
00:40 markus1199 joined
00:41 louispan joined
00:42 <tobiasBora> Hello,
00:42 <tobiasBora> I'd like to know, in this library:
00:42 <tobiasBora> https://hackage.haskell.org/package/parallel-io-0.3.3/docs/Control-Concurrent-ParallelIO-Local.html
00:43 <tobiasBora> if I compile with -thread, run it with +RTS -N4, but put withPool 1000, will I have indeed 1000 threads shared on 4 cores?
00:46 <ertes> tobiasBora: most likely it will create 1000 *haskell threads*
00:46 <ertes> those don't correspond directly to OS threads
00:46 <tobiasBora> ertes: the lightweight efficient threads right
00:47 <ertes> yes
00:47 <ertes> but if you give it 4 capabilities, then it will most likely use 4-5 OS threads
00:47 <ertes> (might be 5, if you have FFI workload)
00:47 acidjnk22 joined
00:48 <tobiasBora> so they are supposed to be better than OS threads if I use in addition the -N option, it's multicore, so OS threads are useless right?
00:48 theDon_ joined
00:49 <Jinxit> is it possible to tell earley to grab *all* occurances matching a pattern in a row? so "aa" can't be split into ["a", "a"] and ["aa"]
00:50 govg joined
00:50 muesli4 joined
00:53 theOtherAdam joined
00:53 Guest34681 joined
00:53 deepfire joined
00:56 epsilonhalbe joined
01:00 dawehner joined
01:02 kolmodin joined
01:02 dawehner joined
01:03 ClaudiusMaximus joined
01:03 xcmw joined
01:05 dawehner joined
01:06 systadmin joined
01:06 <ertes> tobiasBora: no
01:06 whiteline joined
01:07 <ertes> tobiasBora: haskell threads are mapped to OS threads, the idea being that you can use threads as an *abstraction* (e.g. having a bunch of threads for each client) without the abstraction ruining your performance
01:08 <tobiasBora> Yes ok
01:08 <tobiasBora> Thank you7
01:08 <ertes> example: you create 100 haskell threads, each doing a blocking read on a socket, and you run your program with 4 OS threads
01:08 <Sornaensis> does that differ from using say pthreads in C++
01:08 <Sornaensis> ..?
01:08 <ertes> then what your program will actually do is 4 OS threads, each doing an epoll on 25 sockets
01:09 <ertes> yes, of course
01:09 <ertes> with pthreads you will have to do this epoll stuff yourself
01:10 <tobiasBora> ok thank you
01:10 <Sornaensis> ertes: neat
01:10 <tobiasBora> And another question linked with threads
01:10 <tobiasBora> Let's say that haskell gives 10ms by thread
01:11 <tobiasBora> If some threads are waiting for an answer (from internet download for example)
01:11 <tobiasBora> Will the process spend 10ms also on the threads that are just waiting for an answer?
01:12 carlosdagos joined
01:12 <ertes> no, blocking is always translated into some kind of OS waiting mechanism, on linux most likely epoll
01:13 <ertes> as long as your thread is blocked, it doesn't run at all
01:13 euler2323 joined
01:13 <parsnip> ah, Aeson has stuff for NominalDiffTime, which is... "equivalent"
01:14 <ertes> tobiasBora: i highly recommend The Book
01:14 <ertes> tobiasBora: http://chimera.labs.oreilly.com/books/1230000000929/
01:15 <parsnip> but it won't take it as a string, i guess easiest thing to do will be to convert them after the fact, or...
01:15 <ertes> tobiasBora: but as a rule of thumb you can generally expect the RTS to do The Right Thing
01:15 <parsnip> try making my own instance
01:16 ebzzry joined
01:16 Supersonic112_ joined
01:18 dawehner joined
01:18 jkay joined
01:19 Conjecture joined
01:19 <Conjecture> What are those ticks marks used for? `
01:19 jkay left
01:19 hexagoxel joined
01:21 <glguy> Conjecture: backticks allow you to turn a variable or constructor into an operator
01:21 stevebash joined
01:21 epsilonhalbe left
01:21 <glguy> x `f` y is f x y
01:22 jkay_ joined
01:23 <glguy> Going the other way you can surround an operator symbol in ()s to use it as a normal identifier (not infix)
01:23 <glguy> x + y is (+) x y
01:23 dawehner joined
01:23 <Conjecture> werid
01:23 <Conjecture> weird*
01:24 FreeBirdLjj joined
01:25 <glguy> That can be useful in cases like: f (+) (-) -- supposing you wanted to apply f to the addition and subtraction functions
01:25 jkay__ joined
01:26 dawehner joined
01:26 <Conjecture> For some reason this reminds me of Lojban
01:26 <Conjecture> f 1 2 3 4 5
01:26 <Conjecture> 1 `f` 2 3 4 5
01:27 <phz_> hey, I’m looking for a way to subtract two dates and have a Date back so that I can see how much days, months and so on are between the dates
01:27 <phz_> is there something like that available?
01:27 <phz_> or I need something that exposes a system date?
01:27 <glguy> Conjecture: If you write that it means: f 1 (2 3 4 5)
01:27 <glguy> note that 2 is being used as a function
01:27 drewr joined
01:28 <glguy> Instead you can write: (1 `f` 2) 3 4 5
01:28 <glguy> which means f 1 2 3 4 5
01:28 <Conjecture> Where all of those values are parameters?
01:28 <zcourts> When you use foreign import ccall "dynamic" do you still need to call freeHaskellFunPtr? The FunPtr docs says its needed for foreign import ccall "wrapper" but it's not clear to me if both "wrapper" and "dynamic" require this
01:29 jkay joined
01:31 dawehner joined
01:32 jkay joined
01:33 jkay joined
01:33 <glguy> zcourts: dynamic wrappers don't allocate anything, there'd be nothing to free
01:33 <Conjecture> glguy, Sorry, I was just a little lost when you wrote (1 `f` 2) 3 4 5
01:34 dawehner joined
01:34 jkay_ joined
01:34 zar joined
01:34 <glguy> > let three x y z = (x,y,z) in (1 `three` 2) 3
01:34 <zcourts> glguy: Thanks for confirming that
01:34 <lambdabot> (1,2,3)
01:35 jkay joined
01:35 <Conjecture> Thanks glguy
01:35 tomboy64 joined
01:35 qqq123 joined
01:36 <Sornaensis> :t (,,) 1 2 3
01:36 <lambdabot> (Num c, Num b, Num a) => (a, b, c)
01:37 dawehner joined
01:39 <Sornaensis> :t (,) . (,)
01:39 <lambdabot> a -> b1 -> (b -> (a, b), b1)
01:39 <Sornaensis> :t (,) (,)
01:39 <lambdabot> b1 -> (a -> b -> (a, b), b1)
01:39 MP2E joined
01:39 badlands joined
01:40 <Sornaensis> how does haskell define pairs
01:41 dfeuer joined
01:41 mvr_ joined
01:41 ziyourenxiang joined
01:41 <Welkin> pairs?
01:41 <Welkin> you mean a tuple?
01:42 <Welkin> data Tuple a b = Tuple a b
01:42 <Welkin> where Tuple has special syntax using (,)
01:42 <Welkin> data (,) a b = (,) a b
01:43 agrif left
01:43 cmsmcq joined
01:44 {emptyset} joined
01:44 <Sornaensis> Welkin: how does haskell do arbitrary tuples
01:44 dawehner joined
01:44 <Sornaensis> or is there a limit
01:44 <Sornaensis> :t (,,,,,,,,,,,,,)
01:44 <parsnip> if i need a new Date for Aeson so that i can take in a string from JSON (not a number) and convert it to NominalDiffTime, will i be using Data, Type or NewType?
01:44 <lambdabot> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
01:44 <Sornaensis> :t (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
01:44 <lambdabot> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> t28 -> t29 -> t30 -> t31 -> t32 -> t33 -> t34 -> (a, b, c, d, e, f,
01:44 <lambdabot> g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t28, t29, t30, t31, t32, t33, t34)
01:44 <glguy> Sornaensis: There's a limit
01:45 <ahihi> :t (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
01:45 <lambdabot> error:
01:45 <lambdabot> A 63-tuple is too large for GHC
01:45 <lambdabot> (max size is 62)
01:45 <Sornaensis> so tuples are magic syntax?
01:45 <glguy> Sornaensis: The report requires at least 15-tuples, GHC supports up to 62-tuples
01:45 peterbec` joined
01:45 <glguy> Tuple syntax is baked into the language
01:45 <Sornaensis> is there a file that defines (,) as a constructor
01:46 <Conjecture> On another note, how would I make a mutable list?
01:46 <Conjecture> Containing mutable floats
01:47 <robkennedy> Yes. But I don't think it's particularly special, except for it's interaction with ie (~1,True~)
01:47 <Conjecture> I should say, a list containing mutable floats
01:47 Rodya_ joined
01:47 <Sornaensis> ..mutable list?
01:47 <robkennedy> A non mutable list containing mutable floats is probably just a lost
01:47 araujo joined
01:47 araujo joined
01:48 <Sornaensis> there are several monads that allow ''mutable'' lists
01:48 <Sornaensis> or mutable references to lists
01:49 dawehner joined
01:49 <Conjecture> My goal for program number two is: load image (with a library), apply a DCT transform to the samples, add that up to zero and divide by (highest value / 255) and save that to an image
01:51 doodlehaus joined
01:51 <Conjecture> Thanks Sornaensis
01:51 exferenceBot joined
01:51 hexagoxel joined
01:51 ChaiTRex joined
01:52 dawehner joined
01:52 Rizy joined
01:53 ali_bush joined
01:53 ali_bush joined
01:53 xcmw joined
01:56 badlands joined
01:57 dawehner joined
01:59 robertkennedy joined
02:00 systadmi1 joined
02:00 eacamero_ joined
02:00 hucksy_ joined
02:02 dawehner joined
02:03 farrioth joined
02:03 pyx joined
02:04 dawehner joined
02:06 systadmin joined
02:07 drewr joined
02:08 Fairy joined
02:09 shayan_ joined
02:09 xtreak joined
02:15 dawehner joined
02:17 dawehner joined
02:19 justicefries left
02:20 dawehner joined
02:21 Xanather joined
02:23 dawehner joined
02:25 <parsnip> Aeson takes Number to UTCTime, but i need to take Text to UTCTime. i have a function that will do it, but i'm not sure how i can write a new instance of FromJSON and parseJSON. can i use newtype, type, data?
02:26 exferenceBot joined
02:27 raycoll joined
02:27 sellout- joined
02:27 <parsnip> getDate :: T.Text -> UTCTime; getDate t = posixSecondsToUTCTime . fromIntegral . go . decimal $ t where go (Right (n, _)) = n
02:28 dawehner joined
02:30 tromp joined
02:30 hexagoxel joined
02:30 dawehner joined
02:31 <Jinxit> is there a `foo` so that `foo <$> "a" <*> "b"` returns `["a", "b"]`? i feel like i'm missing something simple here
02:31 caconym joined
02:32 <muesli4> Jinxit: What do you mean by "returns"? In the sense of "pure"? Because if you mean equals then no.
02:33 dawehner joined
02:33 <Jinxit> in the sense of pure i think
02:34 <Jinxit> i'm not sure tbh
02:35 jmcarthur joined
02:35 <muesli4> Jinxit: Well in the sense of "pure" choose foo a b = [a, b], but I don't think that is what you meant.
02:36 dawehner joined
02:36 systadmin joined
02:37 Rainb joined
02:37 dddddd joined
02:37 e14 joined
02:38 caconym joined
02:38 dawehner joined
02:41 dawehner joined
02:41 ddere joined
02:41 <Jinxit> i'm using earley to parse, so let's say i have `some token 'a'` (:: Prod r e t [t], where Prod is Applicative r e t) and `some token 'b'`. i want to run these two in sequence and put the result of both in a list, in order
02:41 <Jinxit> muesli4: ^
02:43 <muesli4> Jinxit: I don't know that lib, but what's the issue with ['a', 'b'] <* (token 'a' *> token 'b') ?
02:45 <Jinxit> that doesn't typecheck
02:47 <muesli4> Jinxit: works perfectly fine for a generic applicative
02:47 safe joined
02:47 caconym joined
02:50 <Jinxit> oh i see what you're doing now, but that's not what i want, i want the outputs of the `token x` functions
02:50 <Jinxit> this just discards them and returns "ab"
02:50 <Jinxit> i probably typed that wrong
02:51 <muesli4> Jinxit: Then just use (\x y -> [x, y]) <$> tokenX <*> tokenY
02:52 <Jinxit> no way to do it without explicitly typing x, y, z, w, etc?
02:52 <Jinxit> if there's more than two
02:52 TCZ joined
02:52 <glguy> sequence
02:53 <glguy> or sequenceA to avoid the Monad constraint
02:53 <glguy> sequenceA [tokenX, tokenY], for example
02:54 e14 joined
02:55 caconym joined
02:55 Jeanne-Kamikaze joined
02:57 <Nolrai> Does anyone have an idea why vi's syntax highLighter for haskell would color "if", "else", and "then" a different color then all other keywords?
02:57 <Nolrai> Or where I should ask?
02:59 markasoftware joined
03:00 <Jinxit> glguy: thanks, exactly what i was looking for, but sadly not what i needed in the end :p
03:00 <glguy> Nolrai: because it the syntax highlighting file is defined that way
03:01 <Nolrai> Right..let me find that. Been a while since I messed with my vi.
03:01 conal joined
03:02 peterbec` joined
03:03 <Nolrai> (I wonder if I can get atom working on windows..last time I tried things kept breaking.)
03:07 mson joined
03:08 e14 joined
03:10 ebzzry joined
03:12 <parsnip> Nolrai: same color as `where` ? works this way on emacs too.
03:13 carlosdagos joined
03:13 <parsnip> same color as strings here too
03:13 <Nolrai> 'where' is the normal keyword color on mine.
03:14 <Nolrai> Just need to find that syntax file.
03:14 systadmin joined
03:14 beerdrop joined
03:15 <parsnip> Nolrai: can you install ranger? maybe with cygwin.
03:16 <Nolrai> What's ranger?
03:16 sypwex joined
03:16 pavonia joined
03:16 <parsnip> a file explorer that helps browse through directories pretty fast, hjkl keys
03:17 jao joined
03:17 <systadmin> lol, Vim-style file explorer
03:18 sypwex left
03:18 Welkin joined
03:18 <parsnip> it's probably in ~/.vim/.../haskell.syntax or something
03:19 <parsnip> fsvo ~ on Windows
03:22 systadmin joined
03:22 ehsanullahjan joined
03:23 sypwex joined
03:23 sypwex left
03:23 hvn0413 joined
03:24 wtetzner joined
03:29 sypwex_ joined
03:31 sypwex joined
03:32 sypwex left
03:32 eacameron joined
03:33 torgdor joined
03:37 MindlessDrone joined
03:37 robkennedy joined
03:37 mizu_no_oto joined
03:37 ryandevilla1 joined
03:38 takle joined
03:38 felixsch__ joined
03:39 sypwex joined
03:39 sypwex left
03:40 spatial joined
03:40 sypwex joined
03:40 sypwex left
03:41 <spatial> fast-logger for logging. Are there examples ?
03:48 sssilver joined
03:49 <spatial> Didn't find it in fast-logger git.
03:50 caconym joined
03:52 <Nolrai> I am on this weird fake linux on windows so finding the right file can be weird. But it lets me use something that feels like the linux comand line so I am happy.
03:53 Blkt joined
03:53 mizu_no_oto joined
03:57 otto_s_ joined
03:57 c137 joined
03:59 takle joined
04:01 hybrid joined
04:01 dylukes joined
04:01 caconym joined
04:03 splanch joined
04:05 <adlaistevenson> noraesae: cygwin?
04:05 badlands joined
04:10 <dmwit> Nolrai: `locate syntax/haskell` finds the appropriate file (and only a few others) on my machine.
04:11 {emptyset} joined
04:11 nomotif joined
04:12 jchia_ joined
04:13 connrs joined
04:15 sssilver joined
04:17 takle joined
04:18 <spatial> What is the simplest file logging utility ?
04:19 <dmwit> What is file logging?
04:20 <dmwit> Never mind. I'm pretty sure I won't know the answer even after you clarify. =P
04:22 systemfault joined
04:23 systemfault joined
04:25 <spatial> Logging to a log file.
04:26 uve joined
04:26 descender joined
04:27 <spatial> Do haskell programmers step through the code or write log to file to debug ?
04:27 sssilver joined
04:27 takle joined
04:27 <ertes> spatial: log to stderr
04:28 <spatial> trace etc.are not useful in this case. It is a Machine Learning problem. Runs for a long time.
04:28 <glguy> Make sure you replant after you log
04:29 <glguy> clear cutting isn't good for anyone
04:29 <spatial> Sure :-)
04:30 <ertes> spatial: you will probably need logging as part of the actual application as well
04:30 <ertes> not just for debugging
04:31 <ertes> abstract the learning algorithm to support logging
04:31 <ertes> before: learn :: Context -> Samples -> Model
04:32 Xanather joined
04:32 <ertes> after: learn :: (Monad m) => Logger m -> Context -> Samples -> m Model
04:32 <spatial> Learning Haskell. So logging isn't as simple as I thought.
04:33 <ertes> where: type Logger m = String -> m ()
04:33 <dmwit> later: learn :: LearnArgs m -> m Model
04:34 <spatial> Can't replace printf with a API call ?
04:34 <ertes> spatial: which part trips you up?
04:35 <spatial> My code is finished and seems to work. Except that I need to stop scrolling printfs and write to a file.
04:35 <dmwit> :t hPrintf
04:35 <lambdabot> HPrintfType r => GHC.IO.Handle.Types.Handle -> String -> r
04:35 <ertes> spatial: ./myprogram > file
04:35 <ertes> or in the case of stderr: ./myprogram 2> file
04:35 <dmwit> There can certainly be a reasonable difference between a logging stream and stdout or stderr.
04:36 <dmwit> Heck, lots of programs want multiple logging streams.
04:36 <ertes> yeah, and i have no idea why
04:36 <dmwit> I think the impulse to do it right is admirable. I just don't know much about the library ecosystem for this stuff.
04:37 rizary joined
04:37 <dmwit> I do know printf should be easy to swap out for hPrintf, though. =)
04:37 <pharaun> ls
04:37 <pharaun> wrong terminal :O
04:37 <spatial> Let me try stderr
04:37 <dmwit> spatial: Why not use a file?
04:38 eklavya joined
04:38 <ertes> because stderr can be redirected to a file
04:38 systadmin joined
04:38 <dmwit> stderr for logging is not the usual convention.
04:38 <dmwit> stderr is for errors.
04:39 <ertes> the usual convention is to use syslog, and that's a terrible convention
04:39 <ertes> log to stderr!
04:40 <spatial> ertex: ./myprogram > file ??
04:40 APic joined
04:40 <spatial> Redirect to file.
04:40 xtreak joined
04:40 <dmwit> `>file` redirects stdout to a file. `2>file` redirects stderr to a file.
04:41 <dmwit> `3>file` redirects file handle 3 to a file. I bet you can guess the pattern from there. =P
04:41 <spatial> I mean I know that :-) Thought log frameworks are common in Haskell.
04:41 <dmwit> Yes, I think there are several on Hackage.
04:42 <spatial> Seems Haskell just works. No need for debugging or logging.
04:42 <ertes> why is writing to stderr not logging to you?
04:42 <dmwit> Hm. Haskell is nice, and prevents a lot of problems early. But I can personally attest that it is still common to write bugs in Haskell programs.
04:43 <ertes> my "logging framework" involves passing a (String -> IO ()) around
04:43 <spatial> ertex: Don't know about Haskell. But logging is different.
04:43 <ertes> and that function is (hPutStrLn stderr) most of the time
04:43 eacameron joined
04:44 <ertes> myAction log = do …; log "message"; …; log "message 2"; …
04:44 <ertes> sometimes with logging levels
04:44 <ertes> but most of the time i don't need them
04:44 fizbin1 joined
04:45 <spatial> I wrote a logger framework for a 24x7 scheduling/File transfer system processing MasterCard/Visa transactions. Java though.
04:46 <dmwit> I am so confused about your goals now. You've asked for logging suggestions. We've given several to choose from. What more are you hoping for? Why do you persist in demanding that Haskell does not have logging?
04:46 <spatial> They are used for forensic evidence.
04:47 <ertes> spatial: i can understand that you would need that in java, because java doesn't support abstraction
04:47 <dmwit> what
04:47 <spatial> dmwit: I am just learning Haskell. Know that there are framework like fast-logger.
04:47 <ertes> but in haskell a "logging framework" is a matter of passing a function around
04:47 cyborg-one joined
04:47 raycoll joined
04:48 <ertes> dmwit: (i'm being sarcastic, but indeed java still lacks proper support for functions)
04:48 Autolycus joined
04:49 <spatial> I run in Spacemacs. So I thought it isn't hard to include log calls.
04:50 <ertes> spatial: how is your editor related to this? please explain what you mean by "logging framework"
04:51 Rizy joined
04:51 <spatial> ertes: It isn't. I failed to understand that the signatures change when you log calls. Right ?
04:51 <ertes> spatial: well, logging usually involves effects
04:52 <dmwit> ertes: I checked out of the conversation. It seems like at least one party is not acting in good faith.
04:52 <spatial> Yes. That was the confusion. Couldn't change them. As my Haskell knowledge isn't up to the mark.
04:53 <ertes> spatial: let's say that your current function signature is this: learn :: Context -> Samples -> Model
04:53 <ertes> it takes a context (e.g. configuration), samples and returns a trained model
04:53 fakenerd joined
04:53 jkay joined
04:53 <ertes> spatial: good so far?
04:54 fizbin joined
04:54 robertkennedy joined
04:55 BartAdv joined
04:55 <spatial> Ok This example http://lpaste.net/353936. Not really functional. Seems to go on infinitely. So I wanted logging.
04:55 uv4smt joined
04:55 splanch joined
04:55 takle joined
04:56 <ertes> ok, i'll just take your example
04:56 <ertes> now logging could be as simple as using hPutStrLn, e.g. you could write this on line 3: hPutStrLn stderr "My message"
04:57 jkay left
04:57 caconym joined
04:57 <spatial> And then redirect to file.
04:58 <ertes> yes, exactly… BTW, i see a few printfs in there… printf writes to stdout, which you can redirect as well
04:58 paulsh94 joined
04:58 <ertes> (but you should rather use stdout for results, not for diagnostics)
04:59 <spatial> Right. Let me check.
04:59 maarhart joined
05:01 dfeuer joined
05:02 <ertes> spatial: however, this approach is not very flexible, because you couldn't disable logging, for example, or control the amount of logging that you want
05:02 <ertes> or even log to multiple places
05:02 <spatial> But that was my question.
05:02 <ertes> that's why you may want to abstract over the logging action
05:03 <ertes> current signature: gameplan :: IOArray Int Double -> BoardState -> BoardState -> IO (IOArray Int Double, BoardState, Double)
05:03 <ertes> new signature: gameplan :: (String -> IO ()) -> IOArray Int Double -> BoardState -> BoardState -> IO (IOArray Int Double, BoardState, Double)
05:04 <ertes> now gameplan takes a function as its first argument that does the actual logging
05:04 <spatial> Ok
05:04 deepfire joined
05:04 <ertes> gameplan log a state newstate = do …; log "message"; …
05:04 <ertes> instead of:
05:04 <ertes> gameplan a state newstate = do …; putStrLn "message"; …
05:04 <ertes> you can still use printf
05:05 <ertes> gameplan log a state newstate = do …; log (printf "format" x y z); …
05:05 <spatial> It is a side-effect one introduces.
05:06 <spatial> And that log function is from where ? Framework.
05:06 <dmwit> nah
05:06 <dmwit> just `hPutStrLn myFileHandle`
05:06 <ertes> when you apply 'gameplan' you hand it a logging action
05:06 <dmwit> or whatever
05:07 <ertes> for example previously you said: gameplan x y z
05:07 <ertes> now you say (gameplan putStrLn x y z), and it will log to stdout
05:07 electrostat joined
05:07 <ertes> you say (gameplan (hPutStrLn stderr) x y z), and it will log to stderr
05:07 <ertes> you say (gameplan (hPutStrLn h) x y z), and it will log to file handle h
05:07 <ertes> you say (gameplan (\_ -> pure ()) x y z), and it will not log at all
05:08 <spatial> Ah! Makes sense
05:10 dylukes joined
05:12 <dmwit> I guess that was enough Haskell for him for today. =P
05:13 <ertes> i may have been a bit too harsh at the beginning =)
05:14 carlosdagos joined
05:16 uv4smt joined
05:16 <ertes> i'm highly opinionated when it comes to these things, but i can explain: there is a bigger picture involved, a masterplan if you will, a goal worth fighting for
05:17 brynedwardz joined
05:18 <ertes> defeat the disease that is known as systemd, destroy syslog along the way, bring back solid design, but with modern knowledge =)
05:18 <adlaistevenson> ertes: Build a wall around SystemD and PulseAudio, jail Pottering
05:18 sleffy joined
05:19 <adlaistevenson> And put Rob Pike in charge of restoring UNIX
05:19 <dmwit> I like pulse. It seems like it's the first audio system that actually got the right idea.
05:19 <ertes> i don't mind pulse that much
05:19 <Sornaensis> what's wrong with systemDick
05:19 <dmwit> I don't know enough about init systems to have an opinion on systemd other than "it's worked ok for me" and "the documentation was good enough to help me out when it broke".
05:20 <dmwit> But pulse I strongly support.
05:20 <Sornaensis> systemD unit files are a godsend
05:20 bjz_ joined
05:21 <ertes> dmwit: it's a mess of monolithic design and global mutable state, and it really wants your system hierarchy to be as flat as possible
05:21 <ertes> no supervision trees, no logging trees, etc.
05:21 mk-fg joined
05:21 mk-fg joined
05:23 <adlaistevenson> Torvalds must hate SystemD
05:24 <adlaistevenson> Torvalds at his best: https://lkml.org/lkml/2012/12/23/75
05:25 <ertes> at the same time it's completely unpredictable what will be the next thing that systemd wants to devour… a while ago i noticed that rsyslogd stopped writing logs, which completely baffled me, until i found it that systemd had taken control over the syslog socket and prevented all other programs from getting log messages by default
05:25 <ertes> because it really wants to sell its "journald" system
05:25 fizbin1 joined
05:26 badlands joined
05:28 <adlaistevenson> ertes: Eww
05:28 <Myrl-saki> http://ix.io/pgt
05:28 <Myrl-saki> How do I make that not consume 10GB of my RAM?
05:28 <rotaerk> remove some RAM
05:28 <rotaerk> I mean ..
05:28 <Myrl-saki> rotaerk: Makes sense.
05:29 meandi_2 joined
05:29 <ertes> Myrl-saki: make 'fibs' local to 'isFib'
05:29 araujo joined
05:29 <ertes> isFib = flip elem fibs where fibs = …
05:29 <adlaistevenson> rotaerk: Or use ulimit
05:29 xtreak joined
05:30 <Myrl-saki> ertes: Didn't work.
05:30 <Myrl-saki> With -O3.
05:30 takle joined
05:30 <dmwit> ertes: may also need to eta expand
05:30 <Myrl-saki> And -O2, just for safe measure.
05:30 <dmwit> GHC *loves* floating CAFs
05:30 <ertes> yeah, indeed
05:31 <ertes> Myrl-saki: make 'fibs' take a start value
05:31 <ertes> fibs x0 = x0 : 1 : …
05:31 <dmwit> But like... we're only going up to 10^3 = 1000 here.
05:31 <dmwit> This shouldn't take 10GB of RAM even if everything stays in memory.
05:31 <dmwit> Oh!
05:31 <dmwit> I know.
05:31 <ertes> dmwit: the numbers grow quickly
05:31 <dmwit> no
05:31 <ertes> although 10 GB is still a lot
05:31 <dmwit> That's not the problem.
05:31 <dmwit> The problem is `elem` is totally the wrong function to use. =)
05:32 <Myrl-saki> dmwit: I mean, sure.
05:32 <ertes> dmwit: is it? it consumes strictly
05:32 <dmwit> Myrl-saki: Use this instead: http://hackage.haskell.org/package/data-ordlist-
05:32 <Myrl-saki> dmwit: But I'd rather not spend more than 1 minute on something that I found on a book. :P
05:32 <Myrl-saki> Ohhh
05:32 <dmwit> ertes: It will never return False!
05:32 <Myrl-saki> Oh wait
05:32 <Myrl-saki> You're right. .-.
05:32 kattak joined
05:33 <dmwit> Myrl-saki: (Of course, even better would be `length . takeWhile (<10^x) $ fibs` and forget this `isFib` thing entirely.
05:33 <dmwit> )
05:33 <ertes> oh, of course
05:33 <ertes> Myrl-saki: you still need to make fibs parametric though, otherwise it will be shared
05:34 <dmwit> Who cares. We're only sharing like a dozen Integers. =P
05:34 <ertes> sharing means that the list will actually be computed
05:34 <Myrl-saki> Might increase this later.
05:34 <Myrl-saki> http://hackage.haskell.org/package/data-ordlist-
05:34 <ertes> dmwit: that's *much* slower than recomputing them, even at this size
05:34 <Myrl-saki> Whoops
05:34 <Myrl-saki> I don't have nvim nor vim.
05:34 <dmwit> > let fibs = 0:1:zipWith (+) fibs (tail fibs) in length . takeWhile (<10^3) $ fibs
05:34 <lambdabot> 17
05:35 <dmwit> ertes: Not sure bare-metal performance is really a need for this toy...
05:35 <Myrl-saki> http://hackage.haskell.org/package/data-ordlist-
05:35 <Myrl-saki> FFS
05:35 <Myrl-saki> isFib x = (== x) . head . dropWhile (<x) $ fibs
05:36 <dmwit> Myrl-saki: Yes, that looks more plausible.
05:36 <dmwit> And is roughly what the proposed `member` does, as well.
05:36 <Myrl-saki> dmwit: Mhm.
05:37 <dmwit> Myrl-saki: But why `filter isFib [1..10^x]` instead of `takeWhile (<=10^x) fibs`?
05:38 araujo joined
05:38 <dmwit> I guess you get an extra `0` and `1` at the beginning -- is that such a bad thing? It's easy enough to fix...
05:38 <Myrl-saki> I honestly didn't think of that. <.<
05:39 <ertes> dmwit: because most protoductions started as toys =)
05:39 bjz joined
05:39 <ertes> look at PHP
05:40 <* dmwit> looks forward to the grand deployment of Web 2.0 Fibonacci Server
05:40 <Myrl-saki> ...I'm honestly quite surprised.
05:40 <Myrl-saki> It takes less than a second even with 10^7.
05:40 <Myrl-saki> Heck, 10^9.
05:41 <Myrl-saki> main = print $ [length $ takeWhile (<= 10^x) fibs | x <- [1..12]]
05:41 <ertes> Myrl-saki: i would expect it to start getting slow at around 2^25
05:41 <ertes> perhaps 2^30
05:41 <Myrl-saki> I'm starting to think that maybe my code is wrong.
05:41 <Myrl-saki> But nope, it's not.
05:41 <dmwit> Nah. Computers are just really, really good at arithmetic.
05:42 <Myrl-saki> Oh wait.
05:42 xtreak joined
05:42 <Myrl-saki> dmwit: Makes sense.
05:42 <mrjake> I'm running into the classic ambiguous type variable problem, but I'm not sure how to fix it. (result, _, _) <- runMultiRWST HNil HNil ... HNil is the empty constructor for Data.HList.HList Am I supposed to add a type signature or something?
05:42 <Myrl-saki> dmwit: Branch prediction loves these kind of stuff.
05:42 <Myrl-saki> Yep, even 10^20. TIL.
05:42 <dmwit> > let fibs = 0:1:zipWith (+) fibs (tail fibs) :: [Integer] in fibs !! (2^16)
05:43 <lambdabot> 7319921446029055283263991581259845453895242583621989356847594492012862286674...
05:43 <dmwit> > let fibs = 0:1:zipWith (+) fibs (tail fibs) :: [Integer] in length (show (fibs !! (2^16)))
05:43 <lambdabot> 13696
05:43 <Myrl-saki> Oh cool. Another reason. fibonacci numbers grow quickly.
05:43 <ertes> Myrl-saki: you can probably ramp it up to 10^100
05:43 <dmwit> That's 10^13696, and fits in \bot's time window. So... yeah.
05:44 <dmwit> mrjake: Yes, you are supposed to add a type signature. Which type signature you need is hard to say without further details.
05:44 <Myrl-saki> Now I'm interested in `fibs !! (fibs !! x)`
05:44 <mrjake> dmwit: Ok. I'll give it a try.
05:44 ebzzry joined
05:44 <Myrl-saki> ertes: Works FastEnough even for 10^1000.
05:45 <Myrl-saki> And 10^10000 takes about 5 seconds.
05:45 <ertes> Myrl-saki: at around 2^21 elements you start seeing numbers with millions of binary digits, so at that point each number will need megabytes of RAM
05:46 <ertes> that's 10^430000
05:47 <Myrl-saki> ertes: Trying now.
05:47 <ertes> depending on your architecture that's the point when your caches become too small and you will see a sudden massive increase in computation time (most of which is waiting for memory transfers)
05:47 <dmwit> amazing what happens when you switch away from on O(\infty) algorithm
05:47 <Myrl-saki> Maybe I should have made this in parallel?
05:48 <dmwit> That depends dearly on your goals.
05:48 <Myrl-saki> But that may also mean more cache problems.
05:48 Deide joined
05:48 <adlaistevenson> Is fibonacci associative?
05:48 <Myrl-saki> ertes: For a point of reference, I'm trying out 10^100000.
05:49 eazar001 joined
05:49 <dmwit> adlaistevenson: Fibonacci is unary. So I don't think the question is even well-typed.
05:50 <Myrl-saki> ./Nyeh 0.95s user 0.00s system 99% cpu 0.952 total
05:50 <Myrl-saki> ./Nyeh 3.82s user 0.04s system 99% cpu 3.869 total
05:50 <Myrl-saki> Exponential?
05:50 <Myrl-saki> 300k should be about 16.
05:51 <Myrl-saki> Err..
05:51 <Myrl-saki> Ah, 2^x/100k.
05:51 <Myrl-saki> ./Nyeh 7.83s user 0.12s system 99% cpu 7.964 total
05:52 <Myrl-saki> Well, something weird happened. 400k gets 15s and 500k gets 24s.
05:53 yogsotot_ joined
05:53 <Myrl-saki> And 600k gets 36s.
05:54 <Myrl-saki> What's interesting is that it didn't notably increase in memory consumption.
05:54 ichor joined
05:54 <dmwit> Yes, I expect it is very friendly to the GC.
05:54 <* geekosaur> wonders what happens with +RTS +B
05:55 <geekosaur> heh
05:55 <adlaistevenson> dmwit: How to do Fibonacci with a cache, so we can take closest precalculated value
05:55 fizruk joined
05:55 <Myrl-saki> geekosaur: How do I enable those flags?
05:55 <Myrl-saki> And what's +B?
05:55 <dmwit> geekosaur: Let's do the fork in the garbage disposal!
05:55 <geekosaur> beep on gc
05:55 <dmwit> ding ding ding da ding ding da ding ding
05:56 <kadoban> I had no idea that was an option, that sound both cool and horrible
05:56 <geekosaur> and you probably need -rtsopts
05:56 <Myrl-saki> lmao
05:56 <kadoban> sounds*
05:56 <* geekosaur> remembers snoop -a, speaking of cool and horrible
05:56 <geekosaur> (play network packets through the speaker)
05:57 <Myrl-saki> I apparently don't have +B
05:57 <Myrl-saki> :(
05:57 rizary left
05:58 <geekosaur> compile with -rtsopts?
05:58 <dmwit> Myrl-saki: You would compile your program like `ghc -rtsopts -O2 foo.hs` and run like `./foo +RTS +B`
05:58 <adlaistevenson> dmwit: ?
05:58 <geekosaur> you get only a small subset of rts options otherwise
05:58 rizary joined
05:58 <Myrl-saki> dmwit: Mhm.
05:58 <Myrl-saki> Nyeh: unexpected RTS argument: +B
05:58 <dmwit> adlaistevenson: Sounds like a fun puzzle. Let me know what you think up.
05:58 <geekosaur> ih I think I typoed
05:58 <adlaistevenson> Okay!
05:59 <geekosaur> -B
05:59 osa1 joined
05:59 osa1 joined
05:59 <adlaistevenson> :-)
05:59 <Myrl-saki> Glasgow Haskell Compiler, Version 8.0.1, stage 2 booted by GHC version 7.10.3
05:59 justanotheruser joined
05:59 <geekosaur> rts opts don't do +, except for +RTS itself
05:59 <Myrl-saki> I think I need to turn on audible beep.
05:59 <Myrl-saki> Okay.
06:00 <Myrl-saki> What terminal supports audible beep?
06:00 <geekosaur> oh, you have vbell? so instead of fork in the garbage disposal, it's epilepsy?
06:00 <Myrl-saki> geekosaur: lmao
06:00 systadmin joined
06:00 <Myrl-saki> geekosaur: I don't use vbell either.
06:00 <geekosaur> many of them do but you have to tweak settings
06:00 <geekosaur> for VTE-based terminals right click and look for something like "edit profile" or "profile preferences"
06:01 <Myrl-saki> urxvt has an .Xresources for it. Trying it out now.
06:01 <geekosaur> for xterm it's control-middle click and vbell on/off is somewhere in the middle section
06:02 dpepsilon joined
06:02 dpepsilon joined
06:02 <geekosaur> control-middleclick for urxvt as well
06:02 <geekosaur> visualBell
06:02 <Myrl-saki> holy cow
06:02 <Myrl-saki> I did not know about Control middle click
06:03 benl23 joined
06:03 <Myrl-saki> Now it looks like I'm using screen the whole time.
06:03 <Myrl-saki> Well... that was boring.
06:04 <Myrl-saki> It was just constant fg.
06:04 <Myrl-saki> Expected a disco.
06:04 splanch joined
06:04 razi1 joined
06:04 takle joined
06:07 psniper joined
06:08 bjz joined
06:08 hamishmack joined
06:10 <adlaistevenson> Languages with compilers that do type checking make me happy.
06:10 Rizy left
06:10 fizbin joined
06:11 <Myrl-saki> Now that that's done, back to real world stuff.
06:13 connrs joined
06:16 snowalpaca joined
06:19 raycoll joined
06:19 <ertes> Myrl-saki: if you're interested, i've written a benchmark for fib computation
06:19 <ertes> https://gist.github.com/esoeylemez/6e7c8214e0306b3653ca3d3a1e37104a
06:19 leat joined
06:20 <ertes> it computed fibs continuously and displays how long it takes and how big the numbers are getting
06:20 <ertes> needs the 'clock' library
06:21 <Myrl-saki> A little side question. If you using reflex-dom, is there a way to change the "pwd"(in the webpage sense), but without actually changing the webpage? Kind of like doing `https://example.com/a -> https://example.com#a`
06:21 <Myrl-saki> If you're*
06:21 arawack joined
06:21 psniper joined
06:21 <Myrl-saki> If I understand correctly, youtube does something like that.
06:22 <Cale> Myrl-saki: You'll want to do an FFI import of something, I don't believe we have anything in reflex-dom itself which manipulates the browser location.
06:23 takle joined
06:23 <Myrl-saki> Cale: Ah. Maybe I should just use one web page but have it all under `?location=...`?
06:23 <Myrl-saki> Oh wait, no, that still wouldn't work.
06:24 <Myrl-saki> I think the # works, though.
06:25 <Cale> We use ? arguments for some routing in some of our apps.
06:26 <Myrl-saki> Cale: Can you explain the details?
06:26 <cocreature> Myrl-saki: fwiw the js API you’re looking for is probably history.pushState
06:27 <Myrl-saki> cocreature: Not only for history, but also for link sharing.
06:28 <Cale> importJS Unsafe "window['location']['search']" "getWindowLocationSearch" [t| forall x m. MonadJS x m => m T.Text |]
06:28 <cocreature> Myrl-saki: I’m not sure what you mean by that. history.pushState changes the url displayed in your browser
06:28 <Cale> importJS Unsafe "window['history']['pushState'](1, null, $1)" "historyPushState" [t| forall x m. MonadJS x m => Text -> m () |]
06:28 splanch joined
06:28 fizbin1 joined
06:29 <Cale> That uses importJS from Foreign.Javascript.TH which you should find in reflex-dom
06:30 <Myrl-saki> cocreature: I guess that was too layman. Literally what it means. Link(or URL) and sharing it with someone else by copying and pasting.
06:31 <cocreature> Myrl-saki: you can just copy the url that your browser shows no? or do you want to add it to the clipboard via js. that is a different problem
06:31 <Myrl-saki> cocreature: Yep, my mistake. I didn't realize that it changes the display URL.
06:32 <Myrl-saki> I'll try it out now. Thanks.
06:33 boombanana joined
06:35 SpinTensor joined
06:37 takuan joined
06:38 ebzzry joined
06:38 takle joined
06:39 eklavya joined
06:39 eklavya joined
06:40 AndroUser joined
06:40 _ashbreeze_ joined
06:41 byorgey joined
06:41 byorgey joined
06:41 moet joined
06:47 eacameron joined
06:52 mkoenig joined
06:54 ali_bush joined
06:54 ali_bush joined
06:55 takle joined
07:01 mson joined
07:02 splanch joined
07:02 mrkgnao joined
07:09 MindlessDrone joined
07:09 eacameron joined
07:09 fizbin joined
07:10 [connor] joined
07:10 [connor] left
07:11 FreeBirdLjj joined
07:12 vlatkoB joined
07:12 xcmw joined
07:12 <Jello_Raptor> Is there a good way to find all the places where I call `show` on a type that won't force me to go through and temporarily nix the show instances of a gigantic pile of other types?
07:12 <Jello_Raptor> like marking it deprecated or something.
07:12 descender joined
07:13 [connor] joined
07:14 carlosdagos joined
07:15 <joneshf-laptop> Jello_Raptor, what are you trying to accomplish?
07:15 <joneshf-laptop> Forgive me for assuming, but your question sounds like a means to an end.
07:15 <Jello_Raptor> I'm making a change to a core type that means I have to lookup a description string from a table, rather than just pull it out of the type.
07:16 <Jello_Raptor> I want to find all the places where I use "show" on that type so I can replace it with a lookup that's actually useful.
07:17 fizbin1 joined
07:17 mdqtpt joined
07:17 <cocreature> you can’t mark instances or instance methods as deprecated so that doesn’t work
07:18 <cocreature> Jello_Raptor: but if you want to replace all places why can’t you temporarely delete the Show instance?
07:19 MoALTz joined
07:19 doodlehaus joined
07:20 <Jello_Raptor> cocreature: It would mean deleting the show instances of a huge pile of other types which isn't necessary and would be a huge pain
07:20 <cocreature> Jello_Raptor: ah right I forgot about that
07:21 <joneshf-laptop> Jello_Raptor, to make something concrete here, are you using the `Show` instance of your data type for pretty printing or formatting?
07:21 <dmwit> Why would it mean that? Don't those other `Show` instances also qualify as uses of `show` at this type?
07:21 <dmwit> (Hence should be replaced with a "useful lookup"?)
07:21 <joneshf-laptop> ^
07:22 MindlessDrone joined
07:24 eacameron joined
07:24 <Jello_Raptor> joneshf-laptop: debug output generally
07:24 mounty joined
07:24 jchia_ joined
07:24 <joneshf-laptop> Jello_Raptor, What I mean to say is that, if you're using the `Show` instance for pretty printing/formatting, you probably want a different function altogether. However, this new function doesn't need to conflict with the `Show` instance. I.e., use `show` when you need a `read`able string, and use this new function when you need pretty print/format.
07:25 <Jello_Raptor> dmwit: not really, the way I've structured my system the
07:26 <Jello_Raptor> dmwit: not really, the way I've structured my system the output will be reasonable regardless.
07:26 <joneshf-laptop> Jello_Raptor, Alternatively, could you hand-write a show instance that did what you wanted? Again, that's against the use case of `Show`, but if it's temporary, it's probably not a big deal.
07:26 <Jello_Raptor> joneshf-laptop: nope, what I need is a monadic operation
07:26 farrioth joined
07:27 takle joined
07:27 <ggVGc> don't we all
07:27 feuerbach joined
07:27 feuerbach joined
07:28 <joneshf-laptop> Jello_Raptor, nope to what? You can't have both `show` and another function? Or, you can't handwrite the `Show` instance?
07:29 <Jello_Raptor> I can't handwrite the show instance without some unsafe IO :/
07:29 <joneshf-laptop> Jello_Raptor, gotcha
07:29 <Jello_Raptor> since the nice names (rather than the tiny integer references) are stored in a state
07:30 <Jello_Raptor> and getting them back out is a monadic operation
07:30 <joneshf-laptop> Jello_Raptor, so, you don't know where you use `show`?
07:30 <joneshf-laptop> Jello_Raptor, Sorry, having a bit of trouble internalizing the problem.
07:30 <Jello_Raptor> joneshf-laptop: I'm looking for an easier to find all the uses for this one type, yes
07:30 <Jello_Raptor> easier way*
07:30 xmonader left
07:31 <joneshf-laptop> Jello_Raptor, also, what about nixing the instance and using `-fdefer-type-errors`? Wouldn't that give you a whole slew of warnings instead of failing at the first errors?
07:31 xmonader joined
07:31 <Jello_Raptor> oh, that might work
07:31 <joneshf-laptop> Or would you still only get the same number of warnings as you would've gotten errors originally?
07:32 <joneshf-laptop> Meaning, just the data types complaining about missing `Show` rather than at the `show` uses.
07:33 <nshepperd_> Remove the instance, mock out all the dependent instances with undefined, then all remaining errors will be lines you need to change
07:33 fizbin joined
07:35 <joneshf-laptop> nshepperd, I think the mocking part is what Jello_Raptor doesn't want to do.
07:35 <Jello_Raptor> nshepperd: reasonable enough, cool.
07:35 <Jello_Raptor> yeah, I'd rather not
07:36 <Jello_Raptor> but eh, I can deal vov
07:36 <MarcelineVQ> mock out?
07:36 connrs joined
07:36 <nshepperd_> Yeah. At least you don't have to delete them recursively, i guess
07:36 <joneshf-laptop> Wouldn't you still have a problem though?
07:37 <joneshf-laptop> If it's `data Foo = Foo ... deriving Show; data Bar = Bar Foo deriving Show` and you delete the `Show` for `Foo`, how do you mock that?
07:37 <MarcelineVQ> Jello_Raptor: idk exactly what you're doing but are you aware of https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#custom-compile-time-errors ?
07:37 <nshepperd_> It might be worth trying with -fdefer-type-errors though in case that works
07:38 ubsan_ joined
07:38 takle joined
07:39 <Jello_Raptor> MarcelineVQ: that looks like it's almost exactly what I want, just mock out the show instance with that and get the errors i need.
07:39 <nshepperd_> joneshf-laptop: instance Show Bar where
07:41 <Jello_Raptor> damn, it triggers errors in the derived show instances too
07:41 jchia_ joined
07:42 slomo joined
07:42 deepfire joined
07:43 <joneshf-laptop> How many dependent data types are we talking here?
07:43 <joneshf-laptop> Might be quicker to just bite the bullet.
07:43 <Jello_Raptor> yeah, I'm in the middle of it now
07:43 raichoo joined
07:44 <Jello_Raptor> probably ~ 50 or so
07:44 <Jello_Raptor> but at least they're mostly defined using `standalone deriving` so it's straightforward to comment them out.
07:45 takle joined
07:46 jchia_ joined
07:48 jchia_ joined
07:49 jchia_ joined
07:51 Kreest__ joined
07:56 fizbin1 joined
07:57 babyelephants joined
07:59 ali_bush joined
07:59 ali_bush joined
07:59 Sh4rPEYE joined
07:59 Vibor joined
08:00 <Vibor> Hi how can I use '.' or '$' to truncate a line like this : DM.appendDB fileName (makeUPTuple (argv !! 1) (argv !! 2 ++ "\n"))
08:01 <Vibor> I meant truncate parenthesis
08:01 <dmwit> appendDB file . makeUPTuple (argv !! 1) $ argv !! 2 ++ "\n"
08:02 <Vibor> dmwit: and is there a way to deal with parenthesis enclosing argv !! 1 ?
08:02 xtreak joined
08:02 <dmwit> Not with the standard library.
08:02 diegoksp joined
08:03 takle joined
08:04 <Vibor> So maybe this question looks stupid, but does it mean it's not always a bad haskell coding style if you have parenthsis around statements cuz cometimes they are just unavoidable?
08:04 <Vibor> dmwit:
08:05 <dmwit> Explicit parentheses are often the most readable style.
08:05 <MarcelineVQ> tons of people prefer parens over $
08:06 <Vibor> MarcelineVQ: really? I saw lots of references recommending getting rid of them for readability
08:06 babyelephants left
08:09 <ertes> Vibor: ($) makes code flat, so you lose a lot of visual structure… unless you restore it by a consistent style or layout, it's preferable to use parentheses
08:09 <MarcelineVQ> ultimately it's up to what you find most readable, anecdotally what I've noticed is that people starting out seem to use $ a lot, possibly due to reccomendations like you've encountered, but use it less as they gain experience.
08:09 <ertes> Vibor: there is one notable exception: associative functions
08:10 <ertes> 1 + 2 + 3 + 4
08:10 <ertes> f . g . h . i
08:10 <MarcelineVQ> I don't have any particular explanation for why this seems to happen, other than as you reason about function application more and also understand precedence $ is often redundant
08:11 <ertes> also "$" is pretty ugly, but that may be my PHP trauma talking =)
08:12 <Vibor> Indeed, not just $ chaining up parameters, I saw others prefer . to compose functions as well, maybe it makes their codes more "functional"
08:13 <dmwit> I prefer (.) to ($) for chaining.
08:13 <ertes> i find myself writing "(f . g . h) x" a lot, just to have a visual cue that somewhere down the line there is an argument following
08:14 <dmwit> In `foo . bar . baz $ quux`, I can extract `foo . bar . baz` as a function (or subterms of this). In `foo $ bar $ baz $ quux`, I cannot extract `foo $ bar $ baz` as a function because it means something significantly different.
08:14 <Vibor> dmwit: indeed
08:15 <ertes> Vibor: i think the important part is that (.) is associative, while ($) is not, so parentheses wouldn't even make a difference
08:15 <ertes> (f . g) . h = f . (g . h)
08:16 <Vibor> Another math lesson lol
08:17 <ertes> welcome to #haskell =)
08:17 <Vibor> I love it a lot so far :D
08:17 ziyourenxiang joined
08:18 fizbin joined
08:18 sagittarian joined
08:25 Copperis joined
08:25 Copperis joined
08:25 Yuras joined
08:28 takle joined
08:29 simukis__ joined
08:33 fizbin joined
08:34 simendsjo joined
08:38 marcopullo joined
08:40 fizbin joined
08:41 ragepandemic joined
08:42 takle joined
08:43 qqq123 joined
08:46 logicmoo joined
08:51 azahi joined
08:54 igniting joined
08:58 fizbin joined
08:59 zar joined
08:59 mmn80 joined
09:01 spaceships joined
09:01 prophile joined
09:01 <parsnip> the . are easier to visually scan for than the $, i find
09:02 robotroll joined
09:02 <parsnip> and the possibility to chop off the tail of f . g . h $ x is nice too
09:02 psniper joined
09:04 takle joined
09:05 fizbin joined
09:06 takle joined
09:07 boombanana joined
09:08 fizbin1 joined
09:12 Varis joined
09:14 thc202 joined
09:14 bungoman joined
09:15 fizbin joined
09:15 carlosdagos joined
09:16 deepfire joined
09:17 dawehner joined
09:19 ner0x652 joined
09:19 rfvizarra joined
09:23 fizbin joined
09:24 Kreest_ joined
09:25 phyrex1an joined
09:26 mda1 joined
09:27 arpl joined
09:27 orbifx joined
09:27 badlands joined
09:28 alanz joined
09:29 bbcue joined
09:29 killtheliterate joined
09:30 ddere joined
09:30 akopacsi joined
09:32 venkat24 joined
09:32 <venkat24> Is there an ideas page for Summer of Haskell yet? Will there be one?
09:33 ragepandemic joined
09:34 catsup joined
09:34 lachenmayer joined
09:34 catsup joined
09:39 castlelore joined
09:39 ebzzry joined
09:41 cpup joined
09:43 simendsjo joined
09:47 raibutera joined
09:48 caconym joined
09:48 geekosaur joined
09:52 connrs joined
09:52 inad922 joined
09:53 spacedog82 joined
09:55 albertus1 joined
10:01 mr_sm1th joined
10:06 eacameron joined
10:06 Vzox0102 joined
10:10 lukaramu joined
10:13 Sh4rPEYE joined
10:15 danvet joined
10:16 yellowj joined
10:16 dmiles joined
10:19 Berra joined
10:22 benl23 joined
10:22 splanch joined
10:24 systadmin joined
10:26 silver joined
10:27 bennofs joined
10:29 venkat24 joined
10:33 oish joined
10:34 ziyourenxiang joined
10:40 geekosaur joined
10:42 tomphp joined
10:48 xcmw joined
10:51 fizbin1 joined
10:55 <reactormonk> I'm experimenting with the code in the eff paper, however, it doesn't compile - http://lpaste.net/1875206206314774528
10:57 systadmin joined
10:57 tomboy64 joined
10:57 <int-e> reactormonk: that >>> should be >>= I guess?
10:58 mizu_no_oto joined
10:58 eacameron joined
10:58 <cocreature> isn’t it >=>?
10:59 <int-e> Right.
10:59 systadmin joined
11:00 <reactormonk> Ah, they call >>> kleisli composition, for whatever reason.
11:00 <Destol> /bye
11:00 osa1_ joined
11:01 <reactormonk> I guess defining an applicative instance is an exercise left to the reader.
11:01 fizbin joined
11:01 <cocreature> I hate it when papers use relatively common symbols but assign a different meaning to them
11:01 <cocreature> reactormonk: that’s easy "pure = return", <*> = ap
11:01 ryandevilla1 joined
11:02 initiumdoeslinux joined
11:02 <reactormonk> cocreature, aaand the functor, but I should manage that one on my own, thanks for your help.
11:03 <cocreature> reactormonk: using do notation, implementing fmap is trivial
11:03 <cocreature> or just use liftM
11:03 grumble joined
11:04 <reactormonk> Hmm, that sounds interesting.
11:04 Fairy joined
11:04 Mon_Ouie joined
11:04 <reactormonk> I would have taken the bruteforce approach
11:04 <cocreature> what’s that?
11:04 <cocreature> play type tetris until it compiles?
11:05 <reactormonk> >>= return basically
11:05 <reactormonk> Yeah, if you know the pieces it's easier :-)
11:05 <cocreature> that’s exactly what liftM and do notation will desugar to :)
11:06 fizbin1 joined
11:07 <reactormonk> ahh, nice.
11:07 marfoldi joined
11:08 <cocreature> "do x' <- x; return f x" desugares to "x >>= return . f"
11:08 <cocreature> eh I’m missing parenthesis
11:08 ziocroc joined
11:10 dawehner joined
11:13 connrs joined
11:14 pylbrecht joined
11:14 Gurkenglas_ joined
11:16 carlosdagos joined
11:18 oleks left
11:18 geekosaur joined
11:20 fizbin joined
11:20 acidjnk22 joined
11:20 IanKelling1 joined
11:24 ramzifu joined
11:24 hackebeilchen joined
11:25 rmrfroot joined
11:26 t7 joined
11:26 araujo joined
11:26 araujo joined
11:28 splanch joined
11:28 vydd joined
11:28 vydd joined
11:28 badlands joined
11:29 hackebeilchen1 joined
11:30 kuribas joined
11:30 kritzcreek_ joined
11:31 albertus1 joined
11:31 <rmrfroot> i have a haskell program that doesn't output everything on stdout when running it using systemd, i have a vague memory about buffering in haskell that could be the issue, anyone know what i'm talking about?
11:32 netheranthem joined
11:33 oisdk joined
11:33 <reactormonk> rmrfroot, default unix buffer flushing is per newline.
11:33 <kuribas> rmrfroot: output with which functions?
11:35 <rmrfroot> kuribas: i'm using Text.putStrLn :)
11:35 simendsjo joined
11:35 fizbin1 joined
11:36 <rmrfroot> reactormonk: alright, so it *should* output everything since I'm using putStrLn
11:37 <rmrfroot> kuribas: where `Text` is: `import qualified Data.Text.Lazy.IO as Text`
11:37 skeuomorf joined
11:37 asthasr joined
11:38 <kuribas> rmrfroot: isn't the output redirected somewhere?
11:38 Jackneill joined
11:38 geekosaur joined
11:39 juhp___ joined
11:39 geekosaur joined
11:40 mstruebing joined
11:42 <rmrfroot> kuribas: i'm not using any redirection when calling the program, and inside the program I only use that putStrLn function, which says "Write a string to stdout, followed by a newline.".
11:42 psychicist__ joined
11:42 FreeBirdLjj joined
11:42 prkc joined
11:43 azahi joined
11:43 <kuribas> rmrfroot: sorry, I don't know then...
11:44 juhp___ joined
11:45 feuerbach joined
11:45 feuerbach joined
11:46 Vibor joined
11:46 <rmrfroot> kuribas: no worries, maybe it's something with systemd, because if if I redirect stdout to a file everything is in that file
11:47 <kuribas> rmrfroot: yeah, that could be it. Maybe line length?
11:47 bjz_ joined
11:47 osa1_ joined
11:47 Gloomy joined
11:47 <Vibor> Hi, I'm having problem with this little piece of code : https://ptpb.pw/Txwi I figured I had to add fromIntegral in order to solve the problem, but why?
11:48 Fairy joined
11:49 <QRealm> I think that's because of the definition of (^) :: (Num a, Integral b) => a -> b -> a
11:49 eklavya joined
11:49 ragepandemic joined
11:51 raichoo joined
11:51 m0rphism4 joined
11:52 insitu joined
11:52 <Vibor> QRealm: so it was (fact oddTerm) did not return the proper type? what did it return without fromIntegral?
11:52 geekosaur joined
11:53 stoopkid joined
11:53 zar joined
11:54 geekosaur joined
11:55 <QRealm> right, fact returns a simple Integer whereas you need a Fractional Integer to do the division
11:55 <QRealm> so it's because of the division op instead of the ^, sorry
11:55 geekosaur joined
11:56 orbifx joined
11:56 connrs joined
11:56 zariuq joined
11:56 JuanDaugherty joined
11:57 <reactormonk> Uhm, how do you do basic string interpolation in haskell? for Show instances.
11:57 <reactormonk> Just with ++?
11:58 JuanDaugherty left
11:58 geekosaur joined
12:00 zar joined
12:00 <rmrfroot> kuribas: seems like the problem is related to systemd/journald: "It's a kernel race... if you program exits, the last messages are lost. This is because before journald can read them, your program is already dead and we cannot figure out which cgroup it belonged to", source: https://github.com/coreos/bugs/issues/373#issuecomment-113631450
12:00 epsilonhalbe joined
12:01 <kuribas> reactormonk: ++, printf, formatting, TH (there are libraries on hackage for that).
12:02 <kuribas> reactormonk: for example https://hackage.haskell.org/package/interpolate
12:03 <Vibor> QRealm: But if I change x^oddTerm simply into x, it would not give me an error message
12:03 <kuribas> reactormonk: I like to use printf, but it's not type safe.
12:04 oish joined
12:04 ADG joined
12:04 geekosaur joined
12:04 <ADG> im trying to do https://projecteuler.net/problem=1
12:04 <ADG> for(int i=1;i<=1000;i++)if(i%3==0||i%5==0)sum+=i;
12:04 <kuribas> reactormonk: this one seems more recent: https://hackage.haskell.org/package/marvin-interpolate-1.1/docs/Marvin-Interpolate.html
12:05 <kuribas> reactormonk: beware that TH may increase compile times.
12:05 sepp2k joined
12:05 ixti joined
12:06 <int-e> ADG: "below"
12:06 <int-e> but what does this have to do with Haskell?
12:06 <ADG> i meant to say that im begining haskell , so i thought proj.eu. wud be a gud place
12:07 <ADG> what do i write something like this for haskell?
12:07 <ADG> sum (x | x<-[1...999] , x%3==0 & x%5==0)
12:07 <ADG> how about this?
12:08 <int-e> > ([1..10],[x | x <- [1..10], x `mod` 3 == 0 || x `mod` 5 == 0])
12:08 <lambdabot> ([1,2,3,4,5,6,7,8,9,10],[3,5,6,9,10])
12:08 <kuribas> ADG: list comprehension you square brackets
12:08 <ADG> how to do `cout`?
12:09 <Vibor> https://ptpb.pw/Txwi It may seem silly but I still don't quite understand why I have to add fromIntegral before (fact oddTerm) in this code, without it it would give me an Ambiguous type variable error
12:09 <kuribas> > sum [x | x<-[1...999] , x `rem` 3==0 && x `rem` 5==0]
12:09 <lambdabot> error:
12:09 <lambdabot> • Could not deduce (Num (Over p f c0 c0 a b))
12:09 <lambdabot> (maybe you haven't applied a function to enough arguments?)
12:09 fizbin joined
12:09 mustafa1 joined
12:09 <int-e> ADG: print, or just evaluate the thing in ghci
12:10 epsilonhalbe left
12:11 <int-e> kuribas: oh wow. all because you had one extra '.'
12:11 <kuribas> > sum [x | x <- [1..999] , x `rem` 3==0 && x `rem` 5==0]
12:11 <lambdabot> 33165
12:11 <kuribas> :t (...)
12:11 <lambdabot> (Plated c, Applicative f) => LensLike f s t c c -> Over p f c c a b -> Over p f s t a b
12:11 <kuribas> int-e: ... is a lens thing?
12:12 <int-e> apparrently.
12:12 <kuribas> ADG: best thing for you would be to get familiar with the prelude.
12:14 geekosaur joined
12:14 <kuribas> ADG: also #haskell-beginners
12:14 <ADG> i did make a 1.hs with ans = sum [x | x<-[1..999],x `mod` 3==0 || x `mod` 5==0]
12:14 <ADG> then ghci, :l 1.hs then ans
12:14 <ADG> it worked
12:16 robotroll joined
12:16 fizbin1 joined
12:17 maarhart_ joined
12:18 dddddd joined
12:18 simendsjo joined
12:22 geekosaur joined
12:23 hurkan joined
12:23 hurkan left
12:23 decaroj joined
12:23 hurkan joined
12:24 oish joined
12:24 spatial joined
12:24 Adrian_____ joined
12:24 <spatial> Is there hprintf ?
12:25 <spatial> Equivalent to printf that writes to file
12:26 <feuerbach> yes, hPrintf
12:26 Levex joined
12:27 moongazer joined
12:28 geekosaur joined
12:29 <Adrian_____> hey guys i've just started haskell today and im unsure about two simply exercises. could one of you possibly help me out and send an .hs file with the solution id really appreciate it! http://imgur.com/a/cUIps
12:32 m0rphism joined
12:32 <Axman6> Adrian_____: You know you're supposed to do these exercises yourself right?
12:32 <feuerbach> Adrian_____: I doubt that having an .hs file with the solution will help you learn Haskell
12:32 <feuerbach> Adrian_____: is there something in particular you're struggling with?
12:33 <Axman6> Adrian_____: how did you start COMP1100 just today by the way?
12:33 <spatial> log message = withFile "C:/Haskell/rl/game.log" AppendMode (\ fd -> hPutStr fd message ) I am trying to pass this to functions to write logs.
12:33 Lord_of_Life joined
12:33 <Levex> Adrian_____, have a look at pattern matching and the operator (:)
12:34 <spatial> The ''message'' is dynamic. How ?
12:34 <Adrian_____> ok im gonna try it out
12:35 <feuerbach> spatial: not sure what you're asking
12:35 <Axman6> Adrian_____: where did you get those exercises anyway? They're clerly from ANU's COMP1100 course, but an old version of them
12:36 <spatial> I mean the call site is this. log $ printf "%d" 1
12:36 dawehner joined
12:36 tangled_z joined
12:36 <Adrian_____> wait really?
12:37 <Adrian_____> im in year 10 high school in sydney
12:37 <Axman6> yes
12:37 <spatial> So 'message' is dynamic parameter
12:37 <Axman6> Adrian_____: that's interesting, how are you connecting from a machine at ANU then?
12:37 mizu_no_oto joined
12:37 <Adrian_____> oh actually
12:37 <Adrian_____> i totally missed that is says anu at the top of the pdf
12:38 <Adrian_____> ok lolmeme
12:38 <Jinxit> lmao
12:38 <feuerbach> wtf was that
12:38 <Axman6> I'm one of the tutors on that course...
12:38 zar joined
12:38 <feuerbach> spatial: the result of printf "%d" 1 is String (at least it can be specialized to String)
12:39 <feuerbach> so I don't see a problem there
12:39 <Jinxit> oh that makes it even better
12:39 <feuerbach> and your log function accepts a String
12:40 oisdk joined
12:41 Malakai joined
12:42 lachenmayer joined
12:42 wildlander joined
12:43 connrs joined
12:43 zariuq joined
12:47 sdothum joined
12:49 geekosaur joined
12:49 ner0x652 joined
12:51 fredcooke1 joined
12:52 <Axman6> @tell chrisdone Hey, it looks like http://ircbrowse.net/browse/haskell is having issues (A web handler threw an exception. Details: libpq: failed (another command is already in progress))
12:52 <lambdabot> Consider it noted.
12:56 JeanCarloMachado joined
12:57 Lord_of_Life joined
12:58 zcourts joined
12:58 geekosaur joined
13:00 t0by joined
13:00 t0by joined
13:01 <zcourts> I'm trying to extract a list of DataCon from GHC module summaries, I wrote http://pastebin.com/C4Mn9jGa - I'm getting "No instance for (GhcMonad Maybe) arising from a use of ‘infoOpt’". I get the gist of what's wrong but I can't figure out how to do infoOpt in the Ghc monad (I thought it was until I got the error)
13:01 geekosaur joined
13:03 <zcourts> full error http://pastebin.com/Q6hQubnL
13:03 geekosaur joined
13:03 alanz joined
13:05 cfricke joined
13:07 geekosaur joined
13:08 <Athas> Does accelerate-cuda use 64-bit arithmetic for its index calculations?
13:09 oisdk joined
13:10 toony1 joined
13:14 eacameron joined
13:15 <spatial> log $ printf "Value %f\n " value This should write if file is opened in append mode ?
13:16 Gloomy joined
13:17 <spatial> logs message = withFile "C:/Haskell/rl/game.log" AppendMode (\ fd -> hPutStr fd message )
13:17 killtheliterate joined
13:17 carlosdagos joined
13:19 raibutera joined
13:20 ADG joined
13:20 laserpants joined
13:20 <ADG> to get the k'th element why is this wrong elementAt (x:xs) k | k==1 = x | otherwise = elementAt xs k-1
13:20 bjz joined
13:21 m0rphism1 joined
13:21 jmcarthur joined
13:21 <cocreature> ADG: you are missing parenthesis "elementAt xs (k-1)"
13:22 eacameron joined
13:22 sypwex joined
13:23 beanbagula joined
13:23 sepp2k joined
13:25 h3nnn4n joined
13:25 Gentilhomme joined
13:26 insitu joined
13:28 fotonzade joined
13:28 takle joined
13:28 geekosaur joined
13:28 spacedog82 joined
13:30 plutoniix joined
13:30 <laserpants> shouldn't it be k==0 = x ?
13:31 <cocreature> laserpants: depends on whether you want 0 or 1-based indices :)
13:32 plutoniix joined
13:33 geekosaur joined
13:33 <laserpants> cocreature: yes, that's true. But you're right.. k-1 should be (k-1)
13:33 jao joined
13:34 <laserpants> otherwise it is interpreted as (elementAt xs k) - 1
13:34 the_2nd joined
13:34 eacameron joined
13:35 <the_2nd> within do notation I'd like to enfore e.g. that length x == length y and return early if that's not the case. Is there an elegant function / way to do that?
13:35 lukaramu_ joined
13:36 geekosaur joined
13:37 <cocreature> :t guard
13:37 <lambdabot> Alternative f => Bool -> f ()
13:37 <cocreature> the_2nd: depending on the Monad that might work
13:38 uwap joined
13:38 mda1 joined
13:39 zargoertzel joined
13:39 geekosaur joined
13:39 <a3f> What do I need to run test files with .T extension that have entries like: test('T4452', normal, compile_and_run, ['-package Win32']) ?
13:39 Claudius1aximus joined
13:39 oisdk joined
13:40 zargoertzel joined
13:40 <the_2nd> cocreature, awesome, thanks
13:40 uwap joined
13:41 <cocreature> the_2nd: just make sure that the Alternative instance does what you expect it to.
13:43 biglama joined
13:46 hurkan joined
13:48 eacameron joined
13:49 psychicist__ joined
13:50 splanch joined
13:50 xtreak joined
13:55 badlands joined
13:56 yellowj joined
13:58 Varis joined
13:58 cfricke joined
14:00 handyc joined
14:00 zar joined
14:00 feuerbach joined
14:00 feuerbach joined
14:01 rightfold joined
14:03 eacameron joined
14:03 skeuomorf joined
14:03 <rightfold> Hi, is there a function `Fold a b -> Fold a c -> Fold a (b, c)` (with Fold from lens)?
14:05 geekosaur joined
14:06 Rainb joined
14:07 <spatial> logs message = withFile "C:/Haskell/rl/game.log" AppendMode (\ fd -> hPutStr fd message ) Is there a way to make hPutStr function passed ? I need to print various things.
14:08 <spatial> In the same function I print lists, strings etc.
14:09 Amadiro joined
14:09 <c_wraith> rightfold: Do you want it to act like zip, in that it discards extras if there is more of one than the other?
14:10 <rightfold> c_wraith: Yes. I have at most one, if either is zero then the result should be zero
14:12 <c_wraith> rightfold: I don't see anything for it offhand.
14:13 <rightfold> I guessed (&&&) but it broke horribly :')
14:13 <c_wraith> Yeah, it's not quite right.
14:14 <rightfold> Maybe this is helpful: https://www.reddit.com/r/haskell/comments/3scjbn/zipzipwith_as_functions_on_traversables/
14:14 Mon_Ouie joined
14:14 geekosaur joined
14:16 e14 joined
14:19 insitu joined
14:20 mohsen_ joined
14:20 connrs joined
14:21 marcopullo joined
14:24 xcmw joined
14:24 ramzifu joined
14:25 Kundry_Wag_ joined
14:25 alx741 joined
14:26 <spatial> log $ printf "Move is [%d] " move log $ putStrLn (show player) log $ print list I use various print statements.
14:26 tirej joined
14:26 tirej left
14:26 AX3L joined
14:26 tirej joined
14:26 saep joined
14:26 <spatial> Now when there is a single log function that writes to a file it fails.
14:28 iomonad joined
14:29 <geekosaur> define "fails"
14:31 augur joined
14:32 lep-delete joined
14:32 cfricke joined
14:33 <spatial> Couldn't match type `a1 -> IO ()' with `[Char]'
14:34 <geekosaur> feel like showing code?
14:34 <geekosaur> @pase
14:34 <lambdabot> Haskell pastebin: http://lpaste.net/
14:35 <geekosaur> although it looks like you're the sort who always pastes in one lump into the channel because somehow it's more convenient that it be unreadable
14:35 <spatial> logs message = withFile "C:/Haskell/rl/game.log" AppendMode (\ fd -> hPutStr fd message )
14:35 splanch joined
14:36 osa1 joined
14:36 augur joined
14:36 <geekosaur> and omitting full code + full error message + pasting always into the channel = making it as hard as possible for others to help you
14:36 <Xnuk> Downloading stack's nightly snapshot is too slow; it still says "Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcomplete.com/) ..."
14:36 <geekosaur> that's always a win
14:37 <Xnuk> Is there anyone like me?
14:37 rfvizarra joined
14:37 xcmw joined
14:37 <spatial> http://lpaste.net/353944
14:37 <Xnuk> Downloading nightly-2017-03-24
14:38 <geekosaur> I don't use stack but would suspect it's a local problem
14:39 <Xnuk> hm
14:39 <geekosaur> spatial, so your code defines "logs" but uses "log". no full error message. you're still making it harder for people to try to help you
14:42 <c_wraith> :t \x y f s -> folded f (zip (toListOf x s) (toListOf y s)) -- rightfold this is the best I can come up with.
14:42 <lambdabot> (Applicative f, Contravariant f, Indexable Int p) => Getting (Endo [a]) s a -> Getting (Endo [b]) s b -> p (a, b) (f (a, b)) -> s -> f [(a, b)]
14:42 <spatial> http://lpaste.net/353945 Full code. I pass the 'logs' function to gameplan
14:43 <spatial> I mean nextvalue
14:44 <c_wraith> rightfold: it's obviously not quite right. Probably could be fixed with the right Rank-2 type signature
14:45 MarioBranco joined
14:46 <bennofs> :t \a b -> runFold ((,) <$> Fold a <*> Fold b)
14:46 <lambdabot> error:
14:46 <lambdabot> • Couldn't match expected type ‘(a1 -> f1 a1) -> s -> f1 s’
14:46 <lambdabot> with actual type ‘t1’
14:46 tomphp joined
14:49 data_hope joined
14:50 <bennofs> :t \a b -> runFold (liftA2 (,) a b)
14:50 <lambdabot> (Applicative f, Contravariant f) => ReifiedFold s a -> ReifiedFold s b -> ((a, b) -> f (a, b)) -> s -> f s
14:50 contiver joined
14:51 tomphp joined
14:51 nomicflux joined
14:51 Welkin joined
14:52 wtetzner joined
14:53 simendsjo joined
14:56 govg joined
14:56 arpl left
14:57 bjz joined
14:59 ebzzry joined
14:59 e14 joined
15:01 augur joined
15:03 peterbecich joined
15:05 oisdk joined
15:07 badlands joined
15:07 Levex joined
15:08 hhhhhlllllloooo joined
15:09 <hhhhhlllllloooo> Is it possible to define an infix operator in Haskell that takes more than 2 parameters?
15:09 <Jinxit> but why
15:09 <Jinxit> text is one-dimensional
15:09 <c_wraith> :t (.)
15:09 <lambdabot> (b -> c) -> (a -> b) -> a -> c
15:10 <c_wraith> infix operator, takes 3 parameters
15:10 <hhhhhlllllloooo> But I think it is defined as taking 2 arguments and returning a function
15:10 <c_wraith> they're the same thing
15:11 <hhhhhlllllloooo> But can you define an infix with pattern matching on 3 params?
15:11 <hhhhhlllllloooo> or 4
15:11 <c_wraith> @src (.)
15:11 <lambdabot> (f . g) x = f (g x)
15:11 <geekosaur> if it knows one is a function, yes
15:11 <hhhhhlllllloooo> x1 y1 ## x2 y2
15:11 <geekosaur> this confuses people all the time when an "extra" parameter pops up in some API
15:11 <hhhhhlllllloooo> something like that
15:11 <geekosaur> but otherwise, no, you have syntactic issues or you must give up partial application
15:11 <c_wraith> haskell's syntax doesn't work that way
15:12 <Jinxit> (x1 y1) ## (x2 y2)
15:12 <geekosaur> not the same
15:12 <hhhhhlllllloooo> that wouldnt work Jinxit
15:12 <c_wraith> that's seen as a pattern match on two arguments
15:12 <Jinxit> i know it's not the same
15:12 <Jinxit> just proposing an alternative
15:12 <geekosaur> again, you lose something else useful
15:12 <hhhhhlllllloooo> Are there any languages that support this kind of thing?
15:13 <hhhhhlllllloooo> ML or something?
15:13 EvilMachine joined
15:13 <geekosaur> since currently that means evaluate the function x1 with parameter y1,and likewise x1 and y2
15:13 <pavonia> How are these two different?
15:13 <c_wraith> possibly Agda - it has
15:13 <c_wraith> err, it has support for arbitrary mixfix syntax
15:13 <Jinxit> sorry, meant (x1, y1) ## (x2, y2)
15:13 <Jinxit> brainfart
15:14 <riaqn> so nobody told me that [2..0] is [], which wasted me half an hour.
15:14 <hhhhhlllllloooo> Ah, yeah agda mixfix looks promising :)
15:14 serendependy joined
15:15 tomphp joined
15:15 <hhhhhlllllloooo> > [2..0]
15:15 <michi7x7> Jinxit: this is just ## :: a -> b -> c
15:15 <lambdabot> []
15:15 <geekosaur> riaqn, the haskell language report is surprisingly readable
15:15 <Jinxit> i am well aware
15:15 data_hope joined
15:15 <michi7x7> > [3,2..0]
15:15 <lambdabot> [3,2,1,0]
15:15 <laserpants> If I have a data type `data X = A | B X X`, algebraically it can be seen as X = 1 + X × X? Then, the data type is the least solution to this equation. In what sense is it the "least" here?
15:16 <laserpants> or I mean, why is it the least solution
15:16 earldouglas joined
15:17 Amadiro joined
15:17 carlosdagos joined
15:18 safe joined
15:18 <geekosaur> laserpants, consider that Maybe () is isomorphic to Bool. (that is, ignoring bottoms, you can take Nothing as False and Just () as True and there are no other values occupying it)
15:19 <geekosaur> ...I thinkt hat's what that means...
15:19 <* geekosaur> not exactly type theory wonk
15:20 bennofs joined
15:20 {emptyset} joined
15:21 <laserpants> geekosaur: Ok... I have to meditate on that a while. (Sorry if the question was slightly off-topic btw.)
15:21 <geekosaur> it's fine for #haskell
15:21 <geekosaur> I'm just not the best person to answer it, but nobody else was
15:22 <geekosaur> anyway the point there, if I understand correctly, is there are more complex ways to implement a type that reduce to the same thing in the end
15:22 <geekosaur> but the algebraic representation will be more complex
15:22 <ezyang> least fp is clearer if we talk about sets
15:22 <Welkin> geekosaur: like Free to implement a List?
15:22 <ezyang> Say you have a function f from one set to another
15:22 caconym joined
15:22 <ezyang> a fixpoint is any set X such that f(X) = X
15:23 <ezyang> what is a least fix point? It is a fixpoint such that for any Y, if f(Y) = Y , X <= Y
15:23 <ezyang> but it's worth noting Haskell doesn't actually define least fixpoints
15:24 <laserpants> ezyang: is there an order on types?
15:24 <Welkin> I don't get it
15:24 <Welkin> if f Y = Y, then X is less than or equal to Y?
15:24 <hpc> http://blog.ezyang.com/2010/12/getting-a-fix-on-fixpoints/
15:25 <hpc> Welkin: basically the least fixed point is the fixed point that's less than or equal to all other fixed points
15:27 <ezyang> you want to start with this post: http://blog.ezyang.com/2010/12/hussling-haskell-types-into-hasse-diagrams/
15:27 <laserpants> thanks, I was just going to ask that..
15:27 <hpc> ezyang: can you actually edit those to add links between each in the series?
15:27 <ezyang> yeah I'll do that
15:27 <hpc> they're not even all consecutive in the archives ;)
15:28 marcopullo joined
15:30 boxscape joined
15:31 splanch joined
15:31 raichoo joined
15:33 yqt joined
15:33 afnizarnur joined
15:33 theelous3 joined
15:33 simendsjo joined
15:34 statusbot joined
15:35 fizruk left
15:38 fizruk joined
15:38 coot joined
15:39 mmachenry joined
15:40 <eatman> Hi 0/
15:40 <eatman> Does anyone here use the gitlab pages service to host Hakyll generated pages?
15:40 sssilver joined
15:40 insitu joined
15:42 afnizarnur joined
15:45 takle joined
15:49 Owatch joined
15:49 <vektorweg1> are there some Maybe to Either (and back) conversion functions in base or have i to define them?
15:50 curious_corn joined
15:50 Enigmagic joined
15:51 oisdk joined
15:51 xcmw joined
15:52 zyla left
15:52 <boxscape> vektorweg1: quick search on hoogle suggests that they don't exist
15:53 <Athas> How come concatMap hasn't been generalised to Monoid m => (a -> m b) -> [a] -> b?
15:53 <Athas> Huh, I guess that's actually just mapM.
15:53 <Athas> If 'm' is a Monad, at least.
15:54 <geekosaur> concatMap's generalization is spelled (=<<) :p
15:56 <geekosaur> more to the point, concatMap pretty much exists to be the implementation of (>>=) for the list monad
15:56 Boomerang joined
15:57 <hpc> also to make it excruciatingly obvious how to implement (>>=) in terms of fmap and join
15:57 sepp2k joined
15:58 <geekosaur> ^
15:58 <geekosaur> thought about saying that and also pointing out the relationship between join and concat
15:58 <MarcelineVQ> :t foldMap
15:58 <vektorweg1> i guess thats why flatMap is their synonym for bind.
15:58 <lambdabot> (Monoid m, Foldable t) => (a -> m) -> t a -> m
15:58 <hpc> and for beginners to learn to code with monomorphic error messages
15:58 m0rphism2 joined
15:59 mada joined
15:59 <Welkin> ew, "flatMap"
15:59 <Welkin> that's how you know when someone is a refugee form scala
16:00 <Athas> Yeah, I've always been confused at that name.
16:00 <Athas> What's flat about it? concatMap is better.
16:00 <geekosaur> vektorweg1, I think it's considered that there are enough use cases that you don't gain anything (you have to specify what to put in the Left, or decide what to do when mapping a Left _ to a Nothing)
16:00 <ezyang> ftp mumble mumble
16:01 muesli4 joined
16:01 <geekosaur> flattening, concatenating, joining
16:01 <rightfold> c_wraith: Thanks for the help, I think I'll use a different approach than lenses for parsing JSON. I found one that includes error messages for missing fields automatically, which is nice.
16:01 <* geekosaur> pretty sure he saw "flat" being used in that sense in ancient computer languages
16:02 <muesli4> Hi, can someone explain me what GHC is trying to tell me with this? (http://codepad.org/Sh9XEKpy) I used these as qualified imports.
16:02 <kuribas> LISP?
16:02 <geekosaur> predating lisp I think?
16:02 insitu joined
16:02 <MarcelineVQ> muesli4: looks like it's saying you shouldn't have capitalized Level
16:02 marvin2 joined
16:03 <muesli4> MarcelineVQ: wow, thanks! Shame!
16:03 takle joined
16:03 afnizarnur joined
16:04 <muesli4> MarcelineVQ: I guess this is one of the downsides of camel case and human perception.
16:04 <kuribas> camel case is pretty bad
16:04 <MarcelineVQ> muesli4: yes it's petty common
16:04 urodna joined
16:04 fizbin joined
16:04 <Welkin> it's not camel case, it's people using it wrong
16:05 <Welkin> "top" and "level" are two distinct words, so L should be capital
16:05 <kuribas> I always avoided it, but in haskell it's not possible.
16:05 <Welkin> also, don;t use long names
16:05 djapo_ joined
16:05 <Welkin> this isn't java
16:05 <boxscape> use single letter n
16:05 <boxscape> oops
16:06 <boxscape> I was gonna say
16:06 <boxscape> names
16:06 <geekosaur> "toplevel" is a single conceptual entity in a gui
16:06 <kuribas> Welkin: I suppose WindowTypeToplevel is a Gtk thing
16:06 <vektorweg1> "use single letter n" is perfect :D
16:06 <boxscape> it kind of is, yeah...
16:08 <boxscape> I really hate typing underscores, so I'm quite happy with any naming scheme that prevents me from having to use them
16:08 <geekosaur> (I was thinking that was some kind of auto conversion, but the web tells me the C version is GTK_WINDOW_TOPLEVEL)
16:09 <geekosaur> although that does make the point about "toplevel" being a conceptual entity in this context
16:09 takle joined
16:09 emc2 joined
16:12 sssilver joined
16:12 connrs joined
16:14 xtreak joined
16:15 gugah joined
16:17 feuerbach joined
16:17 feuerbach joined
16:17 asthasr joined
16:17 badlands joined
16:18 conal joined
16:20 laserpants joined
16:20 afnizarnur joined
16:20 oisdk joined
16:24 handyc left
16:28 hackebeilchen joined
16:31 badlands joined
16:33 JeanCarloMachado joined
16:35 xtreak joined
16:36 Einwq joined
16:38 robkennedy joined
16:39 xcmw joined
16:39 zcourts_ joined
16:42 xtreak joined
16:42 conal joined
16:43 albertus1 joined
16:43 venkat24 joined
16:46 sipian joined
16:47 justan0theruser joined
16:47 insitu joined
16:50 ragepandemic joined
16:50 marsam joined
16:52 xcmw joined
16:52 oisdk joined
16:52 data_hope joined
16:56 eacameron joined
16:58 xcmw joined
17:00 ystael joined
17:00 freth_ joined
17:02 e14 joined
17:03 Modius joined
17:05 <freth_> Is there some rule of thumb on when to use Data.Set? Like, a lot of the time my lists *do* represent something like sets, i.e. i don't care about ordering or duplicates, just about membership, but using Data.Set all the time turned out to be quite cumbersome, e.g. doing list comprehension becomes difficult, checking if the list / set is empty takes longer because the set type isn't lazy, etc.
17:05 <cocreature> can I link to a package in haddock?
17:05 Micamo joined
17:05 <ezyang> I generally use Data.Set if I actually need set ops
17:05 <ezyang> usually this is obvious
17:05 oisdk joined
17:05 <freth_> i see
17:06 tangled_z joined
17:07 raycoll joined
17:09 dawehner joined
17:10 afldcr joined
17:10 Zialus joined
17:10 laserpants joined
17:12 mojjo joined
17:14 geekosaur joined
17:14 <mojjo> hi! is someonw up for a little code review? It's about a function that generates the intermediate computation steps of the imperative InsertSort algorithm. Just a few lines.. ;-) Well, here's the gist: https://gist.github.com/thought2/e9a58bb6392ab271484c832936c81a3d
17:15 afldcr joined
17:15 augur joined
17:16 augur joined
17:16 <statusbot> Maintenance update: everything operational again! -- http://status.haskell.org/pages/maintenance/537c07b0cf1fad5830000093/58d7ead6b13e15472000002c
17:17 jsgrant- joined
17:17 gugah joined
17:18 oish joined
17:18 carlosdagos joined
17:18 Sh4rPEYE joined
17:21 sleffy joined
17:23 mkoenig joined
17:23 caconym joined
17:24 torgdor joined
17:28 tushigushi joined
17:29 ryandevilla1 joined
17:29 augur joined
17:31 aglorei joined
17:32 ner0x652 joined
17:33 systemfault joined
17:34 cfricke joined
17:34 alibabzo joined
17:34 maarhart joined
17:35 epsilonhalbe joined
17:36 epsilonhalbe left
17:36 tom7942 joined
17:37 fizruk joined
17:37 connrs joined
17:38 coot joined
17:38 anmin joined
17:39 fizbin joined
17:39 hive-mind joined
17:39 myname_ joined
17:39 augur joined
17:39 <myname_> Hello
17:40 laserpants joined
17:40 Noldorin joined
17:41 eacameron joined
17:41 aglorei joined
17:42 sigmundv_ joined
17:42 ggVGc joined
17:42 moth joined
17:42 <myname_> +i
17:43 insitu joined
17:43 <Nolrai> So ..I think it's impossible to give "Gen" an associative (<|>), am I right?
17:43 <Nolrai> Hi myname_.
17:43 kadoban joined
17:45 takle joined
17:46 conal joined
17:47 Amadiro joined
17:47 tushigushi left
17:48 <myname_> Can anyone explain me pattern matching syntax? I understand the principles but i really get stucked at shit like this: someThing :: (Integral a) => a -> b ?
17:48 insitu joined
17:49 <Athas> Is there a parser for GHC .prof files?
17:49 Micamo joined
17:49 <myname_> I thought I understood everything when i wrote code but it didn't work
17:49 <cocreature> myname_: that has nothing to do with pattern matching. that’s a type signatu
17:50 lordcirth joined
17:51 <cocreature> myname_: what is means is that someThing is a function that takes something of type a as an argument and returns something of type b
17:51 <myname_> oh thx (it's name of the LYHGG chapter) sry
17:51 <cocreature> myname_: in addition to that a has to be Integral
17:51 <mojjo> myname_: you might confuse the arrow -> with the one that occurs in a case statement. In the latter you have pattern matching..
17:51 dan_f joined
17:51 MP2E joined
17:53 tomphp joined
17:53 <myname_> What if function takes two arguments? should I write like that: smth :: (Integral a, Show a) => a -> a -> a ?
17:55 afnizarnur left
17:55 afnizarnur joined
17:55 bennofs joined
17:55 <boxscape> myname_: if both arguments have the same type, yes
17:55 <myname_> what if they doesn't?
17:55 cmsmcq joined
17:56 <boxscape> Well, something like "fun :: Int -> String -> Char" would be a function that takes two arguments of different types
17:56 <mojjo> myname_: Should the two args and the result be of the same type plus have the same typeclass constraints? then, yes.
17:56 <Myrl-saki> myname_: You could also do `smth :: (Integral a, Show a) => a -> b -> a` but that doesn't really make sense for the most part.
17:56 <geekosaur> do you understand the differnce between types and typeclasses?
17:57 <myname_> Yes. Types ate the sets of values while typeclases are the sets of types
17:58 aglorei joined
17:58 sophiag joined
17:58 ptvirgo joined
17:59 thunderrd_ joined
17:59 <mauke> omnomnom
17:59 <sophiag> can different records really not have the same field names? seems so, but i find that rather odd
18:00 <mojjo> sophiag: without language extensions, unfortunately not. they are just reagular functions defined at the toplevel
18:00 jchia_ joined
18:01 afnizarnur joined
18:02 <sophiag> mojjo: ah ok, so the fields are similar to defining new types that exist globally?
18:02 JavaSucksMan joined
18:02 <boxscape> new functions, not new types
18:03 conal joined
18:03 <dxtr> sophiag: Create field X in a record - now you have a function called X that you use to access field X
18:03 <michi7x7> sophiag: "field names" are just convinience functions like field (Data _ _ _ x _ _ ) = x
18:04 stevebash joined
18:04 <sophiag> ah, right. they only become types with the DataKinds extension, yes?
18:05 <sophiag> also, what's the extension i can use if i want to have multiple ones with the same fields?
18:05 <dxtr> But I thought it was possible, without language extensions, to tell it to not create these convenience functions. Or do I not remember correctly?
18:05 <mojjo> sophiag: `data Person = Person {name :: String}` equals `data Person = Person String; name (Person n) = n`
18:05 <sophiag> mojjo: yeah i get that now. the syntax was confusing me to think it was like using DataKinds
18:05 meba joined
18:06 data_hope joined
18:07 <boxscape> sophiag: OverloadedRecordFields. But it looks like OverloadedRecordFields is not yet part of ghc?
18:07 diwank joined
18:07 Rodya_ joined
18:07 <sophiag> oh yeah, it looks like it's still a proposal
18:07 <sophiag> anyway, i can do without it
18:07 <diwank> hey guys, haskell newbie here. Needed some help with a side project that uses minimax
18:08 <diwank> Anyone care to take a quick look?
18:08 nilof joined
18:08 <sophiag> my second question about records was going to be whether there's a way to specify fields as optional. i suppose i could just create an adt to do that, but wondering if there's a simpler way
18:10 osa1 joined
18:10 osa1 joined
18:10 <Nolrai> @sophiag Use Maybe.
18:10 <lambdabot> Unknown command, try @list
18:10 <unclechu> can i check if my app is compiling on gnu/linux or freebsd using CPP extension using GHC?
18:10 <Nolrai> sophiag: Use Maybe.
18:10 <sophiag> Nolrai: ah, yeah of course. thanks
18:10 <mojjo> sophiag: fields cannot be optional, they are positional arguments (the order defined in the record syntax) to the data constructor.
18:10 jchia_ joined
18:10 <davean> unclechu: using cabal
18:11 <mrjake> Has anyone used the Diagrams library? Their examples aren't type checking for me. I'm getting illegal equational constraint and non type variable argument errors in their mandelbrot set example: http://projects.haskell.org/diagrams/gallery/Mandelbrot.html
18:11 <geekosaur> unclechu, this is usually done with cabal if os(whatever)
18:11 ertesx joined
18:11 dominik_ joined
18:12 <geekosaur> I don't know if os defies get passed through; they tend to cause problems
18:12 oisdk joined
18:12 <* geekosaur> reminded of the pain of "#define sun 1" back in the day :p
18:12 <Nolrai> sophiag: You can additionally define convienence constructors say "mkDefault non_optional = MyCons Nothin non_optional Nothing.
18:13 IanKelling1 joined
18:13 mojjo` joined
18:13 <sophiag> Nolrai: yeah i figured i'd have two constructors, one with the field and one without, but didn't think far enough that i could just use maybe and pass Nothing for the latter
18:14 phyrex1an joined
18:14 angelos joined
18:14 <Nolrai> Your first idea can work, but if your use record syntax it creates partial functions. :/
18:15 <sophiag> i'm not sure i understand the difference in what you're suggesting
18:15 <sophiag> i'll try to paste a gist in a moment
18:15 <unclechu> geekosaur: how actually i can do it using cabal?
18:16 <diwank> [REPOST] hey guys, haskell newbie here. Needed some help with a side project that uses minimax Anyone care to take a quick look? (Much appreciated; been banging my head for hours)
18:17 augur joined
18:18 <michi7x7> diwank: just ask right away or post a link, nobody cares to ask you what your problem is
18:18 <diwank> michi7x7: Ah, thanks
18:19 AstroDroid joined
18:19 <diwank> Wrote a tiny minimax implementation for tic-tac-toe but it seems to have a logical bug
18:19 <mojjo`> sophiag: You could also have a default instance of your type. ` defaultPerson = Person "Max" 20;` And then you'd use record update syntax to enhance only the fields you like. e.g: `me = defaultPersion{name="Me"}` This gives you a complete person of age 20, Many libraries use this approach...
18:19 <diwank> https://github.com/creatorrr/tic-tac-toe/blob/master/src/AI.hs
18:20 <diwank> Can't figure out what I got wrong..
18:20 <michi7x7> diwank: Debug.Trace is a great way to find these errors
18:21 <sophiag> mojjo`: this is how i'm structuring it now: http://lpaste.net/353948
18:21 paulsh94 joined
18:21 <diwank> michi7x7: Thanks! Let me give that a shot
18:21 eacameron joined
18:21 <sophiag> basically i'm going to have parsers of these types and cons the records into lists i can ultimately evaluate in a list monad
18:23 <sophiag> so the ones that are tagged will match constraints to particular values rather than constraints for every record
18:23 noam joined
18:23 rcat joined
18:25 ramzifu joined
18:25 robertkennedy joined
18:25 <sophiag> although i'm wondering if having constraints of type Bool will actually work considering what i really want are expressions that return type Bool...which to parse i may have to use HaskellDef or something like that (same for passing lists, although I could also probably due that in a hacky way using a regular parser)
18:25 Rodya_ joined
18:28 tom7942 joined
18:28 <geekosaur> unclechu, something like http://hackage.haskell.org/package/network- except you likely want os(freebsd)
18:28 mmachenry joined
18:28 caconym joined
18:30 <unclechu> geekosaur: interesting, thanks, it might work too, but i also found exact answer here https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/phases.html#options-affecting-the-c-pre-processor
18:30 <unclechu> os_HOST_OS=1
18:30 <* geekosaur> very strongly recommends against relying directly on cpp
18:30 <geekosaur> since you are not writing C
18:31 <geekosaur> (that we use it at all is a wart, and freebsd is exactly where it will bite you because clang's cpp knows that it is intended for c/c++ not haskell)
18:31 psychicist__ joined
18:31 nakal joined
18:33 e14 joined
18:33 takle joined
18:34 <Boomerang> mojjo`: are you mojjo? If so here's your code from earlier with a couple of suggestions: https://gist.github.com/basile-henry/f7f68b744f5d924104cc86adaa4edf30 I am not sure trying to translate imperative code to haskell like this is the best way, you could refactor to remove most mentions of indices.
18:34 conal joined
18:34 ystael joined
18:35 eacameron joined
18:36 e14_ joined
18:37 ragepandemic joined
18:37 Sh4rPEYE joined
18:38 aarvar joined
18:38 psychicist__ joined
18:38 <sophiag> is anyone familiar with Text.ParserCombinators.Parsec.Language? i'm wondering if i can use it to create lexers for haskell lists and boolean expressions relatively painlessly. the only examples i've seen using it are from the old Parsec docs, but they're much lower level than that...like tables of infix operators and such :/
18:40 connrs joined
18:40 Rodya_ joined
18:40 ph88 joined
18:41 e14 joined
18:43 curious_corn joined
18:43 tomphp joined
18:43 <geekosaur> sophiag, it concentrates on tose because operator parsers are the hard part of parsing. lists are fairly easy
18:44 ixti joined
18:44 <geekosaur> (once you throw associativity and precedence into the mix, operators are non-trivial)
18:45 <sophiag> geekosaur: but is there something in HaskellDef that just reads lists?
18:45 <ph88> hello, ghc reports that a type variable is ambiguous https://bpaste.net/show/188d02e77be6, i just don't understand what value it's talking about, could someone take a look?
18:45 <geekosaur> ...and while you can write them by hand, they perform poorly
18:45 <sophiag> or you're saying because it's so easy to do sepBy "," and cons them?
18:45 <geekosaur> sophiag, no
18:45 <geekosaur> right, it's easy to make your own parser for that
18:46 <geekosaur> so Language handles things like tracking lexical analysis for you (e.g. what's a valid identifier?) and operators (hard to get right, harder to get fast)
18:46 goldpank joined
18:47 aglorei joined
18:47 <sophiag> right...which it seems like i'll need for the only actually hard part: i want to essentially parse lambdas. or at least something similar
18:47 data_hope joined
18:48 <sophiag> hmm...i wonder if i could use System.Eval.Haskell for that?
18:48 eazar001 joined
18:49 raycoll joined
18:49 takle joined
18:51 <cocreature> ph88: that’s the "a" in the type signature of changeLastValue2. neither "id" nor "\_ -> True" provide GHC with enough information to figure out what this should be
18:52 dawehner joined
18:52 <ph88> cocreature, do you have any idea what it could be? i have hard time to "infer" this myself tbh
18:52 <alx741> hello everyone, I'm trying to use Hakyll and have a 'preview' of each post on index.html, but when i use $body$ in 'templates/post-list.html' it includes the post like it's rendered in the full page (including the navbar). How could I get onlye the body of the post itself?
18:53 e14 joined
18:53 <ph88> cocreature, by the way, that type signature you suggested worked very well !
18:53 <cocreature> ph88: there is no way to infer this. you just have to chose something by adding a type annotation. anything should work I think
18:54 <ph88> cocreature, i mean to say i don't know what to choose
18:54 adlaistevenson joined
18:54 chaosmasttter joined
18:54 <cocreature> ph88: I’m not so sure about this. I was just looking for something that compiles but I’m not sure the type signature of "changeLastValue2" makes sense. there is still no relation enforced between "a" and "b"
18:55 puregreen joined
18:55 <cocreature> and I’m too lazy to look up all those lenses to figure out what you are actually trying to do :)
18:55 int-index joined
18:57 asthasr joined
18:57 <ph88> cocreature, i made some helper functions and it seems to type check now .. still i'm a bit confused why this could not be infered, let me show you in a new paste
18:57 <cocreature> ph88: I think you first need to give me a quick summary of what you expect changeLastValue2 to do
18:57 WhiskyRyan joined
18:57 <ph88> cocreature, https://bpaste.net/show/f51f15f6d767
18:58 e14_ joined
18:58 <rotaerk> that sure is a lot of code for a hello world program
18:58 <geekosaur> heh
18:59 <glguy> ph88: nothing specifies the type a in your previous paste, but that a needs to have a Generic instance
18:59 <puregreen> Could someone explain why heterogeneous type equality is not needed in this example with GADTs, but needed with a typeclass? http://lpaste.net/353950
18:59 fizbin1 joined
19:00 connrs joined
19:00 <ph88> cocreature, i think b is the "normal" value and a is the generic representation of the value. Not sure what you mean by "there is still no relation enforced between a and b"
19:00 tomphp joined
19:01 <glguy> puregreen: the kinds aren't different in your first constructor
19:01 <cocreature> ph88: ah so EotTerminal is supposed to give you a Traversal for an _arbitrary_ "a"
19:01 <cocreature> that seems kind of weird
19:01 <ph88> cocreature, changeLastValue2 is suppose to go over all the elements of the generic representation backwards (so starting at the last one) then if the predicate is true you can change the value of that one element and return the entire structure with the last element changed. I can show an example of this with a integers
19:02 <ph88> cocreature, it gives a traversal of all types that have derived Generic .. why does that seem kind of weird? I think it's pretty powerful to be able to traverse over the generic structure
19:02 azahi joined
19:02 <glguy> puregreen: It's like if you'd written: FooSame :: Foo a a
19:03 <cocreature> ph88: that’s not really what you’re getting here. at best you are going over all elements of type "a" but you’re missing all other fields. and that "a" might not even exist in "b" which is why I was saying that there is no relation enforced between a and b
19:04 <int-index> glguy, but "Foo :: (a :: k) -> (b :: k')" -> Type, so we have to assume k~k' as well.
19:04 insitu joined
19:04 <ph88> cocreature, to illustrate here is how changeLastValue2 works on a much simpler structure (tuples of ints) https://bpaste.net/show/4ff93ace47c7
19:04 <puregreen> glguy: if I don't include “a ~ b”, kinds *could* be different (e.g. I could add a constructor “FooNotSame :: Foo a b” without equality and then use “FooNotSame Int Maybe”), so I still don't understand why a ~ b works in the first example but not the second one
19:05 <puregreen> unless GHC has some special rules which make it treat “(a ~ b) => Foo a b” as “Foo a a”
19:05 <glguy> puregreen: because you included the a ~ b you implicitly added an additional constraint that hte kinds will be the same
19:06 <cocreature> ph88: right but here HasTokens only requires a "Traversal' a Int". "EotTerminal" requires that you find a traversal sufficiently general that it works for any "a" that is an instance of Generic
19:06 <glguy> puregreen: The k and k' in your data declaration don't mean that all of the data constructors will support all kinds
19:06 <int-index> glguy, are you saying that `(a :: k) ~~ (b :: k')` is exactly the same as `(k ~ k', a ~ b)`?
19:06 shookees left
19:06 fizbin joined
19:06 <cocreature> ph88: and I’m not quite sure you can actually make useful instances of that. however, this might just be due to my lack of familiarity with generics
19:07 e14 joined
19:07 <ezyang> puregreen: “(a ~ b) => Foo a b” as “Foo a a” are not the same, as far as mathcing is concerned
19:07 <glguy> ezyang: You mean in the context of type class instance resolution , right?
19:07 <ezyang> yeah
19:07 <ph88> cocreature, what "other fields" are you talking about ? I think when you have a type like data Foo = Foo1 | Foo2 and you have a value val = Foo1 then val is of type b and a is not going to cover the entire space of possible generic representations of Foo, but only the generic representation of Foo1 ... at least so far the theory and so far as i understand it !
19:08 <ezyang> doesn't look like what you guys are talking about though lol
19:08 Hi-Angel joined
19:08 <glguy> I'm saying that when GADT syntax is translated to explicit equality constraints you'll get a kind equality constraint from that definition
19:08 Jackneill joined
19:08 <cocreature> ph88: "data Foo = Foo Int Bool Int Bool". which value should me modified? you can either chose the last Int or the last Bool but not the last field regardless of the type because you need to provide type information upfront
19:09 <puregreen> glguy: so something like “instance (a ~ b, k ~ k') => GetFoo (a :: k) (b :: k') where { getFoo = FooSame }” should work?
19:09 <glguy> and that it's not just kind equalties that can be implicitly generated
19:09 fizbin joined
19:09 <puregreen> hm
19:10 <puregreen> is there any place I could read about those implicit equality constraints that get added?
19:10 <cocreature> ph88: try making an instance of "EotTerminal" for "data Foo = Foo Int"
19:11 <Hi-Angel> What was called the extension to omit the first argument to record accessor-functions? So for "data Foo = Foo{bar :: Int}" I'd write in a function not "bar myFoo", but just "bar"?
19:12 <puregreen> Hi-Angel: RecordWildCards, maybe?
19:12 <puregreen> (and then you have to write Foo{..})
19:12 <Hi-Angel> puregreen: oh, thank you!
19:12 <ph88> cocreature, "that you find a traversal sufficiently general that it works for any "a" ... yes but that a is provided by the generics-eot library which transforms the more complicated structure of GHC.Generics into a much simpler representation of nested tuples (see tutorial of generics-eot) .. but i think that the "dive into the nested structure" has been handled by the instances of EotTerminal and the generics-eot glues this together. So basically this
19:12 <ph88> gives you the ability to go through all the elements (that is all the generic representations in the structure) .. and then the Lens part allows you to compose this "go-over" function (that is provided by generics-eot and my self written instances) with some other cool traversing functions like backwards (provided by lens)
19:12 <glguy> puregreen: Avoid GADTs if you want less magic and more understanding
19:12 <glguy> puregreen: For example: data HEq (a :: k') (b :: k'') = (a ~~ b) => Refl
19:13 <glguy> while you can't use (a ~ b)
19:13 <ph88> cocreature, please understand that this stuff is already mind boggling to me. So maybe i sound like i understand it all, but i surely don't this is just what i'm barely grasping by studying this stuff for months now
19:13 <heath> who has statusbot setup in here?
19:14 <cocreature> ph88: I’d still like to see if you can write an instance of EotTerminal that actually modifies values :) your current instances are sort of boring in the sense that they don’t do anything
19:14 Igloo joined
19:14 conal joined
19:16 testuservx joined
19:16 <ph88> cocreature, in case of your example "data Foo = Foo Int Bool Int Bool" i think this is handled by the instance i wrote on line 79 of this paste https://bpaste.net/show/f51f15f6d767 this is where the fields of the constructor are represented as nested tuples .. so let's say R stands for the generic representation then you would get (R Int, (R Bool, (R Int, R Bool))) .. then i traverse them in the order of left to right (unless i use special Lens
19:16 <ph88> function backwards) .. which one should be modified depends now on the lens functions that take the predicate i provide
19:17 <ph88> cocreature, yes for sure my next goal is to actually make it change values !!! this is the whole point haha .. but i'm just at the point that it type checks AND i'm getting the same value back ... so now le moment supreme :P
19:17 <int-index> glguy, why does this work?
19:17 <int-index> data HEq (a :: k') (b :: k'') = (a ~~ b) => Refl
19:17 <int-index> (sorry, not this)
19:17 <int-index> this modified version
19:17 <int-index> data HEq (a :: k') (b :: k'') where { Refl :: (a ~ b) => HEq a b }
19:17 <int-index> it appears to use homogeneous equality
19:17 <cocreature> ph88: my point is that I’m not sure that it is actually possible to write instances that change values. I might be wrong here (and I’d love to know how you can do that!) but it’s also possible that you’re on the wrong track here
19:17 <glguy> int-index: Because GADTs add extra constraints automatically
19:18 <int-index> glguy, does this GADT add a heterogeneous equality constraint?
19:18 <ph88> cocreature, certainly ! i will try it with this type data Foo = Foo Int Bool ok ?
19:18 <cocreature> ph88: sure, looking forward to see what you come up with!
19:18 <glguy> int-index: It translates that to: Refl :: forall k'' (b :: k''). HEq b b
19:19 <glguy> Refl :: forall k'' (b :: k''). HEq k'' k'' b b
19:19 safe joined
19:19 carlosdagos joined
19:20 ompaul joined
19:21 Eduard_Munteanu joined
19:22 tom7942 joined
19:22 Elish joined
19:23 <int-index> glguy, say I take Foo (a :: k1) (b :: k2) as input to a function. If I match on FooSame, shouldn't it bring a~~b into scope?
19:23 <glguy> There's a difference
19:23 <glguy> case (undefined :: HEq Maybe Bool) of Refl -> ()
19:23 <glguy> You can't do this^
19:24 <int-index> there must be heterogeneous equality stored inside
19:24 <glguy> because Refl doesn't have the right kinds
19:24 <glguy> You don't learn that the kinds of equal
19:24 <glguy> Refly just isn't valid
19:28 <glguy> (so there's an important distinction between how GADT syntax adds type and kind constraints)
19:29 vydd joined
19:29 vydd joined
19:29 da1 joined
19:30 shayan_ joined
19:30 <glguy> Oh, nevermind, you get the same inaccessible problem with undefined :: HEq Int Bool
19:31 <int-index> glguy, yep, but depending on the definition of Refl (with GADT or without) you get different errors with HEq Maybe Bool
19:31 <int-index> kind error in one case, type error in another
19:32 boxscape joined
19:32 mson joined
19:32 <int-index> although I wouldn't expect GHC to accept/insert homogeneous equality there in the first place.
19:33 drewr joined
19:35 chaosmasttter joined
19:37 sssilver joined
19:37 Vzox0102 joined
19:37 curious_corn joined
19:37 ystael joined
19:37 <ph88> cocreature, ok confusion has set in https://bpaste.net/show/248384e4d3a8
19:37 psychicist__ joined
19:38 <cocreature> ph88: right, that’s what I expected :)
19:39 Vzox0102 joined
19:39 AdolphusGustavus joined
19:40 <ph88> cocreature, do you also think i'm traversing over the values and not the generic representation ? If so .. do you have any idea how i can traverse over the generic representation ?
19:40 Vzox01 joined
19:42 <geekosaur> does the generic representation even exist at runtime?
19:42 <Theophane> folks.
19:42 <glguy> geekosaur: It does if you're not careful
19:42 <Theophane> I came up with the |~> operator so I could pipe a variable as the 2nd argument of a function…
19:43 <Theophane> I think I caught the "custom operator" virus they warned me about :(
19:43 <cocreature> ph88: I think you might be better of using some Biplate like stuff (lens has it’s own copy of that) instead of Generics. but that might be related to me not really knowing generics :)
19:43 <Jinxit> are duplicate record names a thing yet?
19:43 <Jinxit> or is that still a problem?
19:44 rightfold left
19:44 <geekosaur> I thouthgt Biplate was where ph88 started a month or so ago
19:44 <cocreature> oh I’ve missed the start of this then
19:44 <geekosaur> Jinxit, still a problem unless you mean lens/whatever creating typeclasses for you
19:44 <Jinxit> alright
19:44 <ph88> cocreature, yeah i guess i'm forced to go the easier route now (the already proven stuff) .. i thought it would be viable to whip something up myself with some creativity .. but i'm close to giving up. Although i saw ndmitchell talking about wanting to reimplementing biplate in ghc.generics sometime but he never got around to it (which made be believe it was possible in the first place)
19:45 <geekosaur> part of the standard support is in 8.0.x, more coming in 8.2.x but OverloadedRecordFields is still future
19:45 <cocreature> Jinxit: GHC 8 has DuplicateRecordFields
19:45 <ph88> geekosaur, i was at biplate a few months ago (for another purpose in my code), then i dropped it to go with ghc generics (which worked for that part of the code). Now i need generics again to do some other stuff (change that last value) .. but for this use case it's seems much more difficult
19:45 splanch joined
19:46 <ph88> geekosaur, very likely for this specific use case it will be wise to consider biplate again .. in all honestly the project is not really progressing in the way i'm trying
19:46 osa1 joined
19:46 osa1 joined
19:46 <geekosaur> I'm not at all clear that the tooling to do what you want exists, tbh
19:46 <geekosaur> but I don't fully understand what you're up to
19:47 <ph88> me neither, it was a hard but interesting thing to discover .. seems not to work out ..
19:47 <ph88> basically lens biplate but on top of GHC.Generics instead of Data
19:47 <ph88> i was still using Typeable though
19:47 <ph88> i need to go (train arrives), be back later
19:47 bjz joined
19:48 diwank joined
19:49 <ph88> thanks guys
19:49 <ph88> bye
19:49 raycoll joined
19:50 orbifx joined
19:51 wtetzner joined
19:51 Disavowed left
19:52 insitu joined
19:53 <nshepperd> heh, * has a Typeable instance with TypeInType
19:54 psychicist__ joined
19:54 augur joined
19:55 Rodya_ joined
19:56 angelos joined
19:58 MitchellSalad joined
20:00 <lpaste_> nshepperd pasted “kind equality” at http://lpaste.net/353953
20:00 AdolphusGustavus joined
20:00 <nshepperd> int-index, glguy: this seems to work?
20:01 Guest62381 joined
20:01 Guest62381 left
20:02 detrumi joined
20:02 <glguy> nshepperd: Yeah, foo seems to show that the GADT translation adds an implicit kind equality to the Refl constructor that becomes available upon pattern matching
20:02 <nshepperd> yeah
20:03 tomphp joined
20:03 <nshepperd> If I cause a type error inside that context, the error message says the context is (k1 ~ k2, (a :: k1) ~~ (b :: k2), ...)
20:04 eacameron joined
20:06 afnizarnur left
20:07 splanch joined
20:07 eacameron joined
20:08 takle joined
20:09 danharaj joined
20:10 Koterpillar joined
20:10 dopey_ joined
20:11 raycoll_ joined
20:12 whatareyou joined
20:12 meoblast001 joined
20:13 <cocreature> well now I wrote a generic traversal for ph88 using generics-sop
20:13 <cocreature> but I still need Typeable
20:13 <cocreature> but at least not Data
20:14 <glguy> cocreature: Like this one? http://hackage.haskell.org/package/lens-4.14/docs/Generics-Deriving-Lens.html#v:tinplate
20:14 whatareyou left
20:14 <cocreature> glguy: yeah
20:14 gillesmajor joined
20:14 <cocreature> glguy: I mostly wanted an excuse to finally play around with generics-sop
20:15 gillesmajor left
20:16 curious_corn joined
20:17 afnizarnur joined
20:18 mkoenig joined
20:18 afnizarnur left
20:18 afnizarnur joined
20:18 a3Dman joined
20:20 psychicist__ joined
20:21 splanch joined
20:23 <CuriousErnestBro> how is haskell for optimization algorithms/dynamic programs?
20:24 jmcarthur joined
20:24 fizruk joined
20:24 curious_corn joined
20:25 Owatch joined
20:25 <Owatch> Hey.
20:25 <Owatch> Can anyone help me with installing Packages?
20:25 <Owatch> I've been trying to get Data.Heap. I thought it was included with the Haskell Platform but it seems not. I also couldn't figure out a way to get it using Cabel.
20:25 <geekosaur> maybe? ask your question
20:26 ramzifu joined
20:26 <geekosaur> hayoo tells me it' from the "heap" package
20:26 armyriad joined
20:26 marcopullo joined
20:26 takle joined
20:27 <Owatch> Ah
20:27 <* geekosaur> still thinks cabal should index exposed modules in a package, so it can do that translation for you
20:27 <Owatch> I see, I was trying: cable install Data.heap
20:27 <Owatch> Not just heap.
20:27 <Owatch> Okay, it seems to be working now.
20:27 <geekosaur> but it doesn't (nor does stack) so you end up having to ask something like hayoo to find the package a module comes from
20:28 <Owatch> Alright, it works now.
20:28 <Owatch> I can import it in Prlude.
20:28 <Owatch> Prelude*. Thank you!
20:29 psychicist__ joined
20:30 e14 joined
20:31 Welkin joined
20:32 dan_f joined
20:32 bshelden joined
20:34 augur joined
20:35 thimoteus joined
20:35 tom7942 joined
20:36 psychicist__ joined
20:36 hybrid joined
20:38 ystael joined
20:39 skeuomorf joined
20:41 data_hope joined
20:44 bartavelle joined
20:46 <orion> cocreature: It's OverloadedRecordFields.
20:46 mda1 joined
20:47 johtso joined
20:48 <orion> Or wait, maybe not.
20:50 sdothum joined
20:50 thimoteus joined
20:52 Fairy joined
20:52 psychicist__ joined
20:52 sbauman_ joined
20:52 Nolrai_ joined
20:53 enolan_ joined
20:53 oisdk joined
20:54 bd___ joined
20:54 lstrano_ joined
20:55 jaargon joined
20:55 jix_ joined
20:55 takle joined
20:55 pyrtsa_ joined
20:55 hnrk_ joined
20:55 jrkp_ joined
20:55 Ornedan_ joined
20:55 s4kashya4 joined
20:55 osa1_ joined
20:56 kipras joined
20:56 monty joined
20:56 KaneTW joined
20:57 marvin2 joined
20:57 afnizarnur1 joined
20:58 danharaj joined
20:59 IndigoTiger joined
20:59 Noldorin joined
21:00 <Cale> CuriousErnestBro: No worse than anything else. For dynamic programming, you can use lazy arrays of various sorts quite effectively.
21:00 whiteline joined
21:00 whiteline_ joined
21:01 <Cale> CuriousErnestBro: Of course, if you're looking for implementations of algorithms, you might not find everything you'd find for Matlab or whatever.
21:01 whiteline_ joined
21:01 IndigoTiger joined
21:01 afnizarnur joined
21:03 <Owatch> Is there a way to mute the messages about user connections / disconnections ?
21:04 coot joined
21:05 <benzrf> Owatch: it depends on your client
21:05 ragepandemic joined
21:06 fizbin joined
21:06 yellowj joined
21:06 <orion> Will lens ever land in base?
21:07 <benzrf> haha'
21:07 <Owatch> @benzrf using the web chat
21:07 <lambdabot> Unknown command, try @list
21:07 <benzrf> Owatch: not sure, then
21:07 whiteline joined
21:07 <Owatch> Oh well.
21:10 spacedog82 joined
21:11 fizbin joined
21:11 bob_ joined
21:12 whiteline joined
21:13 detrumi joined
21:14 ragepandemic joined
21:14 oisdk joined
21:14 <michi7x7> Owatch: I think you can, using the freenode-webchat, that is
21:14 Welkin joined
21:14 takle joined
21:15 <michi7x7> Owatch: yeah, options-menu and "Hide JOINS/PARTS/QUITS:"
21:15 afnizarnur joined
21:18 fizbin joined
21:19 twanvl joined
21:20 data_hope joined
21:20 carlosdagos joined
21:21 whiteline joined
21:21 raycoll joined
21:23 bjz joined
21:25 kirillow_ joined
21:26 eacameron joined
21:27 <Owatch> Are there any priority queues that come with the Haskell platform I can use?
21:28 <Owatch> Besides implementing my own, which would be a sort of 'insertion sort'.
21:29 ystael joined
21:30 kirillow_ joined
21:30 <hpc> does it have to be part of the platform? https://hackage.haskell.org/package/priority-queue
21:33 whiteline joined
21:34 kirillow_ joined
21:35 <Owatch> Well if it's short and I can implement it myself then I guess it'll work too.
21:35 kirillow_ joined
21:36 tom7942 joined
21:36 dawehner joined
21:36 kirillow_ joined
21:39 fosskers joined
21:39 takle joined
21:41 coot joined
21:43 Tesseraction joined
21:43 <sophiag> can anyone explain these errors I'm getting from Parsec? everything i'm trying to do is pretty simple so i'm a bit confused as to what's going wrong: http://lpaste.net/353955
21:44 sigmundv_ joined
21:46 <geekosaur> for the first one, sepBy wants the separator first but you are passing the list first
21:46 LuckyRawApe joined
21:46 dsh joined
21:47 <geekosaur> sepBy parser thing or parser `sepBy` thing (sepBy is not really infix-friendly, at least by its naming)
21:48 Rainb joined
21:48 fizruk joined
21:48 afnizarnur1 joined
21:48 <sophiag> ah, ok. thanks
21:49 <geekosaur> the second one, an HList is not a Haskell list and can't be used with []
21:49 cpup joined
21:49 <sophiag> oh, the reason i used infix sepBy in that order was because that's how the docs have it
21:50 <sophiag> HList is an adt i defined at the top. i don't believe i ever use it with [] here...
21:51 kylepotts joined
21:51 <geekosaur> oh. that's confusing. HList is kinda a standard thing heterogeneous list type)
21:51 <sophiag> geekosaur: why do the docs use this example for sepBy? "commaSep p = p `sepBy` (symbol ",")"
21:51 <kylepotts> thoughts on http://haskellbook.com/ and if its worth the $60?
21:52 <sophiag> yeah, i named it that beacuse what i wanted *is* a heterogenous list, but perhaps i should choose a more unique name that doesn't overlap with a common package
21:53 <* geekosaur> is getting confused trying to decipher this (not your fault, just took heavy duty sinus meds for it but they haven't kicked in yet)
21:53 fizbin joined
21:53 hiratara joined
21:53 cyborg-one joined
21:54 Scip joined
21:54 data_hope joined
21:54 <geekosaur> hm, your parseList seems wrong
21:54 oisdk joined
21:55 <geekosaur> but I don't think that's a compile time issue, the parser will diverge at runtime because there's nothing to stop the recursion
21:55 <orion> Let'
21:55 <sophiag> how so? i fixed all the calls to sepBy to be opposite order from the docs and that cleared up parsing for the second data type
21:55 <sophiag> oh i see
21:56 Eduard_Munteanu_ joined
21:56 <geekosaur> it parses '[' and reinvokes itself, requiring another '[' after which it reinvokes...
21:56 <geekosaur> never parses an *item*
21:56 <geekosaur> I think you have the same issue with parseRequireTagged
21:56 <sophiag> hmm?
21:56 splanch joined
21:56 <sophiag> it doesn't parse '[' tho. it calls between
21:58 <orion> Let's say I need an embedded DSL. I choose to represent the AST as a Free Monad and I'm off to the races. But later on I discover that I need to apply "transformations" to programs, which are defined like, "If the embedded program contains OperationA followed by OperationB, reverse the two operations". How do I continue?
21:59 tomboy64 joined
22:00 the_wit joined
22:00 takle joined
22:00 <orion> It seems kind of inelegant to represent the entire program as a List (e.g. [OperationA, OperationB, OperationC, ...]).
22:00 <the_wit> > take 5 [1..] ==> [1,2,3,4,5]
22:00 <lambdabot> error:
22:00 <lambdabot> • Couldn't match expected type ‘Bool’ with actual type ‘[Integer]’
22:00 <lambdabot> • In the first argument of ‘(==>)’, namely ‘take 5 [1 .. ]’
22:00 <sophiag> geekosaur: ghci is asking me if i want to add an OverloadedStrings pragma. do you think that has to do with it? i couldn't make sense of what you were saying before. it seemed to confuse the bodies of several functions
22:01 <geekosaur> re between, the first thing it does is call your opener parser which is (char '[
22:01 <the_wit> @sophiag, what are you trying to do and what ghc extensions are you using?
22:01 <lambdabot> Unknown command, try @list
22:01 <geekosaur> (char '[')
22:02 <sophiag> right, in a call to between
22:02 <sophiag> so it reads everything between that and (char ']')
22:02 <geekosaur> yes
22:02 <geekosaur> but it always looks for that open '['
22:02 <geekosaur> so it parses [[[[[[[[[...
22:03 <geekosaur> because there is no code path that does not immediately call (char '[')
22:03 <sophiag> really? i don't have a recursive call there
22:03 <geekosaur> parseList = do
22:03 <geekosaur> list <- between parseList (char '[') (char ']')
22:03 <geekosaur> looks recursive to me
22:04 <geekosaur> you might update your paste, including the full new error
22:04 <sophiag> oh i see what you're saying
22:04 <sophiag> that wsa the full error...
22:04 <the_wit> \clear
22:04 <geekosaur> the OverloadedStrings thing? that was not the full error
22:05 <sophiag> that was after i fixed the sepBy calls (which i'm still confused as to why the docs lists an opposite argument order)
22:05 <geekosaur> (it may suggest OverloadedStrings if you have mistakenly used a literal String where some other type is wanted)
22:05 fizbin joined
22:05 <geekosaur> parsec has a number of bugs including some documentation bugs that havebn't been fixed
22:06 <geekosaur> megaparsec is currently recommended because it has fixes for that stuff
22:06 <geekosaur> also, Text.ParserCombinators.Parsec is the old parsec 2 interface
22:06 <geekosaur> but I usppose whatever docs you're using are for parsec 2
22:06 takle joined
22:07 <sophiag> well i was looking at Text.Parsec, but still wondering why examples are incorrect
22:11 Gurkenglas_ joined
22:11 augur joined
22:12 ChaiTRex joined
22:14 fizbin joined
22:15 <zcourts_> How do I add a constraint to isConLike in http://pastebin.com/C4Mn9jGa to prevent http://pastebin.com/Q6hQubnL i.e. "No instance for (GhcMonad Maybe) arising from a use of ‘infoOpt’"?
22:16 hamishmack joined
22:17 <sophiag> geekosaur: i can't even figure out the type signature for Parsec 3. as in what to use for stream and state types? every Parsec tutorial uses Parsec 2 and the haddocks docs are not so helpful. i'm still wondering why they list the argument order to sepBy incorrectly, for example. unless they flip when it becomes infix?
22:18 <mauke> sophiag: what exactly is incorrect where?
22:19 fizbin joined
22:21 <sophiag> mauke: what i mentioned above. sepBy
22:21 <mauke> ...
22:21 <sophiag> commaSep p = p `sepBy` (symbol ",")
22:22 <mauke> where is that from?
22:22 <geekosaur> I may have misread hat you were doing, I'm still dizzy (and trying to back away from kbd...)
22:23 <sophiag> ok, i'll just state my question in whole again
22:23 dawehner joined
22:24 <sophiag> i'm still why the Parsec 3 docs the argument order to sepBy incorrectly. unless they flip when it becomes infix?
22:24 <mauke> sophiag: what exactly is incorrect where?
22:25 <sophiag> mauke: <geekosaur> for the first one, sepBy wants the separator first but you are
22:25 <sophiag> passing the list first [17:46]
22:26 eacameron joined
22:26 ramzifu joined
22:26 fizbin joined
22:26 <mauke> so geekosaur = the parsec 3 docs?
22:27 <geekosaur> yes, "I'm still dizzy (and trying to back away from kbd...)" absolutely means I am all in on any discussion
22:27 geekosaur left
22:27 the_wit joined
22:27 <sophiag> ok, how about this... give me a minute to change my code back to what it was an hour ago and then i'll start fresh
22:28 <mauke> it sounds like you don't want to help me
22:28 <mauke> this is a bit annoying
22:29 <sophiag> mauke: no, it's fine. it's just i apparently got a bunch of false advice so if you'd like to look at my code i need to change it back to before i changed everything incorrectly
22:29 <sophiag> i'm relatively new to haskell so i assume when someone says something authoratatively on here they're correct. that's all
22:30 eacamero_ joined
22:30 <MarcelineVQ> no one can be right every time :>
22:30 <mauke> I don't want to look at your code
22:30 <sophiag> ok, fine
22:30 <mauke> I want to look at the documentation you said was wrong
22:30 <MarcelineVQ> you can confirm quickly yourself how a parser works if its behavior is confusing you, load up your project in ghci (don't worry if it fails to load) and import Text.Parsec you now have access to the normal parsers of Parsec
22:31 ystael joined
22:31 oisdk joined
22:31 <mauke> but you're not telling me where you found it
22:31 <sophiag> mauke: the documentation isn't wrong. someone made a mistake in telling me that
22:31 hiratara joined
22:31 <sophiag> also i said several times where it was
22:31 <MarcelineVQ> or whichever way you import the parser lib in your own project
22:32 <sophiag> MarcelineVQ: i'm really confused by what you're saying
22:32 Koterpillar joined
22:32 <sophiag> someone told me an hour ago that my project wasn't compiling because i needed to do something differently from in the docs, i kept changing things, then they just said "oops i'm sick and was wrong"
22:33 <sophiag> that's all that's going on here
22:33 <MarcelineVQ> I'm saying if something's confusing you can play with it directly, e.g. import Text.ParserCombinators.Parsec in ghci and use parseTest
22:33 <sophiag> i'm also wondering if i have a connection problem because i seem to type a lot of things that no one sees
22:33 robkennedy joined
22:33 <sophiag> MarcelineVQ: the question was about compiler errors
22:34 fizbin joined
22:34 <mauke> if by "where" you mean "the Parsec 3 docs", that's a bit vague. I thought you might have a direct link handy
22:34 robkennedy joined
22:35 <sophiag> i didn't think that was vague. there's only one place it's officially documented
22:35 <hexagoxel> sophiag: how about "list <- between (char '[') (char ']') (yourElemParser `sepBy` char ',')"
22:36 tom7942 joined
22:36 <mauke> there's at least two
22:37 robertkennedy joined
22:37 agjacome joined
22:38 <sophiag> hexagoxel: thanks! i'm just getting an error on the return type now
22:38 fizbin joined
22:38 <hexagoxel> sophiag: sure, because the return types of »sepBy« and your function differ.
22:39 augur joined
22:39 eacameron joined
22:40 <sophiag> i'm also curious why it throws an error when i split it into two lines
22:40 <sophiag> even if i remove many, which apparently was unnecessary
22:41 fizruk_ joined
22:41 kau joined
22:41 <hexagoxel> because f (g x) is not the same as f >>= g.
22:42 <hexagoxel> sepBy takes, as first argument, a _parser_ for elements. you can't give it the _output of a parser_.
22:42 <sophiag> ah, ok. got it
22:43 <hexagoxel> apart from that the order of elements for between is messed up in the lpaste, but that is out of date anyways probably.
22:44 JeanCarloMachado joined
22:45 <sophiag> yeah, i realize that. i would use Parsec 3, but i couldn't figure out the type signatures considering literally every tutorial uses Parsec 2
22:45 <sophiag> what should be the stream and state types?
22:45 dfeuer joined
22:46 ebzzry joined
22:47 ddere joined
22:47 Voldenet joined
22:47 Voldenet joined
22:49 <mauke> in the simplest case? stream = String, state = ()
22:49 hvn0413 joined
22:50 <sophiag> i was asking generally and figured hexagoxel could help since they were looking at my paste
22:50 <hexagoxel> your paste is not relevant if the question was about the general case oO
22:50 the_wit joined
22:51 conal joined
22:51 <sophiag> ok, well i think i get what stream should be
22:51 <hexagoxel> stream can be String/Text/ByteString
22:51 <sophiag> right, i get that part
22:51 <mauke> I'm pretty sure parsec2 already had a user state
22:52 conal joined
22:52 <sophiag> i think the sugared type signatures in parsec 2 just ommitted the stream type, but could be wrong
22:52 <sophiag> if you just say Parser String, for example
22:52 <hexagoxel> sophiag: to make this clear: that kind of reply to mauke, who was clearly trying to answer your question, is not nice in my opinion.
22:53 <tobiasBora> Hello,
22:53 <tobiasBora> I'd like to know, I'm using the library https://hackage.haskell.org/package/parallel-io-0.3.3/docs/Control-Concurrent-ParallelIO-Local.html
22:53 <sophiag> hexagoxel: my intention was to spare them time since they stated earlier "i don't want to look at your paste"
22:53 <sophiag> that's all
22:53 <sophiag> and i didn't state it rudely
22:54 louispan joined
22:54 <tobiasBora> Do you agree that the function parallelE_ gives the result in the same order as the list input?
22:54 fizbin1 joined
22:54 <sophiag> my questions at this point are likely to be invovled so if someone says they don't have the time or interest then why waste their time? that would seem rude to me
22:54 <hexagoxel> a nice response would look like "ok, thanks; what about the general case?"
22:55 <tobiasBora> (I'm using this property to zip the errors with the input list in order to try them later, so I'd like to be sure that it is indeed corresponding)
22:55 <hexagoxel> sophiag: the first response you got on your question was unfortunate, without any parting having bad intentions.
22:55 <hexagoxel> it probably confused you more than it helped, and i am sorry for that.
22:55 dawehner joined
22:56 <sophiag> you mean geekosaur? that's fine. he's sick and made a mistake
22:56 mmachenry joined
22:56 <mauke> my earlier comments were in the context of *me* asking *you* a question
22:56 <sophiag> mauke: have we cleared up the doc confusion tho?
22:56 <sophiag> why i even asked that and why it's not an issue?
22:57 <lyxia> tobiasBora: That sounds quite likely.
22:57 <tobiasBora> lyxia: Ok thank you, I wasn't sure to understand the doc correctly.
22:58 <* hexagoxel> needs to learn to switch to pm for certain kind of feedback.
22:58 <mauke> sophiag: probably not because I didn't realize you were asking anything
22:58 <sophiag> mauke: right when you came into the discussion geekosaur clarified he made a mistake and so that issue is mute
22:59 <sophiag> *moot
22:59 <sophiag> anyway
22:59 splanch joined
22:59 <sophiag> anyway, what i was asking after that was about the type signatures
22:59 <hexagoxel> sophiag: argh the parsec2 docs are confusing. GenParser does not even have docs? meh.
22:59 eacameron joined
23:00 <sophiag> no, i mean as in examples. the hackage page refers you to real world haskell, write yourself a scheme, and parsec 2 docs from the wayback machine
23:00 conal joined
23:01 <sophiag> so like i can't find any examples anywhere using parsec 3 just to figure out type signatures
23:01 Gentilhomme joined
23:03 rcat joined
23:03 fizbin joined
23:03 ermau joined
23:04 sypwex joined
23:04 augur joined
23:04 dawehner joined
23:05 suls joined
23:05 <sophiag> well, if any one can help me with parsec 3 type signatures as compared to parsec 2 that would be appreciated. i can't find examples anywhere :/
23:05 tom7942 joined
23:08 <davean> sophiag: Are you trying to update ancient code?
23:08 <sophiag> every tutorial on parsec uses parsec 2
23:09 <davean> Why don't you just go off the haddocks?
23:09 <sophiag> i'm trying to switch from the only way possible to learn it to the current version
23:09 <davean> https://hackage.haskell.org/package/parsec-3.1.11/docs/Text-Parsec.html
23:09 <sophiag> haddock is not very helpful if you've never used something before
23:10 <davean> Oh, its how I learn just about everything
23:10 wtetzner joined
23:10 <sophiag> you learned haskell by reading type signatures with no examples?
23:10 <davean> Do you ahve any particular things that aren't clear? I might be able to help with that?
23:10 <davean> Yes?
23:10 <sophiag> wow ok
23:10 suls joined
23:10 <sophiag> i actually had to learn what types were and such before i could read haddock
23:10 <sophiag> that's impressive
23:11 <davean> I think its pretty normal
23:11 <davean> With some experience I expect you'll find it easy and intuative
23:11 <davean> But, here, if you ahve a specific question, maybe I can answer it?
23:11 <davean> I haven't used Parsec in years, but I've got hte docs open
23:11 louispan joined
23:11 <sophiag> sure. but i'm saying as a beginner
23:11 <hexagoxel> in rust i am annoyed that the docs default to showing docs+examples, instead of just giving an overview of types first :p
23:11 <davean> hexagoxel: I know, itsn't it annoying?
23:12 whaletechno joined
23:12 <sophiag> davean: i'm just wondering what a type signature should look like in parsec 3
23:12 <hexagoxel> (in haskell i'd just search by type, so how the docs are displayed is no issue)
23:12 <davean> sophiag: for?
23:12 <davean> sophiag: you'll have to be more specific about what you want it to DO
23:12 <davean> a type depends on function
23:12 <sophiag> well if you're parsing a string in parsec 2 you can just use "Parser String" and that's it
23:13 <davean> Right, so we've got "type Parsec s u = ParsecT s u Identity" then
23:13 <davean> we want a String out
23:13 aglorei joined
23:13 <davean> sophiag: so, what are we parsing it out of?
23:13 <sophiag> in 3 i need the stream type (which i understand), the state, and then two more types
23:13 <davean> We know it'll be "Parsec s String"
23:13 <davean> but we need to fill in s
23:14 <sophiag> the stream is a string
23:14 <davean> (since you're getting out a string, thats u)
23:14 <davean> Ok, so you're parsing a string otu of a string?
23:14 <sophiag> but that's not sufficient. the compiler says in need something like "Parsec String String -> * -> *
23:14 <sophiag> in one example i am
23:15 <davean> are you using ParsecT or Parsec?
23:15 <sophiag> Parsec
23:15 <hexagoxel> (u is not the output.. or do i misunderstand?)
23:15 <mauke> no, u is the state
23:15 ludat joined
23:15 <davean> hexagoxel: sorry, I did say that wrong
23:15 <sophiag> u is the state
23:15 sandonfuge joined
23:15 <mauke> if your parser doesn't use it, you can leave it a variable
23:15 <sophiag> the stream in this case is String
23:16 <sophiag> ah ok. i may actually use it, but not yet
23:16 <davean> Parsec String u String
23:16 <davean> let me check that
23:17 <sophiag> oh damn, that looks right
23:17 <davean> runParser (undefined :: Parsec String () String) () "test" "Test"
23:17 <davean> types
23:17 <mauke> in parsec 2 we had: type Parser a = GenParser Char () a
23:17 <mauke> i.e. the user state was hardcoded to ()
23:17 <sophiag> right, that confused me
23:17 bryanlemon joined
23:17 <davean> Yah, I dropped in () because we're ignoring it here
23:18 <sophiag> although i think the newer way is more straightforward if you're actually using it as a state monad
23:18 <davean> sophiag: here, let me take you through how I did that?
23:18 <sophiag> which i may. i'm just trying to get it to work for now
23:18 <davean> first I went to "runParser :: Stream s Identity t => Parsec s u a -> u -> SourceName -> s -> Either ParseError a"
23:18 <davean> I know what we want to get out must be 'a'
23:18 <davean> so I just filled that in for "runParser :: Stream s Identity t => Parsec s u String -> u -> SourceName -> s -> Either ParseError String"
23:19 <sophiag> oh i see. you're saying when i need to figure out type signatures for the first time that's how to approach it
23:19 <davean> Yah, just start filling stuff in and see where you get
23:20 <sophiag> right, and the errors should get more descriptive
23:20 <davean> now, I can tell s must be what we're parsing out of because of the class constraint
23:20 OGLoli joined
23:20 <davean> so, we can have a little question about its form, but to resolve that we can jump to the class definition
23:20 <davean> instead I just threw in String because I was pretty sure that would be a valid stream for it
23:20 <davean> then I had to look at the actual comments for u
23:21 <davean> decided we didn't care about it, and threw in ()
23:21 <davean> Does that help?
23:21 <mauke> looking at run* functions is generally a good idea because it tells you what the inputs and outputs are
23:21 <davean> mauke: right
23:21 bryanlemon joined
23:21 <mauke> e.g. you can see 's' and 'u' going on and 'a' coming out
23:21 <sophiag> yeah, i didn't think about that
23:21 <mauke> *goin in
23:21 <mauke> blargh
23:22 <davean> sophiag: does that make it clearer how to teach yourself given the haddocks? You should be able to not need a tutorial with a little practice
23:22 <davean> generally I was just doing "unification" by hand
23:22 <sophiag> for the type signatures at least. i'd still need a tutorial to understand much of how things work
23:23 <davean> sophiag: well, a lot of things can only work one way if their types are general enough
23:23 <davean> see Theorems for Free
23:23 carlosdagos joined
23:23 <sophiag> i mean basic syntax usually
23:23 <davean> oh
23:24 <davean> yah, syntax is a different issue, thats general haskell knowlege
23:24 <davean> I won't suggest you don't want a tutorial for learning the *language*
23:24 <sophiag> that seemed to be the case. lol
23:24 <sophiag> but thanks, this was helpful
23:24 <davean> Just that a well-typed library quickly removes the interest in having a tutorial
23:24 <davean> one finds a tutorial is just in the way if they types are done well
23:24 augur joined
23:24 <davean> sophiag: glad I could be of service!
23:25 markus1209 joined
23:25 ramzifu joined
23:25 markus1219 joined
23:25 <sophiag> well, i'm still where i was 2.5 hrs ago except i've switched to parsec 3. lol
23:25 <davean> sophiag: if you ahve any more questions, ask. Specific questions get the best answers though.
23:26 fizbin1 joined
23:26 <davean> "How do I use Parsec 3" will likely get silence
23:26 <davean> "How do I do $X with Parsec 3" is far more likely to get a useful response
23:26 <sophiag> no, it was originally a whole paste then i got some wrong answers then some people got mad when i repeated them, etc.
23:26 mmn80 joined
23:26 <sophiag> that's been my last two hours
23:26 <davean> lol
23:26 theDon_ joined
23:26 <davean> sorry
23:27 <sophiag> eh, it goes with irc
23:27 <sophiag> a lot is learning who has trouble communicating slash a bad temper
23:28 eacameron joined
23:28 <sophiag> here's my code updated to use Parsec 3: http://lpaste.net/353955
23:29 <sophiag> on line 19 i'm not sure how to deal with the return type
23:29 <sophiag> i want it to be able to return lists of either strings, chars, or nums. hence that adt
23:29 <davean> well
23:30 <davean> you need to tell it WHAT to return
23:30 <davean> so maybe take a parser for what you want to parse?
23:30 <davean> parseList :: Parser String u a -> Parser String u [a]
23:30 <sophiag> oh i see. rather than specifying the type
23:31 <sophiag> that signature doesn't work
23:31 <davean> TECHNICALLY what I did specifies the type, but the first argument, but doesn't specify VIA the type
23:31 <davean> well, it makes your function take an argument
23:31 <davean> which is a parser for the type your list is made of
23:31 ystael joined
23:32 <sophiag> no, that's not what it does
23:32 <kylepotts> Has anyone used this book to learn Haskell what do you think about it? http://haskellbook.com/
23:32 <sophiag> it is a parser that returns a list of type HList (defined on line 3)
23:32 <orion> kylepotts: 10/10 would read again
23:32 <sophiag> it parses streams of strings
23:32 <davean> sophiag: You really want the HList there?
23:33 <sophiag> yes, because i made this just to use in parsers that return a record that requires it
23:33 fizbin joined
23:33 <davean> I dobut you actually do, but ok
23:33 slack1256 joined
23:33 <davean> ok, so, first off, your HList definition is ... well, its screwy
23:34 splanch joined
23:34 <sophiag> lol ok
23:34 <davean> data HList = List String | Char | Num deriving (Show)
23:34 <davean> So you have 3 constructors
23:34 <slack1256> how to use cabal's data-files: and cabal build? (data files are only placed on cabal copy, not cabal build)
23:34 <davean> List, which holds a String
23:34 <davean> Char, which holds nothing, and Num which holds notihng
23:35 <davean> Do you want anything like that at all?
23:35 <sophiag> i think i want something like this: data HList = HList [String] | HList [Char] | HList [Num] deriving (Show)
23:35 lambda-11235 joined
23:35 <sophiag> right?
23:36 <davean> Ok, you want it to contain a list, which can be all of Char, or all of Num, or all of String?
23:36 <davean> (mind you Num isn't valid)
23:36 <davean> and yes, that makes more sense
23:36 <sophiag> yes. oh Num can only be a constraint?
23:36 <davean> yes, its a class, it isn't a type
23:36 <sophiag> is there a general numerical type?
23:37 <davean> No, what would happen if you added a Float to a Quaternion?
23:37 <sophiag> realistically i could use Integer for now i suppose
23:37 Kallis joined
23:37 <davean> What operation is that?
23:37 <davean> it certainly isn't Float or Quaternion addition!
23:37 <sophiag> aren't floats part of the Num instance?
23:38 <sophiag> so they use the same addition?
23:38 <davean> No, each type uses DIFFERENT addition
23:38 <davean> a Quaternion also could (probably?) be Num
23:38 <davean> (I'm pretty sure but I'd have to double check)
23:38 <Koterpillar> there's no "Num instance", there are different instances
23:38 <Koterpillar> sophiag: Int and Bool are both instances of Eq, but you can't compare them
23:39 dan_f joined
23:39 splanch joined
23:39 TCZ joined
23:40 <sophiag> oh, i'm thinking of an example that used the Num instance and had "default (Integer, Rational, Double)"
23:40 <Koterpillar> sophiag: typically we say "Int instance for Num", not "Num instance"
23:40 <Koterpillar> so I'm not sure what you meant
23:40 <sophiag> "instance (Num a, Eq a) => Num [a] where"
23:41 <Koterpillar> that's an instance of Num for [a]
23:41 <davean> Based on the instance of Num for a
23:42 <davean> Theres only 2 Num instances used there
23:42 <davean> the one being writen
23:42 <sophiag> right. and you said typically we don't use the Num instance
23:42 <davean> and the one for the *single* type the list contains
23:42 <davean> All we're doing there is saying there *is* a num instance
23:43 <sophiag> ok, so in the interest of debugging my actual code...do you think it even makes sense to have that adt for different lists?
23:43 <davean> sophiag: no, not really, thats what I was getting at
23:43 <sophiag> yeah, seems like it
23:43 <davean> I'd do something like:
23:44 <davean> parseList :: Parser String u a -> Parser String u [a]
23:44 <davean> and then
23:44 <sophiag> except, i already mentioned that doesn't compile
23:44 <davean> parseList parseNum <|> parseList parseString <|> parseList parseChar :: HList
23:44 <davean> if I WAS going to use HList
23:45 <davean> No, that function CAN exist, it just isn't what you've writen
23:45 <davean> I'm proposing a change to the function
23:45 <davean> I'm proposing defining your parser based on another parser
23:45 <davean> now, why don't you know what you'll be parsing out ahead of time?
23:45 <davean> lets go there
23:45 <davean> why does HList exist at all?
23:46 <sophiag> because i know I WILL be parsing all three of those types
23:46 <sophiag> at least Ints, maybe other numerical types
23:46 <davean> Sure
23:46 <davean> when
23:46 <dmwit> davean: Because people keep thinking they want it. I mean, they keep being wrong, mostly, but... the heart is inscrutable.
23:46 <davean> dmwit: this isn't THAT HList
23:46 <dmwit> oh =P
23:47 <davean> I know why people think they want the ACTUAL HList
23:48 <OGLoli> Hello, I'm new to Haskell and new to programming in general. I was wondering if anyone could point me to any resources so that I can learn for myself on how to solve this problem. http://lpaste.net/353961
23:48 <sophiag> davean: so keeping in mind what i'm actually doing rather than changing this to do something else?
23:48 fizbin1 joined
23:48 <davean> sophiag: But since it doesn't work I can't tell what you're doing
23:48 <davean> If I could tell, it would compile :-p
23:49 <davean> Ok
23:49 <dmwit> OGLoli: That's an admirable question!
23:49 <davean> so lets work with minimal change
23:49 <sophiag> ok, i have this record: data Amb = Amb { tag :: Maybe String, value :: [a] } deriving (Show)
23:49 bryanlemon joined
23:49 <sophiag> i want the value field to be lists of several types
23:49 <dmwit> OGLoli: You might like Hoogle. It is a Haskell search engine where you give it a type and it proposes a function.
23:49 <dmwit> ?where hoogle
23:49 <lambdabot> http://haskell.org/hoogle http://fpcomplete.com/hoogle – See also Hayoo, which searches more packages: http://hayoo.fh-wedel.de/
23:49 <davean> sophiag: so, Amb is a tagged value, and 'a' depends on the contents of the String?
23:49 <OGLoli> Thank you, dmwit. I will give it a try.
23:49 geekosaur joined
23:49 <davean> sophiag: what does Nothing lead to?
23:50 <sophiag> Nothing means there's nothing in that field
23:50 <dmwit> OGLoli: In this case, you want to give it the function (-) and get back a function that does (-) on two lists. So:
23:50 <sophiag> a does not depend on the contents of the String
23:50 <sophiag> it's wholly distinct
23:50 <davean> Ok, so first off, note theres nothing specify 'a'
23:50 <dmwit> ?hoogle (Double -> Double -> Double) -> [Double] -> [Double] -> [Double]
23:50 <lambdabot> Data.KMeans kmeansGen :: (a -> [Double]) -> Int -> [a] -> [[a]]
23:50 <lambdabot> Data.List deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
23:50 <lambdabot> Data.List unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
23:50 <sophiag> that's why it's a separate field
23:50 <davean> so you can't ever actually put anything there
23:50 <dmwit> ?hoogle+
23:50 <lambdabot> Data.List intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
23:50 <lambdabot> GHC.OldList deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
23:50 <lambdabot> GHC.OldList unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
23:50 <sophiag> well you saw what it said before and suggested i change it
23:50 mizu_no_oto joined
23:51 <davean> so, are you sure that the list will contain all the same type?
23:51 <dmwit> OGLoli: Those results aren't too great. But the website one seems to do better. =P
23:51 <sophiag> yes
23:51 <davean> ok
23:51 bryanlemon joined
23:51 <OGLoli> I'll use the website. Thank you, dmwit.
23:51 <davean> then data HList = SList [String] | CList [Char] | IList [Integer]
23:51 <sophiag> and then parseList is a helper function that just creates a list from a string that contains a list in standard haskell form
23:51 <davean> then parseList :: Parser String u HList
23:51 <davean> but then your problem is two fold
23:52 <davean> first off "(parseList `sepBy` char ',')" is recursive and won't ever parse anything
23:52 <dmwit> OGLoli: If you spend five or ten minutes without making progress, I encourage you to come back here. We're happy to help, and it will only take us a few seconds to put you on the right track.
23:52 <davean> second, you need choice
23:52 <davean> so
23:52 <davean> parseList :: Parser String u HList
23:52 <davean> parseList = do
23:52 <sophiag> davean: again, not something i had orginally. i was told to change it to that by someone on here
23:52 <davean>
23:52 <davean> er, lets start over
23:52 <davean> parseList :: Parser String u HList
23:53 <sophiag> yeah
23:53 marsam joined
23:53 Rodya_ joined
23:53 <sophiag> i feel like i need to remember everyone who forcefully yells at me about something and then turns out to be wrong. lol
23:53 <sophiag> i could save hours of time :p
23:53 <davean> parseList = (IList <$> parseSub parseI) <|> (SList <$> parseSub parseS) <|> (CList <$> parseSub parseC)
23:53 <davean> where
23:54 <davean> parseSub p = (between (char '[') (char ']') (p `sepBy` char ',')
23:54 <davean> there
23:54 <davean> see how that works?
23:54 <sophiag> yup. thanks :)
23:54 <davean> we're parsing 'p's that are seperate by ','s
23:54 <davean> The order of the options matters
23:54 <sophiag> i just figured once i had HList i could use it to generically parse all of those types
23:55 sypwex joined
23:55 <davean> Numbers probably parse as Strings
23:55 <davean> and chars probably parse as Strings
23:55 <sophiag> oh, that's good. i wouldn't have thought of that
23:55 <davean> We still have a problem
23:55 <davean> single digit numbers might parse as chars
23:56 <davean> or chars that are only numbers might parse as nums
23:56 <sophiag> yeah there seem to be lots of possibilites for error there
23:56 <davean> sadly your format is ambiguous
23:56 <davean> your format doesn't have enough specificity to actually be parsed "correctly"
23:56 sgronblo joined
23:56 <davean> which is why I don't think you actually want HList
23:57 <davean> but I think my order makes the best guess possible for most needs
23:57 fizbin joined
23:57 sleffy joined
23:57 <sophiag> i probably need something more complicated than this
23:58 <sophiag> i didn't want to have to use all the structure in Write Yourself a Scheme, especially since it uses Parsec2 and stores everything in IORefs. a lot of choices i wouldn't make
23:58 <davean> Yah, which is why I was giving you pushback all the way up top
23:58 YongJoon joined
23:58 <sophiag> well, it's different saying "make your program do a different thing"
23:59 e14 joined
23:59 <davean> No, I was saying "Doing that isn't really well defined"