Questions Concepts
GitHub icon

Frege

Frege - Programming language

< >

Frege is an open source programming language created in 2011.

Source code:
git clone https://github.com/frege/frege
#177on PLDB 12Years Old 223Repos

Frege is a non-strict, purely functional programming language for the Java virtual machine in the spirit of Haskell. It is considered a Haskell dialect or simply "a" Haskell for the Java virtual machine. Frege has a strong static type system with type inference. Read more on Wikipedia...


Example from Linguist:
{-- This program displays the current time on stdandard output every other second. -} module examples.CommandLineClock where data Date = native java.util.Date where native new :: () -> IO (MutableIO Date) -- new Date() native toString :: Mutable s Date -> ST s String -- d.toString() --- 'IO' action to give us the current time as 'String' current :: IO String current = do d <- Date.new () d.toString {- "java.lang.Thread.sleep" takes a "long" and returns nothing, but may throw an InterruptedException. This is without doubt an IO action. public static void sleep(long millis) throws InterruptedException Encoded in Frege: - argument type long Long - result void () - does IO IO () - throws ... throws .... -} -- .... defined in frege.java.Lang -- native sleep java.lang.Thread.sleep :: Long -> IO () throws InterruptedException main args = forever do current >>= print print "\r" stdout.flush Thread.sleep 999
Example from Wikipedia:
{-- This program displays the current time on standard output every other second. -} module examples.CommandLineClock where data Date = native java.util.Date where native new :: () -> IO (MutableIO Date) -- new Date() native toString :: Mutable s Date -> ST s String -- d.toString() --- 'IO' action to give us the current time as 'String' current :: IO String current = do d <- Date.new () -- reads system timer, hence IO d.toString main args = forever do current >>= print -- print formatted date print "\r" -- followed by carriage return stdout.flush -- make sure it's shown Thread.sleep 999L -- wait 0.999 seconds

Language features

Feature Supported Token Example
MultiLine Comments {- -}
{- A comment
-}
Comments
-- A comment
Line Comments --
-- A comment
Type Inference
Semantic Indentation X

View source

- Build the next great programming language · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Traffic · Traffic Today · Day 305 · feedback@pldb.com · Logout