File: Parameters.hs

package info (click to toggle)
bali-phy 4.0~beta16%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 15,192 kB
  • sloc: cpp: 119,288; xml: 13,482; haskell: 9,722; python: 2,930; yacc: 1,329; perl: 1,169; lex: 904; sh: 343; makefile: 26
file content (36 lines) | stat: -rw-r--r-- 1,727 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Parameters where

import Range
import Foreign.String     -- for list_to_string
import Effect             -- for Effect
import Numeric.LogDouble  -- for LogDouble

-- An Effect may be a node in a graph??

foreign import bpcall "Modifiables:" modifiable :: a -> a

foreign import bpcall "Modifiables:" register_prior :: Effect -> LogDouble -> IO Effect

foreign import bpcall "Modifiables:" register_likelihood :: a -> LogDouble -> IO Effect

foreign import bpcall "Modifiables:register_in_edge" builtin_register_in_edge :: a -> Effect -> CPPString -> IO Effect
register_in_edge var dist role = builtin_register_in_edge var dist (list_to_string role)

foreign import bpcall "Modifiables:" register_out_edge :: Effect -> a -> IO Effect

-- FIXME: Eliminate the CPPString, and allow each dist to only have one property
foreign import bpcall "Modifiables:register_dist_property" builtin_register_dist_property :: d -> a -> CPPString -> IO Effect
register_dist_property dist value property = builtin_register_dist_property dist value (list_to_string property)

foreign import bpcall "Modifiables:register_dist" builtin_register_dist :: CPPString -> Int -> IO Effect
-- The extra parameter to prevent invocations out of functions being floated
-- out of let statements by referencing a local variable.
register_dist_sample  name = builtin_register_dist (list_to_string name) 0
register_dist_observe name = builtin_register_dist (list_to_string name) 1

foreign import bpcall "Modifiables:changeable_apply" ($?) :: (a -> b) -> a -> b

-- Make into an IO operation to prevent  floating.
foreign import bpcall "Modifiables:" modifiable_apply :: (a -> b) -> a -> IO b
modifiableIO action = modifiable_apply unsafePerformIO action