Relevant material
https://hyperpolyglot.org/ml

Summary

Who needs hyperpolyglot when you have GPT-3?

I translate Haskell into Clojure using the following prompt.

haskell-to-clojure.prompt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
title: "Translate Haskell to Clojure"
prompt: |+
    Haskell:
    zip (map show [1,5,9]) ["a","b","c"]
    Clojure:
    (println (map vector '(1 2 3) '(4 5 6)))

    Haskell:
    map toUpper "MiXeD cAsE"
    Clojure:
    (clojure.string/upper-case "MiXeD cAsE")

    Haskell:
    putStrLn "Hello World"
    Clojure:
    (println "Hello World")

    Haskell:
    import Data.Time.Clock
    import Data.Time.Calendar
    date :: IO (Integer, Int, Int) -- :: (year, month, day)
    date = getCurrentTime >>= return . toGregorian . utctDay
    Clojure:
    (defn date [] (.toString (java.util.Date.)))

    Haskell:
    <1>
    Clojure:    
engine: "davinci"
temperature: 0.3
max-tokens: 60
top-p: 1.0
frequency-penalty: 0.5
# If I make presence-penalty 0 then it will get very terse
presence-penalty: 0.0
best-of: 1
stop-sequences:
- "\n\n"
inject-start-text: yes
inject-restart-text: yes
show-probabilities: off
vars:
- "haskell code"
examples:
- "min 1 2"
external: ""
filter: no
# Keep stitching together until reaching this limit
# This allows a full response for answers which may need n*max-tokens to reach the stop-sequence.
stitch-max: 0

Demonstrations

asciinema recording

asciinema recording

Translate Haskell into Clojure

Haskell

1
div 7 3

Clojure

1
(/ 7 3)

It’s not perfect

Haskell

1
2
3
z = x * y
  where x = 3.0
        y = 2.0 * x

Clojure

1
(defn z [x y] (* y x))

But it’s pretty good

Haskell

1
let absn = if n < 0 then -n else n

Clojure

1
(defn absn [n] (if (negative? n) (- n) n))