Skip to content
module FunctionRecord where
data FRecord = FRecord {
parent :: FRecord,
name :: String,
toString :: (FRecord -> String)
}
prototype = FRecord { parent = prototype, name = undefined, toString = (\r -> r.name) }
dierk = prototype.{ name = "Dierk" }
------------------------------------------------------------------------------------------------------------------------------
-- ROSE TREES, FUNCTORS, MONOIDS, FOLDABLES, Frege version by Dierk Koenig
------------------------------------------------------------------------------------------------------------------------------
module Lab6 where
import frege.prelude.Math(round, sin)
data Rose a = Rose a [Rose a]
derive Show Rose a
module Countdown where
-- Countdown example from chapter 11 of Programming in Haskell,
-- Graham Hutton, Cambridge University Press, 2007.
-- Template for homework 10 in the FP101x course
-- Frege adaptions by Dierk Koenig
-- How Java's Date looks like through the Frege glasses
data Date = native java.util.Date where
module Lab4 where
------------------------------------------------------------------------------------------------------------------------------
-- RECURSIVE FUNCTIONS, Frege version by Dierk Koenig
------------------------------------------------------------------------------------------------------------------------------
-- import frege.prelude.Math(pi) -- uncomment this when trying to use pi
-- ===================================
-- Ex. 0
-- Functional parsing library from chapter 8 of Programming in Haskell,
-- Graham Hutton, Cambridge University Press, 2007.
-- Template file for the homework in the FP101x EdX course.
-- Read also: http://www.cs.nott.ac.uk/~gmh/monparsing.pdf
-- adapted to Frege by Dierk Koenig
-- uncomment code as needed
module Parsing where
import Data.Char
import java.util.function.Function // requires Java 8
class NullSafe<T> {
protected final T t
protected NullSafe(T t) {this.t = t}
static NullSafe<T> enter(T t) { new NullSafe<T>(t) } // enter or "return" is like a constructor
// in the general case, applicative would have the type Function<T, NullSafe<T>> but we don't need that here
NullSafe<T> rightShift (Function<T,T> applicative) {
module realworld.experiments.ExampleTests where
test_that_is_expected_to_pass = 1 == 1
test_that_is_expected_to_fail = 1 == 2
//@Grab('org.spockframework:spock-core:0.7-groovy-2.0')
import spock.lang.*
import java.lang.reflect.Field
class FregeSpec extends Specification {
@Shared Class testClass = realworld.experiments.ExampleTests
@Shared List<Field> testFields = testClass.fields.findAll { Field it -> it.modifiers == 25 && it.name.startsWith("test") }
@Unroll
// has all methods of List
trait ListLike {
@Delegate List linkedList = new LinkedList()
}
// stores anything but exposes only Strings
class StringList implements ListLike {
String get(int index) { linkedList.get(index).toString() }
}
View ModularGroovyTraits
trait HasId {
long id
}
trait HasVersion {
long version
}
trait Persistent {
boolean save() { println "saving ${this.dump()}" }
}
trait Entity implements Persistent, HasId, HasVersion {
Something went wrong with that request. Please try again.