Skip to content

add an example on how to use lenses #22

@legrostdg

Description

@legrostdg

I can't get how to use the lenses generated by purescript-bridge...

Let's suppose I have the following haskell types defined:

data Book = Book { author :: Author, pages :: Int }
data Author = Author { name :: String }

given a purescript Book:

let a = { name: "James" }
let b = { author: a, pages: 100}

How can I access to the number of pages, and the author name?
I would expect something like this:

let pages = b ^. _pages
let name = b ^. _author ^. _name

but it does not seem to work...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions