Sunday 15 June 2014

ghci - Implementation of a signature in Haskell -


I have the following function signatures and implement it to execute a haschail function.

  Method :: (A -> (A -> B)) - & gt; (A -> B)   

Although I tried different ways to do it, but I miss a starting point. I think I might be able to do it with feats like (> gt; & gt; =), but I'm not really sure about it since I'm a lot new enough, so I'm pretty sure also It is not how the output is function rather than value like int or bull.

It should be handled by using a La Agada through the "hole-driven development". We want to define the method , which is a function at the highest level. We make works using Lambhdas, so we can leave some holes on ourselves by starting there.

  method = \ f - & gt; # {1}   

Where we know that f :: (a -> (a -> b)) and our holes, Code> # {1} :: (A -> B) . We need to use f in any way to create some type of # {1} since we now want another function , # {1} , let's use other lambda

  method = \ f - & gt; \ A - & gt; # {2}   

Now a :: a and # {2} :: b . Using b by using f and a types f :: (a -> (a -> Need to generate.)) and a :: a . Hopefully this is becoming obvious, but it keeps on keeping it down.

Type in the Notation Note that the function arrows are (->) correct associations, so whenever we see A -> (B -> C) We will call it about a -> B - & gt; C . In addition, we have two logic functions such as a -> gt; B - & gt; C and pairs of jobs (a, b) - & gt; C . This equivalence is absolutely curry / unstable , but it is useful in our case.

Let's rewrite the f function to be equivalent to f ':: (a, a) - & gt; When the bee is f '(a, b) = a a b . Given that we always have the "diagonal" function diag :: a -> You can use. (A, A) To create identical pairs, we have done we use f from any (a, a) to b < / Code> and we can use diag from any a to create a (a, a) we Want a b and we have a a .

  method = \ f - & gt; \ A - & gt; (A, B) = fag diag A = (A, A)   

or

  method fa = faa   < P> So you can see a specific general work  method  as  shrinking  more typical of working on the diagonals . A type of signature that also makes clear that our  f ' uses the trick:  
  method :: ((A, A) -> gt; ; B) - & gt; (A -> B) method f 'a = f' (a, a)    

No comments:

Post a Comment