Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6949015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:53:56+00:00 2026-05-27T13:53:56+00:00

Edit: Here’s a truly simple example. Motivation for this example below. This compiles: {-#

  • 0

Edit: Here’s a truly simple example. Motivation for this example below.

This compiles:

{-# LANGUAGE TypeFamilies #-}

type family F a b

f :: a -> F a b
f = undefined

f' [a] = f a

And ghci reports that:

*Main> :t f'
f' :: [a] -> F a b

But if we add this type signature to the file above, it complains:

*Main> :r
[1 of 1] Compiling Main             ( test.hs, interpreted )

test.hs:9:14:
    Couldn't match type `F a b0' with `F a b'
    NB: `F' is a type function, and may not be injective
    In the return type of a call of `f'
    In the expression: f a
    In an equation for `f'': f' [a] = f a
Failed, modules loaded: none.

What gives?


Motivation:

After seeing this question, I thought I’d be a smart-alec and write a little joke solution. The plan of attack is to start with type-level numbers (as usual), then write a little type-level function Args n a c that yields the function type that takes n copies of a and yields a c. Then we can write a little type class for the various n and be on our way. Here’s what I want to write:

{-# LANGUAGE TypeFamilies #-}

data Z = Z
data S a = S a

type family Args n a c
type instance Args Z a c = c
type instance Args (S n) a c = a -> Args n a c

class OnAll n where
    onAll :: n -> (b -> a) -> Args n a c -> Args n b c

instance OnAll Z where
    onAll Z f c = c

instance OnAll n => OnAll (S n) where
    onAll (S n) f g b = onAll n f (g (f b))

I was surprised to discover that this didn’t type-check!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:53:57+00:00Added an answer on May 27, 2026 at 1:53 pm

    This is a GHC bug, as can be demonstrated by the following, even further simplified example:

    type family F a
    
    f :: b -> F a
    f = undefined
    
    f' :: b -> F a
    f' a = f a
    

    I suggest reporting it to GHC HQ.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit : Here is a much more simpler example of this issue (i've deleted
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: Here is the new code: $(#normalcontent).hide(fast).load($this.attr(href) + #normalcontent,,function(){ $(this).slideDown(normal); $(this).find(img).each(function(){ if($(this).hasClass(large)) { var
EDIT: Here's the "better" one. First Page <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css"
Edit: The code here still has some bugs in it, and it could do
EDIT - The code looks strange here, so I suggest viewing the files directly
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Edit: OK I asked the wrong question here. I'm going to be coding a
EDIT Sorry I forgot the most important part here. Each key can have more
[ edit ] For the record, here's the problem portion of the query, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.