Re: [Haskell-cafe] import functionality in DSLs

2011-04-17 Thread wren ng thornton
On 4/16/11 9:55 AM, Felipe Almeida Lessa wrote: On Sat, Apr 16, 2011 at 10:29 AM, Nikhil A. Patil patil.nik...@gmail.com wrote: doit :: DSL Term doit = do (+)- (+) n0- n0 k- k -- begin beautiful DSL code let x = k + n0 return $ x + x I

[Haskell-cafe] import functionality in DSLs

2011-04-16 Thread Nikhil A. Patil
Hi, I am planning a simple monadic DSL (frankly, calling it a DSL is a bit of a stretch; it's just a somewhat glorified state monad), and I wish to implement some kind of import functionality for it. The DSL code looks something like this: doit :: DSL Term doit = do (+) - define_function + 2

Re: [Haskell-cafe] import functionality in DSLs

2011-04-16 Thread Felipe Almeida Lessa
On Sat, Apr 16, 2011 at 10:29 AM, Nikhil A. Patil patil.nik...@gmail.com wrote: doit :: DSL Term doit = do (+) - (+)           n0  - n0           k   - k           -- begin beautiful DSL code           let x = k + n0           return $ x + x I guess the core problem is that on each time

Re: [Haskell-cafe] import functionality in DSLs

2011-04-16 Thread Nikhil A. Patil
On Sat, Apr 16, 2011 at 08:55 CDT, Felipe Almeida Lessa wrote: On Sat, Apr 16, 2011 at 10:29 AM, Nikhil A. Patil patil.nik...@gmail.com wrote: doit :: DSL Term doit = do (+) - (+)           n0  - n0           k   - k           -- begin beautiful DSL code           let x = k + n0    

Re: [Haskell-cafe] import functionality in DSLs

2011-04-16 Thread Luke Palmer
You can get away with this using {-# LANGUAGE RecordWildCards #-}, if you put your prelude into a record. Here's a test I did to make sure the technique worked: {-# LANGUAGE RecordWildCards #-} import Prelude hiding ((+)) data Foo = Foo { (+) :: Int - Int - Int, n0 :: Int } prelude

Re: [Haskell-cafe] import functionality in DSLs

2011-04-16 Thread Nikhil A. Patil
On Sat, Apr 16, 2011 at 13:49 CDT, Luke Palmer wrote: You can get away with this using {-# LANGUAGE RecordWildCards #-}, if you put your prelude into a record. Here's a test I did to make sure the technique worked: {-# LANGUAGE RecordWildCards #-} import Prelude hiding ((+)) data Foo