ekmett / ekmett/linear

`OverloadedRecordDot` support

Open
#181 2 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
Haskell
Stars
220
Forks
55
PR merge metrics
No merged PRs in 30d

Description

I've found defining instances like the following to be rather nice on the common occasion where I just want field access without the syntactic noise of `lens`:

```hs
instance HasField "x" (V2 a) a where
getField = (^. lensVL _x)
instance (HasField "x" (f a) a) => HasField "x" (Point f a) a where
getField = getField @"x" . unP
instance HasField "y" (V2 a) a where
getField = (^. lensVL _y)
instance (HasField "y" (f a) a) => HasField "y" (Point f a) a where
getField = getField @"y" . unP
```

Ideally we'd have more general instances like `instance R1 t => HasField "x" (t a) a where getField = (^. lensVL _x)`, but this gives an error: `Illegal instance declaration for ‘HasField "x" (t a) a’: Record data type must be specified.`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.