We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In Erang, we can often see the following code, -type text() :: string() | binary(). -type print_text(text()) -> ok.
In Hamler, we can use type class to simulation
class IsText a
instance IsText (List Char) instance IsText Binary
printText :: forall a. IsText a => a -> IO () printText a = do xxxx
But if we can directly support untagged union, may be better
data Text = String | Binary
data Text = forall a.IsText a IsText a = let type = typeof(a) in a == typeof(String) || a == typeof(Binary)
or printText :: (forall a. IsText a) -> IO ()
This is like the following Erlang code: -spec print_text(A) -> xxx when A :: string() | binary().
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Abstract
In Erang, we can often see the following code,
-type text() :: string() | binary().
-type print_text(text()) -> ok.
In Hamler, we can use type class to simulation
class IsText a
instance IsText (List Char)
instance IsText Binary
printText :: forall a. IsText a => a -> IO ()
printText a = do
xxxx
But if we can directly support untagged union, may be better
Design
Untagged Union
data Text = String | Binary
Refinement Type
data Text = forall a.IsText a
IsText a = let type = typeof(a) in
a == typeof(String) || a == typeof(Binary)
or
printText :: (forall a. IsText a) -> IO ()
This is like the following Erlang code:
-spec print_text(A) -> xxx
when A :: string() | binary().
The text was updated successfully, but these errors were encountered: