The idea being a list of commands processed by a function, but each has variations, hence subtypes with multiple constructors. This is hard to do in Haskell, but useful for IO processing with queues...
If you give an example of what you want, I may be able to suggest a way to do it.
Is it possible to make subtypes of datatypes, and then put them in a list or array of the parent type, and create a function that can pattern patch on subtypes, or directly on subtype constructor pair So?
The idea being a list of commands processed by a function, but each has variations, hence subtypes with multiple constructors. This is hard to do in Haskell, but useful for IO processing with queues...
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/b47f0866-9753-4e66-9cc3-bed27ab27e21%40googlegroups.com.
datatype Command = Command ()
datatype Run : Command =
| RunFast of (address, data)
| RunSlow of (address, data, speed)
datatype Wait : Command = Wait of delay
datatype Composite : Command = Command of list<Run>
val c = Composite (List (RunFast (0x90, 0x7765), Wait (50)))
val l = [c,c,c]: List<Command>
fun execute (cmd: List<Command>) = let
fun loop (h:hs) = case h of
Run => case h of
RunFast (c, w) => io operation
RunSlow (...) => ...
Composite ...
Wait (d) => delay(d)
val () = execute(l)
For example, if all commands had an integer code, that would be in the supertype, and subtypes would add data. The first example sort of does that. And in the first example I think it is possible to pattern match on Run alone.
In neither example is the subtype idea defined separately in that one file defines the supertype and related functions, and another file contains subtypes that can be used with supertype functions.
In this sense libraries could be extended by users. I think type classes sort of do this, but in a different way. Rather than extending data, you adorn it with type classes and functions. Perhaps what I pointed to of extending data is closer to an OO world view than a functional one.
Given the mention of subtypes in the intro doc, what was the original intent?
Can someone perhaps explain in the context of the option datatype, why it uses covariance, using an example of type/subtype?
--
You received this message because you are subscribed to a topic in the Google Groups "ats-lang-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ats-lang-users/k7qXXrCvmsA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/3cf9b907-550b-46cf-91d9-bc266abc4708%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/09e82744-650b-4d02-b036-5c07c94e5812%40googlegroups.com.