[Haskell-cafe] AMP - how do you motivate this in teaching?
Tony Morris
tonymorris at gmail.com
Fri Nov 20 12:20:03 UTC 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 20/11/15 20:15, Joachim Breitner wrote:
> Hi,
>
> Am Freitag, den 20.11.2015, 12:02 +0200 schrieb Oleg Grenrus:
>> - `Errors` [4], which could be specialised to `Either (NonEmpty
>> err) a` and `ap` would gather all errors!
>
> this is actually a pretty nice and convincing example: „A
> effectful computation (e.g. a stateless parser) that may fail in
> various spots with errors, where the type system can guarantee that
> _all_ errors will be reported (and not just the first found).“
>
It's a pretty nice example of further splitting of the type-class
hierarchy, since if given,
instance Monoid a => Applicative (Either a) where
-- we gather all the errors
then we could not have Either (NonEmpty err), since (NonEmpty err)
does not have a Monoid, only a binary, associative operation (Semigroup)
.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJWTw/vAAoJEFkczQCvdvv0T4cH/28/pj2xqaRDHAGtoLF5mnLA
phbQ9J3mbbdmTQLlx5Rp77VCBV2BvjLe4gu+sCz+Qb/cvXo9lsCpJUCZFMP6CMSF
HMLD6hxZqCTyKu0/47Lmrh6AvkWFQ/YG2N99ZK4el3omoRXsBbGTxwOUBAPm5jZZ
94X6Q5jFoHOqCmeL1I7GTyx4IhnzOeMb2vTJvaiDbNUelu34ZzyzPLpaLA5uxnoC
G3MZNUeHX3USPzhg2KOwno6NNmHO8E8p90TiUWriLCjr8x6VqYj+5tNx6IVamA61
0nIE2BQo/D6n8Zr+LxWmVKoaC1QK/K5wGONmIcZRDCl6IW1aGD4XkuHcWGhnQqg=
=A8/9
-----END PGP SIGNATURE-----
More information about the Haskell-Cafe
mailing list