SlideShare a Scribd company logo
1 of 10
Download to read offline
Frege
https://github.com/Frege/frege
Frege is a Haskell for the JVM
FizzBuzz sample
public class FizzBuzz { // IMPERATIVE

public static void main(String[] args) {

for (int i = 1; i <= 100; i++) {

if (i % 15 == 0) {

System.out.println("FizzBuzz");

} else if (i % 3 == 0) {

System.out.println("Fizz");

} else if (i % 5 == 0) {

System.out.println("Buzz");

} else {

System.out.println(i);

}

}}}
2
module FizzBuzz where // FUNCTIONAL
fizzes = cycle ["", "", "fizz"] -- cycle :: [a] -> [a]
buzzes = cycle ["", "", "", "", "buzz"]
pattern = zipWith (++) fizzes buzzes -- zipWith:: (a -> b -> c) -> [a] -> [b] -> [c]
numbers = map show [1..] -- map :: (a -> b) -> [a] -> [b]
fizzbuzz = zipWith max pattern numbers -- max :: Ord a => a -> a -> a
main _ = do -- main :: [String] -> IO
for (take 100 fizzbuzz) println -- take :: [Int] -> [a] -> [a]
http://c2.com/cgi/wiki?FizzBuzzTest
FizzBuzz complexity
3
Imperative Functional
Conditionals 4 0
Operators 4 1
Nesting Level (3 zur Info) 0
McCabe:M= 8 1
https://de.wikipedia.org/wiki/McCabe-Metrik
Frege Syntax (Function)
--‘=‘ is a mathematical operator ( NO ASSIGNMENT )
one = 1 -- ‘public static Integer one = 1;‘
two = 2 -- ‘public static Integer two = 2;‘
oneTwoTuple = (one, two) -- ‘()‘ tuple constructor
assertTuple = oneTwoTuple == (1,2) -- ‘True‘
oneTwoList = [one, two] -- ‘[]‘ list constructor
assertList = oneTwoList == [1,2] -- ‘True‘
-- aset is a unique list
aset list = unique list -- type: ‘aset:: (Eq a) => [a] -> [a]‘
-- amap is a list of (key,value) tuples
amap keys values = zip keys values -- type: ‘amap :: [a] -> [b] -> [(a,b)]‘
amap2 f values = zip (map f values) values -- type: ‘amap2:: (b -> a) -> [b] -> [(a,b)]‘
unique [] = [] -- type: ‘unique:: (Eq a) => [a] -> [a]‘
unique (x:xs)
| elem x xs = unique xs
| otherwise = x : unique xs
naturals = [1..] -- type: ‘naturals::[Int]‘=[1,2,..,Int.MAX]
evens = [ x | x <- [1..], even x] -- type: ‘evens ::[Int]‘=[1,3,..,Int.MAX-1]
4https://dierk.gitbooks.io/fregegoodness/
Frege Syntax (Types)
-- interface Interface<A> {...}
class Interface a where
methode :: a -> a -> Bool
-- interface DomainInterface {...}
data DomainInterface =
DomainIntImpl { int::Int } --class DomainIntImpl implements DomainInterface{ }
| DomainStringImpl{string::String}--class DomainStrImpl implements DomainInterface{ }
derive Show DomainInterface --class DomainIntImpl{ @Overwrite public String toString() }
--class DomainStringImpl{@Overwrite public String toString() }
instance Interface DomainInterface where
methode (DomainIntImpl {int=a}) (DomainIntImpl {int=b}) = a == b
methode (DomainStringImpl{string=a}) (DomainStringImpl {string=b}) = a == b
methode _ _ = False
-- class DomainIntImpl { @Overwrite public String methode(a,b)}
-- class DomainStringImpl { @Overwrite public String methode(a,b)}
ints = map DomainIntImpl [1..10] -- [ 1 , 2 ,.., 10 ]
strings = map DomainStringImpl $ map show [1..10] -- [“1“,“2“,..,“10“]
find_1_Int = head $ map (DomainIntImpl 1).methode ints -- True
find_1_String = head $ map (DomainStringImpl "1").methode strings -- True
5https://en.wikibooks.org/wiki/Haskell/Classes_and_types
Frege Syntax (Monad)
main _ = do // FUNCTIONAL
url <- URL.new "http://www.google.com" >>= either throw return
ios <- url.openStream >>= either throw return
rdr <- InputStreamReader.new ios "UTF-8" >>= either throw return
bfr <- BufferedReader.new rdr >>= either throw return
maybe <- bfr.readLine >>= println
ios.close
return()
6
public static void main(String[] args) { // IMPERATIVE
final URL url;
try { url = new URL("http://www.google.com");
} catch (MalformedURLException e) { throw new RuntimeException(e);}
final InputStream ios;
try { ios = url.openStream();
} catch (IOException e) {throw new RuntimeException(e);}
InputStreamReader rdr = new InputStreamReader(ios);
BufferedReader bfr = new BufferedReader(rdr);
String next = null;
try {
while((next = bfr.readLine()) != null){ System.out.println(next); }
} catch (IOException e) {throw new RuntimeException(e);}
try { ios.close();
} catch (IOException e) {throw new RuntimeException(e);}
}
http://www.learnyouahaskell.com/a-fistful-of-monads
Frege PROs
7
• Eleganz
• Pure Functional
• Thread Safe by Design
• Global Type inference
• Mvn, Gradle tooling exist
• Hoogle
http://de.slideshare.net/Mittie/frege-tutorial-at-javaone-2015
Frege CONs
8
• IDE (only eclipse :( )
• Compiler errors messages
• Debugging
• Laziness vs Performance
• Missing libraries
Blue or red pill?
9
Links
• GitHub: https://github.com/Frege
• Language: http://www.frege-lang.org/doc/Language.pdf
• Types: https://en.wikibooks.org/wiki/Haskell/Classes_and_types
• Monad: http://www.learnyouahaskell.com/a-fistful-of-monads
• EBook: https://dierk.gitbooks.io/fregegoodness/
• Video: http://www.yt.fully.pk/watch/1P1-HXNfFPc#
10

More Related Content

What's hot

How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cythonAnderson Dantas
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in SwiftSeongGyu Jo
 
Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)진성 오
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPaweł Dawczak
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2osfameron
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기진성 오
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScriptniklal
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionIan Barber
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonakaptur
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tiebrian d foy
 

What's hot (20)

The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
Functional programming with php7
Functional programming with php7Functional programming with php7
Functional programming with php7
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cython
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in Swift
 
Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to Elixir
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
 
C99.php
C99.phpC99.php
C99.php
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
 

Viewers also liked

James Higginbotham - API Design
James Higginbotham - API DesignJames Higginbotham - API Design
James Higginbotham - API DesignJohn Zozzaro
 
Rolf Stephan - Axon Ivy Intro
Rolf Stephan -  Axon Ivy IntroRolf Stephan -  Axon Ivy Intro
Rolf Stephan - Axon Ivy IntroJohn Zozzaro
 
Annual Client Presentation
Annual Client PresentationAnnual Client Presentation
Annual Client PresentationTom O'Malley
 
Surfing the Waves of Growth
Surfing the Waves of GrowthSurfing the Waves of Growth
Surfing the Waves of GrowthNiall McArdle
 
Leading Change In the Game Industry
Leading Change In the Game IndustryLeading Change In the Game Industry
Leading Change In the Game Industryjhouchens99
 
Thỏa sức sáng tạo trong văn phòng đặc biệt
Thỏa sức sáng tạo trong văn phòng đặc biệtThỏa sức sáng tạo trong văn phòng đặc biệt
Thỏa sức sáng tạo trong văn phòng đặc biệtThi công sơn giá rẻ
 
