Test Frege Tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module hellofrege.JavaList where | |
| data LinkedList a = native java.util.LinkedList where | |
| native add :: Mutable s (LinkedList a) -> a -> ST s Bool | |
| native get :: Mutable s (LinkedList a) -> Int -> ST s (Maybe a) | |
| native new :: () -> STMutable s (LinkedList a) | |
| fromFregeList :: [a] -> STMutable s (LinkedList a) | |
| fromFregeList xs = LinkedList.new () >>= loop xs where | |
| loop (x:xs) jlist = LinkedList.add jlist x >> loop xs jlist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object InterpreterTest { | |
| import scala.tools.nsc._ | |
| import interpreter._ | |
| def break(params: NamedParam*): Unit = { | |
| val repl = new ILoop | |
| repl.settings = new Settings | |
| repl.settings.Yreplsync.value = true | |
| repl.in = SimpleReader() | |
| repl.createInterpreter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module hellofrege.ProcessTest where | |
| data ProcessBuilder = mutable native java.lang.ProcessBuilder where | |
| native new :: MutableIO StringArr -> IO ProcessBuilder | |
| native redirectErrorStream :: ProcessBuilder -> Bool -> IO () | |
| native start :: ProcessBuilder -> IO Process throws IOException | |
| native directory :: ProcessBuilder -> MutableIO File -> IO ProcessBuilder | |
| data Process = mutable native java.lang.Process where | |
| native getOutputStream :: Process -> IO OutputStream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package javacallingfrege; | |
| import frege.prelude.PreludeBase.TList; | |
| import frege.prelude.PreludeText; | |
| import fregeforjava.Foo; | |
| public class Main { | |
| public static void main(final String[] args) { | |
| // Get the instance of D1 for class 'A' | |
| final Foo.CA aInst = Foo.IA_D1.it; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module fregeforjava.Foo where | |
| class A a where | |
| f1 :: a -> Bool | |
| f2 :: a -> Int -> [a] | |
| data D1 = D1 String Int | |
| derive Show D1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Data.Array | |
| import Data.List | |
| data Direction = DRight | DDown | |
| isValid (a, b) board = a >= 0 && a <= m && b >= 0 && b <= n where | |
| (_, (m, n)) = bounds board | |
| canMove board (a, b) (DRight, step) = isValid (a, b + step) board && | |
| board ! (a, b + step) >= board ! (a, b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| toc={1:4157860} |
NewerOlder