<    June 2018     >
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 _2_2 23  
24 25 26 27 28 29 30
11:35 irclogger_com joined
11:35 Topic for
11:35 initiumdoeslinux joined
11:36 zzq joined
11:37 <lyxia> You can check that it is not rewritten by looking at the optimized Core of "main = (reverse . reverse) [1,2,3] `seq` return ()"
11:40 amirpro joined
11:43 HZun joined
11:44 davr0s joined
11:45 <* hackage> aeson 1.4.0.0 - Fast JSON parsing and encoding http://hackage.haskell.org/package/aeson-1.4.0.0 (AdamBergmark)
11:46 trishmapow joined
11:46 thc202 joined
11:48 jix joined
11:49 louispan joined
11:49 philippD joined
11:49 beka joined
11:52 GodotMisogi joined
11:53 twandy joined
11:53 <rszibele[m]> Any stack maintainers here? Would be nice if someone could review my pull request: https://github.com/commercialhaskell/stack/pull/3952
11:54 <rszibele[m]> It basically adds the command 'run' to stack which builds and executes an executable or falls back to the first available executable if no executable is specified.
11:55 <rszibele[m]> Similar to cabal run
11:56 sytherax joined
12:02 sytherax joined
12:03 louispan joined
12:10 beauby joined
12:11 MarcelineVQ joined
12:14 haskell_noob1 joined
12:16 <* hackage> LambdaHack 0.8.1.2 - A game engine library for tactical squad ASCII roguelike dungeon crawlers http://hackage.haskell.org/package/LambdaHack-0.8.1.2 (MikolajKonarski)
12:17 <* hackage> Allure 0.8.1.2 - Near-future Sci-Fi roguelike and tactical squad game http://hackage.haskell.org/package/Allure-0.8.1.2 (MikolajKonarski)
12:22 pagnol joined
12:22 sytherax joined
12:22 gestone joined
12:24 carafe joined
12:24 sigmundv joined
12:25 twandy joined
12:30 rihards joined
12:32 AndreasK joined
12:33 sytherax joined
12:33 Linter joined
12:34 tzemanovic joined
12:36 reactormonk joined
12:36 <reactormonk> Can I resolve type families somehow in TH? Similar to :kind! in ghci. From what I see, I'd have to do the resultion manually and can't ask GHC to do it for me.
12:38 progfun joined
12:39 danso joined
12:40 <lyxia> I don't think so.
12:40 louispan joined
12:44 slomo joined
12:45 agander joined
12:46 zzq joined
12:46 sytherax joined
12:48 <reactormonk> aye, so manual resolution it is.
12:49 <reactormonk> Is there a way to grab information of a Generic instance on the TH function?
12:49 agander_ joined
12:50 <haskell_noob1> i am having an ffi call fail. I need some help with the FFI call: https://lpaste.net/3475865200987471872 whats the right way to convert from an int to cuint ?
12:51 otto_s joined
12:53 <AndreasK> haskell_noob1: What exactly is failing?
12:53 <haskell_noob1> andreask : the call to the library complains that the flags are invalid.
12:53 <lyxia> reactormonk: That also seems unlikely. TH knows very little about the meaning of the things it manipulates.
12:53 <AndreasK> fromIntegral seems ok, although it better matches Word32
12:53 <lyxia> reactormonk: what are you trying to do BTW
12:53 <haskell_noob1> oddly (i guess because i dont understand) the repl works as expected.
12:54 <reactormonk> lyxia, replicate a bunch of typelevel magic with TH, because the use of extensible records makes GHC round in circles
12:54 <haskell_noob1> when i run it through tasty , the types dont seem to be getting resolved to CUInt, i believe.
12:54 nickolay_ joined
12:54 <reactormonk> lyxia, here's the story: https://github.com/reactormonk/modules
12:55 <cocreature> haskell_noob1: what exactly do you mean by “the call to the library complains”?
12:55 <haskell_noob1> let me paste the error real quick.
12:56 <haskell_noob1> https://lpaste.net/3923253213859414016
12:56 carafe joined
12:56 latk joined
12:56 <haskell_noob1> and when i run the function from repl, it seems to resolve the types correctly to create the file.
12:57 <haskell_noob1> https://lpaste.net/3001649039973285888
12:58 <AndreasK> haskell_noob1: Maybe something about file access rights/relative paths is causing it
12:58 <haskell_noob1> so repl is able to magically do something that my tasty unit test is not able to or most likely the function implementation has a bug.
12:58 <* hackage> first-class-patterns 0.3.2.4 - First class patterns and pattern matching, using type families http://hackage.haskell.org/package/first-class-patterns-0.3.2.4 (shersh)
12:58 <haskell_noob1> hmm?
12:58 <AndreasK> Not familiar with the library but the error seems like something that would happen if it can't find/open/write to the path
12:59 <haskell_noob1> let me try with a fully qualified path.
12:59 twandy joined
12:59 <haskell_noob1> its likely..and when in repl the cwd is probably set sanely.
12:59 ZeuPiark joined
13:01 amar joined
13:01 sdrodge joined
13:03 <haskell_noob1> andreask when i try with repl, the call works all the time. I am not sure why tasty is giving this error.
13:03 <haskell_noob1> https://lpaste.net/3001649039973285888
13:03 <AndreasK> well did it work with absolute paths?
13:04 <haskell_noob1> i tried with absolute path..it doesnt work.
13:04 <haskell_noob1> and it works in the repl as expected.
13:04 <AndreasK> in neither test nor repl?
13:04 <haskell_noob1> repl works all the time. which is why i am a bit confused.
13:04 owickstrom joined
13:04 FreeBird_ joined
13:05 sytherax joined
13:05 <haskell_noob1> https://lpaste.net/2890028135644921856
13:05 <AndreasK> Does it work when you compile it as a simple program without tasty? I'Ve neither used tasty nur the hdf stuff so can only give generic advice :/
13:06 <haskell_noob1> thats going to be my next step. I was hoping to get my repl tests in a tasty file. Now i will try to use the executable and test it that way and see if that works. Thank you. this was helpful.
13:07 Ecto2501[m] joined
13:07 shangxia1 joined
13:08 liyang joined
13:09 SpinTensor joined
13:10 Heffalump left
13:12 <ZeuPiark> hello
13:12 VishalIRC2 joined
13:12 xkapastel joined
13:16 progfun joined
13:16 matsurago joined
13:19 emilypi joined
13:20 aarvar joined
13:26 sz0 joined
13:28 xkapastel joined
13:30 twandy joined
13:30 UnChallengeD joined
13:32 Kundry_Wag joined
13:34 latk joined
13:35 oldnborg joined
13:37 beka joined
13:38 Linter joined
13:38 davr0s joined
13:38 sytherax joined
13:39 pzp joined
13:40 alistairtpotts joined
13:45 brocoli joined
13:47 sytherax joined
13:48 initiumdoeslinux joined
13:49 bdwong joined
13:49 tzemanovic joined
13:53 twandy joined
13:54 `Guest00000 joined
13:55 <pzp> Which web framework would you recommend? Yesod sounds like it is pretty popular but I'm looking for something with a little less "magic" (read TH?).
13:56 <Clint> what do you want instead of "magic"?
13:56 zzq joined
13:56 haskell_noob1 joined
13:57 alistairtpotts joined
13:58 progfun joined
13:58 thy0 joined
13:58 kamog joined
13:58 <pzp> I would prefer doing more of the work myself than relying on code generation.
13:58 progfun_ joined
13:59 <pzp> I like to be able to see what is happening in the code so that I can reason better about it.
14:00 <pzp> I think I saw somewhere that it's possible to use Yesod without relying on the TH stuff. Is there a good tutorial/guide for that?
14:00 beefjoe joined
14:01 twandy joined
14:04 <pzp> happstack-lite looks pretty good. Anything like that that I should consider?
14:05 latk joined
14:07 infinisil joined
14:08 <* hackage> tpdb 2.1.0 - Data Type for Rewriting Systems http://hackage.haskell.org/package/tpdb-2.1.0 (JohannesWaldmann)
14:09 forell joined
14:11 philippD joined
14:11 nD5Xjz joined
14:11 philippD joined
14:16 hph^ joined
14:16 tijko joined
14:16 phenoble joined
14:16 raingloom joined
14:16 sytherax joined
14:16 Snircle joined
14:17 son0p joined
14:19 zariuq joined
14:20 kefin_ joined
14:21 vcool_ left
14:21 vcool_ joined
14:21 vcool_ left
14:21 zargoertzel joined
14:23 <philippD> Are there any interesting relationships between Foldable, Traversable and Applicative, Monad? Like getting definitions for classes for free if you provide other ones (besides the Monad, Applicative relation)
14:25 nD5Xjz joined
14:27 netheranthem joined
14:28 jmcarthur joined
14:28 TCZ joined
14:30 progfun joined
14:30 <Tuplanolla> At least there are `sequenceA = traverse id` and `foldMap f = getConst . traverse (Const . f)`, philippD.
14:31 progfun_ joined
14:32 taktoa joined
14:32 alamut joined
14:32 progfun__ joined
14:32 twandy1 joined
14:32 sytherax joined
14:33 <philippD> Tuplanolla: Makes sense. If there were more you wouldn't need classes for these functions.
14:33 <alamut> hello
14:33 <philippD> hey
14:33 progfu___ joined
14:33 <alamut> does anyone mind telling me what is the type for a even.length function?
14:35 <hexagoxel> :t even . length
14:35 <lambdabot> Foldable t => t a -> Bool
14:36 progf____ joined
14:36 grizato joined
14:36 <alamut> even tho i dont know why it worked it did, thanks
14:37 progfun_ joined
14:38 progfun__ joined
14:39 progfun__ joined
14:40 progfun joined
14:42 <dmwit> pzp: I've heard good things about scotty and warp, and my understanding is that they go for minimal magic.
14:43 <dmwit> I've also personally used snap without any of its magic (it has a lot) and it's quite usable without it.
14:45 <philippD> why does `error` have such a strange signature? https://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:error
14:46 <philippD> I get the `HasCallStack` constraint, but why the `TYPE` and `RuntimeRep` stuff?
14:47 <dmwit> For most uses, you can ignore all that. If you want the full details, the thing to google is "levity polymorphism".
14:48 <dmwit> In short: so that `error` can be used both for lifted types (that can have a bottom) and primitive, magic, unlifted types like Int# (that don't have a bottom).
14:48 <hexagoxel> alamut: specialized on lists would be [a] -> Bool
14:48 <dmwit> :t even . length @[]
14:48 <lambdabot> error:
14:48 <lambdabot> Pattern syntax in expression context: length@[]
14:48 <lambdabot> Did you mean to enable TypeApplications?
14:48 <philippD> :t even . (length :: [a] -> Int)
14:48 <lambdabot> [a] -> Bool
14:48 <dmwit> % :t even . length @[]
14:48 <yahb> dmwit: [a] -> Bool
14:48 plugin joined
14:49 ixxie joined
14:49 <dmwit> (...I'll admit I find it a bit weird that `error` can be used for unlifted types.)
14:49 <hexagoxel> wait, what does "error" do if not creating bottom?
14:49 <dmwit> ...yeah
14:49 infinisil joined
14:51 <philippD> hexagoxel: undefined actually does the same magic
14:51 quelqun_dautre left
14:51 _janne joined
14:53 <dmwit> philippD, hexagoxel: https://stackoverflow.com/q/49986342/791604 looks relevant
14:54 <dmwit> Looks like the `HasCallstack` constraint is part of the magic; that makes it a function (which is lifted) under the hood.
14:54 bertschn_ joined
14:55 urodna joined
14:55 <hexagoxel> interesting, thanks
14:56 <philippD> how about `errorWithoutStackTrace` then? https://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:errorWithoutStackTrace
14:56 thunderrd joined
14:56 xcmw joined
14:56 Sampuka joined
14:57 <dmwit> yeeesh
14:58 thoradam joined
14:59 <hexagoxel> still a function, because of the [Char] ? i'd guess the one thing you can not write is `undefinedWithoutStackTrace`.
14:59 <dmwit> Actually, I believe Richard's answer on SO does more or less cover this, too.
15:00 <dmwit> "x is unlifted" just means "no code that looks at x has to worry that x might be undefined", because in case the thing you bound to x is bottom that code never runs.
15:00 <philippD> hexagoxel: since `undefined = error "Prelude.undefined"` you could: https://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Err.html#undefined
15:01 <philippD> dmwit: but isn't that true for * as well?
15:02 Zipheir joined
15:02 <philippD> hexagoxel: you seem to be right. errorWithoutStackTrace just fakes an empty StackTrace
15:03 twandy joined
15:04 <dmwit> philippD: No, it is not true for * as well. For example, in `let x = undefined in False && x`, the `(&&)` really does run. If `x` were an unlifted type, it would not.
15:05 <philippD> ahh, of course. Thanks
15:06 <hexagoxel> does (&&) "look at x" in that case?
15:06 <dmwit> Maybe not. But my statement is true for `let x = undefined in True && x`, too.
15:07 <philippD> are all functions on unlifed types automatically strict?
15:07 <dmwit> I *think* the question doesn't make sense, because the function can't be called with bottom as an argument.
15:08 <dmwit> But, like... basically yes.
15:08 <hexagoxel> % :t let u = errorWithoutStackTrace "undefined" in I# u
15:08 <yahb> hexagoxel: ; <interactive>:1:50: error:; * Couldn't match a lifted type with an unlifted type; When matching types; a0 :: *; Int# :: TYPE 'GHC.Exts.IntRep; * In the first argument of `I#', namely `u'; In the expression: I# u; In the expression: let u = errorWithoutStackTrace "undefined" in I# u
15:09 <dmwit> % :t I# (errorWithoutStackTrace "undefined")
15:09 <yahb> dmwit: Int
15:09 <dmwit> % const (I# (errorWithoutStackTrace "undefined")) 3
15:09 <yahb> dmwit: *** Exception: undefined
15:09 stondo joined
15:10 <dmwit> I# never gets called here. (nor const)
15:10 stondo joined
15:10 <hexagoxel> wait, there is defaulting to lifted?
15:10 <stondo> hi all
15:11 <* dmwit> waves at stondo
15:11 paidnode joined
15:12 <philippD> hi stondo
15:13 <philippD> hexagoxel, what do you mean by that? Unless specified otherwise any typevariable has kind *
15:14 <hexagoxel> let-bound entities are always lifted?
15:14 Gurkenglas joined
15:14 <dmwit> No, but let behaves differently for lifted and unlifted types.
15:15 <hexagoxel> why exactly is my let u = .. a type error?
15:15 <dmwit> % :t let u :: Int#; u = errorWithoutStackTrace "undefined" in I# u
15:15 <yahb> dmwit: Int
15:16 <dmwit> I suspect philippD has the right of it.
15:16 <dmwit> You start with `u :: a`, which, because it's not specified otherwise, is given kind *, then unification tries to set `a ~ Int#` and fails because `Int#` does not have kind *.
15:16 asheshambasta joined
15:17 <hexagoxel> "kind defaulting" ?
15:17 <hexagoxel> but yeah, that makes sense.
15:17 blackandblue joined
15:18 xcmw joined
15:18 <dmwit> But this is a guess, not actually knowledge. It is backwards science, magical explanation.
15:18 <dmwit> All the same problems as phlogiston. Doesn't actually predict anything.
15:18 <Tuplanolla> % :seti -XMonoLocalBinds
15:18 <yahb> Tuplanolla:
15:18 <stondo> I'm reading Programming in Haskell and I'm a bit confused about how to pass a function to another function
15:18 <Tuplanolla> % :t let u = errorWithoutStackTrace "undefined" in I# u
15:18 <yahb> Tuplanolla: ; <interactive>:1:50: error:; * Couldn't match a lifted type with an unlifted type; When matching types; a0 :: *; Int# :: TYPE 'GHC.Exts.IntRep; * In the first argument of `I#', namely `u'; In the expression: I# u; In the expression: let u = errorWithoutStackTrace "undefined" in I# u
15:19 <stondo> all' :: (a -> Bool) -> [Bool] -> Bool
15:19 <stondo> all' f xs = and [True | x <- xs, f x]
15:19 <hexagoxel> (of course type defaulting machinery is a bit more complex and customizable, while there seems to be one static rule for kinds here.)
15:19 <dmwit> stondo: You know how to pass non-functions to other functions? It's just like that, except instead of putting something that isn't a function there, you put a function there. ;-)
15:19 <stondo> why isn't this valid? I don't understand the compiler's error message
15:20 <philippD> stondo: what's the error message
15:20 xtreak joined
15:20 <stondo> Couldn't match expected type ‘a’ with actual type ‘Bool’ etc, etc
15:20 <philippD> in what code?
15:21 <dmwit> stondo: Because `xs` is a `[Bool]`, so `x` is a `Bool`, but you said `f` takes an `a`, not a `Bool`.
15:21 <stondo> I just pasted 2 lines..
15:21 zargoertzel joined
15:21 <dmwit> stondo: So `f x` doesn't work.
15:21 <dmwit> stondo: You can fix it by either changing the `(a -> Bool)` argument to `(Bool -> Bool)`, or by changing the `[Bool]` argument to `[a]`.
15:21 <stondo> I thought f was just a placeholder for something, in this case a function that will take an a and returns a Bool
15:21 <dmwit> (I know which I would prefer!)
15:22 <dmwit> stondo: It is indeed. What makes you now think it is not?
15:22 <stondo> dwit: that's not what the exercise is asking though
15:22 <dmwit> stondo: The problem is that you have given `f` something that isn't an `a`!
15:22 <stondo> I even tried with pattern matching and guards, but I must be not getting something
15:22 <dmwit> stondo: Perhaps you had better show us the exercise, as well, then.
15:23 zariuq joined
15:23 <stondo> thought a was of type of the element in my list?
15:24 <dmwit> stondo: Why did you think that?
15:24 <stondo> the exercise says: Without looking at the definitions in the standard prelude, write those functions: all, any, and some others
15:24 <stondo> using map and filter
15:24 <stondo> let me show what I wrote at first
15:24 Kundry_Wag joined
15:24 <Tuplanolla> Your declared type is wrong, stondo.
15:25 <Tuplanolla> Read it out loud to yourself.
15:25 <dmwit> I don't understand why you think the exercise you have just said is incompatible with the advice I gave.
15:25 codesoup joined
15:26 <stondo> I just copied it from the book
15:26 <stondo> all :: (a -> Bool) -> [Bool] -> Bool
15:26 <Tuplanolla> :t all
15:26 <lambdabot> Foldable t => (a -> Bool) -> t a -> Bool
15:26 <stondo> I just added ' not to hide original all
15:27 <dmwit> Are you sure you copied that from the book accurately?
15:27 <dmwit> If so, there is an error in the book.
15:27 <stondo> pretty damn sure, yes, I have the book here just in fron of me
15:27 <stondo> I can show a piacture
15:27 <dmwit> Okay. Then there is an error in the book.
15:27 <stondo> damn, really_
15:28 <philippD> :t \ f xs -> and [True | x <- xs, f x]
15:28 <stondo> one sec, uploading the pic
15:28 <lambdabot> (t -> Bool) -> [t] -> Bool
15:29 <stondo> where can I upload a pic and share the link plz?
15:29 Kundry_Wag_ joined
15:29 osa1 joined
15:29 <dmwit> With all the love in the world: nobody cares.
15:29 <dmwit> Just fix your type signature and move on with learning.
15:30 <stondo> I just want to make sure there's really an error in the book and not something else I'm not understading correctly
15:31 <stondo> https://ibb.co/nCsOq8
15:32 xtreak joined
15:32 <stondo> here the photo of a portion of that page
15:32 <dmwit> The book is in error.
15:32 tombusby joined
15:33 <stondo> dwit that was driving me crazy
15:33 <stondo> but I didn't want to look at the type definition of the all version in the the standard prelude
15:34 <stondo> so the types definition of all the functions on that page are wrong?
15:34 <stondo> http://www.cs.nott.ac.uk/~pszgmh/pih-errata.html
15:34 <stondo> yup, there's definetly an error. Thanks everyone
15:34 twandy joined
15:35 <philippD> stondo: whenever you have a function that takes a function like `f :: (a -> b) ...` there has to be a source for an `a` somewhere
15:36 <dmwit> :t let nuhUH :: (a -> b) -> (); nuhUH f = () in nuhUH
15:36 <lambdabot> (a -> b) -> ()
15:36 agander joined
15:37 <dmwit> ...but it's a good rule of thumb anyway. I should maybe have just stayed quiet.
15:37 sigmundv joined
15:37 <philippD> dmwit: yep :-p
15:38 <stondo> philippD: I thought that a could be as well be a Bool, so I woudln't have noticed the error in the definition :(
15:38 zdenal joined
15:38 <stondo> *could as well be a Bool
15:40 Kundry_Wag joined
15:40 <dmwit> stondo: Yeah, that is a common tripping point of polymorphic types.
15:40 <philippD> stondo: it can but the function has to work for any type `a`. If you want to restrict what types `a` can be you have to use classes
15:40 initiumdoeslinux joined
15:41 <dmwit> The protocol in Haskell is that the person using a value of a given type gets to choose what types go in the variables; the person implementing the type isn't allowed to at all.
15:43 johnw joined
15:44 plugin joined
15:45 Math22232 joined
15:45 <Math22232> how do I get the hwid in haskell as a string?
15:45 SenasOzys joined
15:46 xpycm joined
15:46 <dmwit> What's an hwid?
15:46 <Math22232> Hardware Identification
15:46 <Math22232> https://www.webopedia.com/TERM/H/HWID.html
15:47 davr0s joined
15:47 <dmwit> I don't know for sure but I would guess you'd have to bind to some external function for that with the FFI.
15:47 <dmwit> You could look through the Win32 package but I don't think it's been updated in a long time.
15:49 nicht joined
15:49 nicht_ joined
15:50 <* hackage> mltool 0.2.0.1 - Machine Learning Toolbox http://hackage.haskell.org/package/mltool-0.2.0.1 (aignatyev17)
15:53 beka joined
15:54 <* hackage> convert 1.5 - Safe and unsafe data conversion utilities with strong type-level operation. checking. http://hackage.haskell.org/package/convert-1.5 (danilo2)
15:55 zargoertzel joined
15:56 codesoup joined
15:57 <heath> https://github.com/hedgehogqa/hallofbugs/blob/master/index.md
16:00 <dmwit> :t traverse
16:00 dhil joined
16:00 <lambdabot> (Applicative f, Traversable t) => (a -> f b) -> t a -> f (t b)
16:00 connrs joined
16:02 <dmwit> :t runState
16:03 <lambdabot> State s a -> s -> (a, s)
16:04 bbrodriguez joined
16:04 ixxie joined
16:06 twandy1 joined
16:07 pfurla_ joined
16:07 Linter joined
16:13 zfnmxt joined
16:14 blankhart joined
16:19 saep joined
16:20 emilypi joined
16:20 beka joined
16:21 <dmwit> heath: Neat. You might want to be more clear that you mean "bugs found by using hedgehog" and not "bugs found in hedgehog". ;-)
16:23 <ahri> can someone explain to me how, in http://www.haskellforall.com/2013/05/program-imperatively-using-haskell.html in the final example putting everything together, I thought at the top level of the `do` block I could get the current score after each action with `s <- score` so that I could then `lift $ putStrLn ("Score: " <> show s)` -- as this is not the case, how can I achieve this?
16:25 <dmwit> `s <- use score`
16:28 louispan joined
16:28 osa1 joined
16:28 Sevior_ joined
16:28 opto joined
16:29 amar joined
16:29 <ahri> dmwit: huh, ok, thanks, I hadn't come across `use` yet. that's awesome :)
16:30 <dmwit> By the way, I don't know lens very well. I discovered this by checking the type of `\f -> gets (^.f)` and then Hoogling that type. =P
16:30 <Sevior_> Hello, what would the type of a function like "function1 g = g . length " and "function2 f = f 2 True" ?
16:30 <dmwit> Sevior_: Why not ask the machine?
16:31 <Sevior_> what do you mean?
16:31 <dmwit> :t let function1 g = g . length in function1
16:31 <lambdabot> Foldable t => (Int -> c) -> t a -> c
16:31 <monochrom> Or do it in ghci
16:32 <dmwit> :t \g -> g . length -- if you don't mind not having a name for it
16:32 <lambdabot> Foldable t => (Int -> c) -> t a -> c
16:32 xcmw joined
16:34 <Sevior_> im not using ghci, im doing some sort of course whic has a platform of its own
16:34 <infinisil> Get yourself ghci then
16:34 <Sevior_> and im asked to define the type of certain functions
16:34 zincy_ joined
16:35 <Sevior_> its kind of a "begginers guide to Haskell"
16:35 <zincy_> Is this the correct way to derive the generic typeclass for Text after you have imported GHC.generics and set the extensions? instance Generic Text
16:36 <dmwit> No. Also I doubt you can derive Generic for Text.
16:36 latk joined
16:36 <dmwit> Let's talk about why you want to do that.
16:36 asheshambasta joined
16:36 <monochrom> You are asking total strangers who do not know your course and will not want to know, and who use ghci to answer you anyway. May as well cut out the middleman.
16:37 twandy joined
16:37 <zincy_> I want to use quickcheck to test some properties about a function
16:37 <zincy_> In order to generate random values of a custom ADT I need to make the type an instance of Arbritrary as well Generic for deriving
16:38 <lyxia> don't derive Generic for Text
16:38 <dmwit> What happens when you try to derive Generic for your ADT?
16:38 <zincy_> It works fine
16:38 <dmwit> So... problem solved?
16:38 <zincy_> sorry
16:38 Hexagenic joined
16:39 <zincy_> deriving generic works for other typeclasses derivation
16:39 <zincy_> but for some reason quickcheck isnt happy
16:39 Big_G joined
16:39 xcmw joined
16:39 <dmwit> Yes, Arbitrary does not have defaults that use Generic.
16:41 <zincy_> ok if i remove the generic derivation for Text
16:41 <zincy_> and run quickcheck test i get
16:41 <zincy_> • Unrecognized Rep: Rep Text Possible cause: missing Generic instance • In the expression: genericArbitraryU In an equation for ‘arbitrary’: arbitrary = genericArbitraryU In the instance declaration for ‘Arbitrary Text’ | 65 | arbitrary = genericArbitraryU
16:41 scampbell joined
16:42 SenasOzys joined
16:42 <paidnode> Surely there is a standrad way of doing this, right? https://lpaste.net/1787816846045478912
16:42 opto left
16:42 fmixing joined
16:43 <ahri> dmwit: thanks for the extra hoogle tip, I'll try to apply that thinking in future
16:43 <dmwit> zincy_: Sounds like GArbitrary is missing some instances for non-Generic leaves in your tree of types.
16:43 <dmwit> paidnode: That looks pretty standard to me.
16:44 Kundry_Wag joined
16:44 <zincy_> thanks!
16:44 raingloom joined
16:44 fmixing joined
16:44 <dmwit> There was a question about another library similar to this the other day.
16:44 <dmwit> Let me see if I can dig it up to see how that other library solves this problem.
16:45 lambda-11235 joined
16:46 <dmwit> Man, Hackage is super slow for me today.
16:46 <nshepperd> does Text even have an Arbitrary instance?
16:46 <* hackage> threepenny-gui 0.8.2.4 - GUI framework that uses the web browser as a display. http://hackage.haskell.org/package/threepenny-gui-0.8.2.4 (sjakobi)
16:46 toovs joined
16:46 <dmwit> nshepperd: Dunno. But even if not it's easy to write.
16:46 fmixing joined
16:47 vilu joined
16:47 <dmwit> zincy_: Ah, the previous question was about the cereal package. You might draw some inspiration from the way it's done in that package; here's a direct link to the Generic-related class. I think its K1 instance is how it bottoms out at non-Generic types that instantiate Serialize.
16:47 <dmwit> https://hackage.haskell.org/package/cereal-0.5.5.0/docs/Data-Serialize.html#t:GSerializePut
16:47 <nshepperd> surely you want some equivalent of the String newtypes ASCIIString, PrintableString etc anyway
16:47 <paidnode> dmwit seems like. What I think I remembered is interact, similar in spirit (i.e. a small helper to void boilerplate) but it does something different. So I guess I just have to write this for every project where I interact with the user...
16:48 keegans joined
16:48 <keegans> what is a better way for me to do, `sequence $ take 4 $ cycle [getLine]`
16:48 beka joined
16:48 <dmwit> replicateM 4 getLine
16:48 Kundry_Wag joined
16:48 <keegans> dmwit: thank you
16:48 <dmwit> `cycle [foo]` is `repeat foo`. `take n (repeat foo)` is `replicate n foo`. `sequence (replicate n foo)` is `replicateM n foo`.
16:49 <keegans> :D
16:49 Kundry_Wag joined
16:50 <lyxia> zincy: Text isn't a generic type so don't use generic-random to implement Arbitrary Text.
16:51 <vilu> Hi, having some newbie issues with haskell. So I'm poking around in a Scotty example application. https://github.com/eckyputrady/haskell-scotty-realworld-example-app. I'm having some issues trying to "log in" and use the JWT token generated by the login step. I can easily find the place in "my" code where it breaks. It's a call to the library which returns a Left with a "BadCrypto" value. What are some steps
16:51 <vilu> that I can take to figure out where exactly in the library things break and how to fix that?
16:51 <keegans> so, I can do `read "[4, 4, 4, 4]" :: [Integer]`, but i would like to be able to `read "4 4 4 4" :: [Integer]`. i can do `words "4 4 4 4"
16:51 <keegans> ["4","4","4","4"]`, but then what is the best way to convert each of those word into an integer list?
16:51 <vilu> My next steps now would be to check out the source code of the library
16:52 <vilu> And try to call this method with the same parameters I'm calling it now?
16:52 <lyxia> zincy: you could lift code from this package https://hackage.haskell.org/package/quickcheck-instances-0.3.18/docs/src/Test-QuickCheck-Instances-Text.html#line-18
16:52 <vilu> But ideally I would love to just be able to step into the source code like I would if I was i.e. on the jvm?
16:52 howdoi joined
16:53 <vilu> Any tips on what I could do?
16:54 <lyxia> keegans: map read
16:57 <keegans> lyxia: r xs = map (read :: String -> Integer) xs
16:57 <keegans> goign to have to map twice i believe because this a 2d thing
16:57 <dmwit> vilu: As sad as it sounds, my current go-to debugging technique is printf debugging. =(
16:57 <keegans> ` r xs = map (read :: String -> Integer) $ words xs` is what i meant
16:58 <vilu> dmwit: so is mine, I'm also quite ok with that.
16:58 <vilu> My problem is as soon as I need to debug something outside my own source code.
16:58 WhatisRT joined
16:58 <vilu> Because I'm having issues in a libr.
16:59 <vilu> The way I tend to do it is to find the source code, run that and try to see if I can figure out what's going on.
16:59 <vilu> However it's a bit cumbersome.
16:59 <dmwit> Yes, me too.
16:59 <geekosaur> vilu, it's a bit more complicated than that in Haskell, because of laziness.
16:59 Thra11 joined
17:00 acarrico joined
17:00 <vilu> geekosaur: Ok, in what sense do you mean that the laziness is an issue in the case of debugging here?
17:00 <geekosaur> you find yourself in code you didn;t expect because an expression gets forced when it's needed, not where it's written.
17:00 <vilu> Ah that's what you mean
17:00 <dmwit> I think the actual complaint here is about the arbitrary divide between library code/own code, not the bad debugging tooling (though that is also a problem, for sure).
17:00 <geekosaur> there's aalso issues with debug information in compiled object code, but if you have ghc 8,4 you have at least a partial solution to that that said, line-level debugging isn;t there yet
17:01 <dmwit> Like, there is a ghci debugger, which is bad for all the reasons geekosaur is saying. But it is also bad because it won't debug into library code.
17:01 <geekosaur> interactive / bytecode-compiled code can do it
17:01 <vilu> Exactly, the laziness part I tend to be able to overcome or at least I have been able to so far with the ghci debugger.
17:01 <vilu> You can force evaluation when in the debugger right?
17:02 <vilu> I remember this being confusing at first but it hasn't been a blocker.
17:02 <vilu> What is hard for me though is what dmwit clarified.
17:02 <geekosaur> there's been some discussion of getting line debugging into object code at some point
17:03 <vilu> For example, looking at the source code now this is using a JWT library. I'm not very familiar with this technique and I see it very possible that either I use the client the wrong way or I haven't set up the server in the correct way (maybe I'm not reading the right certs or whatever).
17:03 good_matty[m] joined
17:04 <vilu> However, I see that the issue will be either in the JWT library or an issue in the attoparsec library that the jwt library uses.
17:04 <vilu> So now I'm looking at what I expect to be 2 - 3 hours of debugging.
17:04 <vilu> For something that most likely is just me not knowing how to use the library.
17:04 <vilu> Or jwt in general.
17:05 <geekosaur> ideally that should be documentation, not debugging…
17:05 <vilu> I was hoping for someone to just tell me, point ghc to whatever and you can see where in the library code things go wrong.
17:05 <geekosaur> reverse engineering an api through a debugger is painful no matter what language
17:07 twandy1 joined
17:09 Kundry_Wag joined
17:09 aidan_gilmore joined
17:09 rasusto joined
17:10 <vilu> Fair enough
17:11 barcabuona joined
17:12 <vilu> Btw dmwit when you say printf, are you referring to Debug.Trace.trace or is there something else?
17:14 <geekosaur> it's usually easier to debug in IO, at which point you can use any IO mechanism (and there is indeed a printf: https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base-4.11.1.0/Text-Printf.html#v:printf)
17:15 <geekosaur> that said, if you're debugging a laziness issue, you really want to use Debug.Trace because it'll be as lazy as the expression you're trying to figure out.
17:15 beka joined
17:15 <* hackage> versions 3.4.0.1 - Types and parsers for software version numbers. http://hackage.haskell.org/package/versions-3.4.0.1 (fosskers)
17:15 initiumdoeslinux joined
17:16 desperek joined
17:17 pagnol joined
17:19 sigmundv joined
17:20 jxv joined
17:22 brocoli joined
17:23 haskell_noob1 joined
17:24 <* hackage> pandoc-types 1.17.5 - Types for representing a structured document http://hackage.haskell.org/package/pandoc-types-1.17.5 (JohnMacFarlane)
17:25 altjsus joined
17:27 rihards joined
17:27 <Cale> Adding something like:
17:28 rihards joined
17:28 <Cale> foo x y z | trace (show (x,y,z)) False = undefined
17:28 <Cale> to the top of your function declaration
17:29 <Cale> is a good way to extract arguments that it's applied to, and then you can hopefully find some where it's not doing the correct thing, and from there break the problem down by looking at what the definition would give for those arguments
17:30 <chindy> what is the most straight forward way/library to check if a string matches a regex in haskell ?
17:30 haskell_noob1 joined
17:30 <* hackage> lines-of-action 0.0.0 - Lines of Action, 2-player strategy board game http://hackage.haskell.org/package/lines-of-action-0.0.0 (jxv)
17:30 asheshambasta joined
17:33 <python476> guys, how much do you owe your understanding of FP to books ?
17:33 <python476> I mean did it bend your mind or was it just 'well duh'
17:33 <johnw> it certainly wasn't 'well duh' for me
17:33 gestone joined
17:33 <python476> johnw, now that's a name I haven't heard in a looong time
17:34 <* python476> makes gnu gang sign
17:34 <johnw> don't call it a comeback
17:34 <Cale> python476: When I started learning Haskell, it took me about 2 months before I felt like I could do anything useful with it, and about a year to get some level of comfort. I'm not sure exactly how much of that was books.
17:34 <Cale> But it was some combination of books and just trying things.
17:34 <python476> Cale: how much exposure to FP prior haskell ?
17:35 <python476> I'm reading some 80s book on FP, and the way of things in that community, which I'm quite fond of, is super foreign in a way
17:35 <Cale> I'd done a bit of scheme, and a little mathematica if that counts, but all the other languages I knew were mostly imperative
17:35 valentinbuza joined
17:35 <python476> aight
17:35 <python476> (peter henderson book)
17:35 <Cale> Actually one of the most helpful experiences was writing an IRC bot as a single long shell pipeline
17:36 <python476> notable the recursive rules for semantics
17:36 <python476> Cale: you mean shell like or actual bash shell ?
17:36 <Cale> yeah
17:36 <Cale> bash
17:36 <python476> funky
17:36 <Cale> It had netcat on one end, and a fifo on the other to tie the knot
17:36 <python476> reminds me that as a kid, I started being enamoured with geeky things because of the * and pipe operators
17:37 <python476> in MSDOS that is
17:37 <Cale> and basically filtered all its input, and passed some of it through to mathematica for evaluation
17:37 <python476> quite neat
17:38 hellozee joined
17:38 twandy joined
17:38 <Cale> chindy: We *mostly* try to avoid regex... if your goal is matching a bunch of text, consider libraries like attoparsec or megaparsec. There are a bunch of regex libraries though. None of the ones I can actually point you at are things I'm particularly happy with.
17:39 <Cale> Gabriel Gonzalez is/was working on something new though...
17:40 <johnw> regex-applicative isn't terrible
17:40 <johnw> basically makes working with regexs feel like parsec
17:40 <Cale> https://github.com/Gabriel439/slides/blob/master/regex/regex.md -- there's some code here along with some really cool info, but I don't know if he's packaged it
17:40 oisdk joined
17:41 <johnw> ah, slow
17:41 rihards joined
17:42 beka joined
17:42 <monochrom> I just disagree with using Num for this.
17:42 <johnw> me too
17:43 <johnw> too cute
17:43 brocoli joined
17:44 <Cale> Num isn't that far off tbh, but negate is a problem.
17:44 haska joined
17:44 <nshepperd> it's Num's fault for not being Semiring
17:44 <int-e> :t abs
17:44 <lambdabot> Num a => a -> a
17:44 <haska> hey all. i've install ghc and have ghc-pck. How do I use it to install protobuf?
17:44 <philippD> :t signum
17:44 <lambdabot> Num a => a -> a
17:45 <Cale> abs too, I suppose, though abs/signum can always be implemented in a trivial way
17:45 <philippD> but do they make sense in this case?
17:45 <Cale> I mean, if you just consider everything "positive", so that abs = id and signum = const 1
17:46 Yuras joined
17:47 keepLearning512 joined
17:49 drbrule joined
17:50 <haska> any suggestions for what plugins to use to get a good Haskell environment in Visual Studio Code?
17:50 emilypi joined
17:51 <philippD> haska: Haskero is nice
17:51 cybai joined
17:52 <haska> philippD: i noticed that. seems like Haskelly has more downloads, but dunno
17:52 <* hackage> astro 0.4.2.1 - Amateur astronomical computations http://hackage.haskell.org/package/astro-0.4.2.1 (aignatyev17)
17:52 ozataman joined
17:53 <philippD> I didn't like Haskelly. Haskero forces you to use stack though. There is also GHC-mod which also works most of the time. It has the tendency to lock up and be killed externally sometimes though. All my experiences are on linux though
17:55 zdenal joined
17:55 <philippD> I went back to a more basic setup with only hlint and running ghcid in an external terminal. Much more productive since you don't have to deal with the plugins not picking up your projects correctly and stuff.
17:57 albertus1 joined
17:57 cloudhead joined
18:00 nschoe joined
18:00 <[exa]> Is there a parser that would be usable for getting rfc822-like message bytestrings to Network.Mail.Mime format?
18:02 toovs joined
18:03 <[exa]> there seems to be Network.Parser.Mime but there doesn't seem to be any simple documentation
18:03 sgflt joined
18:05 bendo joined
18:06 zdenal joined
18:06 <hpc> parseMimeHeaders might read the whole message, as weird as it sounds
18:07 <hpc> mvContent is what you would typically think of as the message
18:07 <hpc> and the Multi constructor for it is multipart mime content-type bodies
18:08 <* hackage> relational-query-HDBC 0.6.4.5 - HDBC instance of relational-query and typed query interface for HDBC http://hackage.haskell.org/package/relational-query-HDBC-0.6.4.5 (KeiHibino)
18:09 elfets joined
18:10 beka joined
18:11 twandy joined
18:11 a3Dman joined
18:12 <* hackage> relational-query-HDBC 0.6.7.1 - HDBC instance of relational-query and typed query interface for HDBC http://hackage.haskell.org/package/relational-query-HDBC-0.6.7.1 (KeiHibino)
18:13 SenasOzys joined
18:14 <haska> philippD: forcing to use stack you say. Not familiar with it, what's bad about stack?
18:16 kmelva joined
18:16 <[exa]> hpc: oh so, thanks!
18:18 <* hackage> hmatrix-morpheus 0.1.1.2 - Low-level machine learning auxiliary functions. http://hackage.haskell.org/package/hmatrix-morpheus-0.1.1.2 (aignatyev17)
18:18 agander joined
18:18 woodson joined
18:18 <philippD> haska: stack is a buildtool that takes some pain away from using cabal but is relatively oppinionated. https://docs.haskellstack.org/en/stable/README/
18:20 blackandblue joined
18:21 <hpc> haska: specifically it's a reproducible build tool - it controls the build environment entirely, down to installing its own ghc
18:21 jeltsch joined
18:22 ian_andrich joined
18:22 <veverak> and does not allow local package storage :/
18:23 <liste> haska: https://marketplace.visualstudio.com/items?itemName=alanz.vscode-hie-server seems promising, especially if you're on Linux/Mac. I'm currently trying to get it work on Windows properly, but that requires some assembly
18:23 cybai joined
18:24 fendor joined
18:24 language_agnosti joined
18:24 <hpc> veverak: it doesn't have a "user" database, if that's what you mean
18:25 <hpc> er wait, ignore that
18:25 <hpc> 2:30 in the afternoon and i am still waking up lol
18:25 <veverak> hpc: :)
18:25 justanotheruser joined
18:25 <veverak> hpc: I mean: 'look here /my/local/packages' for the stuff listed in extra-deps
18:25 <veverak> not on hackage
18:25 <hpc> yeah
18:26 <* veverak> went for cabal because of that
18:26 <hpc> "local hackage" instead of "things i already installed"
18:26 <veverak> point is: got a big ass ecosystem that has custom package system
18:26 <veverak> want to integrate haskell into that
18:26 <hpc> i think you can do some stuff with httpd to host a local package database, but i have never had to try
18:26 <veverak> "custom package system" -> "custom build tools" (cmake overlay)
18:27 <hpc> ouch
18:27 <veverak> so, I need that feature...
18:27 <veverak> otherwise I won't integrate
18:27 <haska> as a new comer, Haskell is a fucking mess, only slightly better than all the web stacks
18:27 emilypi joined
18:27 <veverak> (the entire problem is more complex ofc...)
18:27 <veverak> haska: anyway, cabal happily provides what I need, so i am happy
18:27 <veverak> sorry, bad nick
18:27 <veverak> hpc: ^^
18:29 ozzymcduff joined
18:30 <philippD> haska: yeah, especially when coming from java or c# land. If you're starting out stack is great at hiding some of the worst parts of cabal from you. But don't be afraid of ditching it in favor of something else like Nix if you see the need.
18:31 davr0s joined
18:32 <philippD> I hope I didn't piss of any stack maintainers here with that statement :D
18:32 dopplergange joined
18:32 <dmwit> Well, I learned a valuable lesson today, thank you haska.
18:33 Meanirelli joined
18:33 <dmwit> I, too, have started learning a thing and had that reaction.
18:34 <dmwit> And until just now I never pondered how absurd "I have only been using this for 60 seconds and I already know all the technical decisions that went into it were decided wrongly" really sounds.
18:36 <sclv> veverak: there's a few ways to do that
18:36 <sclv> you can set up a local packagedb in the file system for one
18:36 hellozee joined
18:36 SovietBeer joined
18:36 <sclv> and also you can set up and run your own hackage instance
18:37 <hpc> dmwit: it helps to try to separate the model of something from its implementation
18:37 latk joined
18:37 Linter joined
18:38 <sclv> veverak: cf https://github.com/haskell/cabal/issues/5060
18:39 <hpc> like say for rust, knowing the difference between the borrow checker not being perfect yet, and when you're just not writing very good code
18:39 karlguy joined
18:39 <hpc> (or for haskell, knowing when you're using IO inappropriately and such)
18:39 ma27 joined
18:41 <veverak> sclv: I know that cabal can
18:41 plugin joined
18:42 <veverak> sclv: will read that link, thanks
18:42 Linter joined
18:43 twandy joined
18:46 mkoenig_ joined
18:47 saep joined
18:47 emilypi joined
18:49 seanparsons joined
18:51 Thra11 joined
18:54 sbauman joined
18:56 Thra11 joined
18:58 rembo10 joined
18:58 dcoutts joined
18:59 Kundry_Wag joined
18:59 simon_ joined
18:59 <chindy> is there a function [a] -> [a] -> bool that checks whether the first list ends with the second list
18:59 <chindy> so that [1,2,3] [2,3] is true
18:59 <hpc> :t isSuffixOf
18:59 <lambdabot> Eq a => [a] -> [a] -> Bool
18:59 <chindy> ahh
19:00 <hpc> > "bacon" `isSuffixOf` "yummy bacon"
19:00 <lambdabot> True
19:00 <hpc> > "bacon" `isSuffixOf` "icky broccoli"
19:00 <lambdabot> False
19:04 initiumdoeslinux joined
19:04 beka joined
19:08 carafe joined
19:10 Linter joined
19:14 vurtz joined
19:14 davr0s joined
19:15 amirpro joined
19:15 twandy joined
19:17 conal_ joined
19:18 kderme joined
19:18 oisdk joined
19:18 Kacia joined
19:20 tijko joined
19:20 nschoe joined
19:21 skeuomorf joined
19:22 rasusto joined
19:22 chaosmasttter joined
19:24 kefin_ joined
19:24 RedNifre joined
19:25 Kundry_Wag joined
19:25 <RedNifre> Hi. I decided to learn stack, would you recommend the official haskellstack.org documentation or is there an even better tutorial somewhere?
19:26 rasusto joined
19:27 oisdk joined
19:29 obi_jan_kenobi_ joined
19:29 acidjnk joined
19:31 <* hackage> reactive-banana-gi-gtk 0.3.0.0 - Simple reactive programming with GTK GObject Introspection http://hackage.haskell.org/package/reactive-banana-gi-gtk-0.3.0.0 (miscyb)
19:31 beka joined
19:36 elfets joined
19:36 xcmw joined
19:37 Tesseraction joined
19:37 MissingNoIOI joined
19:40 Luke joined
19:42 APic joined
19:44 beka joined
19:45 takuan joined
19:47 plugin joined
19:47 twandy joined
19:50 epsilonhalbe joined
19:50 jao joined
19:52 Yaargh_ joined
19:52 conal_ joined
19:53 latk joined
19:54 beka joined
19:55 ciboire_ joined
19:57 hjdskes joined
19:58 shadowdaemon joined
19:59 ciboire_ left
20:00 blankhart joined
20:02 Solonarv joined
20:02 djbeau joined
20:03 blackandblue joined
20:03 vukasink joined
20:04 beka joined
20:08 t7 joined
20:09 carlomagno joined
20:14 beka joined
20:15 haskell_noob1 joined
20:17 <sms> r
20:17 oisdk joined
20:17 <sms> Woops
20:18 <haskell_noob1> when implementing ffi, should i consider breaking a given header file into corresponding modules? The reason i ask is that multiple files will have a reference to the same header file. Is that ok? I am looking at that design as an oo developer (or perhaps just plain modules and file sizes)?
20:19 twandy joined
20:20 Kundry_Wag joined
20:20 carafe joined
20:22 <srk> hmm
20:23 <dmwit> I don't understand the question at all.
20:23 <srk> how can I convert an odering into a -> b -> Bool
20:23 <srk> dmwit: this channel has magic properties
20:23 <srk> just switching to it sometimes resolves the issues
20:24 <dmwit> How do you represent the ordering?
20:24 beka joined
20:24 <paidnode> you know your sunday evening gets frustrating when you need something between fold and a map that can take a function a -> b -> c instead of a -> b
20:24 <srk> pPrint $ L.groupBy ( comparing $ head . (filter ((== periph) . SVD.periphName)) . SVD.devicePeripherals . snd ) svds
20:24 <sm> RedNifre: the official doc is not well organised, but it's got the info; nothing much better
20:24 <srk> but then I've realized groupBy is not like sortBy
20:24 <RedNifre> sm Thanks, I'm reading it right now and it seems okayish.
20:25 <sm> RedNifre: and for most people, what you need to learn to use it is not much
20:25 kamog joined
20:25 <srk> paidnode: :D pretty much
20:25 <dmwit> Just in case the IRC messages have arrived in a different order for other folks than they did for me: when I said "I don't understand the question at all." I was talking about haskell_noob1's question, not srk's.
20:25 <srk> ok :)
20:25 <philippD> haskell_noob1: I tend to keep all my ffi bindings in one file since they only contain binding boilerplate.
20:26 freeman42x]NixOS joined
20:26 <RedNifre> sm I already got a project set up, what I'm currently looking for is how to do ... local dependencies? As in, I want to have three separate projects where A uses B and B uses C.
20:26 <philippD> paidnode: traverse over a State monad?
20:26 <haskell_noob1> hmmm philippD, interesting. I find that for a largish library, i want to break down lib init calls, from lib module calls much as the library is structured? is that too much org overhead?
20:27 mud joined
20:27 <dmwit> paidnode: `map` can take an `a -> b -> c` function no problem. ;-)
20:27 <dmwit> :t map (undefined :: a -> b -> c)
20:28 <lambdabot> [a] -> [b -> c]
20:28 <dmwit> how deceptive
20:28 <sm> RedNifre: all projects sharing one stack.yaml, or.. ?
20:28 <paidnode> :)
20:28 <haskell_noob1> the reason i dont like my approach is precisely that, there is boiler plate and i am not gaining much except for smaller file sizes (which may reduce some conflicts, though thats not a consideration).
20:28 davr0s joined
20:28 Arcaelyx joined
20:30 <philippD> haskell_noob1: you wont be calling the ffi functions directly in most cases but rather write wrapper functions that hide the procedural nature. The bindings than are a 1-1 representation of the headers, the wrapper code can than be organized nicely in logical modules
20:30 <RedNifre> sm no, like, my projects tend to fall apart into specialized libraries all by myself, so I'd like to actually split them into totally independent projects, but not upload them to hackage/stackage... last time I used Haskell was years ago, but there was a way to put a local project into the cabal file of another local project, I think.
20:30 <sclv> RedNifre: the common way with cabal these days is new-build with .project files
20:30 <sm> RedNifre: for local testing, I'll sometimes put one project directory (or a symlink) inside other, since I think stack.yaml packages list doesn't allow ..
20:31 <sclv> things in the same project can depend on one another
20:31 <dmwit> Internal libraries are a thing with the newest cabals, but I don't know much about how they work. Googling should get you some docs.
20:31 <haskell_noob1> philippD, quite. In fact i am seeing that with my approach, I am creating a parallel structure : logical and internal. I went this path because there were some attributes that were being overloaded in the library and i was seeing name issues.
20:31 <sclv> this is different than internal libs
20:31 <RedNifre> hmmmmm
20:31 <paidnode> OK ,I give up, I'll post this on lpaste. It's just... it is a simple problem in an imperative language, and I aspire to be a professional Haskeller one day maybe, so not being able to proceed just feels like I don't have the intelligence for it. It also feels pretty hypocritical at times like this to think about times when I preach about how FP is better
20:31 valentinbuza joined
20:32 <RedNifre> Not sure I understand this.
20:32 <dmwit> But yes, I would recommend making a project with several packages, one per library. That codepath is well-tested, and easy to get other people's experience on.
20:32 <sclv> http://cabal.readthedocs.io/en/latest/nix-local-build.html#configuring-builds-with-cabal-project
20:32 <dmwit> sclv: Yes, I know, I was offering an alternative not a clarification. =)
20:32 seizo joined
20:32 <sclv> sure
20:33 <haskell_noob1> though, i think i get the general principle behind the ffi design that you are proposing, philippD and this approach lends itself to the tools that generate most bindings. the library i am working on uses macro functions so i still have to deal with things by hands.
20:33 <RedNifre> Yeah, but what if I want to share code between projects? If I write library code, do I HAVE to publish it on stackage, or is there a cleaner way?
20:33 <RedNifre> (I have to look up how I did that with cabal years ago...)
20:33 c1b01r3 joined
20:33 <sm> RedNifre: you just list the project directories in stack.yaml packages list
20:34 <paidnode> https://lpaste.net/6897021095673593856, was at the point where I apply the runPhase function so that it encrypt my matrix, that's the gibberish that's the current state of encrypt
20:34 <sm> and reference the packages in your cabal files
20:34 beka joined
20:34 <paidnode> it's from here: https://www.reddit.com/r/dailyprogrammer/comments/8n8tog/20180530_challenge_362_intermediate_route/
20:34 ozzymcduff joined
20:34 simukis joined
20:35 <dmwit> RedNifre: No. We have lots of libraries at work that are not published on Hackage for legal reasons. We share them between projects by just having a git repo for them.
20:36 <dmwit> (Then use whatever technique you want to make sure each project has pulled the repo down before you build. Submodules are popular at work, but there are other ways.)
20:36 <RedNifre> dmwit okay, but how exactly do you use those libraries in projects?
20:36 <RedNifre> oh
20:36 zzq joined
20:36 <philippD> paidnode: could you reduce the code to your specific problem please?
20:37 <RedNifre> Well, submodules would work, but I personally think that telling stack "for this project, also look over there in this local directory when resolving the dependencies, one of the dependencies is in there and not on stackage".
20:37 rasusto joined
20:37 <dmwit> RedNifre: Yes, cabal new-build can do that. I'm not expert enough to say how to do it with stack, but I'm confident that's possible there, too.
20:38 <RedNifre> dmwit that sounds encouraging, I'll look into it some more.
20:38 <dmwit> RedNifre: With new-build, you'd just toss `packages: path/to/other/directory` in your `cabal.project` (or `cabal.project.local`).
20:39 <paidnode> phillipD is this better? https://lpaste.net/7671594374215499776
20:40 <paidnode> as I said, that encrypt function isn't the way I definitely want to do it, it was just a try to proceed with this, other approaches are welcome
20:42 <paidnode> so I have to apply runPhase to what remains from the matrix until it is empty, collecting and concatenating the lists returned as the second element of the tupes
20:42 <paidnode> or at least that's how I think about it
20:42 <paidnode> it does sort of sound like fold
20:44 beka joined
20:44 <philippD> paidnode: So if I get you what you want to do could be expressed in an imperative language by storing the phase in a variable and looping over the matrix in some way and push elements into a list?
20:46 agander joined
20:46 <paidnode> yes, i guess, reading the elements of the matrix in a specific way (forming a "spiral")
20:46 <paidnode> so state monad?
20:47 kmurphy4 joined
20:47 borkr joined
20:47 errelion joined
20:48 <paidnode> (as you said?)
20:48 <philippD> If you want to keep some kind of state between steps it is useful. Looking at the challenge though I think it can be done without keeping the state this way
20:49 epsilonhalbe left
20:51 twandy joined
20:52 initiumdoeslinux joined
20:52 <paidnode> kinda planned to keep state using recursion, explicit or hidden behind a fold/map/etc. Do I not really need that either? How should Iapproach this then?
20:57 abetaev joined
20:57 errelion left
20:58 fendor joined
21:00 silver joined
21:03 beka joined
21:04 HZun joined
21:04 <[exa]> paidnode: if you don't need the thing to be very fast, a common way to make a spiral is to rotate the matrix and strip off first row after each rotation
21:04 jmcarthur joined
21:04 abetaev joined
21:07 hasky joined
21:07 woodson joined
21:07 <hasky> hi, trying to use proto-lens: Could not find module ‘Proto.Google.Protobuf.Wrappers’
21:07 <hasky> ideas?
21:09 <abetaev> hi! i am complete newbie in haskell, and it looks like i'm getting to stupid question (sorry for that). i have a `data Problem {capacity :: Int, items :: [Item]}` and another type `data Solution {volume :: Int, items :: [Item]}`. could please somebody help me to understand why compiler says that `items` is declared twice?
21:09 MP2E joined
21:09 <paidnode> [exa] that sounds like another cool approach, thx
21:10 <paidnode> although it seems like just another implementation of runPhase, I think I solved that part now (modulo not yet discovered bugs :) )
21:13 reactormonk joined
21:14 beka joined
21:14 detrumi left
21:15 Luke joined
21:15 <philippD> paidnode: this is what I came up for the encrypt function https://hastebin.com/uxolutasil.hs
21:15 Luke joined
21:15 <electrocat> abetaev: it's a limitation of haskell record syntax
21:16 <electrocat> abetaev: you defined two types with fields with the same name
21:16 <electrocat> these fields are compiled to functions to extract this value
21:16 Luke joined
21:16 <electrocat> and you would have two functions with the same name
21:17 Luke joined
21:17 <electrocat> does that make sense?
21:17 Luke joined
21:19 abetaev left
21:19 abetaev joined
21:21 <abetaev> yes, sure, it does
21:22 twandy joined
21:23 initiumdoeslinux joined
21:24 beka joined
21:24 <[exa]> abetaev: there's IIRC some pragma that allows the field names to be overloadable, but that adds another level of complexity and a source of confusion, so just renaming one 'items' is usually the best way
21:24 Vapeur joined
21:25 <abetaev> [exa] okay, that's the way i'll go :)
21:25 <paidnode> philipD wow, that matrix function is just so not how I think... I guess you can only get so far without interacting with people who know more than you.
21:25 <* hackage> rattletrap 4.1.1 - Parse and generate Rocket League replays. http://hackage.haskell.org/package/rattletrap-4.1.1 (fozworth)
21:26 brocoli joined
21:26 DirtyTaco joined
21:26 oisdk joined
21:28 dddddd joined
21:28 <philippD> paidnode: Don't think in terms of mutating state but rather in terms of pipelines. Also the code leverage the fact that you can have lists of infinite length in haskell. First I create a matrix of infinite size that is padded with 'X' in every direction and than trim it to size.
21:28 <heath> dmwit: good point :) i'll mention that to Tim who's doing the asking
21:32 patbecich joined
21:32 <paidnode> philippD the funny thing is I chose matrix to make my life easier. Well apparently I made it quite a bit harder by loosing the ability to patternmatch on it in a x:sx way... have to trust in lists more!
21:33 armyriad joined
21:33 <philippD> paidnode: Matrix is nice if you want to perform common matrix operations in an efficient manner. For stuff like this Lists rule
21:34 beka joined
21:34 <[exa]> paidnode: just an interesting side note -- there's an almost-mathematical mapping between spiral indices and final list indices
21:36 <* hackage> json-feed 1.0.2 - JSON Feed http://hackage.haskell.org/package/json-feed-1.0.2 (fozworth)
21:37 hamishmack joined
21:38 hackebeilchen joined
21:38 guest6626 joined
21:39 Linter joined
21:39 amar joined
21:39 emilypi joined
21:40 <paidnode> [exa] can you expand on that?
21:41 shaylew joined
21:41 <[exa]> matrix coords and index in the "spiral" list can be converted in O(1)
21:41 thoradam joined
21:43 <mjoldfield> I've been messing around with some code which uses -XFlexibleInstances. So I have x which can either have type a or b i.e, x :: a and x :: b return the right thing at the ghci prompt. If I define fn x = (x,x), then fn x :: (a,a) and fn x :: (b,b) work too. Is there a way, presumably by way of an extension, to make fn x :: (a,b) work ?
21:43 <[exa]> way matrix->list: find min(distance from border), see how many indexes are in more-outer layers (just by subtracting rectangle areas), and solve for 4 cases of which side the coordinates belong to
21:44 beka joined
21:44 ziyourenxiang joined
21:44 <paidnode> do you mean the index of an element in a list representing the spiral and the coordinates of the same element in a matrix that's been unrolled injto that list? That's neat.
21:45 <paidnode> I'm thinking about whether that could in some way be leveraged to construct a more performant solution
21:45 <* hackage> smoothie 0.4.2.9 - Smooth curves via several interpolation modes http://hackage.haskell.org/package/smoothie-0.4.2.9 (DimitriSabadie)
21:45 <[exa]> way back involves solving a quadratic equation to quickly see what level from the _middle_ of the matrix the index is inside, but after you have the level you're basically done
21:47 Kundry_Wag joined
21:47 SovietBeer_ joined
21:48 Linter joined
21:48 <phz_> damn, I have post-party blues (ZuriHac) :(
21:48 <[exa]> aaand the performant and cool solution: what about you run the same thing with rotating the matrix and making it smaller, just don't actually rotate it but use a different coordinate system for the movement
21:48 <[exa]> paidnode: ^
21:48 <sm> phz_: quick, organize a conf in your town
21:49 <c_wraith> mjoldfield: If I understand what you're asking correctly, -XRankNTypes will do the job, if you give fn a properly polymorphic type.
21:49 <phz_> sm: hehe, yeah
21:49 <sm> non-stop haskell party!
21:49 <phz_> sm: I haven’t found a way to hack around the segfault issue of mine
21:50 <phz_> so I decided to make a system call to file…
21:50 <phz_> I hate it
21:50 <phz_> but at least, it’s an ISO-like change
21:50 <sm> heh
21:50 <mjoldfield> c_wraith: Thanks, I shall go and read up on this. The code comes from http://conway.rutgers.edu/~ccshan/wiki/blog/posts/WordNumbers2/ and is somewhat higher level than I know
21:50 <[exa]> paidnode: so the state is initially something like: dirLeft = (1,0), dirDown=(0,1), itemsOnLeft=0, itemsOnRight=10, itemsAbove=0, itemsBelow=5
21:50 plugin joined
21:50 <[exa]> (and ofc mtxPosition=(0,0))
21:50 <RedNifre> Hang on, maybe I got this all wrong... so with cabal I created separate packages that I used as local dependencies for other packages... but a stack "project" can contain multiple cabal packages, which solves the same problem? Can one package be in multiple stack projects at the same time? Would I do that with links in the file system or better, git submodules?
21:50 wollw joined
21:51 <c_wraith> mjoldfield: the type would be something like `(forall a. Foo x => x) -> (A, B)' , where Foo is the class involved, and A and B are concrete types
21:52 <[exa]> paidnode: btw the direction should be dirRight ofcourse, it's getting late here :D
21:52 <sm> RedNifre: "yes", I think..
21:52 hiratara joined
21:53 <RedNifre> So if I want to create a local "library" that I don't want to publish, it would be a classic cabal project and my stack projects would have it as a submodule?
21:53 <mjoldfield> c_wraith: Gosh, it works!
21:53 dim1tri joined
21:53 <c_wraith> mjoldfield: now do the reading on it. :)
21:53 <RedNifre> ...but it's also possible to create libraries with stack, right? Can stack projects contain other stack projects, or only packages?
21:53 <mjoldfield> c_wraith: Do you have a good reference ?
21:54 dim1tri joined
21:54 <sm> stack projects consist of cabal packages.
21:54 <electrocat> *usually
21:54 <ZeuPiark> bye
21:54 <RedNifre> sm so if I want to reuse code across projects I have to either publish a stack project and add it as a dependency or put it in a package and use that one across stack projects?
21:54 <c_wraith> mjoldfield: https://ocharles.org.uk/blog/guest-posts/2014-12-18-rank-n-types.html is a good starting point
21:55 beka joined
21:55 <electrocat> RedNifre: i don't follow
21:55 <RedNifre> Well, what's the recommended way to do code reuse when using stack?
21:55 Cthalupa joined
21:55 twandy joined
21:55 <RedNifre> (I'm new to stack)
21:56 juliagoda joined
21:56 <electrocat> well in stack.yaml you can specify "packages"
21:56 <sm> RedNifre: I'm not sure where the complexity is coming from.. did you peruse the stack user guide ?
21:56 <electrocat> and point to several cabal packages
21:56 <paidnode> [exa] I think I kinda get it on first read, if you dont rotate the matrix but "the world around it" you get the same state as rotating the matrix, only the former is much less recource needy
21:57 <[exa]> paidnode: yeah. anyway dirDown isn't needed as well if you're sure about left/right-handedness of the coordinate system
21:57 dim1tri joined
21:58 <RedNifre> Well, I have this simpleSQLite library I made that's just a very thin layer on top of HDBC, which I want to use in my first stack project. It's actually a cabal package so I guess it'll work perfectly as-is, but I was wondering if that's the best approach.
21:59 <electrocat> well just add that library as a dependency in your other cabal project
21:59 <RedNifre> I would have expected some way to create a local "repository" so that my stack projects can list stuff from the local repository as dependencies, instead of linking them in.
21:59 <electrocat> en point the stack file to the location
21:59 <electrocat> and*
21:59 <sm> I see that it's confusing from the outside and maybe we're explaining it badly, but if you try it, following the user guide, I think it's pretty simple
21:59 <RedNifre> electrocat how exactly?
21:59 <[exa]> paidnode: have to go afk, you might also use this: turnDirRight (x,y) = (y,-x)
21:59 <sm> packages list in stack.yaml
21:59 <paidnode> [exa] yeaah, I should go too
22:00 <RedNifre> okay, I'll try and see if I can get it to work.
22:00 <paidnode> thanks both to you and philippD for the insights
22:00 <sm> (as we've mentioned several times :)
22:00 <electrocat> RedNifre: see that usually every stack.yaml file has a "packages" field? just add the location of your home-made dependencies there
22:00 <electrocat> so stack knows where to find them
22:01 <RedNifre> Yeah, what I find odd is that I don't turn that library package into a stack project, but maybe I'm thinking about it the wrong way.
22:01 carlo1 joined
22:01 <sclv> the stack project scopes over the cabal packages
22:01 <RedNifre> I thought that stack "replaces" cabal, but it seems to be something that you build around your cabal packages.
22:01 <sclv> right
22:02 <sclv> stack-executable can be used instead of cabal-install-the-executable
22:02 <electrocat> right with stack you can make 1 single project for multiple cabal packages
22:02 <sclv> but it isn't a different package-management-system
22:02 <sclv> electrocat: you can do that with cabal new-install btw
22:02 <RedNifre> I think it's getting clearer now.
22:02 <electrocat> sclv: oh right, have to try that out sometime
22:03 MindlessDrone joined
22:03 barcabuona joined
22:03 <electrocat> RedNifre: look at it this way, cabal is used as a build system for your packages, stack manages your dependencies
22:04 beka joined
22:04 <RedNifre> ...but doesn't cabal also deal with dependencies?
22:04 <electrocat> well
22:04 <electrocat> it can
22:04 <electrocat> the cabal tool can
22:05 <sm> maybe https://docs.haskellstack.org/en/stable/stack_yaml_vs_cabal_package_file/ helps ?
22:05 <electrocat> it's complicated :p
22:05 <sclv> its two alternative ways of managing them
22:05 <sclv> that's all
22:05 <electrocat> i guess yeah
22:06 wollw joined
22:06 plugin joined
22:08 kefin_ joined
22:08 <sm> stack is a layer on top of cabal, adding features like projects built from multiple local packages. Separately, cabal has been adding similar features, which some people prefer over stack. It's complicated enough that you really do have to read the docs.
22:08 fmixing joined
22:09 haskell_noob1 joined
22:09 <RedNifre> sm thank you, that clarified it some more.
22:11 <RedNifre> If I understand it correctly, the idea of having the cabal files say "I need some version of X" and the stack file say "If you need X, use version 0.3" is that you no longer run into the problem of two packages in your dependencies depending on two different versions of X, right?
22:11 bdwong joined
22:11 <electrocat> right
22:12 <electrocat> that's one of the problems it solves
22:12 fendor joined
22:12 <RedNifre> I'm now starting to feel that stack might be a good ;)
22:13 <glguy> That problem was already solved, the problem it solves is that sometimes it was hard for cabal-install to determine what versions of packages to use, it's solved now by you manually specifying which versions to use in stack.yaml
22:13 <RedNifre> Would I ever use stack if I only have one package?
22:14 carlomagno joined
22:14 <sm> sure
22:14 <RedNifre> ...or does stack only make sense when dealing with at least two packages?
22:14 beka joined
22:14 <RedNifre> Why?
22:14 dim1tri joined
22:14 <electrocat> so you don't have conflicts between dependencies
22:14 <glguy> You don't need stack to ensure you only get one version of each package
22:15 <sclv> stack is fundamentally about making use of stackage snapshots
22:15 MindlessDrone joined
22:15 <sclv> which fix versions of a universe of dependencies
22:15 <sclv> and its just a tool optimized for that workflow
22:15 <sclv> of pinning your entire universe to snapshots managed by the stackage curator team
22:15 <sclv> the cabal-way is to specify version bounds for depts individually
22:16 <sclv> and let the solver solve for them
22:16 <sclv> rather than pinning everything to a single fixed universe
22:16 <glguy> You still need to specify you versions for the stack way when making libraries
22:16 matsurago joined
22:16 <glguy> since the stack workflow only pins down a particular build environment, it doesn't capture dependencies as needed for mixing libraries together
22:16 <sclv> glguy: right, when you're publishing you generate them for use by others
22:16 <glguy> even if you're using multiple libraries for yourself
22:16 <sclv> but if you're just writing your own app or project you just pin to a single snapshot
22:17 pfurla joined
22:17 <phz_> The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
22:17 <phz_> installed package haddock-library-1.4.5 is broken due to missing package haddock-library-1.4.5-JMywL3gQR7h8vuSGU4Yu5w-attoparsec
22:17 <phz_> argh, any idea how to solve that?
22:17 <phz_> I thought a stack clean + rm -r .stack-work would solve it
22:17 <sclv> phz_: oh ugh this is the internal libraries bug in stack
22:17 <phz_> lovely :D
22:17 gestone joined
22:18 <sclv> phz_: https://github.com/commercialhaskell/stack/issues/4071
22:18 <sclv> is the latest i know about it
22:18 <RedNifre> Alright, so since my unpublished library is only one cabal package using it in multiple stack projects should be simple... but what would I do if I have an unpublished library that is a stack project?
22:18 codesoup joined
22:18 amar joined
22:18 <RedNifre> (I'm kinda getting ahead of myself here, since I don't actually have that problem yet)
22:18 <glguy> with a single unpublished library you probably don't need the extra complexity of stack
22:19 <sclv> agreed
22:19 <haskell_noob1> if i would like a specific function to be always called before any function gets called inside a monad, whats the pattern i am looking for?
22:19 <sclv> haskell_noob1: that's not necessarily a well-formed question
22:19 <haskell_noob1> for example, always initialize a library,before calling open.
22:19 <jle`> haskell_noob1: what do you mean by 'function gets called inside a monad'?
22:19 <RedNifre> haskell-noob1 sounds like aspect oriented programming
22:19 <sclv> ok so in haskell one way to do this is with "regions"
22:20 zzq joined
22:20 <haskell_noob1> i see.
22:20 <sclv> a general approach would be that e.g. you use a reader monad
22:20 <sclv> and the reader is over a handle to the library
22:20 <sclv> so you can only invoke the monad by calling initialize on the library to get the handle
22:20 <sclv> (then you wrap it up in newtypes or something to enforce abstraction)
22:21 <sclv> that enforces that a function gets called before you execute the monadic code
22:21 <haskell_noob1> that makes sense. I can use a reader. Let me outline the problem a bit further: the library i am calling is doing a couple of side effects : initialize the library, and check the version and then the actual call. Now I am not sure if calling init on the library again is undefined behaviour. Lets assume it is. Should i be having 2 readers stacked?
22:22 <sclv> if 2 readers are stacked you get double initialization, right?
22:22 <sclv> so instead you use the single reader to thread through the sequencing
22:22 sjakobi left
22:22 <sclv> another pattern is often to just do this in IO at the top level, and not thread the handle through, but its a bug if the init doesn't get called
22:22 <haskell_noob1> can you please elaborate "thread through" part.
22:23 <sclv> its less type-safe
22:23 <sclv> haskell_noob1: that's what reader does, it passes the argument to each successive thing
22:23 <sclv> that's how the bind of the monad works
22:24 beka joined
22:24 <sclv> for the less type-safe version see e.g. `withSocketsDo`: http://hackage.haskell.org/package/network-2.7.0.0/docs/Network-Socket-Internal.html#v:withSocketsDo
22:24 <haskell_noob1> i see. sclv. I can prevent double initialization by carrying a state (not RWS) but say ReaderT A (StateT B) IO C..
22:24 <sclv> you can also "cheat" and use a top level mutable var to store the initialized state to prevent accidental double initialization
22:24 <sclv> that's really hacky
22:24 <sclv> but also an idiomm people use
22:25 <sclv> haskell_noob1: no i'm describing something slightly different
22:25 <sclv> just have ReaderT LibHandle IO
22:25 crobbins joined
22:25 <sclv> but the only way to create a LibHandle is to call invoke on the lib
22:26 <haskell_noob1> the inner functions need to call CheckVersion before the actual call (at least that what the macro is doing). How do i model this?
22:26 <jle`> haskell_noob1: note that 'monad' here is a red herring. this has nothing to do with monads, and the handling of opening things is unrelated to any monadic aspect here
22:26 lumm joined
22:26 <sclv> so you have a runLib :: ReaderT LibHandle IO a -> IO a that calls invoke then passes that libhandle to the runreader function
22:26 dim1tri joined
22:26 <sclv> haskell_noob1: your bound inner functions can just call checkversion now
22:26 <sclv> maybe you can actually pack the version into your libhandle
22:27 raynold joined
22:27 <haskell_noob1> i like that. I think thats more idiomatic. because in the c library, this call is copied in each macro. Though i think version and and handle being part of the reader is a bit more elegant.
22:28 pfurla__ joined
22:28 brocoli_ joined
22:28 <aarvar> jle`: "this has nothing to do with monads". I suspect that's true the majority of the time when people say "monad" :)
22:28 Linter joined
22:28 <jle`> indeed :)
22:28 <jle`> trying to think of a solution in terms of 'a monad' is going to usually lead you down a lot of dead ends
22:28 <haskell_noob1> well the monad part was part of the library..these calls are within the IO monad. And I wanted to ensure that a function gets called before the actual work is done.
22:29 <jle`> haskell_noob1: these calls aren't within the IO monad
22:29 <jle`> haskell_noob1: these calls are within IO
22:29 <haskell_noob1> whats the difference?
22:29 <jle`> haskell_noob1: they have nothing to do with the monadic interface of IO
22:29 <aarvar> Monad is an abstraction. IO is one thing which that abstraction happens to apply to
22:29 <haskell_noob1> jle` i thought that IO was all part of the IO monad either at the top or the bottom of a stack?
22:29 <jle`> they're just ... IO actions
22:29 <jle`> haskell_noob1: `IO a` represents an IO action
22:29 <haskell_noob1> i see.
22:30 <aarvar> Strings have an Order, but you don't say "the String Ord" every time you talk about strings
22:30 twandy joined
22:30 <jle`> `IO a` has a pretty expressive API that allows you to do a lot of interesting and useful things with them
22:30 <jle`> monad is just one aspect of that API
22:30 <jle`> but in this case it's an aspect that you aren't utilizing or i relevant at all
22:31 <jle`> so it's kind of like saying "i want to write a function to find the sum of two numbers...but I'm only allowed to use `sqrt`"
22:31 <jle`> or trying to find a solution to sum two numbers...but being fixated on the irrelevant function 'sqrt'
22:32 <haskell_noob1> hmm. so, if i had restated the problem as : i need to ensure that a function gets invoked before anything else happens in computation? is that a better way to put it?
22:32 hiratara joined
22:32 <jle`> yeah, that might be a better way to start your search :)
22:33 <aarvar> or you need to ensure that an action gets executed before any other actions happen?
22:33 ixian joined
22:33 <haskell_noob1> now that the question is there: is Reader still the approach to take, because it does seem to take care of a couple of my requirements.
22:34 <jle`> ReaderT is a commonly used pattern for situations like this
22:34 <haskell_noob1> the fact that the functions need to be inside the IO monad, are the choices limited to ReaderT atop IO () ?
22:35 <jle`> another option you have is just having it be a function, `LibHandle -> IO a`, and requiring that your user provides a valid lib handle somehow
22:35 <haskell_noob1> (this is because i need to pass a CString to the library).
22:35 <jle`> but this might not be the best because users might think they ar eexpected to re-make a LibHandle multiple times
22:36 <jle`> ReaderT LibHandle sort of gives a "suggestion" that you're only supposed to make one once, and use it for your entire computation
22:36 danthemyth joined
22:37 <haskell_noob1> Nice. I like this model. I will wrap the handle inside a ReaderT.
22:38 exarkun joined
22:38 tijko joined
22:39 son0p joined
22:39 <shaylew> is there an ordered map data structure that supports efficient splitting?
22:39 cloudhead joined
22:39 abhi56rai joined
22:40 x1ddos joined
22:42 <shaylew> (that is to say, where you can split by a key k and get back two maps, one for things inserted before k was and one for things inserted after k was)
22:43 <shaylew> Data.Map.Ordered exists but doesn't have that operation, and I'm not sure it's efficiently implementable with its representation
22:43 Tops2 joined
22:44 mrBen2k2k2k_ joined
22:44 <haskell_noob1> shaylew : partition :: (a -> Bool) -> Map k a -> (Map k a, Map k a)? will this work?
22:48 Kundry_Wag joined
22:49 <jle`> shaylew: do you mean a map that remembers the order in which items were added?
22:51 <shaylew> yeah. or (equivalently, i hope) a sequence of key-value pairs with an efficient "find the pair for this key" operation
22:52 beka joined
22:52 michaelpj joined
22:52 ego joined
22:52 <jle`> maybe you want a priority search queue, which is like an ordered map with two different "keys"
22:53 <jle`> two different lookup methods
22:53 <jle`> so you basically have (key1,key2,value) with optimized lookup for both keys
22:53 floryst joined
22:53 <jle`> er, usually one of the keys just have optimal min/max lookups
22:54 bontaq` joined
22:57 <jle`> it's a [(p,k,v)] where (1) k's are unique and you can look them up easily (2) p's are non-unique and you can get the min/max easily
22:59 acarrico joined
23:00 harfangk joined
23:02 bbrodriguez joined
23:03 twandy joined
23:03 <shaylew> i'm not sure that quite works for what i'm doing. the idea of being able to split/append them is so you can drop a suffix (ie split and keep only the things before) or insert things right before a specific item (split there, add the things to the 'before' map, merge that the 'after' map)
23:04 <nshepperd> I haven't fully worked it out, but you can sorta add efficient lookups to an unordered sequence by putting it to the leaves of a tree with some representation of the set of keys in the inner nodes
23:05 <nshepperd> data Tree k v = Leaf k v | Inner Int (Set k) v
23:06 <nshepperd> er
23:06 <nshepperd> 'Inner Int (Set k) (Tree k v) (Tree k v)' obv
23:07 wollw joined
23:07 <nshepperd> the Int counts the number of leaves or similar, so that you can split by index in O(log n)
23:07 <nshepperd> while you can recursively search for key k by set membership searches in O(log n^2)
23:08 harfangk joined
23:08 Durbley joined
23:08 <nshepperd> the constant factors are probably terribad though
23:08 pavonia joined
23:09 <shaylew> nshepperd: oh yeah, that would work. basically finger tree sequence decorated with the set of elements
23:11 kmurphy4 joined
23:11 <nshepperd> yep
23:11 Solonarv joined
23:12 initiumdoeslinux joined
23:12 brocoli joined
23:13 <shaylew> this is for a for-fun implementation of type checker with ordered contexts, so i may just stick to the metathory (... with lists and slow lookup...) until it's working and worry about it later
23:13 <shaylew> but i thought i'd ask in case there was something off the shelf
23:15 jfredett_ joined
23:18 kmurphy4 joined
23:18 wollw joined
23:19 <* hackage> ftp-client-conduit 0.5.0.1 - Transfer file with FTP and FTPS with Conduit http://hackage.haskell.org/package/ftp-client-conduit-0.5.0.1 (miscyb)
23:19 justanotheruser joined
23:19 beka joined
23:20 dented42 joined
23:20 tsoernes joined
23:22 xenomai joined
23:23 acarrico joined
23:24 UnChallengeD joined
23:24 VishalIRC2 joined
23:26 xenomai left
23:28 Welkin joined
23:30 missa joined
23:35 twandy joined
23:36 VishalIRC2 joined
23:38 xcmw joined
23:44 oisdk joined
23:45 tzemanovic joined
23:46 ddellacosta joined
23:46 beka joined
23:46 wollw joined
23:51 bbrodriguez joined
23:56 Kundry_Wag joined
23:58 gregberns joined