Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
A Brief Introduction to Dialyzer and Proper
Search
Christopher Meiklejohn
February 02, 2014
Programming
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
A Brief Introduction to Dialyzer and Proper
Christopher Meiklejohn
February 02, 2014
More Decks by Christopher Meiklejohn
See All by Christopher Meiklejohn
Towards a Solution to the Red Wedding Problem
cmeiklejohn
0
470
Language Support for Cloud-Scale Distributed Systems
cmeiklejohn
0
610
Towards a Systems Approach to Distributed Programming
cmeiklejohn
3
420
Scaling a Startup with a 21st Century Programming Language
cmeiklejohn
0
450
Practical Evaluation of the Lasp Programming Model at Scale
cmeiklejohn
4
2.9k
Just-Right Consistency - Closing the CAP Gap
cmeiklejohn
3
330
Declarative, Convergent, Edge Computation
cmeiklejohn
1
270
Just-Right Consistency - Closing the CAP Gap
cmeiklejohn
3
1.4k
A Certain Tendency of the Database Community
cmeiklejohn
0
510
Other Decks in Programming
See All in Programming
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
160
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.2k
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
150
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
300
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
はじめてのPLATEAU
nokonoko1203
1
620
LLM 101
dalinaum
0
470
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
960
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
Railsバージョンを4倍にした話
optim
0
960
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
510
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
Building Applications with DynamoDB
mza
96
7.3k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Optimising Largest Contentful Paint
csswizardry
37
4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
610
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
370
Transcript
Dialyzer / PropEr Christopher Meiklejohn Basho Technologies, Inc.
Static analysis tool for Erlang Dialyzer
Based on success typings Dialyzer
-opaque gcounter() :: orddict:orddict(). ! -type gcounter_op() :: increment |
{increment, pos_integer()}. ! %% @doc Create a new, empty `gcounter()' -spec new() -> gcounter(). new() -> orddict:new(). ! %% @doc Create a `gcounter()' with an initial update -spec new(term(), pos_integer()) -> gcounter(). new(Id, Count) when is_integer(Count), Count > 0 -> {ok, Cnt} = update({increment, Count}, Id, new()), Cnt.
%% @doc Create a `gcounter()' with an initial update -spec
new(term(), atom()) -> gcounter(). new(Id, Count) when is_integer(Count), Count > 0 -> {ok, Cnt} = update({increment, Count}, Id, new()), Cnt.
riak_dt_gcounter.erl:63: Invalid type specification for function riak_dt_gcounter:new/2. The success typing
is (_,pos_integer()) -> riak_dt_gcounter:gcounter()
%% @doc Create a `gcounter()' with an initial update -spec
new(riak_dt:actor(), pos_integer()) -> gcounter(). new(Id, Count) when is_integer(Count), Count > 0 -> {ok, Cnt} = update({increment, Count}, Id, new()), Cnt. ! %% @doc `increment' the entry in `GCnt' for `Actor' by 1 or `{increment, Amt}'. %% returns an updated `gcounter()' or error if `Amt' is not a `pos_integer()' -spec update(gcounter_op(), riak_dt:actor(), gcounter()) -> {ok, gcounter()}. update(increment, Actor, GCnt) -> {ok, increment_by(1, Actor, GCnt)}; update({increment, Amount}, Actor, GCnt) when is_integer(Amount), Amount > 0 -> {ok, increment_by(Amount, Actor, GCnt)}.
riak_dt_gcounter.erl:64: Function new/2 has no local return riak_dt_gcounter.erl:65: The call
riak_dt_gcounter:update({'incremet',pos_integer()},Id::any(),riak_dt_g counter:gcounter()) breaks the contract (gcounter_op(),riak_dt:actor(),gcounter()) -> {‘ok',gcounter()}
%% @doc Create a `gcounter()' with an initial update -spec
new(riak_dt:actor(), pos_integer()) -> gcounter(). new(Id, Count) when is_integer(Count), Count > 0 -> {ok, Cnt} = update({increment, Count}, Id, new()), Cnt. ! %% @doc `increment' the entry in `GCnt' for `Actor' by 1 or `{increment, Amt}'. %% returns an updated `gcounter()' or error if `Amt' is not a `pos_integer()' -spec update(gcounter_op(), riak_dt:actor(), gcounter()) -> {ok, gcounter()}. update(increment, Actor, GCnt) -> {ok, increment_by(1, Actor, GCnt)}.
riak_dt_gcounter.erl:64: Function new/2 has no local return riak_dt_pncounter.erl:216: The created
fun has no local return
Demo
Property-based testing tool PropEr
Inspired by QuickCheck; licensed under GPL PropEr
Full integration with Erlang specifications PropEr
Simple
-module(simple_props). ! %% Properties are automatically exported. -include_lib("proper/include/proper.hrl"). ! %%
Functions that start with prop_ are considered properties prop_t2b_b2t() -> ?FORALL(T, term(), T =:= binary_to_term(term_to_binary(T))).
1> c(simple_props). {ok,simple_props} 2> proper:quickcheck(simple_props:prop_t2b_b2t()). ................................................... ................................................. OK: Passed 100
test(s) true
Stack
-spec new() -> stack(_T). new() -> {0, []}. ! -spec
push(T, stack(T)) -> stack(T). push(X, {N,Elems}) -> {N+1, [X|Elems]}. ! -spec pop(stack(T)) -> {T,stack(T)}. pop({0, []}) -> throw(stack_empty); pop({N, [Top|Rest]}) when N > 0 -> {Top, {N-1,Rest}}.
prop_push_pop() -> ?FORALL({X,S}, {integer(),stack(integer())}, begin {Y,_} = pop(push(X,S)), X =:=
Y end).
Eshell V5.10.3 (abort with ^G) 1> proper:quickcheck(stack:prop_push_pop()). ...................................................................... .............................. OK:
Passed 100 test(s). true
Lists
prop_reverse() -> ?FORALL(X, list(integer()), lists:reverse(lists:reverse(X)) == X).
7> proper:quickcheck(lists_proper:prop_reverse()). ...................................................................... .............................. OK: Passed 100 test(s). true
prop_delete() -> ?FORALL(L, non_empty(list(integer())), ?FORALL(X, elements(L), not lists:member(X, (lists:delete(X, L))))).
16> proper:quickcheck(lists_proper:prop_delete()). ........! Failed: After 9 test(s). [-1,-1] -1 !
Shrinking (0 time(s)) [-1,-1] -1 false 17>
17> proper:quickcheck(lists_proper:prop_delete()). ..................................! Failed: After 35 test(s). [2,-10,-7,13,70,2] 2 !
Shrinking ......(6 time(s)) [2,2] 2 false
prop_delete() -> ?FORALL(L, non_empty(list(integer())), ?FORALL(X, elements(L), lists:foldl(fun(Y, Acc) -> case
Y of X -> Acc + 1; _ -> Acc end end, 0, L) - 1 == lists:foldl(fun(Y, Acc) -> case Y of X -> Acc + 1; _ -> Acc end end, 0, lists:delete(X, L)))).
22> proper:quickcheck(lists_proper:prop_delete()). ...................................................................... .............................. OK: Passed 100 test(s). true
Thanks!