Search Haskell Channel Logs

Monday, February 6, 2017

#haskell channel featuring kadoban, tsahyt, jstolarek, doubleleft_, Atlantic778, jameseb, and 10 others.

jameseb 2017-02-06 03:48:16
Atlantic778: why can't you use external libraries?
Atlantic778 2017-02-06 03:49:50
jameseb: I'm learning haskell by solving examples from programming competitions. You upload code and "online judge" (automated tests) will tell if your solution is good enough. Code gets compiled online and I can't use any external dependencies.
shapr 2017-02-06 03:50:26
Atlantic778: which online competition(s) uses Haskell?
Atlantic778 2017-02-06 03:51:13
shapr: SPOJ (sphere online judge) backend has support for haskell, to. For example, you can solve tasks on the codechef site in haskell.
jstolarek 2017-02-06 03:51:20
from Control.Arrow:
jstolarek 2017-02-06 03:51:22
first :: a b c -> a (b, d) (c, d)
jstolarek 2017-02-06 03:51:30
is there a monadic equivalent?
jstolarek 2017-02-06 03:51:34
rougly:
kadoban 2017-02-06 03:52:25
hackerrank and codeforces allow haskell as well. I like those places
jstolarek 2017-02-06 03:52:42
a b (m c) -> a (b, d) (m (c, d))
jameseb 2017-02-06 03:52:44
Atlantic778: okay, so does the competition say what do you have access to?
kadoban 2017-02-06 03:53:28
jre2: \f -> sequence . first f probably?
Atlantic778 2017-02-06 03:53:30
jameseb: as far as I know, it's says only ghc-7.6.3.
Tuplanolla 2017-02-06 03:54:13
@let import Data.Bitraversable
Atlantic778 2017-02-06 03:54:14
it says*
lambdabot 2017-02-06 03:54:15
Defined.
Tuplanolla 2017-02-06 03:54:31
> bisequenceA (bimap (Just . negate) pure (42, 13)) -- This, jstolarek?
lambdabot 2017-02-06 03:54:34
Just (-42,13)
kadoban 2017-02-06 03:54:36
hackerrank has GHC 7.8.4, I think codeforces is 7.8.3 for some reason
jameseb 2017-02-06 03:54:57
Atlantic778: okay, then I assume you only have access to GHC base
kadoban 2017-02-06 03:56:33
Usually there's a bit more allowed beyond base, though it can be a tad annoying figuring out what
jameseb 2017-02-06 04:03:59
kadoban: these may be the modules you can use https://downloads.haskell.org/~ghc/7.6.3/docs/html/libraries/index.html
merijn 2017-02-06 04:04:14
I need something like a queue, but where duplicates are only read once. i.e. if I input "1,3,5,19,1,3,1,17" I expect to get '1,3,5,19,17' as output
kadoban 2017-02-06 04:05:24
jameseb: My question wasn't the original. But in my experience that won't be all. For example, hackerrank allows using stuff from parsec and a few others.
Quintasan 2017-02-06 04:05:44
merijn: Data.Set?
kadoban 2017-02-06 04:05:54
And codeforces disallows using some of that, I think the non-safe parts of base.
merijn 2017-02-06 04:05:58
Quintasan: How would I extract which elements have already been read?
kadoban 2017-02-06 04:06:35
merijn: A set + a queue, you check if something has been seen yet (check the set) before you add it to the queue, then you add it to both.
merijn 2017-02-06 04:06:46
I suppose I could use an MVar and limit access to the Chan with a check on the MVar
Benzi-Junior 2017-02-06 04:12:37
hey I have a type A = (B,C) , is it possible to force strictness onto B and C like you could with a data declaration ?
quchen 2017-02-06 04:13:15
No, type synonyms are just new lables for existing things.
quchen 2017-02-06 04:14:30
You could however use a smart constructor like »myTuple :: a -> b -> (a,b); myTuple !a b = (a,b)« if you want to make the first element of your tuple strict.
jaspervdj 2017-02-06 04:14:31
merijn: psqueues should be able to do what you need
quchen 2017-02-06 04:15:00
The better choice would probably be defining your own data type, since GHC knows that *all* use sites of your tuple have a strict »a«, possibly enabling more optimizations.
merijn 2017-02-06 04:18:18
jaspervdj: Ah, but those aren't concurrent, are they?
dramforever 2017-02-06 04:20:38
Is the haddock-building status of hackage publicly available somewhere?
jaspervdj 2017-02-06 04:21:19
merijn: Ah, no, I missed part of the question.
merijn 2017-02-06 04:22:35
jaspervdj: Basically, I'm writing a concurrent webscraper and have no clean way of getting ids and want to avoid rescraping ids I already encountered. But I guess just storing a Set in an MVar is the best way to go
dramforever 2017-02-06 04:23:35
merijn: I would keep both a Set and a Chan
quchen 2017-02-06 04:23:36
dramforever: Yes. I even knew where at some point.
dramforever 2017-02-06 04:24:03
because you don't want ids to go away after from the Set even after they leave the Chan
dramforever 2017-02-06 04:24:29
quchen: even for PENDING haddocks?
quchen 2017-02-06 04:24:35
dramforever: Example: https://hackage.haskell.org/package/pipes-4.3.2/reports/
quchen 2017-02-06 04:24:37
Hmmmmm
quchen 2017-02-06 04:24:38
Not sure
merijn 2017-02-06 04:24:54
I don't suppose Set has an operation that computes both union and difference
tsahyt 2017-02-06 04:25:09
hello. I'm implementing a way to record some statistics about an effectful calculation that's already running on an IO based transformer stack. My current approach is to have an IORef StatsRecord wrapped up in a newtype and exposing a function modifyStats :: MonadIO m => Statistics -> (StatsRecord -> StatsRecord) -> m (). I have two questions about this. first, is this a code smell? IORefs always seem a bit
tsahyt 2017-02-06 04:25:11
dirty to me. second, to implement functions StatsRecord -> StatsRecord I'll probably end up reinventing lenses. Does it make sense to pull in the entire thing with all its dependencies just for this one use case?
quchen 2017-02-06 04:25:12
dramforever: The API has lots of functions available, maybe there's something in it for you! https://hackage.haskell.org/api
quchen 2017-02-06 04:25:38
dramforever: I suggest starting to read at »The reports-core feature«
dramforever 2017-02-06 04:25:43
I'm hoping for something that looks like https://travis-ci.org/ the webpage
dramforever 2017-02-06 04:25:52
just a bit anxious :(
dramforever 2017-02-06 04:26:50
quchen: hardly anything more than the link you gave :(
dramforever 2017-02-06 04:27:14
I guess I should wait by sleeping (midnight here)
quchen 2017-02-06 04:27:16
That was all I got :-/
doubleleft_ 2017-02-06 04:36:13
I have two functions : lexer1 and lexer of type [a]->String->[a], and lexer a st = reverse $ lexer1 a st. How can I simplify this ?
jophish 2017-02-06 04:39:39
doubleleft_: one simple thing you can do: lexer a = reverse . lexer1 a
jophish 2017-02-06 04:39:57
not sure what kind of simplifications you're looking for though
jophish 2017-02-06 04:40:13
you could even do: lexer = reverse .: lexer1
jophish 2017-02-06 04:40:23
although that could be a little cryptic
doubleleft_ 2017-02-06 04:43:47
jophish: (.:) ? I never met it.
doubleleft_ 2017-02-06 04:44:32
jophish: An operator like (.) ?