[Haskell-cafe] Overcome type restrictions?
Dušan Kolář
kolar at fit.vutbr.cz
Fri Mar 7 09:43:58 UTC 2014
Thanks.
I think this is the simplest solution.
Dušan
On 03/07/2014 10:37 AM, Tobias Brandt wrote:
> The problem is, that the type parameter 'a' of the functions in the
> list is fixed. You can work around that with RankNTypes:
>
> newtype Wrap = Wrap { unwrap :: forall a. [a] -> a }
>
> unwrap $ (\(h:t) -> (unwrap h) t) [Wrap head, Wrap last]
>
> This specializes the type of the functions at every point of use
> separately.
>
>
> On 7 March 2014 09:14, Kolář Dušan <kolar at fit.vutbr.cz
> <mailto:kolar at fit.vutbr.cz>> wrote:
>
> Well my fault, the example should have been like this:
>
> We have and error of infinite type for
> Prelude> :t ((\(h:t) -> h t) [head, last, head, last, head, last])
>
> Of course, head and tail are incompatible on type level...
>
> Dušan
>
>
>
> On Fri, 07 Mar 2014 07:57:09 +0100, Kolář Dušan
> <kolar at fit.vutbr.cz <mailto:kolar at fit.vutbr.cz>> wrote:
>
> :
> :
>
> But we have an error of infinite type construction for
>
> Prelude> :t ((\(h:t) -> h t) [head,tail, head, tail, head,
> tail])
>
> Well I can overcome this by encoding functions into data
> types and then performing "conversion" back and forth,
> nevertheless, is there any way how to overcome this?
>
>
> It seems like you need heterogenous collections[0]
>
> Regards,
> Henk-Jan van Tuyl
>
>
> [0] http://www.haskell.org/haskellwiki/Heterogenous_collections
>
>
> --
> Folding at home
> What if you could share your unused computer power to help
> find a cure? In just 5 minutes you can join the world's
> biggest networked computer and get us closer sooner. Watch the
> video.
> http://folding.stanford.edu/
>
>
> http://Van.Tuyl.eu/
> http://members.chello.nl/hjgtuyl/tourdemonad.html
> Haskell programming
> --
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140307/17ed5179/attachment.html>
More information about the Haskell-Cafe
mailing list