RE: Block simulation / audio processing

2000-05-18 Thread Mike Jones

Jerzy,

1. Block simulators, dataflow interfacing etc...
   People mentiond FRAM, but somehow I missed (improbable
   that nobody fired the *obvious* keyword here): HAWK!!!
   See the Haskell Home page, you find all about.

This is exactly what I have been looking at. My be problem is how to
dynamically control the step size of algorithms to support algorithms that
have non-uniform step size. Perhaps some kind of clock divider scheme.

Mike





Block simulation

2000-05-11 Thread Mike Jones

Hi,

Has anyone built any block simulators (for modeling continuous electronic
systems, like OP Amps, RC networks, etc) in Haskell? If so, any website URLs
would be of help to me.

Mike





RE: Showing tuples

2000-05-09 Thread Mike Jones

Chris,

Yes, I do derive Show for MyData. I was surprised it did not work.

Mike

-Original Message-
From: Chris Angus [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 09, 2000 12:57 AM
To: 'Mike Jones'; [EMAIL PROTECTED]
Subject: RE: Showing tuples


Do you derive Show for MyData?

 -Original Message-
 From: Mike Jones [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2000 05:58
 To: [EMAIL PROTECTED]
 Subject: Showing tuples
 
 
 Hi,
 
 I am having trouble with Show and tuples.
 
 I have a data structure, say:
 
 data MyData = ...
 
 And a value, say:
 
 value = (MyData..., MyData..., MyData)
 
 Then try to:
 
 show value
 
 I get a compiler message from ghc 4.05 that says:
 
 No instance for `Show (MyData, MyData, MyData)...
 
 What is the best way to deal with this problem?
 
 Thanks,
 
 Mike
 
 






RE: Showing tuples

2000-05-09 Thread Mike Jones



Sven,

That explains it. My tuples are of size 20.

Thanks,

Mike


Deriving works, but GHC currently only contains instance declarations
for tuples up to 5 elements, so you have to write you own boring
instances for larger ones.  *yawn*

Cheers,
   Sven
-- 
Sven PanneTel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen  Oettingenstr. 67
mailto:[EMAIL PROTECTED]D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne





Showing tuples

2000-05-08 Thread Mike Jones

Hi,

I am having trouble with Show and tuples.

I have a data structure, say:

data MyData = ...

And a value, say:

value = (MyData..., MyData..., MyData)

Then try to:

show value

I get a compiler message from ghc 4.05 that says:

No instance for `Show (MyData, MyData, MyData)...

What is the best way to deal with this problem?

Thanks,

Mike





Show class on ADT with function

2000-05-05 Thread Mike Jones

Hi,

I want to put a function in an ADT and make the ADT an instance of Show.
Like the following small example:

data Fn = Fn (Float - Float) Int
deriving Show

But, I get the error from GHC as follows:

Stimulus.hs:12:
No instance for `Show (Float - Float)'
When deriving classes for `Fn'

Compilation had errors

make: *** [Stimulus.o] Error 1

Is there any way to do this? Note that it would be ok to generate blank
text.

Thanks,

Mike





PANIC Line 84 causes panic

2000-05-03 Thread Mike Jones

module Stimulus (
Stimulus(..),
VectorPattern(..),
VoltageUnits(..),
CurrentUnits(..),
TimeUnits(..),
FrequencyUnits(..),
Percent(..),
SlewRateUnits(..),
CapacitanceUnits(..),
Max(..),
Min(..),
ValueType(..),
VectorStructure(..),
VectorFormat(..),
TimeSet(..),
FormatSet(..),
Format(..),
Time(..),
Vih(..),
Vil(..),
Voh(..),
Vol(..)
) where

import Monad
import Array

{
STIMULUS
-}

data Stimulus =
  Nothing
| Voltage {
v_voltage   :: Float,
v_voltageUnits  :: VoltageUnits,
v_accuracy  :: Float,
v_percent   :: Percent,
v_currentLimit  :: Float,
v_currentUnits  :: CurrentUnits,
v_max   :: Max,
v_slewRate  :: Float,
v_slewRateUnits :: SlewRateUnits,
v_capacitance   :: Float,
v_capacitanceUnits  :: CapacitanceUnits
}
| Current {
i_current   :: Float,
i_currentUnits  :: CurrentUnits,
i_accuracy  :: Float,
i_percent   :: Percent,
i_voltageLimit  :: Float,
i_voltageUnits  :: VoltageUnits,
i_max   :: Max,
i_capacitance   :: Float,
i_capacitanceUnits  :: CapacitanceUnits
}
| Waveform {
w_waveform  :: Float - Float,
w_voltage   :: Float,
w_voltageUnits  :: VoltageUnits,
w_type  :: ValueType,
w_accuracy  :: Float,
w_percent   :: Percent,
w_currentLimit  :: Float,
w_currentUnits  :: CurrentUnits,
w_max   :: Max,
v_capacitance   :: Float,
v_capacitanceUnits  :: CapacitanceUnits
}
| HIGH {
h_format:: Format,
h_fs:: Int, 
h_time  :: Time,
h_ts:: Int
}
| LOW {
h_format:: Format,
h_fs:: Int,
h_time  :: Time,
h_ts:: Int
}
}

data VectorPattern =
  VectorPattern {
p_data  :: [VectorStructure],
p_time_sets :: [TimeSet],
p_format_sets   :: [FormatSet],
p_vil_tag   :: Vil,
p_vil_value :: Float,
p_vil_units :: VoltageUnits,
p_vih_tag   :: Vih,
p_vih_value :: Float,
p_vih_units :: VoltageUnits,
p_vol_tag   :: Vol,
p_vol_value :: Float,
p_vol_units :: VoltageUnits,
p_voh_tag   :: Voh,
p_voh_value :: Float,
p_voh_units :: VoltageUnits,
p_frequency :: Float,
p_freq_units:: FrequencyUnits
}

data VectorStructure = 
  VECTOR {
v_data  :: [Stimulus]
}
| LOOP {
l_count :: Int,
l_vectors   :: [VectorStructure]
}
| JUMP {
j_position  :: Int
}
| REPEAT {
r_count :: Int,
r_vector:: VectorStructure
}

data VoltageUnits = PV | NV | UV | MV | V | KV
data CurrentUnits = FA | PA | NA | UA | MA | A
data TimeUnits = PS | NS | MS | S
data FrequencyUnits = HZ | KHZ | MHZ | GHZ
data Percent = PERCENT
data SlewRateUnits = VperS | VperMS | VperUS | VperNS
data CapacitanceUnits = PF | UF | MF | F
data Max = MAX
data Min = MIN
data ValueType = RMS | PEAK
data VectorFormat = RZ | NRZ | RO | NRO | SBC
data TimeSet = TS {
ts_num  :: Int,
ts_d1   :: Float,
ts_d1_unit  :: TimeUnits,
ts_d2   :: Float,
ts_d2_unit  :: TimeUnits,
ts_c1   :: Float,
ts_c1_unit  :: TimeUnits,
ts_c2   :: Float,
ts_c2_unit  :: TimeUnits,
   

++ efficiency

2000-05-03 Thread Mike Jones

Hi,

If I use ++ to concatenate two lists, how do I calculate the number of copy
operations, i.e. how do I approximate its efficiency compared to adding one
element at a time?

For example:

Does 1:2:3:4:5:6:7:8 execute faster than [1, 2, 3, 4] ++ [5, 6, 7, 8], where
the first case is executed recursively in a function?

Mike






Changing - to :=

2000-04-28 Thread Mike Jones

All,

Is there a way to define (:=) to be (-) in the context of a do? This would
then allow:

result = do
initialize
vi1 := Vi.create
Vi.setValue vi1 5.5
Vi.enable vi1
vi2 := Vi.create
Vi.setValue vi2 6.0
cond1 (isnt (Vi.enabled vi2)) (Vi.setValue vi2 0.0)
s := Vi.value vi2
return s

The goal is to make the language look Pascal like for those who will use it.

Mike





RE: Changing - to :=

2000-04-28 Thread Mike Jones

Tim,

I am aware that it is not an assignment, but rather a binding to a value.
However, my intent is to model a system that has both declarative and
imperative constructs, then build it in another language. If I can use :=, I
can make it look more like the final system, which is good for
demonstrations to those who know nothing about functional programming, and
in fact don't even know that lambda calculus exists. Furthermore, they have
no desire to know, because they believe that Microsoft tools make the world
go around.

I know, I know, it sucks, but hey, I have to eat. At least they don't care
how I build my prototypes, which means Haskel, and Eiffel.

Thanks for the help.

Mike

-Original Message-
From: Thimble Smith [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 28, 2000 7:26 PM
To: Mike Jones
Cc: [EMAIL PROTECTED]
Subject: Re: Changing - to :=


On Fri, Apr 28, 2000 at 07:08:22PM -0700, Mike Jones wrote:
 Is there a way to define (:=) to be (-) in the context of a do?

 The goal is to make the language look Pascal like for those who will use
it.

I'd say that goal is ill-concieved.  If you are trying to help
people learn functional programming, then this will only confuse
them.  - in Haskell does not work the same as := in Pascal.  It
is not assignment in the Pascal sense, and it's no good to make
people think that it is.

Tim





Derived class problem

2000-04-27 Thread Mike Jones

All,

I am having a problem with a derived class. I define:

class (Monad m) = InstrumentMonad m where
yuck :: a - m a

Then I define:

instance InstrumentMonad Vi where  (Line 30)
return a = Vi (\s - (s, a))
Vi sf0 = f =
Vi $ \s0 - 
let
(s1, a1) = sf0 s0
Vi sf1 = f a1
(s2, a2) = sf1 s1
in (s2, a2)

And when I compile, I get the error:

Vi.hs:30:
No instance for `Monad Vi'
arising from an instance declaration at Vi.hs:30

Vi.hs:31: Class `InstrumentMonad' does not have a method `return'

Vi.hs:32: Class `InstrumentMonad' does not have a method `='

I am not sure what is going on here.

Mike





RE: Use of irrefutable

2000-04-20 Thread Mike Jones

Let me explore this a bit:

  lazyMap ~(x:xs) = f x : lazyMap f xs

Now you tell the compiler that the list you are constructing
is infinite. Moreover, you can inspect the *result* of the
function before it ever evaluates its argument!

What exactly do you mean by inspect the result before the evaluation? Do you
mean you can start consuming the produced list before all elements are
generated?

Mike





Use of irrefutable

2000-04-19 Thread Mike Jones

Hi,

I have a rather naive question, being new to Haskell.

I am looking at the Hawk Signal module, where the following definition
occurs:

lift1 f (List xs) = List $ lazyMap f xs
 where
 lazyMap f ~(x:xs) = f x :  lazyMap f xs

Now setting aside how the function is used in Hawk, I ran a little
experiment to see what happens when the irrefutable definition is removed by
calling it with:

a = List [1, 2]
b = lift1 (+ 1) a

Now without it I get an error for a "non-exhaustive pattern". With it, I get
an "irrefutable pattern failed".

Can some one explain to me the advantages and disadvantages of using
irrefutable matching, including how irrefutable matching is used in general?
Why and when it is used, etc.

Thanks,

Mike