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

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 

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