具有限定名称的Import Union类型

时间:2018-03-27 04:15:06

标签: elm

所以我有两种联合类型:JobStatusTaskStatus

module Data.Job exposing (..)


type JobStatus
    = Submitted
    | Started
    | Finished

-

module Data.Task exposing (..)


type TaskStatus
    = Created
    | Running
    | Finished

我将它们导入第三个模块

module Home exposing (..)


import Data.Job as Job exposing (JobStatus(..))
import Data.Task as Task exposing (TaskStatus(..))


type alias Model =
    { jobStatus : JobStatus
    , taskStatus : TaskStatus
    }


model : Model
model =
    { jobStatus = Finished
    , taskStatus = Finished
    }

但是Finished太混乱了,我想把它写成JobStatus.FinishedTaskStatus.Finished我怎么能这样做?

1 个答案:

答案 0 :(得分:9)

如果您从此

更改了导入
import Data.Job as Job exposing (JobStatus(..))
import Data.Task as Task exposing (TaskStatus(..))

到这个

import Data.Job as Job 
import Data.Task as Task

您可以使用Job.Finished和Task.Finished。