Skip to content

Type checking a phantom type succeeds when it should not #1491

Open
@joneshf

Description

@joneshf

Might be a duplicate, but I couldn't find a similar example.

With the following example, broken should not type check because (OnePlus m, m) is not the same type as (m, m). However, the compiler gives it a type of a.

I am not sure how to make this example smaller, but there's probably a way to do so.

OS: Linux 4.7.2-1-ARCH #1 SMP PREEMPT Sat Aug 20 23:02:56 CEST 2016 x86_64 GNU/Linux
Browser: Chromium Version 53.0.2785.101 (64-bit)
Elm: 0.17.1

module Vect exposing (..)

type OnePlus m
    = OnePlus

type Vect m a
    = Vect (List a)

nil : Vect ( m, m ) a
nil =
    Vect []

head : Vect ( OnePlus m, m ) a -> a
head (Vect xs) =
    Maybe.withDefault (Debug.crash "") (List.head xs)

broken =
    head nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions