Programming-Idioms

Implementation
Haskell

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Implementation edit is for fixing errors and enhancing with metadata.

Instead of changing the code of the snippet, consider creating another Haskell implementation.

Other implementations
import "io/ioutil"
tmpfile, err := ioutil.TempFile("", "")
sysutils
var
  H: THandle;
begin
  H := FileCreate(GetTempFileName);
end.
import std.stdio;
auto f = File.tmpfile();
require 'tempfile'
file = Tempfile.new('foo') 
import tempfile
file = tempfile.TemporaryFile()
$f = tmpfile();
use tempdir::TempDir;
use std::fs::File;
let temp_dir = TempDir::new("prefix")?;
let temp_file = File::open(temp_dir.path().join("file_name"))?;
open (newunit=u,status="scratch")
#include <stdlib.h>
const char tmpl[] = "XXXXXX.tmp";
int fd = mkstemp(tmpl);
use Path::Tiny qw(tempfile);
my $path = tempfile;
using System.IO;
string file = Path.GetTempFileName();
(ns programming-idioms
  (:import [java.io File]))
(File/createTempFile "prefix" "suffix")
(ns programming-idioms
  (:import [java.io File]))
(File/createTempFile "prefix" "suffix" (new File "/tmp"))
file = io.tmpfile()