purescript-contrib / purescript-profunctor-lenses

Pure profunctor lenses
MIT License
144 stars 51 forks source link

Add `simple` for helping type inference #99

Closed LiamGoodacre closed 5 years ago

LiamGoodacre commented 5 years ago

Relating to https://github.com/purescript-contrib/purescript-profunctor-lenses/pull/98 Here's an example scenario:

> import Prelude
> import Data.Newtype
> import Data.Lens
> import Data.Lens.Iso.Newtype
> import Data.Lens.Common
> newtype X = X Int
> derive instance newtypeX :: Newtype X _
> X 42 ^. _Newtype
Error found:
in module $PSCI
at <internal> line 0, column 0 - line 0, column 0
  The inferred type
    forall t3 t5. Newtype t3 t5 => Int
  has type variables which are not mentioned in the body of the type. Consider adding a type annotation.

> X 42 ^. simple _Newtype
42

Wasn't sure where to put it, currently in Data.Lens.Common.