Antonia Edwards Medical 2016
Antonia Edwards Medical 2016Antonia Edwards Medical 2016
Antonia Edwards Medical 2016Antonia Edwards
 
Introduccion al derecho 4ta parcial
Introduccion al derecho 4ta parcialIntroduccion al derecho 4ta parcial
Introduccion al derecho 4ta parcialobfloresc
 
Сервис-Ориентированная Архитектура: путь от потребностей к возможностям
Сервис-Ориентированная Архитектура: путь от потребностей к возможностямСервис-Ориентированная Архитектура: путь от потребностей к возможностям
Сервис-Ориентированная Архитектура: путь от потребностей к возможностямAlexander Makeev
 

Viewers also liked (17)

James Higginbotham - API Design
James Higginbotham - API DesignJames Higginbotham - API Design
James Higginbotham - API Design
 
Rolf Stephan - Axon Ivy Intro
Rolf Stephan -  Axon Ivy IntroRolf Stephan -  Axon Ivy Intro
Rolf Stephan - Axon Ivy Intro
 
Annual Client Presentation
Annual Client PresentationAnnual Client Presentation
Annual Client Presentation
 
CV_RHansen_2016_v2
CV_RHansen_2016_v2CV_RHansen_2016_v2
CV_RHansen_2016_v2
 
Surfing the Waves of Growth
Surfing the Waves of GrowthSurfing the Waves of Growth
Surfing the Waves of Growth
 
Progetto_BIOCASPO
Progetto_BIOCASPOProgetto_BIOCASPO
Progetto_BIOCASPO
 
Leading Change In the Game Industry
Leading Change In the Game IndustryLeading Change In the Game Industry
Leading Change In the Game Industry
 
Thỏa sức sáng tạo trong văn phòng đặc biệt
Thỏa sức sáng tạo trong văn phòng đặc biệtThỏa sức sáng tạo trong văn phòng đặc biệt
Thỏa sức sáng tạo trong văn phòng đặc biệt
 
Nmdl final
Nmdl finalNmdl final
Nmdl final
 
Agriculture.
Agriculture.Agriculture.
Agriculture.
 
AMIR C.V.
AMIR C.V.AMIR C.V.
AMIR C.V.
 
Antonia Edwards Medical 2016
Antonia Edwards Medical 2016Antonia Edwards Medical 2016
Antonia Edwards Medical 2016
 
Introduccion al derecho 4ta parcial
Introduccion al derecho 4ta parcialIntroduccion al derecho 4ta parcial
Introduccion al derecho 4ta parcial
 
Back to italy
Back to italyBack to italy
Back to italy
 
Сервис-Ориентированная Архитектура: путь от потребностей к возможностям
Сервис-Ориентированная Архитектура: путь от потребностей к возможностямСервис-Ориентированная Архитектура: путь от потребностей к возможностям
Сервис-Ориентированная Архитектура: путь от потребностей к возможностям
 
Franklin Dcosta Resume
Franklin Dcosta ResumeFranklin Dcosta Resume
Franklin Dcosta Resume
 
Git basics
Git basicsGit basics
Git basics
 

Similar to Frege is a Haskell for the JVM

Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with PythonHan Lee
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
From Javascript To Haskell
From Javascript To HaskellFrom Javascript To Haskell
From Javascript To Haskellujihisa
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheetGeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheetJose Perez
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick touraztack
 
Useful javascript
Useful javascriptUseful javascript
Useful javascriptLei Kang
 
Hello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebHello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebMuhammad Raza
 
20191116 custom operators in swift
20191116 custom operators in swift20191116 custom operators in swift
20191116 custom operators in swiftChiwon Song
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programmingLukasz Dynowski
 
Swift Rocks #2: Going functional
Swift Rocks #2: Going functionalSwift Rocks #2: Going functional
Swift Rocks #2: Going functionalHackraft
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collectionsMyeongin Woo
 
Functional perl
Functional perlFunctional perl
Functional perlErrorific
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Calvin Cheng
 
