Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapped #80

Open
stdlib-h opened this issue Jan 20, 2021 · 3 comments
Open

wrapped #80

stdlib-h opened this issue Jan 20, 2021 · 3 comments
Labels
area: commands Commands, cogs and extensions status: discussion Discussing the implementation type: enhancement Changes or improvements to existing features

Comments

@stdlib-h
Copy link

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
Copy link
Contributor

Yeah! This would be a good idea.

@vivax3794
Copy link
Contributor

vivax3794 commented Jan 23, 2021

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 vivax3794 added area: commands Commands, cogs and extensions status: discussion Discussing the implementation type: enhancement Changes or improvements to existing features labels Jan 23, 2021
@vivax3794
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: commands Commands, cogs and extensions status: discussion Discussing the implementation type: enhancement Changes or improvements to existing features
Projects
None yet
Development

No branches or pull requests

3 participants