tsahyt 2017-01-31 05:45:10
but surely it's only ever going to be evaluated once
c_wraith 2017-01-31 05:46:18
there's a non-zero cost to checking that something is already evaluated, even if it's less than the cost of doing the evaluation
tsahyt 2017-01-31 05:46:34
hmm I hadn't thought of that
reactormonk 2017-01-31 05:54:41
Does something like [(a, Maybe b)] -> [(a, b)] already exist?
kadoban 2017-01-31 05:56:28
:t catMaybes . map sequence
lambdabot 2017-01-31 05:56:31
Traversable t => [t (Maybe a)] -> [t a]
kadoban 2017-01-31 05:56:54
:t catMaybes . map sequence :: [(a, Maybe b)] -> [(a, b)]
lambdabot 2017-01-31 05:56:56
[(a, Maybe b)] -> [(a, b)]
kadoban 2017-01-31 05:57:16
Ya, that unifies. So you convert it into [Maybe (a, b)] and then just use catMaybes
tsahyt 2017-01-31 06:02:22
@djinn (a, Maybe b) -> Maybe (a,b)
lambdabot 2017-01-31 06:02:22
f (a, b) =
lambdabot 2017-01-31 06:02:22
case b of
lambdabot 2017-01-31 06:02:22
Nothing -> Nothing
lambdabot 2017-01-31 06:02:22
Just c -> Just (a, c)
reactormonk 2017-01-31 06:02:23
Is there a better way to write `fmap ("redirect_uri",) $ fmap serializeURIRef' $ oauthCallback oa`
tsahyt 2017-01-31 06:02:33
well that wasn't as helpful as I hoped
tsahyt 2017-01-31 06:05:11
@hoogle (a, f b) -> f (a,b)
lambdabot 2017-01-31 06:05:12
Music.Theory.Tuple t2_sort :: Ord t => (t, t) -> (t, t)
lambdabot 2017-01-31 06:05:12
Data.Vector.Hybrid projectFst :: Vector u v (a, b) -> u a
lambdabot 2017-01-31 06:05:12
Data.Vector.Hybrid projectSnd :: Vector u v (a, b) -> v b
tsahyt 2017-01-31 06:05:27
hmm, surely there must be something like that somewhere
roxxik 2017-01-31 06:05:40
:t _2 :: Lens' (a,b) b
lambdabot 2017-01-31 06:05:42
Functor f => (b -> f b) -> (a, b) -> f (a, b)
tsahyt 2017-01-31 06:05:57
:t sequenceA
MarcelineVQ 2017-01-31 06:05:59
tsahyt: yes it's called sequence as kadoban used :>
lambdabot 2017-01-31 06:06:01
(Traversable t, Applicative f) => t (f a) -> f (t a)
tsahyt 2017-01-31 06:07:07
I gotta remember that, I have this sort of transformation happening way too often
tsahyt 2017-01-31 06:08:01
and (,) <$> pure (fst x) <*> snd x is very unsatisfying
tsahyt 2017-01-31 06:08:23
sometimes I can't see the forest for all the trees I suppose
mwl 2017-01-31 06:08:47
hey haskell, um, i have a question
MarcelineVQ 2017-01-31 06:08:53
reactormonk: fmap f . fmap g = fmap (f . g) so if I'm reading your text correctly, an improvement could be: fmap (("redirect_uri",) . serializeURIRef') $ oauthCallback oa
roxxik 2017-01-31 06:10:20
:t \k (a,b) -> (, a) <$> k b
lambdabot 2017-01-31 06:10:22
Functor f => (t2 -> f t) -> (t1, t2) -> f (t, t1)
tsahyt 2017-01-31 06:10:37
mwl: just ask
roxxik 2017-01-31 06:11:50
:t _2 id `asAppliedTo` ("hello", pure 2)
lambdabot 2017-01-31 06:11:52
(Applicative f, Num b) => ([Char], f b) -> f ([Char], b)
mwl 2017-01-31 06:13:31
so, while running with ghci, and ":load"ing the haskell code, the lines print out exactly how I want them, but when compiling with ghc, it seems to skip one line of execution, then print two lines in the same line
mwl 2017-01-31 06:13:42
let me grab the code so you can see what im talking about
mwl 2017-01-31 06:14:19
import Control.Monad
mwl 2017-01-31 06:14:19
main :: IO ()
mwl 2017-01-31 06:14:19
main = forever loop
mwl 2017-01-31 06:14:19
loop = do
mwl 2017-01-31 06:14:19
putStr ">> "
mwl 2017-01-31 06:14:22
cmdInput <- getLine
mwl 2017-01-31 06:14:24
putStrLn ( "you said: " ++ cmdInput)
phadej 2017-01-31 06:14:27
use pastebins
mwl 2017-01-31 06:14:35
shit, my b
phadej 2017-01-31 06:14:45
e.g. http://lpaste.net/
phadej 2017-01-31 06:14:52
np
mwl 2017-01-31 06:15:09
the code: http://pastebin.com/n6HQGWCa
ph88^ 2017-01-31 06:18:13
mwl, maybe after cmdInput you need to print another ln ?
MarcelineVQ 2017-01-31 06:18:21
possilby some sort of buffering issue in your terminal :X your code works for me in ghci and compiled
ph88^ 2017-01-31 06:18:39
MarcelineVQ, maybe try without ghci
zipper 2017-01-31 06:18:51
How do you guys mock network calls?
mwl 2017-01-31 06:19:20
yeah it works exactly how i want in ghci, but actually compiling it seems to not work
zipper 2017-01-31 06:19:35
Is this a thing https://haskell-servant.readthedocs.io/en/stable/ ?
mwl 2017-01-31 06:19:45
i thought it may be a terminal buffering thing but i'm not sure how to test that
mwl 2017-01-31 06:19:54
zipper: checking that out
MarcelineVQ 2017-01-31 06:20:19
zipper: what are you asking? :>
mwl 2017-01-31 06:20:48
oh my b zipper, thats something else
zipper 2017-01-31 06:20:58
MarcelineVQ: I have a function that reads a lazy bytestring off the network, I probably want to use pipes for this though.
zipper 2017-01-31 06:21:16
Anyway I want to be able to test that it only reads part of the file and such
glguy 2017-01-31 06:21:47
mwl: The stdout in a compiled program using LineBuffering by default
MarcelineVQ 2017-01-31 06:21:49
ah I meant about servant sorry, it is indeed a thing and quite interesting
zipper 2017-01-31 06:21:56
I need to make e.g a get request for a larger then 32 kb resource and check that it only read 32 kb
glguy 2017-01-31 06:22:05
mwl: If you want to print a partial line you'll need to use hFlush stdout
zipper 2017-01-31 06:22:16
MarcelineVQ: Oh ok is it easy to use servant to mock a webserver?
zipper 2017-01-31 06:22:27
mwl: What do you mean?
glguy 2017-01-31 06:22:29
mwl: GHCi disables buffering
mwl 2017-01-31 06:23:27
glguy: ah, ty. i'll try to use hFlush and see if that works
mwl 2017-01-31 06:23:54
zipper: sorry, thougt your question was a suggestion for my question, but it was completely unrelated...
zipper 2017-01-31 06:24:48
MarcelineVQ: As I read the doc I see the :> pun haha
MarcelineVQ 2017-01-31 06:25:05
coincidence but fitting
tsahyt 2017-01-31 06:25:46
mwl: http://sprunge.us/HOWS an alternative way to disable the buffering
MarcelineVQ 2017-01-31 06:26:05
it's easy to get a webserver started with servant, I don't have enough experience with it and servers in general to say much more than that though
MarcelineVQ 2017-01-31 06:26:58
possibly better off with scotty if you want something to just get working on right away, not sure
mwl 2017-01-31 06:29:12
glguy: using hFlush worked, ty :)
tsahyt 2017-01-31 06:29:31
mwl: you can just disable the buffering altogether too if you need to
tsahyt 2017-01-31 06:29:33
in some cases that makes sense
dfrown 2017-01-31 06:29:51
What is the current, best way to learn Haskell? Is haskellbook good enough?
mwl 2017-01-31 06:30:11
tsahyt: i think i prefer your solution actually, for what i'm trying to do
bitemyapp 2017-01-31 06:30:18
joeyh: Barely, I just picked up maintenance.
bitemyapp 2017-01-31 06:30:34
joeyh: upgrading to 2.5 was a matter of reusing an existing fork I'd been kicking around (I didn't write that)
bitemyapp 2017-01-31 06:31:07
joeyh: Persistent 2.5 that is. mrkkrp brought it up to persistent 2.6 and base 4.9
ryantrinkle 2017-01-31 06:31:19
does anyone know of a utility that can automatically split a package into two (or more?) packages?
ryantrinkle 2017-01-31 06:31:29
e.g.: suppose I have a package with Foo.Bar and Foo.Baz
ryantrinkle 2017-01-31 06:31:34
and i'd like Foo.Bar to be in its own package now
MarcelineVQ 2017-01-31 06:31:46
dfrown: if you mean haskell programming from first principles, yes it's certainly good enough
mwl 2017-01-31 06:32:09
yeah tsahyt, ty, i like that
stephaner 2017-01-31 06:32:21
hi everyone, I have the impression that stack clean then stack build does not reflects my code modifications in the generated executable. And if I do stack clean, then stack exec my-executable still works. Any idea what I should check to know what's wrong ?
dfrown 2017-01-31 06:32:38
MarcelineVQ thanks! That's all the confirmation I need
tsahyt 2017-01-31 06:33:33
mwl: keep in mind that in some cases buffered output is more performant for when you're doing a lot of print calls
MarcelineVQ 2017-01-31 06:35:02
stephaner: you might need stack clean --full I'm having trouble finding in the documentation what stack clean actually cleans
kadoban 2017-01-31 06:35:45
stephaner: Check 'stack exec -- which my-executable'
mwl 2017-01-31 06:36:29
tsahyt: if i left buffered output on, whats the best way to avoid messing up the print order like i had before?
tsahyt 2017-01-31 06:36:45
mwl: explicitly flushing when you need to
tsahyt 2017-01-31 06:37:02
you could of course also define a putStr' that is "strict" in its output, i.e. flushes immediately
mwl 2017-01-31 06:37:05
tsahyt: so use hFlush pretty much?
tsahyt 2017-01-31 06:37:21
putStr' x = putStr x >> hFlush stdout
mwl 2017-01-31 06:37:44
ahh ic ic
stephaner 2017-01-31 06:38:56
kadoban: stack exec --which my-executable doesnt seem to work. the command does seem to accept the --which flag
MarcelineVQ 2017-01-31 06:39:07
the space after -- is important
kadoban 2017-01-31 06:39:20
stephaner: There's a space that was intended
MarcelineVQ 2017-01-31 06:41:22
stack clean doesn't delete .stack-work/install so your exe will still exist after a clean, you could try stack build --force-dirty and see if that rebuilds things
MarcelineVQ 2017-01-31 06:42:54
you should check in a basic way whether modifcations to your code produce a changed executable, something simple like spitting out a string in main or from the module you suspect isn't being recompiled
lpaste 2017-01-31 06:43:35
qmm pasted "my first stack overflow with haskell :) (help very much appreciated)" at http://lpaste.net/351827
MarcelineVQ 2017-01-31 06:44:12
qmm https://wiki.haskell.org/Foldr_Foldl_Foldl'
MarcelineVQ 2017-01-31 06:45:03
allthough, second infinite?
kadoban 2017-01-31 06:45:05
"second" appears to be an infinite list, and you're apparently using the result