QuickCheck is a lightweight tool for randomly testing Haskell programs. It uses type classes like Arbitrary and CoArbitrary to generate random test cases for data types and functions. Properties to check are specified using a domain specific language embedded in Haskell. Case studies show it can find errors in programs like unification and pretty printing. While lightweight, QuickCheck has limitations like difficulty testing non-terminating programs and formal specifications are still needed to fully check programs.
Both Haskell and Scala are very expressive functional programming languages which are undergoing active development.
We will look at fundamental concepts and goals which inspired their design. We will examine similarities and differences between various features of these languages using code examples. We will also attempt to briefly assess their practicality in software engineering context.
Refinement types are an approach for expressing more detailed properties of data types using propositional logic predicates. Liquid Haskell is a static refinement type checker capable of veryfing refinement type safety. We will examine the possibilites this approach opens for increasing development productivity.
Both Haskell and Scala are very expressive functional programming languages which are undergoing active development.
We will look at fundamental concepts and goals which inspired their design. We will examine similarities and differences between various features of these languages using code examples. We will also attempt to briefly assess their practicality in software engineering context.
Refinement types are an approach for expressing more detailed properties of data types using propositional logic predicates. Liquid Haskell is a static refinement type checker capable of veryfing refinement type safety. We will examine the possibilites this approach opens for increasing development productivity.
In this core java training session, you will learn Collections – Sorting, Comparing. Topics covered in this session are:
• Recap of Arrays, ArrayLists
• Basically, there can be 2 operations that you would want to perform on Arrays/ArrayLists.. (and maybe, other collections)
• Search: Override equals() and hashCode().
• Sort: provide comparison logic – Two ways
• Comparable interface
• Comparator interface
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
Slides I prepared for the 29 January 2014 Ecma TC39 meeting, on Value Objects in JS, an ES7 proposal -- this one shotgunned the roadmap-space of declarative syntax, to find the right amount per TC39 (nearly zero, turns out).
A teaser talk for Scala newbies, introducing five basic elements that (in my opinion) make the transition from Java to Scala a no-brainer.
Given at the 7th JJTV (Israeli Java/JVM user group) tool night, July 2nd, 2013.
Beyond xUnit example-based testing: property-based testing with ScalaCheckFranklin Chen
Test-Driven Development has become deservedly popular in the past decade, with easy-to-use xUnit unit testing frameworks leading the way toward encouraging developers to write tests. But xUnit has limitations: how does one know one has written enough test cases for a desired behavior? And what if the behavior is conditional on other behavior? Property-based testing, first popularized for Haskell with the QuickCheck library, but available now for other languages as well, offers a powerful addition to one's testing toolkit.
I will discuss the concepts of property-based testing and illustrate them concretely using ScalaCheck for Scala, and point toward similar test frameworks in other languages.
In this core java training session, you will learn Collections – Sorting, Comparing. Topics covered in this session are:
• Recap of Arrays, ArrayLists
• Basically, there can be 2 operations that you would want to perform on Arrays/ArrayLists.. (and maybe, other collections)
• Search: Override equals() and hashCode().
• Sort: provide comparison logic – Two ways
• Comparable interface
• Comparator interface
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
Slides I prepared for the 29 January 2014 Ecma TC39 meeting, on Value Objects in JS, an ES7 proposal -- this one shotgunned the roadmap-space of declarative syntax, to find the right amount per TC39 (nearly zero, turns out).
A teaser talk for Scala newbies, introducing five basic elements that (in my opinion) make the transition from Java to Scala a no-brainer.
Given at the 7th JJTV (Israeli Java/JVM user group) tool night, July 2nd, 2013.
Beyond xUnit example-based testing: property-based testing with ScalaCheckFranklin Chen
Test-Driven Development has become deservedly popular in the past decade, with easy-to-use xUnit unit testing frameworks leading the way toward encouraging developers to write tests. But xUnit has limitations: how does one know one has written enough test cases for a desired behavior? And what if the behavior is conditional on other behavior? Property-based testing, first popularized for Haskell with the QuickCheck library, but available now for other languages as well, offers a powerful addition to one's testing toolkit.
I will discuss the concepts of property-based testing and illustrate them concretely using ScalaCheck for Scala, and point toward similar test frameworks in other languages.
Slideshare hasn't imported my notes, so here's the link to the Google Presentation: https://goo.gl/Gl4Vhm
Haskell is a statically typed, non strict, pure functional programming language. It is often talked and blogged about, but rarely used commercially. This talk starts with a brief overview of the language, then explains how Haskell is evaluated and how it deals with non-determinism and side effects using only pure functions. The suitability of Haskell for real world data science is then discussed, along with some examples of its users, a small Haskell-powered visualization, and an overview of useful packages for data science. Finally, Accelerate is introduced, an embedded DSL for array computations on the GPU, and an ongoing attempt to use it as the basis for a deep learning package.
Introduction to Functional Programming and usage of basic constructs in Java 7 using Guava.
Further, the session introduces Reactive Systems architecture and design.
IIUG 2016 Gathering Informix data into RKevin Smith
A basics walk-through on how to setup R to work with Informix JDBC, ODBC, and ReST/JSON. After taking the datasets examples and uploading them to Informix you can also look through the http://www.slideshare.net/thoi_gian/iris-data-analysis-with-r?qid=414b5431-9759-49e7-b3ba-c89a7bb357be&v=&b=&from_search=1, but replace the data targets with Informix ReST/JSON. Hint since the iris dataset's column names have a non-Informix compliant character I used JSON to store the data into Informix. If you rename the column you can get the data into a normal table through JDBC or ODBC.
Example Iris to JSON to Informix through ReST:
library(datasets)
library(jsonlite)
library(httr)
data(iris)
myjson <-><-><-><->)
dataset[1:3]
Extending Spark for Qbeast's SQL Data Source with Paola Pardo and Cesare Cug...Qbeast
Slides of the Barcelona Spark meetup of the 24th of October 2019. The recording is available at https://www.youtube.com/watch?v=eCoCcBH4hIU.
Abstract
One of the key strengths of Spark is its flexibility as it integrates with dozens of different storage systems and file formats. However, it is not the same reading from a CSV file, or a SQL database, or an exotic stratified sampled multidimensional database. And finding the right balance between modularity and flexibility is not easy!
In this presentation, we will talk about the evolution of Spark's DataSource API, and how it integrates with the SQL optimizer, highlighting how we can make much faster queries with logical and the physical plans that better integrates with the storage. From theory to practise, we will then discuss how we extended the Spark's internals, and we built a new source integration that allows the push-down of both sampling and multidimensional filtering.
About the speakers:
Paola Pardo is a Computer Engineer from Barcelona. She graduated in Computer engineer this last summer at the Technical University of Catalunya with a thesis focused on Data storage push down optimization based on Apache Spark. She is, and she is currently working at Barcelona Supercomputing Center and in its spin-off Qbeast developing a Qbeast-Spark connector.
Cesare Cugnasco is a PhD in Computer Architecture and a researcher at the Barcelona Supercomputing Center. His research focuses on NoSQL databases, distributed computing and High-performance storage. He invented and patented a new database architecture for Big Data, and he is building a spin-off for its commercialization.
Some languages, like SML, Haskell, and Scala, have built-in support for pattern matching, which is a generic way of branching based on the structure of data.
While not without its drawbacks, pattern matching can help eliminate a lot of boilerplate, and it's often cited as a reason why functional programming languages are so concise.
In this talk, John A. De Goes talks about the differences between built-in patterns, and so-called first-class patterns (which are "do-it-yourself" patterns implemented using other language features).
Unlike built-in patterns, first-class patterns aren't magical, so you can store them in variables and combine them in lots of interesting ways that aren't always possible with built-in patterns. In addition, almost every programming language can support first-class patterns (albeit with differing levels of effort and type-safety).
During the talk, you'll watch as a mini-pattern matching library is developed, and have the opportunity to follow along and build your own pattern matching library in the language of your choice.
Scala, Haskell and LISP are examples of programming languages using the functional programming paradigm. Join us in this TechTalk to know why functional programming is so important, how to implement some of its core concepts in your existing programming languages, and how functional programming inspired Google's Map Reduce, Twitter's Algebird, and many other technologies.
By Mohammad Ghabboun - Senior Software Engineer, SOUQ.com
Enroll Here --> https://goo.gl/xBJMA5 (50% OFF) Video Course
Do you know that all the web client frameworks are based on JavaScript?
Like AngularJS, ReactJS, NodeJS, etc., So, now it is the time for you to not only build a strong base in JavaScript basic programming but also to understand the basics of object oriented programming using JavaScript.
Yes, the buzzword of the market that is TypeScript and AngularJS2+ are completely based on oops through the JavaScript.
When it comes to the passing data from a client to the server then JSON formatted data is the hero, which again reminds the object or collection of objects of JavaScript.
Now no way to escape from learning JavaScript, if you want to stick to web technology with any platform whether it is Microsoft or Java or PHP or anything else.
So, no worries! we made it dam simple for you to master it :)
Enroll Here --> https://goo.gl/xBJMA5 (50% OFF) Video Course
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppGoogle
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-fusion-buddy-review
AI Fusion Buddy Review: Key Features
✅Create Stunning AI App Suite Fully Powered By Google's Latest AI technology, Gemini
✅Use Gemini to Build high-converting Converting Sales Video Scripts, ad copies, Trending Articles, blogs, etc.100% unique!
✅Create Ultra-HD graphics with a single keyword or phrase that commands 10x eyeballs!
✅Fully automated AI articles bulk generation!
✅Auto-post or schedule stunning AI content across all your accounts at once—WordPress, Facebook, LinkedIn, Blogger, and more.
✅With one keyword or URL, generate complete websites, landing pages, and more…
✅Automatically create & sell AI content, graphics, websites, landing pages, & all that gets you paid non-stop 24*7.
✅Pre-built High-Converting 100+ website Templates and 2000+ graphic templates logos, banners, and thumbnail images in Trending Niches.
✅Say goodbye to wasting time logging into multiple Chat GPT & AI Apps once & for all!
✅Save over $5000 per year and kick out dependency on third parties completely!
✅Brand New App: Not available anywhere else!
✅ Beginner-friendly!
✅ZERO upfront cost or any extra expenses
✅Risk-Free: 30-Day Money-Back Guarantee!
✅Commercial License included!
See My Other Reviews Article:
(1) AI Genie Review: https://sumonreview.com/ai-genie-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIFusionBuddyReview,
#AIFusionBuddyFeatures,
#AIFusionBuddyPricing,
#AIFusionBuddyProsandCons,
#AIFusionBuddyTutorial,
#AIFusionBuddyUserExperience
#AIFusionBuddyforBeginners,
#AIFusionBuddyBenefits,
#AIFusionBuddyComparison,
#AIFusionBuddyInstallation,
#AIFusionBuddyRefundPolicy,
#AIFusionBuddyDemo,
#AIFusionBuddyMaintenanceFees,
#AIFusionBuddyNewbieFriendly,
#WhatIsAIFusionBuddy?,
#HowDoesAIFusionBuddyWorks
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
QuickCheck - Software Testing
1. QuickCheck:
A Lightweight Tool for Random Testing
of Haskell Programs
Koen Claessen, John Hughes ICFP ‘00
CMSC 737 Software Testing
Fang Cheng javran@cs.umd.edu
2. Prelude - Haskell
● Functional Programming
○ Functions as First-class Citizens
○ More Controls over Side-effects
○ Implicit Control Flow
● Strong Static Typing
○ Reasoning about Types
○ Rule out “bad programs” at compile time
○ If it compiles, it works!
3. Prelude - Haskell
● Functional Programming
○ First-class citizen
■ g . f = λx -> g (f x)
○ Side effects
■ nextRandom :: () -> Int
■ nextRandom :: Seed -> (Int, Seed)
○ Implicit control flow
■ sum . map (^2) . filter (< 4) $ [1..10]
4. Prelude - Haskell
● Strong Static Typing
○ Reasoning about Types
■ f1 :: ∀a . a -> a
■ f2 :: ∀a b . a -> b
■ f3 :: ∀a . [a] -> [a]
5. Prelude - Haskell
● Strong Static Typing
○ Reasoning about Types
■ f1 :: ∀a . a -> a
● Can only be the identity function
■ f2 :: ∀a b . a -> b
● Impossible
■ f3 :: ∀a . [a] -> [a]
● Theorems for free! [Wadler 1989]
● map f . f3 == f3 . map f
6. Prelude - Haskell
● Strong Static Typing
○ f: plus 2
○ f3: swap the first two element if possible
map f
[1,2,3,4] [3,4,5,6]
f3 f3
map f
[2,1,3,4] [4,3,5,6]
7. Overview - QuickCheck
● Test Case Generation
○ Value Generation
○ Function Generation
● Output Verification
○ Describing Desired Properties
● Case studies
● Discussion
8. Test Case Generation - Type Class
● Type class: ad hoc polymorphism support
○ in Prolog:
eq(bool).
eq(char).
…
ord(X) :- eq(X).
9. Test Case Generation - Arbitrary
● newtype Gen a = Gen (Rand -> a)
○ reads “some computation(Gen) that will give you a”
class Arbitrary a where
arbitrary :: Gen a
instance Arbitrary Int where
arbitrary = choose (-20,20)
instance (Arbitrary a, Arbitrary b) => Arbitrary (a,b) where
arbitrary = do {v1 <- arbitrary; v2 <- arbitrary; return (v1,v2)}
We split a random seed (using a primitive function) into two independent
seeds, notation “<-” and “return” will take care of that.
10. Test Case Generation - Arbitrary
● newtype Gen a = Gen (Rand -> a)
○ reads “some computation(Gen) that will give you a”
instance (Arbitrary a, Arbitrary b) => Arbitrary (a,b) where
arbitrary = liftM2 (,) arbitrary arbitrary
-- shorthand:
-- liftM f m1 = do { v1 <- m1; return (f v1) }
-- liftM2 g m1 m2 = do { v1 <- m1; v2 <- m2; return (g v1 v2) }
11. Test Case Generation - Arbitrary
● Generate Recursive Data Structure
○ data Tree a = Branch (Tree a) (Tree a)
| Leaf a
deriving (Show)
instance (Arbitrary a) => Arbitrary (Tree a) where
arbitrary = frequency
[ (1, liftM Leaf arbitrary)
, (2, liftM2 Branch arbitrary arbitrary)
]
12. Test Case Generation - Arbitrary
● Generate Recursive Data Structure
○ data Tree a = Branch (Tree a) (Tree a)
| Leaf a
deriving (Show)
instance (Arbitrary a) => Arbitrary (Tree a) where
arbitrary = frequency
[ (1, liftM Leaf arbitrary)
, (2, liftM2 Branch arbitrary arbitrary)
]
● The generator might not terminate
● Likely to produce huge trees
13. Test Case Generation - Arbitrary
● Generate Recursive Data Structure
○ Limit the size
○ The notion of “size” is hard to define, leave it to
programmers
○ newtype Gen a = Gen (Int -> Rand -> a)
○ sized :: (Int -> Gen a) -> Gen a
14. Test Case Generation - Arbitrary
● Generate Recursive Data Structure
○ data Tree a = Branch (Tree a) (Tree a)
| Leaf a
deriving (Show)
instance (Arbitrary a) => Arbitrary (Tree a) where
arbitrary = sized arbTree
arbTree :: Int -> Gen a
arbTree 0 = liftM Leaf arbitrary
arbTree n = frequency
[ (1, liftM Leaf arbitrary)
, (4, liftM2 Branch (arbTree (n `div` 2) )
(arbTree (n `div` 2) )
]
15. Test Case Generation - CoArbitrary
● Generate Functions
○ Use input value to perturb the random generator Gen b
■ class CoArbitrary a where
■ coarbitrary :: a -> Gen b -> Gen b
○ We should be able to generate an arbitrary b using Gen b
○ Use input value a to perturb Gen b so that we will have a modified
Gen b
○ This is a pure function because given the same generator, the output
depends merely on input value.
16. Output Verification - DSL
● a Domain Specific Language (DSL)
embedded in Haskell
○ Property
○ Function Equality
○ Conditional Laws
○ Classify Input
○ Custom Data Generator
17. Output Verification - DSL
prop_RevUnit x =
reverse [x] == [x]
prop_RevApp xs ys =
reverse (xs++ys) == reverse ys++reverse xs
prop_RevRev xs =
reverse (reverse xs) == xs
● Property
● Function Equality (===)
type Endo a = a -> a
prop_CompAssoc :: Endo Int -> Endo Int -> Endo Int -> Int -> Bool
prop_CompAssoc f g h = f . (g . h) === (f . g) . h
18. Output Verification - DSL
● Conditional Laws (==>)
○ “A ==> B” is different from “not A || B”
○ try checking it for 100 test cases satisfying the
condition
○ generate only a limited number of test cases
prop_MaxLe :: Int -> Int -> Property
prop_MaxLe x y = x <= y ==> max x y == y
19. Output Verification - DSL
● Classify Input: classify, collect
● Custom Data Generator: forAll
prop_Insert :: Int -> Property
prop_Insert x =
forAll orderedList $ xs ->
classify (null xs) “trivial” $
ordered (insert x xs)
20. Case studies
● Unification
○ Random generated terms are unlikely to be unified
○ New types are introduced to produce a different input distribution
● Lava
○ Provide symbolic input and use external theorem prover
● Pretty Printing
○ Extending Arbitrary type class to include:
○ shrink :: a -> [a]
21. Discussion
● On Random Testing
○ a Haskell test framework written in Haskell
■ Lightweight
■ Doesn’t tie to a particular implementation
○ Many criteria need reinterpretation
■ Reachable statement?
■ Constraint solving in Haskell program is hard
22. Discussion
● Correctness Criteria
○ a Haskell test framework written in Haskell
■ Property Language is much more general
● Function Equality (e.g. current vs. known correct version)
● Result Checking (e.g. mathematical properties)
● Conditional Properties (e.g. insert on sorted list)
● Testing High-Order Functions (e.g. function composition)
○ No published work on automatic testing of functional
programs against specification
23. Discussion
● Test Data Generation
○ a Haskell test framework written in Haskell
■ another DSL for describing test data generation
● Grammar inherited from Haskell
● Minimum learning effort
○ Controlling sizes to guarantee termination
■ Need developer to
● Interpret the meaning of “size”
● Specify generators for his/her own new types
24. Discussion
● Some Reflections
○ Formulating formal specification improves our
understanding of our programs
○ Three types of errors divided evenly
■ Errors in test generators
■ Errors in the specification
■ Errors in the program
25. References
● Claessen, Koen, and John Hughes. "QuickCheck: a lightweight tool for
random testing of Haskell programs." Acm sigplan notices 46.4 (2011): 53-
64.
● Wadler, Philip. "Theorems for free!." Proceedings of the fourth international
conference on Functional programming languages and computer
architecture. ACM, 1989.
● Weyuker, Elaine J. "On testing non-testable programs." The Computer
Journal 25.4 (1982): 465-470.