Skip to content
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
Merged

Add prelude stuff #1

merged 3 commits into from Sep 12, 2018

Conversation

@isovector
Copy link
Contributor

@isovector isovector commented Sep 12, 2018

No description provided.

isovector added 2 commits Sep 12, 2018
@Lysxia
Copy link
Owner

@Lysxia Lysxia commented Sep 12, 2018

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

@isovector
Copy link
Contributor Author

@isovector 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
Copy link
Contributor Author

@isovector 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
Copy link
Owner

@Lysxia 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
Copy link
Contributor Author

@isovector 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
Copy link
Owner

@Lysxia Lysxia commented Sep 12, 2018

Awesome, thanks!

@Lysxia Lysxia merged commit a494ded into Lysxia:master Sep 12, 2018
1 check passed
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants