How to compile this example code?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to compile this example code?

Magicloud Magiclouds
Hi,
  I am learning to use data-flags, and got this example code:
import Data.Flags
newtype MyFlags = MyFlags CInt deriving (Eq, Flags)
#{enum MyFlags, MyFlags
 , myFlag1 = C_FLAG1
 , myFlag2 = C_FLAG2
 , myFlag3 = C_FLAG3
 }

  I modified it trying to compile it. Well, I got illegal syntax at "#{e".
  In fact, I am not quite know the syntax here. Any clue?
--
竹密岂妨流水过
山高哪阻野云飞

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: How to compile this example code?

Roel van Dijk-3
{- forgot to reply to list -}

This isn't Haskell syntax. Atleast not directly. It is either
hsc2hs[1] or c2hs [2]. Also see [3] for the difference between the
two. Soin order to compile that code you first have to run it through
aspecial preprocessor.
1 - http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/hsc2hs.html2
- http://www.cse.unsw.edu.au/~chak/haskell/c2hs/3 -
http://stackoverflow.com/questions/6009031/difference-between-hsc2hs-and-c2hs
2011/10/3 Magicloud Magiclouds <[hidden email]>:

> Hi,
>  I am learning to use data-flags, and got this example code:
> import Data.Flags
> newtype MyFlags = MyFlags CInt deriving (Eq, Flags)
> #{enum MyFlags, MyFlags
>  , myFlag1 = C_FLAG1
>  , myFlag2 = C_FLAG2
>  , myFlag3 = C_FLAG3
>  }
>
>  I modified it trying to compile it. Well, I got illegal syntax at "#{e".
>  In fact, I am not quite know the syntax here. Any clue?

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: How to compile this example code?

Magicloud Magiclouds
On Mon, Oct 3, 2011 at 3:50 PM, Roel van Dijk <[hidden email]> wrote:

> {- forgot to reply to list -}
>
> This isn't Haskell syntax. Atleast not directly. It is either
> hsc2hs[1] or c2hs [2]. Also see [3] for the difference between the
> two. Soin order to compile that code you first have to run it through
> aspecial preprocessor.
> 1 - http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/hsc2hs.html2
> - http://www.cse.unsw.edu.au/~chak/haskell/c2hs/3 -
> http://stackoverflow.com/questions/6009031/difference-between-hsc2hs-and-c2hs
> 2011/10/3 Magicloud Magiclouds <[hidden email]>:
>> Hi,
>>  I am learning to use data-flags, and got this example code:
>> import Data.Flags
>> newtype MyFlags = MyFlags CInt deriving (Eq, Flags)
>> #{enum MyFlags, MyFlags
>>  , myFlag1 = C_FLAG1
>>  , myFlag2 = C_FLAG2
>>  , myFlag3 = C_FLAG3
>>  }
>>
>>  I modified it trying to compile it. Well, I got illegal syntax at "#{e".
>>  In fact, I am not quite know the syntax here. Any clue?
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

I see. I was mislead, did not noticed the c binding part.
Thank you.

--
竹密岂妨流水过
山高哪阻野云飞

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe