Skip to content

folds are actually case analysis #24

@maxsnew

Description

@maxsnew

Maybe this is a bit pedantic but the functions like foldJson are not really folds since they only inspect one layer of the structure, whereas folds deeply traverse a structure.
I was a bit confused in trying out this library by this naming.
I would expect foldJson to have the type

foldJson :: forall a.
            (JNull -> a) -> (JBoolean -> a) -> (JNumber -> a) ->
            (JString -> a) -> (Array a -> a) -> (StrMap a -> a) ->
            Json -> a

which of course you can implement using the current foldJson and recursion.

It's probably too much of a pain, but it seems to me like all the things currently called foldFoo should be caseFoo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions