gurkult / gurkbot

Our community bot, used for running the server.
MIT License
18 stars 16 forks source link

wrapped #80

Open stdlib-h opened 3 years ago

stdlib-h commented 3 years ago

for wrapping.yml maybe we can add more header files or import more classes by

c: "#include <stdio.h>\n#include <math.h>\nint main() {code}"
cpp: "#include <iostream>\n#include <cmath>\nint main() {code}"
cs: "using System;class Program {static void Main(string[] args) {code}}"
java: "import java.util.Random;\npublic class Main {public static void main(String[] args) {code}}"
rust: "fn main() {code}"
d: "import std.stdio; void main(){code}"
kotlin: "fun main(args: Array<String>) {code}"

and add more for the other languages

Shivansh-007 commented 3 years ago

Yeah! This would be a good idea.

vivax3794 commented 3 years ago

haskell could maybe be

import Control.Monad
import Data.List

main = {code}
-- or: main = print $ {code}

I am on the edge if I want the print in there or not, for example if we run with wrapped on take 10 [0..] it would print out the result, BUT if we do mapM_ print [1, 2, 3, 4, 5] it would error as it can't call print on IO () we could do some magic to make it work

{-# LANGUAGE FlexibleInstances #-}

import Control.Monad
import Data.List
import System.IO.Unsafe (unsafePerformIO)

instance Show a => Show (IO a) where
    show p = "IO " ++ (show $ unsafePerformIO p)

main = print $ {code}

but as the unsafePerformIO says, it is unsafe.

vivax3794 commented 3 years ago

we could also just not have any wrapping with haskell, seeing as it's main method is not really that complex to just write.