Problem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdfProblem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdfebrahimbadushata00
 

Similar to Frege is a Haskell for the JVM (20)

Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
From Javascript To Haskell
From Javascript To HaskellFrom Javascript To Haskell
From Javascript To Haskell
 
Javascript
JavascriptJavascript
Javascript
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheetGeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheet
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
 
Hello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebHello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC Unideb
 
20191116 custom operators in swift
20191116 custom operators in swift20191116 custom operators in swift
20191116 custom operators in swift
 
Miracle of std lib
Miracle of std libMiracle of std lib
Miracle of std lib
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
Swift Rocks #2: Going functional
Swift Rocks #2: Going functionalSwift Rocks #2: Going functional
Swift Rocks #2: Going functional
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collections
 
Functional perl
Functional perlFunctional perl
Functional perl
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)
 
Problem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdfProblem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdf
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 

More from jwausle

Blockchain Ethereum Iota
Blockchain Ethereum IotaBlockchain Ethereum Iota
Blockchain Ethereum Iotajwausle
 
Svn to-git
Svn to-gitSvn to-git
Svn to-gitjwausle
 
Bndtools.key
Bndtools.keyBndtools.key
Bndtools.keyjwausle
 
Gogo shell
Gogo shellGogo shell
Gogo shelljwausle
 
Docker.key
Docker.keyDocker.key
Docker.keyjwausle
 

More from jwausle (6)

Slides
SlidesSlides
Slides
 
Blockchain Ethereum Iota
Blockchain Ethereum IotaBlockchain Ethereum Iota
Blockchain Ethereum Iota
 
Svn to-git
Svn to-gitSvn to-git
Svn to-git
 
Bndtools.key
Bndtools.keyBndtools.key
Bndtools.key
 
Gogo shell
Gogo shellGogo shell
Gogo shell
 
Docker.key
Docker.keyDocker.key
Docker.key
 

