mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	What is Frege? ------------- Frege is a non-strict, pure functional programming language in the spirit of Haskell for the JVM. It enjoys a strong static type system with type inference. Higher rank types are supported, though type annotations are required for that. Frege programs are compiled to Java and run in a JVM. Existing Java Classes and Methods can be used seamlessly from Frege. The Frege programming language is named after and in honor of Gottlob Frege. Project State: ------------- The compiler, an Eclipse plugin and a provisional version of the documentation can be downloaded from here https://github.com/Frege/frege/releases. The REPL can be downloaded from here https://github.com/Frege/frege-repl/releases. An online REPL is running here http://try.frege-lang.org/. Examples: -------- 1) Command Line Clock: https://github.com/Frege/frege/blob/master/examples/CommandLineClock.fr 2) Brainfuck: https://github.com/Frege/frege/blob/master/examples/Brainfuck.fr 3) Concurrency: https://github.com/Frege/frege/blob/master/examples/Concurrent.fr 4) Sudoku: https://github.com/Frege/frege/blob/master/examples/Sudoku.fr 5) Java Swing examples: https://github.com/Frege/frege/blob/master/examples/SwingExamples.fr
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| {-- 
 | |
|     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
 | |
|                  |