0

I'm digging around in the Haskell Lava HDL system and am stuck in understanding http://hackage.haskell.org/package/chalmers-lava2000-1.6.1/docs/src/Lava-Vhdl.html#writeVhdl

Can someone tell me what function (var "inp") in writeVhdlresolves to?

Function var is not defined yet and seems to be generated with some meta-programming that is not familiar to me in class Constructive in http://hackage.haskell.org/package/chalmers-lava2000-1.6.1/docs/src/Lava-Generic.html#line-253 .

Function var seems to act like a constructor. How is this mechanism working?

The input to writeVhdl is a circuit description like

halfAdd (a, b) = (sum, arry)
  where
    sum = xor2 (a, b)
    arry = and2 (a, b)
Konrad Eisele
  • 3,088
  • 20
  • 35

1 Answers1

2

Can someone tell me what function (var "inp") in writeVhdlresolves to?

It depends on what you pass to writeVhdl 2nd argument, namely circ. The type of its argument (if I read that correctly) is exactly the type that gets returned by var "foo".

You can observe expression types in ghci by typing :t some expression. Try loading your code into GHCi session and play with :t command.

arrowd
  • 33,231
  • 8
  • 79
  • 110
  • ```:t halfAdd``` yields ```halfAdd :: (Signal Bool, Signal Bool) -> (Signal Bool, Signal Bool)```. I asked this question also on #haskell irc and got some insight there. User dmjio extracted it into a gist: https://gist.github.com/dmjio/36a394ff36e382b8f9da53ec1687acb2 – Konrad Eisele May 05 '19 at 20:51