Recently uploaded

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Frege is a Haskell for the JVM

  • 2. FizzBuzz sample public class FizzBuzz { // IMPERATIVE
 public static void main(String[] args) {
 for (int i = 1; i <= 100; i++) {
 if (i % 15 == 0) {
 System.out.println("FizzBuzz");
 } else if (i % 3 == 0) {
 System.out.println("Fizz");
 } else if (i % 5 == 0) {
 System.out.println("Buzz");
 } else {
 System.out.println(i);
 }
 }}} 2 module FizzBuzz where // FUNCTIONAL fizzes = cycle ["", "", "fizz"] -- cycle :: [a] -> [a] buzzes = cycle ["", "", "", "", "buzz"] pattern = zipWith (++) fizzes buzzes -- zipWith:: (a -> b -> c) -> [a] -> [b] -> [c] numbers = map show [1..] -- map :: (a -> b) -> [a] -> [b] fizzbuzz = zipWith max pattern numbers -- max :: Ord a => a -> a -> a main _ = do -- main :: [String] -> IO for (take 100 fizzbuzz) println -- take :: [Int] -> [a] -> [a] http://c2.com/cgi/wiki?FizzBuzzTest
  • 3. FizzBuzz complexity 3 Imperative Functional Conditionals 4 0 Operators 4 1 Nesting Level (3 zur Info) 0 McCabe:M= 8 1 https://de.wikipedia.org/wiki/McCabe-Metrik
  • 4. Frege Syntax (Function) --‘=‘ is a mathematical operator ( NO ASSIGNMENT ) one = 1 -- ‘public static Integer one = 1;‘ two = 2 -- ‘public static Integer two = 2;‘ oneTwoTuple = (one, two) -- ‘()‘ tuple constructor assertTuple = oneTwoTuple == (1,2) -- ‘True‘ oneTwoList = [one, two] -- ‘[]‘ list constructor assertList = oneTwoList == [1,2] -- ‘True‘ -- aset is a unique list aset list = unique list -- type: ‘aset:: (Eq a) => [a] -> [a]‘ -- amap is a list of (key,value) tuples amap keys values = zip keys values -- type: ‘amap :: [a] -> [b] -> [(a,b)]‘ amap2 f values = zip (map f values) values -- type: ‘amap2:: (b -> a) -> [b] -> [(a,b)]‘ unique [] = [] -- type: ‘unique:: (Eq a) => [a] -> [a]‘ unique (x:xs) | elem x xs = unique xs | otherwise = x : unique xs naturals = [1..] -- type: ‘naturals::[Int]‘=[1,2,..,Int.MAX] evens = [ x | x <- [1..], even x] -- type: ‘evens ::[Int]‘=[1,3,..,Int.MAX-1] 4https://dierk.gitbooks.io/fregegoodness/
  • 5. Frege Syntax (Types) -- interface Interface<A> {...} class Interface a where methode :: a -> a -> Bool -- interface DomainInterface {...} data DomainInterface = DomainIntImpl { int::Int } --class DomainIntImpl implements DomainInterface{ } | DomainStringImpl{string::String}--class DomainStrImpl implements DomainInterface{ } derive Show DomainInterface --class DomainIntImpl{ @Overwrite public String toString() } --class DomainStringImpl{@Overwrite public String toString() } instance Interface DomainInterface where methode (DomainIntImpl {int=a}) (DomainIntImpl {int=b}) = a == b methode (DomainStringImpl{string=a}) (DomainStringImpl {string=b}) = a == b methode _ _ = False -- class DomainIntImpl { @Overwrite public String methode(a,b)} -- class DomainStringImpl { @Overwrite public String methode(a,b)} ints = map DomainIntImpl [1..10] -- [ 1 , 2 ,.., 10 ] strings = map DomainStringImpl $ map show [1..10] -- [“1“,“2“,..,“10“] find_1_Int = head $ map (DomainIntImpl 1).methode ints -- True find_1_String = head $ map (DomainStringImpl "1").methode strings -- True 5https://en.wikibooks.org/wiki/Haskell/Classes_and_types
  • 6. Frege Syntax (Monad) main _ = do // FUNCTIONAL url <- URL.new "http://www.google.com" >>= either throw return ios <- url.openStream >>= either throw return rdr <- InputStreamReader.new ios "UTF-8" >>= either throw return bfr <- BufferedReader.new rdr >>= either throw return maybe <- bfr.readLine >>= println ios.close return() 6 public static void main(String[] args) { // IMPERATIVE final URL url; try { url = new URL("http://www.google.com"); } catch (MalformedURLException e) { throw new RuntimeException(e);} final InputStream ios; try { ios = url.openStream(); } catch (IOException e) {throw new RuntimeException(e);} InputStreamReader rdr = new InputStreamReader(ios); BufferedReader bfr = new BufferedReader(rdr); String next = null; try { while((next = bfr.readLine()) != null){ System.out.println(next); } } catch (IOException e) {throw new RuntimeException(e);} try { ios.close(); } catch (IOException e) {throw new RuntimeException(e);} } http://www.learnyouahaskell.com/a-fistful-of-monads
  • 7. Frege PROs 7 • Eleganz • Pure Functional • Thread Safe by Design • Global Type inference • Mvn, Gradle tooling exist • Hoogle http://de.slideshare.net/Mittie/frege-tutorial-at-javaone-2015
  • 8. Frege CONs 8 • IDE (only eclipse :( ) • Compiler errors messages • Debugging • Laziness vs Performance • Missing libraries
  • 9. Blue or red pill? 9
  • 10. Links • GitHub: https://github.com/Frege • Language: http://www.frege-lang.org/doc/Language.pdf • Types: https://en.wikibooks.org/wiki/Haskell/Classes_and_types • Monad: http://www.learnyouahaskell.com/a-fistful-of-monads • EBook: https://dierk.gitbooks.io/fregegoodness/ • Video: http://www.yt.fully.pk/watch/1P1-HXNfFPc# 10