Created
March 30, 2015 18:59
-
-
Save sigwinch28/dc272b80a151a93e42eb to your computer and use it in GitHub Desktop.
The weakness of success types.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(discrep). | |
-export([run/0]). | |
% example of where type annotations fail to perform as expected. | |
% running `dialyzer discrep.erl` will return something similar to: | |
% | |
% Checking whether the PLT /home/joe/.dialyzer_plt is up-to-date... yes | |
% Proceeding with analysis... done in 0m0.29s | |
% done (passed successfully) | |
% | |
% even though there's a type error evident by the type annotations. | |
run() -> some_op([]). | |
-spec add_one(integer()) -> integer(). | |
add_one(Num) -> Num + 1. | |
-spec some_op([integer()]) -> [boolean()]. | |
some_op(Nums) -> lists:map(fun add_one/1, Nums). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment