-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to erlandono #81
Open
schonfinkel
wants to merge
1
commit into
master
Choose a base branch
from
move-to-erlandono
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
sasl, | ||
csv, | ||
epgsql, | ||
erlando | ||
erlandono | ||
]}, | ||
{env, []}, | ||
{modules, []}, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
{deps, [ | ||
{pure_migrations, "1.3.0"}, | ||
{epgsql, "4.7.1"}, | ||
{erlando, "3.1.1"} | ||
{erlandono, "3.1.2"} | ||
]}. |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
-module(postgres_m). | ||
|
||
-behaviour(monad). | ||
|
||
-export(['>>='/2, return/1, fail/1]). | ||
|
||
-type(monad(_A) :: {{'ok', any(), any()}, 'select'} | ||
| {{'ok', any()}, 'delete'} | ||
| {{'ok', any()}, 'insert'} | ||
| {{'ok', any(), any(), any()}, 'insert'} | ||
| {{'ok', any()}, 'update'} | ||
| {{'error', any()}, any()}). | ||
-include_lib("erlando/include/monad_specs.hrl"). | ||
% This only makes sense if we export it or use dialyzer | ||
%-type monad(_A) :: | ||
% {{ok, any(), any()}, select} | | ||
% {{ok, any()}, delete} | | ||
% {{ok, any()}, insert} | | ||
% {{ok, any(), any(), any()}, insert} | | ||
% {{ok, any()}, update} | | ||
% {{error, any()}, any()}. | ||
|
||
-spec return(X) -> Result | ||
when X :: any(), | ||
Result :: {ok, any()}. | ||
return(X) -> | ||
{ok, X}. | ||
|
||
return(X) -> {ok, X}. | ||
fail(X) -> {error, X}. | ||
-spec fail(X) -> Result | ||
when X :: any(), | ||
Result :: {error, any()}. | ||
fail(X) -> | ||
{error, X}. | ||
|
||
'>>='({{ok, FullColumns, Values}, select}, Fun) -> Fun({FullColumns, Values}); | ||
'>>='({{ok, Count}, delete}, Fun) -> Fun(Count); | ||
'>>='({{ok, Count}, insert}, Fun) -> Fun(Count); | ||
'>>='({{ok, _, _, _}, insert}, _) -> fail("Unexpected use of Insert on Server side"); | ||
'>>='({{ok, Count}, update}, Fun) -> Fun(Count); | ||
'>>='({{error, Error}, Tag}, _) -> | ||
'>>='({{ok, FullColumns, Values}, select}, Fun) -> | ||
Fun({FullColumns, Values}); | ||
'>>='({{ok, Count}, delete}, Fun) -> | ||
Fun(Count); | ||
'>>='({{ok, Count}, insert}, Fun) -> | ||
Fun(Count); | ||
'>>='({{ok, _, _, _}, insert}, _) -> | ||
fail("Unexpected use of Insert on Server side"); | ||
'>>='({{ok, Count}, update}, Fun) -> | ||
Fun(Count); | ||
'>>='({{error, Error}, Tag}, _) -> | ||
io:format("Tag: ~p\nError: ~p\n", [Error, Tag]), | ||
fail("Unexpected error (operation or PSQL) on Server side"). | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{"1.2.0", | ||
[{<<"csv">>,{pkg,<<"csve">>,<<"3.0.3">>},0}, | ||
{<<"epgsql">>,{pkg,<<"epgsql">>,<<"4.7.1">>},0}, | ||
{<<"erlando">>,{pkg,<<"erlando">>,<<"3.1.1">>},0}, | ||
{<<"erlandono">>,{pkg,<<"erlandono">>,<<"3.1.2">>},0}, | ||
{<<"pc">>,{pkg,<<"pc">>,<<"1.15.0">>},0}, | ||
{<<"pure_migrations">>,{pkg,<<"pure_migrations">>,<<"1.3.0">>},0}]}. | ||
[ | ||
{pkg_hash,[ | ||
{<<"csv">>, <<"69E7D9B3FDC72016644368762C6A3E6CBFEB85BCCADBF1BD99AB6C827E360E04">>}, | ||
{<<"epgsql">>, <<"D4E47CAE46C18C8AFA88E34D59A9B4BAE16368D7CE1EB3DA24FA755EB28393EB">>}, | ||
{<<"erlando">>, <<"50E54F9A9DFEC564DDFEB7FC7129F80F491856F5E07686F405CEF4E970BDFE46">>}, | ||
{<<"erlandono">>, <<"65C546236E33946573C76349954D142DE8ED4986AC3D04BD1DBA7676E1E64F38">>}, | ||
{<<"pc">>, <<"0DE7D4DF1BB23897E27965FC134DC63156DD2E5B512A9536CB7004D984400A45">>}, | ||
{<<"pure_migrations">>, <<"B758A62A9EDD6C1B40B668F4D6CE9E5588DBD4D99A4469BCE46BC7089B594AF7">>}]}, | ||
{pkg_hash_ext,[ | ||
{<<"csv">>, <<"741D1A55AABADAA3E0FE13051050101A73E90C4570B9F9403A939D9546813521">>}, | ||
{<<"epgsql">>, <<"B6D86B7DC42C8555B1D4E20880E5099D6D6D053148000E188E548F98E4E01836">>}, | ||
{<<"erlando">>, <<"9633CB4978DBD78827FA76EA4C3B0BD24CFBD4DD9AF48088E922E7115494A344">>}, | ||
{<<"erlandono">>, <<"103FA6E742B2EF74C87819A2E8FD3AAF63B6B6F8E2C626EB104648856563E75E">>}, | ||
{<<"pc">>, <<"4C0FAD4F6437CAE353D517DA218FE78347B8FFA44B9817887494CAAAE54595B3">>}, | ||
{<<"pure_migrations">>, <<"00269DE0A1A9BBE1B7681EC1F3FA59EE9D8081582226A94C633E6F94B5C88BC3">>}]} | ||
]. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate why this would only make sense if we export it? I would like to keep it in order to keep it consistent on how the original
erlando
does its monads.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to know which functions use this otherwise it's never used by the functions inside the module (it never typed anything) or outside it.
If you want to use outside it, we can export the type btw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow why this needs to be used somewhere to be uncommented. My intention is to keep it in order to maintain the pattern created by
erlando
. In this sense, keeping it in form of a comment, although non-ideal, is ok.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EduardoLR10 then why not import
monad.monad
? the lib actually exports the type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I actually haven't thought of that. Should we do that?