Thanks for the feedback Max. I'm new to Elm, so I wasn't entirely sure what you meant by Opaque Union Types, until I came across a previous thread where you clearly explain what they are, and why they're useful:
https://groups.google.com/d/msg/elm-discuss/0XbEEb4hkjM/fP2iAjbNBgAJ That thread was extremely helpful. We do something nearly identical in Go with packages. - encapsulating the inner workings of the module while allowing the user to interact with an "Opaque" type . With that said, I think it would make more sense to design my module something like this instead: module ApiService exposing (Req, getApples, createOrange, peelBanana) type alias ReqRecord msg a = { settings : Http.Settings , request : Http.Request , decoder : Json.Decode.Decoder a , error : Http.Error -> msg , success : a -> msg } type Req msg a = R ReqRecord msg a getApples : Req msg a getApples = R ReqRecord {... specify record ...} createOrange : String -> Req msg a createOrange name = R ReqRecord {... specify record ...} peelBanana : String -> Req msg a peelBanana name = R ReqRecord {... specify record ...} toCmd : Req msg a -> Cmd msg toCmd (R info) = Task.process info If I've misunderstood, let me know. Thanks again Max. On Sunday, July 3, 2016 at 11:49:42 PM UTC-4, Max Goldstein wrote: > > If you're writing a library, the general rule is to keep union types > opaque (i.e. the type itself is exported but the tags are not). This allows > you to add or remove tags as you need to without committing to a major > version bump. If you wanted to export some of the tags, you'd have to > export some functions that wrap them. At that point, you might as well go > with option 2. > > A union type is really good for "this value will be one of a few possible > things". But you have a slightly different problem: "this value will come > from one of a few possible places, but the shape of the value itself it > always the same". So go with option 2, the "factory" functions. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
