Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ScopedTypeVariables #181

Open
mcandre opened this issue Dec 9, 2012 · 8 comments
Open

Allow ScopedTypeVariables #181

mcandre opened this issue Dec 9, 2012 · 8 comments

Comments

@mcandre
Copy link

mcandre commented Dec 9, 2012

When I try to compile my Fay code, it says:

$ make install
fay ../ios7crypt.hs
fay: ScopedTypeVariables is not enabled

So I added {-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable #-}, but Fay doesn't like the syntax.

$ make install
fay ../ios7crypt.hs
fay: Parse error: {-# LANGUAGE

Can we add {-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable #-} syntax to Fay like GHC uses?

@chrisdone
Copy link
Contributor

Where did you put it in the file?

@chrisdone
Copy link
Contributor

Oh, after module. Yeah, that's not supported in either GHC or Fay. It's just ignored in GHC. haskell-src-exts counts it as a parse error.

@mcandre
Copy link
Author

mcandre commented Dec 9, 2012

I tried positioning the directive before the module declaration and after. Fay reports a parse error either way.

@bergmark
Copy link
Member

bergmark commented Dec 9, 2012

[V~/tmp] > cat test.hs 
{-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable #-}
module Main where

import Language.Fay.Prelude

main :: Fay ()
main = return ()
[V~/tmp] > fay test.hs && node test.js
[V~/tmp] > 

OK here

@mcandre
Copy link
Author

mcandre commented Dec 9, 2012

I modified ios7crypt.hs but fay still fails to compile it.

Trace:

$ fay ios7crypt.hs
fay: ScopedTypeVariables is not enabled

Snippet (Lines 1-7):

-- Allows derivating Typeable and Data
{-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable #-}

module IOS7Crypt where

import Language.Fay.FFI
import Language.Fay.Prelude

...

Specs:

$ fay --version
fay 0.10.1.0

Which version of Fay are you using? How did you build Fay? I used cabal install with no special options.

@bergmark
Copy link
Member

Okay this is a bug, the flag is not propagated to ghc, here's a minimal reproduction

{-# LANGUAGE ScopedTypeVariables #-}

module Test where

foo (x :: Int) = x

@bergmark bergmark reopened this Dec 10, 2012
@bergmark
Copy link
Member

OK nope, it is haskell-src-exts that needs extensions = [ScopedTypeVariables]. Also this needs to be handled in the fay compiler, just treat the declaration as if the type wasn't there, should be a simple to fix if anyone wants to give it a shot.

fay: unsupported pattern syntax: x :: Int

@bergmark
Copy link
Member

bergmark commented Jan 8, 2014

A minor quirk to consider is what this would mean:

f :: Foo
f :: Ptr Foo = ffi "..."

It should probably throw an error.

See #378 for discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants