Skip to content

NonEmptyList/comonad seems off #52

Description

@joneshf

@MonoidMusician and I were discussing NonEmptyList/comonad in slack, and it seems like it's not working as intended. In particular, the tail is always an empty list. It seems like the coherence with Functor doesn't match. We hope that map f x = extend (\x -> f (extract x)) x, but it doesn't seem to:

let NonEmptyList = ./NonEmptyList/Type

let extend = (./NonEmptyList/comonad).extend

let extract = (./NonEmptyList/comonad).extract

let map = (./NonEmptyList/functor).map

let f : Natural  Natural = λ(x : Natural)  x

let nel : NonEmptyList Natural = { head = 1, tail = [ 2, 3, 4 ] }

in  { left =
        map Natural Natural f nel
    , right =
        extend
        Natural
        Natural
        (λ(x : NonEmptyList Natural)  f (extract Natural x))
        nel
    }
$ dhall <<< ./bunk.dhall
{ left =
    { head = 1, tail = [ 2, 3, 4 ] }
, right =
    { head = 1, tail = [] : List Natural }
}

I was going to send a PR, but extend always throws me for a loop. So if someone wants to PR, go for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions