Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-30 21:35:00 fendor_ joins (~fendor@178.165.130.8.wireless.dyn.drei.com)
2021-03-30 21:35:08 <edwardk> so no one size fits all choice was available to bitonic
2021-03-30 21:35:17 <edwardk> so you have to opt into sets of translations or add your own
2021-03-30 21:36:14 <edwardk> when orking with inline-c or inline-c-cpp i'll typically build up a bunch of little helper contexts like:
2021-03-30 21:36:15 <edwardk> https://github.com/ekmett/codex/blob/master/freetype/raw/Graphics/FreeType/Internal.hsc#L690
2021-03-30 21:36:18 × LKoen quits (~LKoen@65.250.88.92.rev.sfr.net) (Quit: “It’s only logical. First you learn to talk, then you learn to think. Too bad it’s not the other way round.”)
2021-03-30 21:36:46 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2021-03-30 21:36:49 <edwardk> then mix it in with others like: https://github.com/ekmett/codex/blob/master/freetype/raw/Graphics/FreeType/Internal.hsc#L626
2021-03-30 21:37:13 <edwardk> (that module uses a small context inside the file, then uses information gained to define a larger context used in later files)
2021-03-30 21:37:33 <RamZess> ahhh no, Let say I have a C++ function void enableThis(bool b). I can call it from haskell something like this [Language.C.Inline.block| enableThis($(bool myFlag::CBool)]
2021-03-30 21:37:49 × coot quits (~coot@37.30.55.131.nat.umts.dynamic.t-mobile.pl) (Quit: coot)
2021-03-30 21:37:56 <edwardk> you often want several of these: https://github.com/ekmett/codex/blob/master/freetype/src/Graphics/FreeType.hsc#L339
2021-03-30 21:37:58 × fendor quits (~fendor@91.141.2.121.wireless.dyn.drei.com) (Ping timeout: 240 seconds)
2021-03-30 21:38:15 × Franciman quits (~francesco@host-79-53-62-46.retail.telecomitalia.it) (Quit: Leaving)
2021-03-30 21:38:23 <edwardk> yeah you need to add a thing to the context that provides what FFI type 'bool' corresponds to and how to swizzle the haskell Bool into that 'bool'
2021-03-30 21:38:46 × dpl quits (~dpl@77.121.78.163) (Ping timeout: 240 seconds)
2021-03-30 21:38:49 conal joins (~conal@64.71.133.70)
2021-03-30 21:38:53 <edwardk> e.g. is your Bool supposed to become a Word8 and then get passed as a char or a CInt?
2021-03-30 21:39:00 dpl joins (~dpl@77.121.78.163)
2021-03-30 21:39:02 <edwardk> different libraries will have different conventions
2021-03-30 21:40:01 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 260 seconds)
2021-03-30 21:40:03 × masterplain quits (ce7fb161@unaffiliated/sayo-) (Quit: Connection closed)
2021-03-30 21:40:22 <RamZess> I'm compiling opencv binding (with opencv4). So it is expected to work like this: c++ bool -> mapped to haskell CBool
2021-03-30 21:40:24 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-03-30 21:41:04 <tefter> C doesn't have bool as well
2021-03-30 21:41:44 × slack1256 quits (~slack1256@dvc-186-186-101-190.movil.vtr.net) (Remote host closed the connection)
2021-03-30 21:41:45 <tefter> if it is called inline-c I guess doesn' support bool
2021-03-30 21:42:42 <edwardk> https://hackage.haskell.org/package/inline-c-0.9.1.4/docs/src/Language.C.Inline.Context.html#baseTypesTable
2021-03-30 21:42:55 <edwardk> (C.Bool, [t| CBool |])
2021-03-30 21:43:14 × Varis quits (~Tadas@unaffiliated/varis) (Remote host closed the connection)
2021-03-30 21:43:19 <edwardk> is the relevant line, so that goes into baseCtx
2021-03-30 21:43:22 dcoutts joins (~duncan@94.186.125.91.dyn.plus.net)
2021-03-30 21:43:26 <edwardk> you need to ensure you have that context loaded
2021-03-30 21:43:43 <RamZess> tefter, the use "import qualified "inline-c-cpp" Language.C.Inline.Cpp as C"
2021-03-30 21:43:50 <edwardk> usually that looks like
2021-03-30 21:43:51 <edwardk> https://github.com/ekmett/codex/blob/master/freetype/src/Graphics/FreeType.hsc#L339
2021-03-30 21:44:00 <edwardk> see how i add C.baseCtx there?
2021-03-30 21:44:05 <edwardk> do you have a similar line?
2021-03-30 21:44:10 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-03-30 21:45:02 × ByronJohnson quits (~bairyn@unaffiliated/bob0) (Ping timeout: 246 seconds)
2021-03-30 21:45:16 <RamZess> C.context (C.cppCtx <> openCvCtx)
2021-03-30 21:45:18 × Tene quits (~tene@poipu/supporter/slacker/tene) (Ping timeout: 240 seconds)
2021-03-30 21:45:25 <edwardk> add C.baseCtx to that list
2021-03-30 21:45:43 <edwardk> then inline-c will understand bools
2021-03-30 21:46:03 <RamZess> edwardk, thx I will try...
2021-03-30 21:46:10 <edwardk> C.cppCtx i think is _just_ the thing that sets up the extern "C" { ... } wrapper
2021-03-30 21:47:09 <edwardk> nevermind, i'm a lying liar.
2021-03-30 21:47:10 <edwardk> https://hackage.haskell.org/package/inline-c-cpp-0.4.0.3/docs/src/Language.C.Inline.Cpp.html#cppCtx
2021-03-30 21:47:15 <edwardk> its included in cppCtx
2021-03-30 21:47:19 <edwardk> hrmm
2021-03-30 21:48:09 Tops2 joins (~Tobias@dyndsl-095-033-026-062.ewe-ip-backbone.de)
2021-03-30 21:48:20 aarvar joins (~foewfoiew@2601:602:a080:fa0:906c:b23f:e55d:e8aa)
2021-03-30 21:49:26 × berberman_ quits (~berberman@unaffiliated/berberman) (Quit: ZNC 1.8.2 - https://znc.in)
2021-03-30 21:49:30 <edwardk> note that CBool and whatever you get out of ffi may not be the same type, so eh, i tend to just make a little conversion to whatever convention the library works with rather than rely on that thing. adding something like https://github.com/ekmett/codex/blob/master/freetype/raw/Graphics/FreeType/Internal.hsc#L698
2021-03-30 21:49:50 berberman joins (~berberman@unaffiliated/berberman)
2021-03-30 21:50:02 <edwardk> then convert to/fro with $(FT_Bool whatever)
2021-03-30 21:50:15 <RamZess> ok
2021-03-30 21:51:09 <edwardk> it does require me to parse it on the back end when it comes out, which often turns into little /= 0 checks or the like: https://github.com/ekmett/codex/blob/master/freetype/src/Graphics/FreeType.hsc#L527
2021-03-30 21:51:37 × Tops22 quits (~Tobias@dyndsl-095-033-026-062.ewe-ip-backbone.de) (Ping timeout: 260 seconds)
2021-03-30 21:51:43 ByronJohnson joins (~bairyn@unaffiliated/bob0)
2021-03-30 21:52:18 Tene joins (~tene@mail.digitalkingdom.org)
2021-03-30 21:52:18 × Tene quits (~tene@mail.digitalkingdom.org) (Changing host)
2021-03-30 21:52:18 Tene joins (~tene@poipu/supporter/slacker/tene)
2021-03-30 21:52:25 <edwardk> i filed an issue to add support for negative antiquotation so you could add little 'on-the-way out' steps like that, so i could marshal haskell Bool in and out to the function cleanly without having the output direction be weird, but bitonic has been busy doing startup things
2021-03-30 21:53:17 <bitonic> edwardk: could you remind me of the issue, just in case?
2021-03-30 21:53:22 <bitonic> like, which issue is it
2021-03-30 21:53:59 <bitonic> i'm sure we discussed it but i can't find anything on https://github.com/fpco/inline-c/issues?q=is%3Aissue+author%3Aekmett so maybe it didn't end up being an issue
2021-03-30 21:54:25 <edwardk> basically an antiquoter gives you the tools for changing the value as it goes into the spliced code. but you don't have a way currently to hook an extra step on the way out when you might want to say bool is the result type and take the last step of converting the CBool -> Bool
2021-03-30 21:54:47 <bitonic> right
2021-03-30 21:54:50 <edwardk> yeah, i guess i filed it by throwing it at you over irc, rather than actually filing it ;)
2021-03-30 21:54:58 <bitonic> ok cool, i'll add it in my list of things to do when i'm bored!
2021-03-30 21:55:02 <bitonic> it doesn't sound very difficult
2021-03-30 21:55:48 × ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection)
2021-03-30 21:56:06 RusAlex joins (~Chel@unaffiliated/rusalex)
2021-03-30 21:56:45 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-03-30 21:57:39 <zephyz> So…Nobody knows how to get GHC to output ARM64 binaries?
2021-03-30 21:59:15 <edwardk> zephyz: correct. complete mystery.
2021-03-30 21:59:41 <tefter> I don't think that ghc supports ARM
2021-03-30 21:59:53 <zephyz> tefter Oh
2021-03-30 22:00:16 <mpickering> zephyz: I think most people cross compile with haskell.nix
2021-03-30 22:00:16 <edwardk> zephyz: (honestly i've never had to cross-compile with it, so in my case it that is an actual true statement, but sarcasm in, sarcasm out.)
2021-03-30 22:00:18 <mpickering> have you tried that?
2021-03-30 22:00:44 <zephyz> that would partially explain why every documentation I find is about bootstrapping GHC itself rather than explain the correct options
2021-03-30 22:00:47 × borne quits (~fritjof@200116b864cfc800f7ed9fd86a2491f0.dip.versatel-1u1.de) (Ping timeout: 250 seconds)
2021-03-30 22:00:55 <zephyz> mpickering I'm not familiar with haskell.nix, what is it?
2021-03-30 22:00:58 × ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 240 seconds)
2021-03-30 22:01:17 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-03-30 22:01:49 <zephyz> mpickering oh, is this what you're refering to? https://input-output-hk.github.io/haskell.nix/tutorials/cross-compilation/
2021-03-30 22:02:02 <mpickering> yeah
2021-03-30 22:02:26 <mpickering> apparently it's quite easy. I know people who regularly compile binaries for rasp pi
2021-03-30 22:02:53 <zephyz> fantastic, I'll give it a go!
2021-03-30 22:03:08 <zephyz> thanks!
2021-03-30 22:04:21 Rudd0 joins (~Rudd0@185.189.115.103)
2021-03-30 22:05:02 <tolt> We use haskell.nix to compile for arm
2021-03-30 22:05:13 <tolt> Works well for us, just takes a while
2021-03-30 22:06:22 Feuermagier_ joins (~CatWithMo@gateway/tor-sasl/catwithmoustache)
2021-03-30 22:06:47 × CatWithMoustache quits (~CatWithMo@gateway/tor-sasl/catwithmoustache) (Remote host closed the connection)
2021-03-30 22:07:44 average joins (uid473595@gateway/web/irccloud.com/x-mdzvkbciicshchec)
2021-03-30 22:09:18 × _d0t quits (void@gateway/vpn/mullvad/d0t/x-89419360) (Ping timeout: 240 seconds)
2021-03-30 22:10:00 Vadrigar_ joins (~Vadrigar@ip5b417208.dynamic.kabel-deutschland.de)

All times are in UTC.