This file contains 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 Main | |
import IdrisJvm.IO | |
namespace ResultSet | |
ResultSet : Type | |
ResultSet = JVM_Native $ Interface "java/sql/ResultSet" | |
next : ResultSet -> JVM_IO Bool |
This file contains 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
{-# LANGUAGE ForeignFunctionInterface #-} | |
{-# LANGUAGE JavaScriptFFI #-} | |
{-# LANGUAGE UnliftedFFITypes #-} | |
{-# LANGUAGE GHCForeignImportPrim #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE TypeFamilies #-} |
This file contains 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
-- | Public interface for the various prelude modules | |
module frege.Prelude | |
-- | The Java @!@ operator on booleans | |
(!) :: Bool -> Bool | |
-- | A head strict variant of (:) | |
-- | |
-- This will be used in list comprehensions |
This file contains 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 helloworld; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Iterator; | |
import java.util.List; | |
import static java.lang.String.format; | |
import static java.lang.System.out; | |
import static java.util.Arrays.asList; |
This file contains 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 mmhelloworld.hellofrege.HelloWorld where | |
import mmhelloworld.hellofrege.Script | |
import Java.Util (List) | |
-- Implement Runnable interface | |
newRunnable :: ST s () -> ST s (Mutable s Runnable) | |
newRunnable action = jsMethod1ST script "Runnable" "create" action where | |
script = | |
"var JRunnable = Java.type('java.lang.Runnable'); \n" ++ |
This file contains 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 fregeappletsupport; | |
import javax.swing.JApplet; | |
import javax.swing.SwingUtilities; | |
import fregeapplet.HelloApplet; | |
/** | |
* A starter class since Frege cannot extend a Java class | |
* |
This file contains 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
--- Small parser, inspired by Parsec, but much less versatile | |
module testfrege.data.NanoParsec where | |
import Data.List | |
import Prelude.PreludeBase (StringJ) | |
import Data.Monoid | |
import Test.QuickCheck as Q() | |
{-- |
This file contains 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
frege> pure native groupCount :: Matcher -> Int | |
frege> match s regex = groups <$> (s =~ regex) where groups m = [m.group i | i <- [1..groupCount m]] | |
frege> Just (Just year: Just month: Just day: _) = "2011-07-15" `match` #(\d\d\d\d)-(\d\d)-(\d\d)# | |
frege> println [year, month, day] | |
["2011", "07", "15"] |
This file contains 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 helloworld.QuicksortInversion where | |
--Quicksort with inversion | |
qsort :: Ord a => [a] -> ([a], Int) | |
qsort xs = ST.run go where | |
go = do | |
jlist <- ArrayList.fromList xs | |
inv <- Ref.new 0 -- initialize the inversion as 0 | |
let qsortImperative !from !to | |
| from < to = do |
This file contains 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 helloworld; | |
import javax.script.Compilable; | |
import javax.script.CompiledScript; | |
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
public class FregeScriptEngineTest { | |
public static void main(final String[] args) throws Exception { |
NewerOlder