Skip to content

findM cannot keep original state #172

Open
@elvis-sik

Description

@elvis-sik

While attempting to implement findM, I ran into problems with this test:

    >>> let p x = (\s -> (const $ pure (x == 'i')) =<< put (1+s)) =<< get in runState (findM p $ listh ['a'..'h']) 8
    (Empty,8)

I couldn't do it (could only get (Empty, 16) so I looked the answer here: https://github.com/tonymorris/course/blob/master/src/Course/State.hs

The answer as semantically the same as mine, though just as a sanity check I copied and pasted it, ran stack test and it still gave me an error.

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