PureScript by example: Applicative Validation: Exercises: stateRegex and nonEmptyRegex

Hi! It says “Write a regular expression stateRegex :: Either String Regex …” in the text, but the test in Main.purs expects Regex because test expects Regex.

Actually I am not sure why we do unsafe things. Because it is shorter?

Could you at least provide a link to the chapter?

@mhmdanas he’s talking about ch7 exercises.

@jim that shouldn’t be the case, all of them should be :: Either String Regex, test expects Either String Regex. Is there something not clear with the exercises?

We just updated this, because Data.String.Regex.regex returns Either String Regex and unsafePartial was used before to convert that to Regex unsafely.

We removed unsafePartial and now all works with Either String Regex only.

Oh, I see, I have used the source from 5 days ago, my bad. And from now on, I will mention the chapter right away. Thanks a lot.


Yes, I believe that was the original motivation for using unsafePartial in this situation.

It would be really nice to get both compile-time safety and conciseness by allowing some of this code to execute as a post-compilation step (perhaps compiledPartial). Elaborated a bit more on this wishlist item in this post.