#2110: Rules to eliminate casted id's
---------------------------------+------------------------------------------
Reporter: igloo | Owner:
Type: feature request | Status: new
Priority: lowest | Milestone: 7.6.2
Component: Compiler | Version: 6.8.2
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by simonpj):
I'm sorry, but I can't follow your line of thought.
In any case, I'm convinced that rewrite rules are not the way to solve
this problem. As a programmer I absolutely do not want to rely on some
relatively-complicated optimisation machinery kicking in to avoid a
complete traversal of my data structure, when all I'm doing is changing
the type. And I want to be able to change the type even if there isn't a
map function.
Really the only difficult thing is surface syntax. Say I have
{{{
newtype Age = MkAge { unAge :: Int }
}}}
Then if I have
{{{
e :: Tree (Either Int Int)
}}}
I'd like to be able to get these things eaily:
{{{
e1 :: Tree (Either Age Int)
e2 :: Tree (Either Int Age)
e3 :: Tree (Either Age Age)
}}}
One possible syntax might be this:
{{{
e1 = e |> Tree (Either MkAge Int)
e2 = e |> Tree (Either Int MkAge)
e3 = e |> Tree (Either MkAge MkAge)
}}}
Here I am using the data constructor `MkAge` in the middle of a type to
say "make the change here!". It's less convenient in the other direction
{{{
e4 :: Tree (Either Int Age)
e4 = e3 |> Tree (Either unAge Age)
}}}
THere's a record selector `unAge` in the middle there. Maybe we need a
more explicit signal that we are dropping from the type world to the term
world, something like
{{{
e4 = e3 |> Tree (Either |unAge| Age)
}}}
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2110#comment:23>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs