Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Frege

< >

Frege is an open source programming language created in 2011.

#206on PLDB 13Years Old 223Repos
Download source code:
git clone https://github.com/frege/frege
Homepage · Source Code · Wikipedia · Twitter · Docs

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 Example Token
MultiLine Comments ✓ {- A comment -} {- -}
Comments ✓ -- A comment
Line Comments ✓ -- A comment --
Type Inference ✓
Semantic Indentation X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v154.2.0