New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prelude stuff #1

Merged
merged 3 commits into from Sep 12, 2018

Conversation

Projects
None yet
2 participants
@isovector
Contributor

isovector commented Sep 12, 2018

No description provided.

@Lysxia

This comment has been minimized.

Show comment
Hide comment
@Lysxia

Lysxia Sep 12, 2018

Owner

Nice, thanks! My only nitpick is I would prefer to call it MapList instead of ListMap.

Owner

Lysxia commented Sep 12, 2018

Nice, thanks! My only nitpick is I would prefer to call it MapList instead of ListMap.

@isovector

This comment has been minimized.

Show comment
Hide comment
@isovector

isovector Sep 12, 2018

Contributor

Cool! Is there a story for promoted typeclass polymorphism here? It'd be nice to write Lookup in terms of promoted fmap rather than its current implementation.

Contributor

isovector commented Sep 12, 2018

Cool! Is there a story for promoted typeclass polymorphism here? It'd be nice to write Lookup in terms of promoted fmap rather than its current implementation.

@isovector

This comment has been minimized.

Show comment
Hide comment
@isovector

isovector Sep 12, 2018

Contributor
type family Fmap (f :: a -> Exp b) (as :: m a) :: m b
type instance Fmap f '[] = '[]
type instance Fmap f (a ': as) = Eval (f a) ': Fmap f as

type instance Fmap f 'Nothing = 'Nothing
type instance Fmap f ('Just a) = 'Just (Eval (f a))

This works but I'm not sure it's in the spirit of fcf.

There's also this:

data Fmap :: (a -> Exp b) -> f a -> Exp (f b)
type instance Eval (Fmap f '[]) = '[]
type instance Eval (Fmap f (a ': as)) = Eval (f a) ': Eval (Fmap f as)

type instance Eval (Fmap f 'Nothing) = 'Nothing
type instance Eval (Fmap f ('Just a)) = 'Just (Eval (f a))

which I guess is nicer, but it's still kinda gross to need to defunctionalize here.

Contributor

isovector commented Sep 12, 2018

type family Fmap (f :: a -> Exp b) (as :: m a) :: m b
type instance Fmap f '[] = '[]
type instance Fmap f (a ': as) = Eval (f a) ': Fmap f as

type instance Fmap f 'Nothing = 'Nothing
type instance Fmap f ('Just a) = 'Just (Eval (f a))

This works but I'm not sure it's in the spirit of fcf.

There's also this:

data Fmap :: (a -> Exp b) -> f a -> Exp (f b)
type instance Eval (Fmap f '[]) = '[]
type instance Eval (Fmap f (a ': as)) = Eval (f a) ': Eval (Fmap f as)

type instance Eval (Fmap f 'Nothing) = 'Nothing
type instance Eval (Fmap f ('Just a)) = 'Just (Eval (f a))

which I guess is nicer, but it's still kinda gross to need to defunctionalize here.

@Lysxia

This comment has been minimized.

Show comment
Hide comment
@Lysxia

Lysxia Sep 12, 2018

Owner

That's neat. I'm in favour of using this to replace the monomorphic versions. (And I'd call it just Map.)

It'd be nice to write Lookup in terms of promoted fmap rather than its current implementation.

I didn't get that.

Owner

Lysxia commented Sep 12, 2018

That's neat. I'm in favour of using this to replace the monomorphic versions. (And I'd call it just Map.)

It'd be nice to write Lookup in terms of promoted fmap rather than its current implementation.

I didn't get that.

@isovector

This comment has been minimized.

Show comment
Hide comment
@isovector

isovector Sep 12, 2018

Contributor

PTAL---added Map type instances for the usual prelude types except for a -> Exp b which I couldn't figure out how to do.

Contributor

isovector commented Sep 12, 2018

PTAL---added Map type instances for the usual prelude types except for a -> Exp b which I couldn't figure out how to do.

@Lysxia

This comment has been minimized.

Show comment
Hide comment
@Lysxia

Lysxia Sep 12, 2018

Owner

Awesome, thanks!

Owner

Lysxia commented Sep 12, 2018

Awesome, thanks!

@Lysxia Lysxia merged commit a494ded into Lysxia:master Sep 12, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@isovector isovector deleted the isovector:prelude branch Sep 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment