foxbored 2017-02-20 03:46:34
hello
mroman 2017-02-20 03:47:38
the only one I know is to convert them to from base_n -> native -> base_n+1 :)
foxbored 2017-02-20 03:47:52
do what?
mroman 2017-02-20 03:47:57
which involves too many divisions.
mroman 2017-02-20 03:48:06
(but not really a haskell question)
foxbored 2017-02-20 03:48:13
*looks cunfoosed at yoo*
foxbored 2017-02-20 03:48:37
whats a haskel?
Theophane 2017-02-20 03:49:32
foxbored: the topic of this channel :P
ongy 2017-02-20 03:49:49
sudoreboot[m]: your message became a link through the matrix gateway on our side... If you are familiar with how C# interacts with static C libraries, you may have a good idea of how things work. If C# has it's own runtime, then the haskell RTS and the C# runtime will probably compete for some resources (both running a thread pool, trying to work around foreign calls). I think there was some discussion
ongy 2017-02-20 03:49:51
around this a while ago in here, you may want to check the logs
foxbored 2017-02-20 03:50:17
uuuuh... i know ome HTML/CSS/Batch and some JS
foxbored 2017-02-20 03:50:20
but no C
ongy 2017-02-20 03:50:42
foxbored: haskell is a general purpose programming language. The main difference to most others is that it's purely functional
foxbored 2017-02-20 03:51:13
oh. ok :)
mroman 2017-02-20 03:51:27
Haskell is like batch. Except there's no @echo off.
ongy 2017-02-20 03:51:40
comparing to those, haskell gives you the nice property of a static and strong type system
foxbored 2017-02-20 03:51:59
huh. you know you dont have to use @echo off... that just hides the code form the user
foxbored 2017-02-20 03:52:22
i came cuz i wanted to talk :)
ongy 2017-02-20 03:53:10
this channel isn't intended for smalltalk, but rather for haskell (and ecosystem) related problems.
foxbored 2017-02-20 03:53:23
ok. ill be on #furry
sudoreboot[m] 2017-02-20 03:55:40
ongy: My whole message became a link (dead I presume)?
sudoreboot[m] 2017-02-20 03:55:41
I'm not sure I have the whole runtime thing down, as I am not sure what would make machine code compiled from haskell and machine code compiled from csharp different in terms of how it is run.
ongy 2017-02-20 03:56:17
sudoreboot[m]: the link is live (on the matrix website) and yes. IRC has a maximum message length of 512chars, so anything longer has to be split (like mine did) or worked around
sudoreboot[m] 2017-02-20 03:57:32
ongy: Is it readable or should I repeat it in parts?
ongy 2017-02-20 03:58:12
it's readable for people that care to follow the link. You should probably cut it down to the essential question and post it
mroman 2017-02-20 04:01:37
(except that C# is bytecode -> jit and Haskell is not?)
ongy 2017-02-20 04:03:05
also the rts can intercept allocations done by haskell code and reschedule, while the C# (is it a C# vm?) probably does something else with thread managing
sudoreboot[m] 2017-02-20 04:03:21
Here's the tldr of my question:
sudoreboot[m] 2017-02-20 04:03:22
I want to compile my Haskell code into a static linked library with an FFI wrapper and use this as a plugin in Unity3D, by calling the library from C# during runtime and get the desired results back. Am I going to have to spend weeks on trying to get this to work?
ongy 2017-02-20 04:03:47
I guess intercept is the wrong word here, the code calls into rts code on to co allocations and the RTS can decide to run another thread
sudoreboot[m] 2017-02-20 04:05:17
mroman: Unity3D has support for compiled plugins, so the fact that it's compiled to machine code while C# is bytecode shouldn't be a problem?
mroman 2017-02-20 04:05:33
C# can do native calls
mroman 2017-02-20 04:05:37
using DllImport and Marshalling.
mroman 2017-02-20 04:06:06
but I sadly don't know how this works together with Haskells RTS.
merijn 2017-02-20 04:06:23
This is rather misleading
merijn 2017-02-20 04:06:42
Calling Haskell from C# is the exact same as calling C from C# (since C FFI is the only thing that exists)
sudoreboot[m] 2017-02-20 04:06:55
mroman: So, in theory, making it work should involvelittle more than following the typical FFI docs?
merijn 2017-02-20 04:07:07
The only difference is that the Haskell library might introduce a bit of overhead in the form of it's own scheduling and memory managment
merijn 2017-02-20 04:07:10
sudoreboot[m]: Yes
mroman 2017-02-20 04:07:19
You can invoke C functions from C#. That's not a problem.
mroman 2017-02-20 04:07:27
If haskell can expose them as C functions.
mroman 2017-02-20 04:07:35
which I take from merijn's answer it can.
merijn 2017-02-20 04:08:00
sudoreboot[m]: I have a minimal example of calling haskell from C here: https://gist.github.com/merijn/4a0fee2b3a5ef3476aa4
merijn 2017-02-20 04:08:23
sudoreboot[m]: Simply replace the C code with C# using C#'s C FFI to call the same functions
sudoreboot[m] 2017-02-20 04:08:58
Thank you, I'm going to try your examples out
merijn 2017-02-20 04:09:23
sudoreboot[m]: Might require a bit of fiddling, but should be rather straightforward, mostly
sudoreboot[m] 2017-02-20 04:09:37
I'm struggling with linking because ghc is telling me ghc needs to be compiled with -fPIC, which is giving me a headache
sudoreboot[m] 2017-02-20 04:10:17
All examples thus far have all given me errors about linking errors
sudoreboot[m] 2017-02-20 04:10:56
s/linking errors/-fPIC/
ongy 2017-02-20 04:11:17
have you tried to pass -fPIC to ghc?
sudoreboot[m] 2017-02-20 04:11:56
ongy: Yeah. libHSbase is the one saying it needs to be recompiled
ongy 2017-02-20 04:13:54
then you are probably trying to link the static library into a dynamic object (if you are on windows that's .lib (I think) into a .dll)
sudoreboot[m] 2017-02-20 04:18:13
Trying to compile using `ghc -O2 --make -no-hs-main -optl '-shared' -o Foo.so Foo.hs` should work according to https://stackoverflow.com/questions/16615641/calling-haskell-from-c-sharp#16618038
sudoreboot[m] 2017-02-20 04:18:27
ongy: I'm on Ubuntu 16.04.4
mauke 2017-02-20 04:18:28
why do people still use --make?
merijn 2017-02-20 04:18:44
mauke: Because the internet is littered without outdated examples that people blindly copy
ongy 2017-02-20 04:18:46
because it shows up on the internet in tutorials
sudoreboot[m] 2017-02-20 04:19:02
mauke: I usually omit it, but I just copy pasted
ongy 2017-02-20 04:19:22
sudoreboot[m]: have you tried to add -fPIC to that line?
ongy 2017-02-20 04:19:30
ah sorry, not where the problem is
ongy 2017-02-20 04:19:32
I should think first
sudoreboot[m] 2017-02-20 04:20:51
```Linking Foo.so ...
sudoreboot[m] 2017-02-20 04:20:52
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
sudoreboot[m] 2017-02-20 04:20:52
(.text+0x20): undefined reference to `main'```
mauke 2017-02-20 04:21:29
it's trying to create an executable
ongy 2017-02-20 04:21:54
https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_guide/using-shared-libs.html mentions -dynamic/-shared as ghc arguments
sudoreboot[m] 2017-02-20 04:22:03
mauke: Why is it doing that with the -shared and -no-hs-main flags
ongy 2017-02-20 04:22:19
mauke: that for example also has the -make and it's ghc docs from 7.8.4. Since when is -make not required anymore?
ongy 2017-02-20 04:23:00
sudoreboot[m]: you are passing the -shared to the linker not ghc itself
sudoreboot[m] 2017-02-20 04:23:53
ongy: Should I pass it both?
mauke 2017-02-20 04:25:41
ongy: 7.0
ongy 2017-02-20 04:29:07
sudoreboot[m]: trial and error? It shouldn't take that long. I would try both and see
merijn 2017-02-20 04:32:53
ongy: --make hasn't been required for years
merijn 2017-02-20 04:34:24
ongy: It exists, but --make is the default unless you override it, so "ghc" and "ghc --make" do the exact same thing
sudoreboot[m] 2017-02-20 04:39:47
merijn: ongy: Thank you for all the help :)
mudri 2017-02-20 04:42:56
cocreature: Okay, thanks. I'll consider Foldable. I don't think I actually want to use containers like Eq a => (a -> Bool), but it somehow seems nice to include them.
mudri 2017-02-20 04:43:13
(Or even not Eq a in that case.)