Closed garyb closed 8 years ago
Bizzarely, _page <<< second
works fine also.
That's odd. Don't the two versions have the same types?
Sent from my iPhone
On Dec 8, 2015, at 1:43 PM, Gary Burgess notifications@github.com wrote:
Starting with:
type X = { page :: Tuple (Maybe String) Int }
_page :: LensP X (Tuple (Maybe String) Int) page = lens .page ( { page = }) Trying to use:
_page <<< _2 Results in:
Could not match type
Function (Star (Const _0) _0 _1)
with type
Object
But using the original definitions we had works fine:
_snd :: forall a b c. Lens (Tuple c a) (Tuple c b) a b snd = lens snd ((Tuple c ) b -> Tuple c b)
_page <<< _snd @paf31 I guess this is more a bug for the typechecker than for this library, should I open something on the compiler repo?
— Reply to this email directly or view it on GitHub.
_2
and _snd
have exactly the same type, yeah.
Sanity check - this is the _2 from this library, not the van Laarhoven one?
Sent from my iPhone
On Dec 8, 2015, at 1:54 PM, Gary Burgess notifications@github.com wrote:
_2 and _snd have exactly the same type, yeah.
— Reply to this email directly or view it on GitHub.
Does it work if you define the alias in a where block?
Sent from my iPhone
On Dec 8, 2015, at 1:54 PM, Gary Burgess notifications@github.com wrote:
_2 and _snd have exactly the same type, yeah.
— Reply to this email directly or view it on GitHub.
_2
is definitely imported from Data.Lens
rather than Optic
. It does work if I define it in a where:
where
_22 :: forall a b c. Lens (Tuple c a) (Tuple c b) a b
_22 = second
It also works if I don't define it in a where
, but in the same module :sob:
Something rather strange going on here...
Ok, there's something really weird going on in fact! I didn't notice, but I'd used _2
elsewhere in the module succesfully. However, if I remove the import of _2
entirely and comment out the other usage, this:
wtf :: Maybe Unit
wtf = do
x <- pure unit
let tmp = review (_page <<< _2)
pure unit
Raises the error, rather than the error it should raise: Unknown value _2
.
Dropping the x <- ...
line means we get the "unknown value" error. Extracting wtf
into its own module also gives us the "unknown value" error rather than the type error. I'm trying to make a smaller test case...
lol: purescript/purescript#1697
Starting with:
Trying to use:
Results in:
But using the original definitions we had works fine:
@paf31 I guess this is more a bug for the typechecker than for this library, should I open something on the compiler repo?