Search Haskell Channel Logs

Friday, February 3, 2017

#haskell channel featuring Tuplanolla, Profpatsch, int-e, Benzi-Junior, tirej, lambdabot, and 7 others.

nitrix 2017-02-03 03:45:54
merijn: Cute.
nitrix 2017-02-03 03:46:15
merijn: Remember how I was discussing this very problem a month ago for a game of mine :P ?
nitrix 2017-02-03 03:46:57
merijn: I ended up with memory cells.
Profpatsch 2017-02-03 03:47:53
How do I make file reads strict?
Profpatsch 2017-02-03 03:48:31
I have the problem that I do newIORef =<< getConfig
nitrix 2017-02-03 03:48:48
merijn: data BoardCategory = BoardCategory { game :: Link Game, category :: Link Category }
nitrix 2017-02-03 03:49:20
merijn: Link was describing a relation between two cells. Each cell is given a unique ID.
Profpatsch 2017-02-03 03:49:22
getConfig should really put the configuratino into the ioRef directly, because otherwise the file handle will be closed when it tries to read the file.
nitrix 2017-02-03 03:50:02
merijn: Since they are memory cell, I'd have O(1) lookups and writes instead of resolving the id in tons of maps.
int-e 2017-02-03 03:50:47
Profpatsch: there's http://hackage.haskell.org/package/strict-0.3.2/docs/System-IO-Strict.html
nitrix 2017-02-03 03:51:06
merijn: And a single id system for all relations possible was very convenient because I could serialize and unserialize easily from disk. Type inference would figure out the rest and an error would be thrown if the json weren't to parse to the proper constructor.
tirej 2017-02-03 03:51:40
what does forward slash means ? e.g. : 5 /= 5
Benzi-Junior 2017-02-03 03:51:43
hey I'm looking at the core for a library that I'm developing and discovered that functions declared in record types aren't being inlined, and adding a INLINE pragma doesn't find the binding
nitrix 2017-02-03 03:51:50
merijn: It was lazy loading/unloading entities as needed to manipulate related data on the fly.
Benzi-Junior 2017-02-03 03:52:14
is there a way to have these inlined ?
fuzzyhorns 2017-02-03 03:53:58
trying to build up my mental model. what's the difference between just passing a bunch of parameters around in a function invocation and setting up the state monad?
nitrix 2017-02-03 03:54:20
Explicit vs. Implicit parameters.
nitrix 2017-02-03 03:54:38
fuzzyhorns: With the state monad, you end up with a tuple being passed implicitly to lambdas.
nitrix 2017-02-03 03:54:49
:t StateT
lambdabot 2017-02-03 03:54:50
(s -> m (a, s)) -> StateT s m a
Profpatsch 2017-02-03 03:54:54
int-e: lel hGetContents h = IO.hGetContents h >>= \s -> length s `seq` return s
nitrix 2017-02-03 03:54:58
fuzzyhorns: That (a, s)
fuzzyhorns 2017-02-03 03:55:09
yeah, what's my advantage in doing that though, do you think? just avoiding boilerplate?
tirej 2017-02-03 03:55:15
anyone?
fuzzyhorns 2017-02-03 03:55:20
i quite like it so far btw, just trying to fully understand :x
nitrix 2017-02-03 03:55:33
fuzzyhorns: Well, the boilerplate that you'll invent will end up being a poor version of a monad.
Tuplanolla 2017-02-03 03:56:00
Nothing, tirej. It's just that `(/=)` is a function.
fuzzyhorns 2017-02-03 03:56:04
nitrix: mm, i'd like to see the comparison sometime — perhaps i should do it as an exercise
mniip 2017-02-03 03:56:21
fuzzyhorns, the difference is syntactic convenience
int-e 2017-02-03 03:56:32
Profpatsch: sure, depending on the package might be overkill.
Tuplanolla 2017-02-03 03:56:35
It means "not equal", tirej.
nitrix 2017-02-03 03:56:48
fuzzyhorns: Let me guess, your functions have the form :: State -> Val -> (State, Result) ?
tirej 2017-02-03 03:56:53
like != in imp lang right Tuplanolla ?
nitrix 2017-02-03 03:57:08
fuzzyhorns: Taking and old state and returning a new state?
nitrix 2017-02-03 03:57:13
s/and/an/
Tuplanolla 2017-02-03 03:57:14
Yes.
tirej 2017-02-03 03:57:17
ty
mniip 2017-02-03 03:57:26
tirej, hardly related to imperative/function
tirej 2017-02-03 03:57:39
mniip: i see
mniip 2017-02-03 03:57:44
just that the haskell committee decided to call it /= because of the mathematical symbol of inequaliy
fuzzyhorns 2017-02-03 03:57:46
nitrix: kinda
nitrix 2017-02-03 03:57:52
:t StateT
lambdabot 2017-02-03 03:57:54
(s -> m (a, s)) -> StateT s m a
fuzzyhorns 2017-02-03 03:57:58
nitrix: basically so
mniip 2017-02-03 03:58:01
nitrix 2017-02-03 03:58:01
fuzzyhorns: Notice (s -> m (a, s))
tirej 2017-02-03 03:58:06
uhm, mniip ty for the info
Tuplanolla 2017-02-03 03:58:10
Do you have a moment to talk about our lord and savior Hoogle, tirej?
mniip 2017-02-03 03:58:32
nitrix, I think ':t state' would be an easier example
unknownln 2017-02-03 03:58:32
http://bloodatius.deviantart.com/art/Tea-661090078
nitrix 2017-02-03 03:58:35
fuzzyhorns: Your function have the same exact form than the StateT monad transformer.
unknownln 2017-02-03 03:58:38
Sorry
nitrix 2017-02-03 03:58:43
:t state
tirej 2017-02-03 03:58:43
Tuplanolla: i googled : )
lambdabot 2017-02-03 03:58:45
MonadState s m => (s -> (a, s)) -> m a
unknownln 2017-02-03 03:58:46
Derped up on my phone
fuzzyhorns 2017-02-03 03:58:51
nitrix: neat, i dont understand yet how that helps me
fuzzyhorns 2017-02-03 03:59:09
i dont understand transformers yet really
nitrix 2017-02-03 03:59:15
fuzzyhorns: Maybe I need to backtrack. Possibly you don't have experience yet with monads?
Tuplanolla 2017-02-03 03:59:22
It'll tell you where functions or types you don't know live, tirej.
mniip 2017-02-03 03:59:31
hmm, is there a stock State that is not a sugared down transformer
nitrix 2017-02-03 03:59:51
mniip: No, which is why I didn't try to sugar coat it :/
mniip 2017-02-03 03:59:56
welp
fuzzyhorns 2017-02-03 04:00:02
https://gist.github.com/mooreniemi/f2b3cf9f6db3cd527254404e5a845beb forgive that it is very messy
fuzzyhorns 2017-02-03 04:00:15
nitrix: i mostly use them via do notation, so i feel like i may not fully understand
fuzzyhorns 2017-02-03 04:00:26
my mental model is basically "use this to carry around some computational context"
nitrix 2017-02-03 04:00:59
... and yet I see Proxy used in your code ._.
tirej 2017-02-03 04:01:08
Tuplanolla: probably didnt ask the right question, or hoogle is just a scam, meh
nitrix 2017-02-03 04:01:19
Is Haskell so intuitive that people do poly-kinded stuff accidently now :P ?
fuzzyhorns 2017-02-03 04:01:19
nitrix: it is from servant :/
mniip 2017-02-03 04:01:21
Proxy hardly is a monad
mniip 2017-02-03 04:01:42
I mean it is but not like...
fuzzyhorns 2017-02-03 04:01:44
i dont fully understand Proxy either, keep in mind I am just copying what servant does for HasDocs without fully understanding it
Tuplanolla 2017-02-03 04:01:45
@hoogle (/=)
reactormonk 2017-02-03 04:01:46
Gurkenglas, ah, works if I put preview instead of view.
lambdabot 2017-02-03 04:01:49
Prelude (/=) :: a -> a -> Bool
lambdabot 2017-02-03 04:01:49
Data.Eq (/=) :: a -> a -> Bool
lambdabot 2017-02-03 04:01:49
Data.GI.Base.ShortPrelude (/=) :: a -> a -> Bool
mniip 2017-02-03 04:01:58
I'm yet to see anyone use a Proxy do-block :p
Tuplanolla 2017-02-03 04:02:00
Works for me, tirej.
nitrix 2017-02-03 04:02:20
fuzzyhorns: If you come over #haskell-beginners, I can dedicate some time to good through was you know and build up from there.
fuzzyhorns 2017-02-03 04:02:23
also this code doesnt fully do what i want it to ultimately do yet, but you can see how I used state monad (clumsily im sure)
nitrix 2017-02-03 04:02:28
fuzzyhorns: Monads are very useful, especially State.
nitrix 2017-02-03 04:02:39
s/good/go/
fuzzyhorns 2017-02-03 04:02:44
cool i will go over there :)
tirej 2017-02-03 04:03:47
Tuplanolla: ty anyway
mbrock 2017-02-03 04:18:06
with lens, is there a nice way to do nested Map access? ``foo ^. bars . at "x" . at "y"`` isn't valid because at gives a Maybe. I would like the whole expression to become Nothing if either "x" or "y" don't exist as keys
Gurkenglas 2017-02-03 04:19:08
mbrock, foo ^? bars . ix "x" . ix "y"
Gurkenglas 2017-02-03 04:19:32
at lenses into Maybe a, ix traverses over a
mbrock 2017-02-03 04:19:47
oh, that seems to work, interesting, thanks
Gurkenglas 2017-02-03 04:20:00
(see http://hackage.haskell.org/package/lens-4.15.1/docs/Data-Map-Lens.html )
Tuplanolla 2017-02-03 04:21:56
How should I define a `newBroadcastChan` for `Control.Concurrent.Chan` (like `newBroadcastTChan` for `Control.Concurrent.STM.TChan`)?
Tuplanolla 2017-02-03 04:25:37
The constructor for `Chan` isn't exposed.