To generate these primes I wrote simple Primes module.
module Primes where factors :: Int -> [Int] factors n = [x | x <- [1..n], n `mod` x == 0] prime :: Int -> Bool prime n = factors n == [1,n] primes :: Int -> [Int] primes n = [x | x <- [2..n], prime x]
And a Main module to generate some primes and print them.
module Main where import Primes main = print $ primes 100
This is basic Haskell which can be compiled by GHC.
$ ghc Main.hs [1 of 2] Compiling Primes ( Primes.hs, Primes.o ) [2 of 2] Compiling Main ( Main.hs, Main.o ) Linking Main ... $ ./Main [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
$ ls Main.hs Primes.hs $ uhc -tjs Main.hs [1/2] Compiling Haskell Primes (Primes.hs) [2/2] Compiling Haskell Main (Main.hs) $ ls Main.core Main.hi Main.hs Main.html Main.js Main.mjs Primes.core Primes.hi Primes.hs Primes.mjs
I also don't know how complete or good UHC is as Haskell compiler. I checked it could compile a simple Chess program which I have been playing with thought it might be fun to try and get running in the browser for a post. Turns out I'm going to have to level up my Haskell a fair bit to get the UI stuff working.